Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HACK][Camera2] init parameters #122

Draft
wants to merge 2 commits into
base: camera2
Choose a base branch
from

Conversation

b100dian
Copy link

@b100dian b100dian commented Feb 9, 2024

This PR is a hack as the title says.

There are two observations around current camera2 initialization that this fixes:

  1. First is that the "params" are sent when nor image, video and not even preview requests are alive. So they go to /dev/null.
    The fix for this was to make a copy of the params and re-apply them when actual requests are alive
  2. The second observation is that exposure-compensation is part of only ONE initial set of params sent from gst-droid, and not the second one. So there are at least TWO param updates before at least the preview request is alive, and only the first one has the exposure. The fix was to always propagate the first exposure-compensation sent until the copied params are applied at actual initialization.

I realize this is not a fix at all - it is just some info.
It does help me with 1. applying edge-mode and noisereduction initially and 2. applying the previous exposure

Change-Id: I16aa912382396026204266fe80c796774b7aa5a7
Change-Id: Id4e30769f50f44333521347075f47e29ec91b790
// Solution: propagate the initial exposure compensation to all subsequent retries before the preview and other requests are 'on'.
std::string exposure_compensation = camera->m_param_map["exposure-compensation"];
camera->m_param_map = param_map;
if (exposure_compensation.size()) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (exposure_compensation.size()) {
if (param_map.count("exposure-compensation") == 0 && exposure_compensation.size()) {

from my understanding there is no longer a way to actually change the value with your code?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First, the code: the [] operator returns a default constructed string if there's none, that's why I check for size. It also creates an entry, so the count may fail next.
Indeed, checking for its' presence with count would be better.

Secondly: The quick hack is around the fact that jolla-camera (or gst-droid itself) does not initialize the camera with the previous exposure compensation setting but ONCE. This change propagates that one time value to all the params at initialization until there's an actual request (be it preview, image or video request) is set - so the code only runs when none of the above are set.
Then, the usual get params / set params should work. So the jolla-camera can now set other values and store other values to use for the next session. My hunch is that the lack of setting the exposure-compensation at the beginning (because not even preview is on) triggers a read of the default compensation and we're left with that - but I am open to being corrected!

Thanks for your comment! This is just a "here, I got it working on my device" PR and it is a HACK. Gstreamer should be aware of this initialization process (maybe?) and act properly with camera2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants