Convert Mat to PvBuffer (from Pleora eBUS SDK lib.)

411 views Asked by At

thank you in advance for reading this.

For better readability I'll list pieces of info. necessary in point form.

  • building an app based on eBUS player sample provided by Pleora.
  • Grabbing images in 16 bit gray in 50 fps.
  • my app is processing image data using openCV within the OnBufferDisplay function in DisplayThread
  • so far, I have successfully processed images suiting my needs and am trying to convert my Mat(processed already) data back to PvImage or PvBuffer s.t. the image can be displayed in the eBUS Player using the already existing display function(this way I can still use other features in the Player app without having to make too many modifications to the original app).
  • The difficulty arises from the fact that display functions and other important functions are hidden in dlls. I can only make modifications to what's exposed.
  • The processing procedure is basically:
void Display Thread::OnBufferDisplay(PvBuffer *aBuffer){
   aBuffer->Attach(imageMat.data, 614400);
   //where imageMat is init'd as
   //imageMat = cv::Mat(cv::Size(imgWidth, imgHeight), CV_16U);

   //process.. the data....

   //at this point, I Have my Mat object ready to go.

   //supposed to create or have another PvImage or PvBuffer with the processed datahere for displaying.
   
   //Display
   mDisplay->Display(*aBuffer);
}

  • What I have tried so far is:
memcpy(aBuffer->GetDataPointer(), imageMat.data 614400);

//and 

aBuffer->free();
//and/or
aBuffer->Detach();
//then
aBuffer->Alloc(614400); //since 640 * 480 in 16 bit gray
memcpy( Mat.data to buffer->datapointer);

Please help me clarify the following:

  • I have discovered after using Attach(), the passed aBuffer does no longer properly display image. Does that mean this function not just copies the data from aBuffer to imageMat.data but erases the data in aBuffer and then copies it to imageMat.data?

  • I went for Attach() because memcpy(imageMat.data, aBuffer->GetDataPinter(), size); didn't work. It didn't copy the data properly like the way Attach() does. Anybody know why?

  • The description for Attach() provided by Pleora is "Attach this PvBuffer to an external memory buffer. To use an internal memory buffer, use Alloc.".

In summary,

How do you properly create a PvImage or a PvBuffer object that contains the data from my Mat object in order to pass to the Display() function?

Are there any detours to make this work without having to create such objects?

0

There are 0 answers