PDA

View Full Version : snapImages and Windows XP



JLBrown
June 3, 2003, 17:46:07
Has anyone else experienced a problem under windows XP with a sony camera? I am currently developing using a (SONY-DFW SX900). In the code fragment under windows 2000 when ever snapImages fails (seems quiet rare to happen) the application sucessfully re-tries and continues. However under Windows XP when snapImages fails when it re-tries it is successful in capturing an image, but the image is all broken up.

Has anyone else experienced this? Should I stop the live image and then start it up again before retrying? The frame sink type is set to 'eSNAP'

Thanks in advance,
John

BOOL CaptureFixedShutterFrame(tCameraBoard *pBoard,int nFramePerImage,long timeoutSeconds=10)
{
REFERENCE_TIME curTime,timeNow;
BOOL bResult = FALSE;
Grabber::tMemBufferPtr pMemBuff = NULL;

//if (!pBoard->pGrabber->isLive())
if (!pBoard->pGrabber->setCallback())return ErrorMessageBox(false,"setCallback(): failed");
if (!pBoard->pGrabber->startLive(false))return ErrorMessageBox(false,">startLive(false): failed");
if (!pBoard->pGrabber->getCurReferenceTime(curTime))return ErrorMessageBox(false,"getCurReferenceTime(): failed");
do{
pBoard->pGrabber->getCurReferenceTime(timeNow);
long sec = nano2sec(timeNow - curTime);
if (sec >= timeoutSeconds){
pBoard->pGrabber->stopLive();
return FALSE;//ErrorMessageBox(false,"Timeout!");
}
if (!pBoard->pGrabber->snapImages(1,2500)){
ErrorMessageBox(false,"snapImages failed!");
continue; // grab images
}

if ((pMemBuff = pBoard->pGrabber->getActiveMemBuffer())==NULL){
ErrorMessageBox(false,"getActiveMemBuffer failed!");
continue;
}

tsMediaSampleDesc desc = pMemBuff->getSampleDesc();
if ((curTime/100000) > desc.SampleStart)
continue;// skip as it's an old frame (with possible drag)
bResult = TRUE;
}while (bResult != TRUE);

if ((pMemBuff = pBoard->pGrabber->getActiveMemBuffer())==NULL){pBoard->pGrabber->stopLive();return FALSE;}
memcpy(pBoard->uFrameBuffer,pMemBuff->getPtr(),pBoard->uFrameBufferSz);
pBoard->pGrabber->stopLive();
return bResult;
}

Stefan Geissler
June 4, 2003, 08:19:42
Jon,

We found a comparable problem with the SONY DFW-SX900. The solution was to wait after startlive() has been called for 500 milliseconds. In this waiting time, the camera has enough time to initialize and start the video stream.
Also, after snapImages() failed, we called stopLive(), waited 500 milliseconds and called startLive(), again with 500 milliseconds waittime. We did hundreds of successful tests with this alghorithm.

JLBrown
June 4, 2003, 11:06:41
I've implemented the code as you said, but it's actually made the problem worse. About every other image it captures now is corrupted. I have even tried adding in additional sleep statements, but it doesn't seem to make a difference.

Any other ideas?
John


Sleep(500);// wait 500 millisecs (see support msg)
if (!pBoard->pGrabber->setCallback())return ErrorMessageBox(false,"setCallback(): failed");
Sleep(500);// wait 500 millisecs (see support msg)
if (!pBoard->pGrabber->startLive(false))return ErrorMessageBox(false,">startLive(false):1 failed");
Sleep(500);// wait 500 millisecs (see support msg)
//Sleep(500);// wait 500 millisecs (see support msg)
if (!pBoard->pGrabber->getCurReferenceTime(curTime))return ErrorMessageBox(false,"getCurReferenceTime(): failed");
do{
pBoard->pGrabber->getCurReferenceTime(timeNow);
long sec = nano2sec(timeNow - curTime);
if (sec >= timeoutSeconds){
//pBoard->pGrabber->stopLive();
pBoard->pGrabber->stopLive();// leave it live???
return FALSE;//ErrorMessageBox(false,"Timeout!");
}
if (!pBoard->pGrabber->snapImages(1,2500)){
ErrorMessageBox(false,"snapImages failed!");
pBoard->pGrabber->stopLive();
Sleep(500);// wait 500 millisecs (see support msg)
if (!pBoard->pGrabber->startLive(false))return ErrorMessageBox(false,">startLive(false):2 failed");
//Sleep(500);// wait 500 millisecs (see support msg)
continue; // grab images
}

if ((pMemBuff = pBoard->pGrabber->getActiveMemBuffer())==NULL){
ErrorMessageBox(false,"getActiveMemBuffer failed!");
continue;
}

tsMediaSampleDesc desc = pMemBuff->getSampleDesc();
if ((curTime/100000) > desc.SampleStart)
continue;// skip as it's an old frame (with possible drag)
bResult = TRUE;
}while (bResult != TRUE);

Stefan Geissler
June 5, 2003, 08:05:27
Jon,

It would be a great help for me, if you could send a corrupted sample image to support@imagingcontrol.com.

Another question: Did you install the correct driver? It is available from our homepage at "FireWire imaging".

Also you should set the frame rate any case, because the original Sony driver uses at start 30 Hz frame rate, that is not supported by the SX 900.

What about smaller video formats? Are the images corrupted to?

Another question: Do you use a desktop PC or a Laptop?