RVCamera1GetImage(Sender: TObject; img: TRVMBitmap);

RVMedia support and discussion (components for displaying and controlling IP cameras, webcams, video conferencing, video chats, recording audio and video files)
Post Reply
ya_vanka
Posts: 65
Joined: Tue Oct 22, 2019 6:24 pm

RVCamera1GetImage(Sender: TObject; img: TRVMBitmap);

Post 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.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

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

Post 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.
ya_vanka
Posts: 65
Joined: Tue Oct 22, 2019 6:24 pm

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

Post by ya_vanka »

Is there an access to this array?

How can I avoid copying img.Data to another class instance?
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

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

Post 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.
Kas
Posts: 8
Joined: Fri Oct 23, 2015 2:49 pm

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

Post 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.
Sergey Tkachenko
Site Admin
Posts: 17557
Joined: Sat Aug 27, 2005 10:28 am
Contact:

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

Post 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.
Post Reply