stereolabs / zed-gstreamer

Package of GStreamer elements to interface with ZED Cameras
https://www.stereolabs.com/docs/gstreamer/
61 stars 23 forks source link

[Question] Ability to control camera parameters at runtime? #23

Open NoTuxNoBux opened 3 years ago

NoTuxNoBux commented 3 years ago

Hello

In #12 support was added to control camera parameters such as brightness and contrast through zedsrc. These work fine, but is it possible to control these at runtime?

To elaborate: the properties are writeable, so I'm trying to write to them whilst the zedsrc element is active. At first sight, the brightness and contrast don't appear to change, but if I restart the zedsrc stream (e.g. reconnect to an RTSP stream using it, which appears to shut down temporarily if no one is connected), both parameters are suddenly correctly applied.

I added debug logs to the zedsrc element to confirm that it's receiving the changes in parameters, and it is. I didn't read the source thoroughly, but is it possible that these parameters are just set once during initialization and not updated at runtime afterwards?

FWIW, v4l2src also exposes brightness and contrast parameters, and controlling these at runtime appears to work, though I can't be sure if it's controlling the actual ZED camera or applying some sort of video filter instead.

Thanks!

Myzhar commented 3 years ago

Hi @NoTuxNoBux runtime controls modification is indeed not handled. We can add this feature, it is indeed really useful. How are you trying to change the values runtime? What is the best method?

NoTuxNoBux commented 3 years ago

Hi @Myzhar and thanks again for the quick response!

I'm currently using the Python GStreamer bindings, spawning a pipeline that uses the zedsrc element programatically, then fetching the element I want from the pipeline ("bin element") using iterate_elements, and then updating the properties at runtime like this:

zedsrc_element.set_property('brightness', new_brightness)
zedsrc_element.set_property('contrast', new_contrast)

In my case, the values of new_brightness and new_contrast are being controlled by a web server accepting a request to update them, but it could of course also be controlled by something else like a GUI slider, CLI input, a file that changed, or a DBus signal for testing purposes.

Of course, C or any other language with GStreamer bindings should also work similarly, only the syntax will differ a little.

keli95566 commented 2 years ago

@NoTuxNoBux I am trying to do the same thing here. However I am very new to Gstreamer and Python, would you mind sharing your live control solution? Thank you very much!

NoTuxNoBux commented 2 years ago

@keli95566 We ended up going with v4l2src for the time being since zedsrc doesn't support this yet. I can't share the code because it is a proprietary code base, but the steps are roughly:

  1. On server/API start-up, also start GStreamer pipeline.
  2. Receive API request from client to update camera parameters.
  3. Search v4l2src element in spawned GStreamer pipeline.
  4. Use set_property (or similar in your language) to update the camera parameters; GStreamer handles the rest.
keli95566 commented 2 years ago

Thank you very much for the instruction! :) However, v412src only returns unrectified image streams if I understood correctly. Perhaps I would just wait for the next release.

bioniwulf commented 9 months ago

Dear @Myzhar, May I ask about progress with control camera parameters at runtime feature? It would be really usefull.