PDA

View Full Version : getSignalDetected() does not work



gye
February 1, 2008, 01:24:57
Hello, there,

I am using grabber.getSignalDetected() to detect if my USB converter has connection to an analog camera. It seemed that getSignalDetected() always returns FALSE whenever there is a connected camera or not. By commenting out getSignalDetected(), the whole program works OK. I tried grabber.isSignalDetectedAvailable() and it returned TRUE. Anyone has similar problem or can help me? A part of my code is as follows:

if( !DShowLib::InitLibrary( 0 ) )
{
fprintf( stderr, "The library could not be initialized ");
fprintf( stderr, "(invalid license key?).\n");
exit( 1 );
}

Grabber grabber;
if( !setupDeviceFromFile( grabber ) )
exit(1);

if (!grabber.isSignalDetectedAvailable())
exit(1);

if (!grabber.getSignalDetected())
exit(1);

Thanks!

Stefan Geissler
February 1, 2008, 08:33:52
Hi,

you are right, the hardware of the USB converter does not support this property correctly. In fact, the hardware seems to deliver frames, even if there is no camera connected.

I am very sorry, but I have no workaround for this problem.

gye
February 2, 2008, 11:47:14
Hello Stefan,

Do you know if there is any other way to check if the USB converter has input video signal from a camera?

Thanks in advance.

Stefan Geissler
February 4, 2008, 12:34:24
Hi,

you may check the incoming images. If the pixels are very homogeneous, then there is no incoming image, because there is no noise.
I did something like this:


if( iCountDown == 0) iCountDown = 20;

while( iCountDown > 0 && !bResult && m_pcGrabber->isDevValid())
{
DShowLib::Error e = m_pSink->snapImages( 1, 500 );
if( !e.isError() )
{
if ( m_pcGrabber->getLastError() ) AfxMessageBox( m_pcGrabber->getLastError() );
pPixel = m_pSink->getLastAcqMemBuffer()->getPtr();
if( pPixel != NULL)
{
pPixel += m_pcGrabber->getAcqSizeMaxX() * (m_pcGrabber->getAcqSizeMaxY()-20) * 3;
pPixel += 30;
TRACE("Pixel: %3d %3d %3d\n",pPixel[0], pPixel[1] , pPixel[2]);
/*if( ( pPixel[0] == 255 && pPixel[1] == 0 && pPixel[2]== 0) ||
( pPixel[0] <= 1 && pPixel[1] <= 1 && pPixel[2] <= 1))*/

if( pPixel[2] < 200)
{
m_szErrorMessage = "No video signal";
m_cErrorCodes.Set(CErrorCodes::eNOVIDEOSIGNAL);
}
else
{
m_szErrorMessage = "";
m_cErrorCodes.Set(CErrorCodes::eNOERROR);
bResult = true;
}
}
}


This checks the values of specified pixels. But in this application I wait for a specified test image, thus I know, which values to be expected. May be this sample code is usefull for you.