After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 790945 - ahcsrc: problems with autofocus on Android
ahcsrc: problems with autofocus on Android
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
1.12.3
Other other
: Normal normal
: 1.13.1
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2017-11-28 15:01 UTC by test.code.010
Modified: 2018-01-26 10:13 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
ahc: enable autofocus callback (1.19 KB, patch)
2017-12-13 04:47 UTC, Justin Kim
none Details | Review

Description test.code.010 2017-11-28 15:01:06 UTC
Hey,

Trying to use the Continuous video focus mode while filming with the ahcsrc element but I think there is a bug with it (and the other focus modes) as it is absolutely not focusing :

GstElement* ahcsrc = gst_element_factory_make("ahcsrc", NULL);
g_object_set(ahcsrc, GST_PHOTOGRAPHY_PROP_FOCUS_MODE, GST_PHOTOGRAPHY_FOCUS_MODE_CONTINUOUS_EXTENDED, NULL);

Also tried to call...

gst_photography_set_autofocus((GstPhotography *) ahcsrc, FALSE);

...just before setting the focus mode but still it is not focusing

Thanks
Comment 1 Justin Kim 2017-11-29 01:57:15 UTC
(In reply to test.code.010 from comment #0)
> GstElement* ahcsrc = gst_element_factory_make("ahcsrc", NULL);
> g_object_set(ahcsrc, GST_PHOTOGRAPHY_PROP_FOCUS_MODE,
> GST_PHOTOGRAPHY_FOCUS_MODE_CONTINUOUS_EXTENDED, NULL);
> 

Do you know the GST_STATE of ahcsrc when you set the mode?

If your codes do really like that, you are setting the mode in NULL state.
The mode can be set only after opening camera device, then the state should be PUASED, or PLAYING.
Comment 2 test.code.010 2017-11-29 16:56:29 UTC
Tried to set it in paused and playing state.

Does not seem it works either.

Maybe I am doing something wrong ?

Would be nice if you could try it yourself :)

Thanks for the help
Comment 3 test.code.010 2017-12-12 08:16:30 UTC
If you've got any more idea ?
Comment 4 Justin Kim 2017-12-13 04:27:29 UTC
I have checked what happens when autofocus is enabled. Currently, autofocus callback is commented out so it crashes after enabling it. ;(
However, even if the callback receives the result properly, my nexus 5 complains error from camera-sensor.

```
12-13 13:19:13.166  9910  9910 D org.freedesktop.gstreamer.camera.GstAhc: AutoFocus: true
12-13 13:19:13.166  9910  9910 D GStreamer+camera-test: 0:00:24.174453085 0x71bcdd3000 /Users/justin/git/gst-ahc-example/app/src/main/jni/android_camera.c:435:gst_native_set_auto_focus Setting Autofocus (1)
12-13 13:19:13.528  2718  9961 E mm-camera-sensor: af_actuator_move_focus:240error
12-13 13:19:13.572  9910  9910 W GStreamer+ahcsrc: 0:00:24.579884532 0x71bcdd3000 gstahcsrc.c:1698:gst_ahc_src_on_auto_focus:<ahcsrc> Auto focus completed : 1
```

I need to investigate more.
Comment 5 Justin Kim 2017-12-13 04:47:19 UTC
Created attachment 365471 [details] [review]
ahc: enable autofocus callback

    It should be enabled to set autofocus properly, but
    it seems to be commented out mistakenly from the first commit.
Comment 6 Justin Kim 2017-12-13 04:50:25 UTC
(In reply to Justin J. Kim from comment #4)
> I need to investigate more.

Oh, I missed adding feature to manifest. With the manifest and the patch above, Autofocus works properly. 

(In reply to test.code.010 from comment #3)
> If you've got any more idea ?

Did you check the manifest?
According to the API, it should have the below one.

 <uses-feature android:name="android.hardware.camera.autofocus" />
Comment 7 Tim-Philipp Müller 2018-01-25 23:01:58 UTC
Should this patch be pushed then or is more work needed?
Comment 8 Justin Kim 2018-01-26 03:35:54 UTC
(In reply to Tim-Philipp Müller from comment #7)
> Should this patch be pushed then or is more work needed?

Yes, could you please merge it if there's no concern?
It should be pushed because it causes a crash by missing callback if autofocus is enabled.
Comment 9 Tim-Philipp Müller 2018-01-26 10:13:39 UTC
Done, thanks:

commit 297f7e4f04d5e2539612e5d29c8ff8b51af16d6c (HEAD -> master)
Author: Justin Kim <justin.kim@collabora.com>
Date:   Wed Dec 13 13:43:30 2017 +0900

    ahc: enable autofocus callback
    
    It should be enabled to set autofocus properly, but
    it seems to be commented out mistakenly from the first commit.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=790945