PDA

View Full Version : Snap Image difficulties



yoduro
September 28, 2015, 15:04:32
Hello,

I have DMK23G445 and DMx 31AU03.AS cameras.
The first one has a gige interface and the other usb.

I am trying to create an interface to run single captures on this cameras.
My function to grab a single frame works with DMK23G445 but it doesn't works with the usb camera (snapImages function doesn't works.) I don't what's goes wrong in my code. Does anyone know why can I capture a frame with the gige camera and not with the other ?

Here is my code :




BYTE* buf[1];

pVidCapDevList = m_pGrabber->getAvailableVideoCaptureDevices();

// Open the selected video capture device.createDevice
m_pGrabber->openDev(pVidCapDevList->at(0));

// Create sink.
pSink = DShowLib::FrameHandlerSink::create( DShowLib::eY800, 1 );

// Enable snap mode
pSink->setSnapMode(true);

// Set the sink.
m_pGrabber->setSinkType(pSink);

m_pGrabber->prepareLive(false);

// Retrieve the output type and dimension of the handler sink.
DShowLib::FrameTypeInfo info;
pSink->getOutputFrameType(info);

Mat newImg = Mat(info.dim.cy, info.dim.cx, CV_8UC1, Scalar(0));

buf[0] = new BYTE[info.buffersize];

// Create a new MemBuffer collection that uses our own image buffers.
pCollection = DShowLib::MemBufferCollection::create( info, 1, buf );
if( pCollection == 0 || !pSink->setMemBufferCollection(pCollection))
std::cerr << "Could not set the new MemBufferCollection";

m_pGrabber->startLive();

pSink->snapImages(1,2000);

pSink->getLastAcqMemBuffer()->save( "D:/test.bmp" );
memcpy(newImg.ptr(), buf[0], info.buffersize);

namedWindow("cap", WINDOW_NORMAL);
imshow("cap", newImg);
waitKey(0);

m_pGrabber->stopLive();

m_pGrabber->closeDev();

Stefan Geissler
September 28, 2015, 17:00:04
Hi

Is it possible, you have the USB camera connected to an USB 3.0 Intel controller? In this case, your USB camera wont provide images, unless you reduce the frame rate.

yoduro
September 29, 2015, 10:55:58
Hi Stephan,

Thank you very much. Indeed it was the reason. I have three usb 3.0 on my computer. If I reduce the fps value, I can snap image on DMx 31AU03.AS camera. I didn't thought to try to do that. Thanks again !

louiebeck
November 24, 2015, 10:13:45
still i got issues,please help me
camera wont connect
Thanks ,

Stefan Geissler
November 30, 2015, 15:01:01
still i got issues,please help me
camera wont connect
Thanks ,


More details please.