Page 1 of 1

RVCamera1GetImage(Sender: TObject; img: TRVMBitmap);

Posted: Wed Oct 30, 2019 9:55 am
by ya_vanka
In my application I need to have a direct access to a frame bitmap. I draw frames by myself via OpenGL texture.

RVCamera has an event OnGetImage, so RVCamera1GetImage is called when a new frame is decoded.
RVCamera1GetImage has input parameter img and property img.Data that is a pointer to an array of pixels.

First I was sure that this pointer is a fixed address where all frames are placed. So I tried just to get data from this address. But I was wrong!
It changes!

Can you explain why?

Because of this I have to copy data of frame each time OnGetImage happens (FLastFrame.AssignRVMBitmap(img)). This is an overhead and useless routine. And I have to do it because of my custom drawing procedure that is called not synchronousely with OnGetImage and I get access violation if I try to access data located at img.Data address.

Re: RVCamera1GetImage(Sender: TObject; img: TRVMBitmap);

Posted: Wed Oct 30, 2019 12:08 pm
by Sergey Tkachenko
TRVCamera uses an array of bitmaps internally. While one bitmap is locked for displaying, another bitmap can be used to get data.

Re: RVCamera1GetImage(Sender: TObject; img: TRVMBitmap);

Posted: Wed Oct 30, 2019 6:44 pm
by ya_vanka
Is there an access to this array?

How can I avoid copying img.Data to another class instance?

Re: RVCamera1GetImage(Sender: TObject; img: TRVMBitmap);

Posted: Wed Oct 30, 2019 8:36 pm
by Sergey Tkachenko
Sorry, I do not understand why do you need it.
If your procedure is called not synchronously with OnGetImage, your drawing will be overridden by TRVCamera.

Re: RVCamera1GetImage(Sender: TObject; img: TRVMBitmap);

Posted: Wed Nov 06, 2019 6:33 pm
by Kas
Hi Sergey,

I faced this in the past in one application when i needed to process very huge images, with current OnGetImage i had to copy the data each time, and this copy happened every frame and made a latency accumulate.

Now as a suggestion if that is possible: Add different version of OnGetImage where img (the data) are declared as TBytes ( any managed type will do, or data pointer with size) and the component will expect a boolean to indicate the ownership of that data/buffer.

eg:

Code: Select all

  TRVCamGetImageDataEvent = procedure(Sender: TObject; img: TBytes; DontFree: Boolean = False) of object;
or

Code: Select all

  TRVCamGetImageExEvent = procedure(Sender: TObject; imgData: Pointer; Length: Integer; NotUsed:Boolean = True) of object;
The boolean return value will tell the component to forget the buffer and allocate new one, ( no free or reallocation), as the data from that point is the responsibility of the application.

Re: RVCamera1GetImage(Sender: TObject; img: TRVMBitmap);

Posted: Thu Nov 07, 2019 7:25 am
by Sergey Tkachenko
We are preparing a new update, where image buffering may be turned off by assigning RVCamera.Latency = 0. In this case, a single bitmap object must be used.