PDA

View Full Version : Acessing Image information



sumitg
May 14, 2005, 20:06:15
hi to all,
I am having a problem in understanding how to access the image information which i would like to use in doing one of my experiments.
I have a sony analog camera ..model-kpc_sc20c..connected to a sony video walkman or a a/d converter DFG -1394-1, connect this to firewire and then to my windows xp machine.
I need to access the image information via a c++ program that i written in microsoft VC++ .
can anyone please tell me what all i need to do for this, as in install which drivers and softwares, what would be the image format stored in the mememory buffer which i need to access from my program.
I would highly appreciate a prompt reply.
Thanks

Sumit

Stefan Geissler
May 17, 2005, 13:26:37
Hi Sumit,

image processing is done within 5 steps:

1. Setup the grabber, that means open the video capture device, select the video format.
2. Then create the memory buffer, where the images are to be saved in.
3. Start the live video and snap an image
4. Stop the live video.
5. Access the image data.

The source code would look like this (it is copied from the „Callback“ sample:


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

Grabber *grabber = new DshowLib::Grabber();

// This is coded in the „common\setupDevice.cpp“ and sets the video norm
// and video format.
if ( !setupDevice( grabber ) )
{
delete grabber;
exit( 1 );
}

// Set the colorformat for the images in memory.
grabber->setSinkType( FrameGrabberSink(
FrameGrabberSink::tFrameGrabberMode::eSNAP, DshowLib::eRGB24) );


// Now create the memory buffer for the images.
Grabber::tMemBufferCollectionPtr pMemBuffColl = grabber->
newMemBufferCollection( 2 );
grabber->setActiveMemBufferCollection( pMemBuffColl );

// Snap an Image
grabber->startLive( true ); // Start the grabber.
grabber->snapImages( 1 ); // Grab NUM_BUFFERS images.
grabber->stopLive();

// Access the image data:
BYTE *pData = m_Grabber.getActiveMemBuffer()->getPtr();

Now you can access the image data, that are pointed to by pData. It is just an unformated stream of bytes. Regarding to the color format in memory, three bytes will specify one pixel. The colors are save as blue, green red.

sumitg
May 19, 2005, 16:16:19
Hi Stefan,
Thanks a lot for the promt reply. Actually i wanted to access the memeory buffer containing the image imformation online.I would need to call for the memory function containing the image information from my Vc++ program one frame at a time online instead of saving the images and then running my program offline.
I have just received the video to firewire converter from IC imaging control. i would highly appreciate it if you could advice me in how to go about doing what i mentioned earlier.

Thanks
Sumit

Stefan Geissler
May 19, 2005, 16:40:03
Sumi,

have a look on GrabberListener class in the documention. It is, what you need for continous image processing.
Inherit a class from GrabberListener ( e.g. CListener) and overwrite the GrabberListener::frameReady method.
Add the CListener object with Grabber::AddListener() to your listener.
Do not forget to setup the image memory (like shown in my last post).
Change the sink from eSNAP to eGRAB.
CListener::frameReady will not be called for each incoming frame. You may use the CListener Class from the "Callback" sample.