PDA

View Full Version : ICImageControl Quick Answer wanted from the developer



zwzhang28
January 22, 2007, 19:25:45
Hi,

We just bought Versoin 3 for .Net. The reason we decided to go with you guys is like this:
Used the .Net P/Invoke wrapper from DirectShow.Net, we have successfully implemented the integration for most device supports DirectShow, but we can not get the WDM thing works.

Question 1:
After call the MemorySnapImage, how to get the image as a System.Drawing.Image (or Bitmap)?

How we did it now: With the DirectShow.Net, we can build a Bitmap use a overriden constructor. We believe you have already did that. Maybe just a clue:

The built Bitmap cannot be used in .Net directly except save it, since the image data buffer is still in the Unmanaged C++ allocated memory.
So we did this:

// Suppose dsImg is the Bitmap built from the SampleGrabFilter. It can not be
// used directly in .Net, since it is in Unmanaged C++ allocated memory.
// Now we we simply copy it to a Managed memory buffer:
Image imgCanBeUsedDirectly = null;
try
{
MemoryStream ms = new MemoryStream();
dsImg.Save(ms.....);
imgCanBeUsedDirectly = Image.FromStream(ms);
// DO NOT close the ms.
}catch{}
return imgCanBeUsedDirectly;

If your MemorySaveImage has an overriden to take a Stream as param, we would be happy.

Question 2: What does the DeviceTrigger do? If it is enabled, does an event being raised when a button on the device pushed? If so, what is the event?

Question 3: How to used the WDM feature?

Suggestion 1:
A property could be easily added: SizeMode.(Center, Zoom, Fit, .....).
With LiveDisplayWidth......etc. How easy this can be done. So do not do it?

Thanks

Stefan Geissler
January 23, 2007, 10:19:09
Hi,



Question 1:
After call the MemorySnapImage, how to get the image as a System.Drawing.Image (or Bitmap)?

IC Imaging Control's Image buffer provides a .NET Bitmap object. Please refer to
http://www.imagingcontrol.com/support/documentation/dotnet/ImageBuffer.htm
for the documentation. I hope, this answer your question, If not, please let me know.



Question 2: What does the DeviceTrigger do? If it is enabled, does an event being raised when a button on the device pushed? If so, what is the event?


Some DCam cameras can be triggered external to capture a single image. This Device Trigger property enables this camera behavior, if it is supported. The trigger signal comes from an external hardware.



Question 3: How to used the WDM feature?

WDM means only "Windows Driver Model". For details please refer to:
http://www.theimagingsource.com/en/resources/whitepapers/download/whatiswdmwp.en.pdf
At least, there is no "WDM" feature available. In IC Imaging Control it means that WDM compliant video capture sources can be handled. Other video capture devices may use proprietary drivers, that are not WDM compliant. These devices can not be handled by IC Imaging Control.



Suggestion 1:
A property could be easily added: SizeMode.(Center, Zoom, Fit, .....).
With LiveDisplayWidth......etc. How easy this can be done. So do not do it?

Not so easy, because it is a change in the interface. The documentation must be enhanced, the functionality must be tested, the setups must be created and tested on different operating systems and Visual Studio versions, the service packs must be created and tested. You see, simply adding methods is not as simple as it looks. I think, this faster done in your software using the video format's width and height and the desired width and height. Please understand my point of view.

lcady
March 22, 2007, 20:48:59
B/W cameras create 8bit pixels.

If you are using a black and white camera the ImageBuffer's Bitmap will have an 8 bit pixel format. If you want to use the Bitmap's setPixel() method you need to convert the format to (i think) 24bit RGB [it may be 32bit ARGB however - not sure]. An easy way to do this is to typecast the ImageBuffer's Bitmap to an Image. Then construct a new Bitmap from the Image.

It looks like this:
Bitmap bmp = new Bitmap((Image)icImageingControl1.ImageActiveBuffer .Bitmap);

This may be slow since its constructing a new Bitmap, but it works well. I'm using this to load a list of Bitmaps, one every 25ms.

Stefan Geissler
March 23, 2007, 09:34:42
Hello,

It is also possible to set the color format of the sink to Y800 (1 byte per) pixel using the "MemoryCurrentGrabberColorFormat" property:
http://www.imagingcontrol.com/support/documentation/dotnet/prop_descICImagingControl_MemoryCurrentGrabberColo rformat.htm


Available color formats are here:
http://www.imagingcontrol.com/support/documentation/dotnet/enum_descrefenum_ICImagingControlColorformats.htm