PDA

View Full Version : Why does my initialization fails ?



vdaanen
July 25, 2007, 17:47:12
Hi,

I want to initalize my grabber by specifying the video format and the image size.
The only way I found is
- first create a MemBufferCollection
- create FrameHandlerSink using the MemBufferCollection created above.

But when I call grabber->startLive, it fails because "the sink could not be connected !"

Here is my initalization code. Does someone see the error ?


// ---------------------------
if (l_Format == CVideoFrame::eFRAME_FORMAT_PAL)
{
if (!m_pGrabber->setVideoNorm("PAL_B"))
{
LOGERR("CVideoGrabberImplImagingSource : Can not initalize Grabber with video signal : PAL_B ");
return false;
}
}
else // (l_Format == CVideoFrame::eFRAME_FORMAT_PAL)
{
if (!m_pGrabber->setVideoNorm("NTSC_M"))
{
LOGERR("CVideoGrabberImplImagingSource : Can not initalize Grabber with video signal : NTSC_M");
return false;
}
}

// use normal video input (no S-VIDEO)
m_pGrabber->setInputChannel(l_VideoOutputNumber);

// --------------
BYTE *l_pBuffer[1]={m_Frame.GetBuffer()}; // the buffer is valid !
tColorformatEnum l_colorFormat = (l_Color == CVideoFrame::eFRAME_RGB_8) ? eRGB24 : eY800;

m_pBuffer = MemBufferCollection::create(l_colorFormat, m_Frame.GetSize(), 1, l_pBuffer);

if (m_pBuffer==0)
{
LOGERR("Can not create the buffer for the grabber");
return false;
}

m_pSink = FrameHandlerSink::create(m_pBuffer);
if (m_pSink==0)
{
LOGERR("Can not create the FrameHandler for the grabber");
return false;
}

m_pGrabber->setSinkType( m_pSink );

// declare the listener
if (!m_pListener)
{
m_pListener = new CListener(this);
if (!m_pListener)
{
LOGERR("Unable to initialize the Listener");
return false;
}
}
m_pGrabber->addListener(m_pListener);

// Start the background grabbing
if (!m_pGrabber->startLive(false)) <---- it's failing here
{
LOGERR("Unable to start background grabbing");
return false;
}

// Pause
m_pSink->setSinkMode(GrabberSinkType::ePAUSE);

V

Stefan Geissler
July 26, 2007, 09:19:41
Vincent,

would it be possible to send me a small project using CVideoFrame class and the grabber, thus I can debug it? Please send it to support@imagingcontrol.com.

This would make things much more easier for me. Thank you.

vdaanen
July 26, 2007, 09:35:10
Hi Stefan,

I can't send you a project because CVideoFrame is part of a customer library.

But I solve the problem : I added a string defining the videoformat when testing the videoNorm and add m_pGrabber->setVideoFormat(....) after the call to m_pGrabber->setVideoNorm.

Don't know if it's right way to do but it is the only one I found to make it works

V

Stefan Geissler
July 26, 2007, 09:38:14
Vincent,

Thank you for the feedback. I did not thought about the video format. But if the size of the video format differs from the size of the mem buffer, then we can get trouble. (Now you mention this.... )

Sorry, that I was not faster with my knowledge.