Hi,
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:
https://help.commonvisionblox.com/NextGen/14.0/md_theory_of_operation_hardware__gen_i_cam__c_v_b__user_guide.html#gcug_chmtopic53
But this is also related to other drivers.
C# function call:
int bResult = Cvb.Driver.IImageRect.IRImageSize
(m_cvImage.Image,
Cvb.Driver.IImageRect.TImageRectCMD.IMAGERECT_CMD_RESET,
ref width,
ref height,
out imgNew);
1 Like
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 IRImageSize
afterwards!
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);
if (SUCCEEDED(res))
{
// it worked; in order for drvImage to live up to its name it should
// now switch roles with the result image...
ReleaseObject(drvImage);
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.