PDA

View Full Version : Help : snapImages() crash



waazimreza
February 18, 2010, 21:25:05
Hi,

I am a very new to cameras and programming it. I have the camera DFK21F04 (Imaging Source) ... I am trying to snap an image from one camera ... I am using the following code...


void CFirstStepView::OnInitialUpdate()
{
CView::OnInitialUpdate();

DShowLib::Grabber grabber;
DShowLib::Grabber m_Grabber;
CString szImageName;
DShowLib::Grabber::tVidCapDevListPtr pVidCapDevList = m_Grabber.getAvailableVideoCaptureDevices();
m_Grabber.openDev( pVidCapDevList->at( 0 ));
if(m_Grabber.isDevValid() )
{
m_Grabber.startLive();
m_Grabber.snapImages(100);
szImageName = "MyImage.bmp";
m_Grabber.getActiveMemBuffer()->save(szImageName);
m_Grabber.stopLive();
m_Grabber.closeDev();
}

}

I am getting an crash [Unhandled exception at 0x10232956 in FirstStep.exe: 0xC0000005: Access violation reading location 0x00000000.] at TIS_UDSHL08_vc8d.dll at line m_Grabber.getActiveMemBuffer()->save(szImageName);


I saw a similar issue in the following thread..
http://www.theimagingsourceforums.com/archive/index.php/t-315651.html

I am not clear how the person resolved it though!

Also ,when I run the code without the snapImages and any memoryBuff things I don't see any crashes and I see the video at the output?



Regards,
Waazim Reza
waazimreza@gmail.com

Stefan Geissler
February 19, 2010, 11:22:21
Hi,

I do not know, whether you have enough memory to capture 100 images. Do you want to snap 100 images and save the last one? If not, then write
m_Grabber.startLive();
m_Grabber.snapImages();
szImageName = "MyImage.bmp";
m_Grabber.getActiveMemBuffer()->save(szImageName);