PDA

View Full Version : how to get raw buffer hi plz help me



brahmakurre
November 12, 2007, 08:37:39
hi every body

my requirement is to get raw image buffer for multi-frames at a time into the disk....

i have used code like this

long gRows,gCols;
Grabber grabber;
grabber.setOverlayBitmapPathPosition( ePP_NONE );
tFrameHandlerSinkPtr pSink = FrameHandlerSink::create( eRGB32,500 );
pSink->setSnapMode( true );
grabber.setSinkType( pSink );
FrameTypeInfo info;
pSink->getOutputFrameType( info );

BYTE* pBuf[500];
for( int i = 0; i < 500; ++i )
{
pBuf[i] = new BYTE[info.buffersize];
}

tMemBufferCollectionPtr pCollection = MemBufferCollection::create( info, 500, pBuf );
if( pCollection == 0 || !pSink->setMemBufferCollection( pCollection ) )
{
std::cerr << "Could not set the new MemBufferCollection, because types do not match.";
return -1;
}

grabber.startLive( true );
pSink->snapImages( 500 );

gRows = grabber.getAcqSizeMaxY();
gCols = grabber.getAcqSizeMaxX();
FILE *fp;
for(i = 0; i < 500; ++i )
{
fp = fopen("C:\\snap.raw","a+");
fwrite((pSink->getMemBufferCollection()->getBuffer( i ))->getPtr(),1,gRows * gCols * 1,fp);
}

fclose(fp);
grabber.stopLive();
grabber.closeDev();

for( int j = 0; j < 500; ++j )
{
delete pBuf[j];
}

in this way iam writing raw buffer into the disk with some file name..... it is working

please advise me is this the correct way...
after that we have to convert that file as a dicom image and we have to use in our pacs

it would be very greatful if i some body advise me the correct way

Stefan Geissler
November 12, 2007, 12:22:49
Hello Brahmakurre,

You have mixed up the membuffer and the framehandler sink. After you have created the framehandler sink, you do not need to create the membuffer collection extra.



long gRows,gCols;
Grabber grabber;
grabber.showDevicePage(); // Select the Y800 video format in this dialog.
grabber.setOverlayBitmapPathPosition( ePP_NONE );
tFrameHandlerSinkPtr pSink = FrameHandlerSink::create( eY800,500 ); // eY800, because you want to have raw data.
// Thats only 1 byte per pixel
pSink->setSnapMode( true );
grabber.setSinkType( pSink );
FrameTypeInfo info;
pSink->getOutputFrameType( info );


grabber.startLive( true );
pSink->snapImages( 500 );
grabber.stopLive();

smart_ptr<MemBufferCollection>pMemBuffColl = pSink->getMemBufferCollection(); // Get the membuffers.

gRows = grabber.getAcqSizeMaxY();
gCols = grabber.getAcqSizeMaxX();
FILE *fp;

fp = fopen("C:\\snap.raw","a+"); // Should be outside of the loop.

for(i = 0; i < 500; ++i )
{
fwrite((getMemBufferCollection->getBuffer( i ))->getPtr(),1,gRows * gCols * 1,fp);
}
fclose(fp);

grabber.closeDev();


This should work. I did not test this on my own, but it should do.