I have an issue converting (Pleora SDK)PvBuffer into an Opencv buffer and process the stream.
this is a sample code i found in (Pleora SDK C++ sample codes)
while ( !PvKbHit() )
{
PvBuffer *lBuffer = NULL;
PvResult lOperationResult;
PvBufferWriter lBufferWriter;
// Retrieve next buffer
PvResult lResult = aStream->RetrieveBuffer( &lBuffer, &lOperationResult, 1000 );
if ( lResult.IsOK() )
{
if ( lOperationResult.IsOK() )
{
PvPayloadType lType;
//
// We now have a valid buffer. This is where you would typically process the buffer.
// -----------------------------------------------------------------------------------------
lFrameRate->GetValue( lFrameRateVal );
lBandwidth->GetValue( lBandwidthVal );
// If the buffer contains an image, display width and height.
uint32_t lWidth = 0, lHeight = 0;
lType = lBuffer->GetPayloadType();
cout << fixed << setprecision( 1 );
cout << lDoodle[ lDoodleIndex ];
cout << " BlockID: " << uppercase << hex << setfill( '0' ) << setw( 16 ) << lBuffer->GetBlockID();
if ( lType == PvPayloadTypeImage )
{
// Get image specific buffer interface.
PvImage *lImage = lBuffer->GetImage();
// Read width, height.
lWidth = lBuffer->GetImage()->GetWidth();
lHeight = lBuffer->GetImage()->GetHeight();
unsigned char * data = lBuffer->GetImage()->GetDataPointer();
Mat OpencvImg = Mat(Size(lWidth, lHeight), CV_8UC1, data);
threshold(OpencvImg, OpencvImg, 100, 255, 0);
if you check the last 3 lines , I am trying to convert the buffer into a Mat but without success . I also would like to display the stream as well .
Thank you in advance.