when i change the camera’s image format and size programmatically in my software, it seems like the driver doesn’t get updated to the new image size (or bit depth) by itself. Does this mean I always have to release and reload the driver again? Because this takes a while…
I was hoping that there is a better way, like a driver update function I can call?
Yes, you can use the IImageRect Interface with its IRImageSize function.
A description can be found in the GenICam User Guide:
But this is also related to other drivers.
C# function call:
int bResult = Cvb.Driver.IImageRect.IRImageSize
One thing to be aware of with the above code sample is that it’s absolutely necessary to call
ReleaseObject (CVCImg.dll) on the input image to
In @Sebastian’s code this is implicitly done because he is using an image from an image control - and the image control will take care of calling
ReleaseObject on its handle sooner or later, but if you are working with blunt
IMG handles this will not be the case. In such a scenario the code should be more like:
// assuming: drvImage is a valid handle to a *.vin driver
cvbdim_t width = 0;
cvbdim_t height = 0;
IMG imgReset = nullptr;
auto res = IRImageSize(drvImage, IMAGERECT_CMD_RESET, width, height, imgReset);
// it worked; in order for drvImage to live up to its name it should
// now switch roles with the result image...
drvImage = imgReset;
imgReset = nullptr; // just to prevent people from using this later on
This snippet also highlights one of the most illusive aspects of the
IRImageSize function: The image
drvImage enters it with the full set of driver interfaces, but once the job is done these driver interface will have passed over to the output image (
imgReset in this case), turning the input image into a plain and simple bitmap.