View Full Version : Dynamically change the ROI

June 20, 2014, 15:17:57
Hi all,

I want to implement an application that dynamically change the ROI of the camera (I am using DFK 23UP031). But I can't seem to do it using setVideoFormat function. Here is my code:

mpGrabber = NULL;

mpGrabber = new Grabber();

if( !setupDeviceFromFile( *mpGrabber ) )
delete mpGrabber;

if(!mpGrabber->setVideoFormat("RGB32 (640x188) [Binning 4x]"))

In the configuration dialog, I used RGB32 (1024x768), then I want to change it to RGB32 (640x188) [Binning 4x], and setVideoFormat returns false.



Update: I can use the setVideoFormat function to set to a format that is in the pGrabber->getAvailableVideoFormats list

Stefan Geissler
June 20, 2014, 16:19:40

The video format "RGB32 (640x188) [Binning 4x]" is not supported by your camera, because the minimum height 192.

if(!mpGrabber->setVideoFormat("RGB32 (640x192) [Binning 4x]"))


You can get a description of the available video formats as follows:

Grabber::tVidFmtDescListPtr DecriptionList;

DecriptionList = m_mpGrabber->getAvailableVideoFormatDescs();

for( Grabber::tVidFmtDescList::iterator pDescription = DecriptionList->begin(); pDescription != DecriptionList->end(); pDescription++ )
SIZE s = (*pDescription)->getStepSize();
if( s.cx > 1 && s.cy > 1 )
// The current video capture device allows many video formats with any sizes
// between min and max size.
TRACE("Description : %s\n", (*pDescription)->toString().c_str());
VideoFormatItem VideoFormat = (*pDescription)->createVideoFormat((*pDescription)->getMaxSize());
TRACE("Maximum Format : %s", VideoFormat.toString().c_str());
// The current video capture has only some static video formats.
VideoFormatItem VideoFormat = (*pDescription)->createVideoFormat((*pDescription)->getMaxSize());
TRACE("Video Format : %s", VideoFormat.toString().c_str());

However, its a firmware issue. I do not know the serial number of your camera, therefore, I guess it has a firmware, that does not support smaller video formats. Newer firmwares do.

I do not provide firmware update via the forum. If you want an update, you must create a support case at http://www.imagingcontrol.com/en_US/support/case/

June 20, 2014, 16:57:23
Thanks Stefan, it is working now.

But from my observation, I seem to need to do stopLive before I can update the ROI. For example following code doesn't update the image as I intended.

mpGrabber->setVideoFormat("RGB32 (640x252)");
mpGrabber->setVideoFormat("RGB32 (640x380)");

Stefan Geissler
June 20, 2014, 17:13:59

It is correct, you need stop live before you can change the video format. Your sample code did not point to a started live video, therefore, I guessed it the wrong direction.

June 20, 2014, 20:00:29
But is there way to get around this?

What I want to do is to grab images at 50Hz, but at each instance, I will need to update ROI to get a different size or location. The stop and restart process seems to have a very large overhead...

Stefan Geissler
June 24, 2014, 09:26:46
If you resize the ROI you can not get around this, because each time the memory for the image buffers must be allocated new.
You can move the ROI while the live video runs, that means, you can change the X and Y offset.

Maybe it is a better idea to set a bigger video format and clip the region of interest in software from the incoming images in the GrabberListener::frameReady function. The problem with bigger video formats is, you will not achieve 50 fps, if they are too big.

June 24, 2014, 14:50:31
Thanks for the reply.