PDA

View Full Version : the usage of ROI



grope
July 21, 2008, 03:19:02
hi,

I used the "Dialog Application Wizard" to create a dialog based application, and use clistener class to show the frames, but how to let it show the region of interested(ROI).

I tried the function below:


void CControlDlg::OnForFree()
{
// TODO: Add your command handler code here
// Load the ROI filter from the stdfilters.ftf module.
#ifdef _DEBUG
smart_com<DShowLib::IFrameFilter> pFilter = FilterLoader::createFilter( "ROI", // Filter name.
"stdfiltersd.ftf" ); // Module file.
#else
smart_com pFilter = FilterLoader::createFilter( "ROI", // Filter name.
"stdfilters.ftf" ); // Module file.
#endif

long lLeft = 0;
long lTop = 0;
long lHeight = 0;
long lWidth = 0;

// Retrieve the current ROI rectangle:
pFilter->getParameter( "Left", lLeft );
pFilter->getParameter( "Top", lTop );
pFilter->getParameter( "Height",lHeight );
pFilter->getParameter( "Width", lWidth );

// Set a new ROI.
lLeft = 100;
lTop = 50;
// The position of the ROI can be set, regardless of whether the live video is running
// because the size of the resulting video format is not changed.
pFilter->setParameter( "Left", lLeft );
pFilter->setParameter( "Top", lTop );

if( m_cGrabber.isLive() == false )
{
// A new ROI width and height can only be set while the live video is stopped. Otherwise,
// an error is returned by setParameter().
lHeight = 120;
lWidth = 180;
pFilter->setParameter( "Height",lHeight );
pFilter->setParameter( "Width", lWidth );
pFilter->endParamTransfer();
pFilter->getParameter( "Height",lHeight );
pFilter->getParameter( "Width", lWidth );
tFrameFilterList filterList;
}

}

but it doesn't work, i am a new user, thank you!

Stefan Geissler
July 21, 2008, 09:01:35
Good Morning!

You simply did not add the ROI filter to your grabber object, thus itis simply not used. The "smart_com<DShowLib::IFrameFilter> pFilter" must be member of your "CControlDlg" class, or of the class, that holds the grabber object.

After the frame filter has been created, you must add it to the grabber:


m_cGrabber.setDeviceFrameFilters(pFilter);

Please refer to:
http://www.imagingcontrol.com/support/documentation/class/meth_descGrabber_setDeviceFrameFilters.htm

grope
July 22, 2008, 02:30:26
thanks for your help!


the points you remind does very important, and give me a lot help. unfortunately, it still dosn't work, here is the code, would you please help me to find the problem.



oinitialdialog:


m_cGrabber.addListener(&m_cListener);
m_cListener.SetParent(this);
m_cListener.SetViewCWnd( (CStatic*)GetDlgItem(IDC_MICRO_IMG) );
// the above is created by the wizard


pFilter = FilterLoader::createFilter( "ROI" );
pFilter->setParameter("ROI", TRUE);
filterList.push_back(pFilter.get());
m_cGrabber.setHWND(GetDlgItem(IDC_MICRO_IMG)->GetSafeHwnd());

// the follow is created by the wizard
m_pSink = FrameHandlerSink::create( DShowLib::eRGB24, 3 );
m_pSink->setSnapMode( false );
m_cGrabber.setSinkType( m_pSink );



the change function:


if( m_cGrabber.isLive() == false )
{

pFilter->beginParamTransfer();

long lLeft = 0;
long lTop = 0;
long lHeight = 0;
long lWidth = 0;

// Retrieve the current ROI rectangle:
pFilter->getParameter( "Left", lLeft );
pFilter->getParameter( "Top", lTop );
pFilter->getParameter( "Height",lHeight );
pFilter->getParameter( "Width", lWidth );

// Set a new ROI.
lLeft = 100;
lTop = 50;
// The position of the ROI can be set, regardless of whether the live video is running
// because the size of the resulting video format is not changed.
pFilter->setParameter( "Left", lLeft );
pFilter->setParameter( "Top", lTop );

// A new ROI width and height can only be set while the live video is stopped. Otherwise,
// an error is returned by setParameter().
lHeight = 120;
lWidth = 180;
pFilter->setParameter( "Height",lHeight );
pFilter->setParameter( "Width", lWidth );

pFilter->endParamTransfer();
}




thanks again!

Stefan Geissler
July 22, 2008, 13:23:38
Hi,

I miss the line m_cGrabber.setDeviceFrameFilters(pFilter); in your code snippet:



pFilter = FilterLoader::createFilter( "ROI" );
pFilter->setParameter("ROI", TRUE);
// Now let the grabber know, that it should use the filter
m_cGrabber.setDeviceFrameFilters(pFilter);