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.
RVCamera1GetImage(Sender: TObject; img: TRVMBitmap);
-
- Site Admin
- Posts: 17553
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: RVCamera1GetImage(Sender: TObject; img: TRVMBitmap);
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);
Is there an access to this array?
How can I avoid copying img.Data to another class instance?
How can I avoid copying img.Data to another class instance?
-
- Site Admin
- Posts: 17553
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: RVCamera1GetImage(Sender: TObject; img: TRVMBitmap);
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.
If your procedure is called not synchronously with OnGetImage, your drawing will be overridden by TRVCamera.
Re: RVCamera1GetImage(Sender: TObject; img: TRVMBitmap);
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:
or
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.
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;
Code: Select all
TRVCamGetImageExEvent = procedure(Sender: TObject; imgData: Pointer; Length: Integer; NotUsed:Boolean = True) of object;
-
- Site Admin
- Posts: 17553
- Joined: Sat Aug 27, 2005 10:28 am
- Contact:
Re: RVCamera1GetImage(Sender: TObject; img: TRVMBitmap);
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.