GearVRf
GearVRf copied to clipboard
GVRCameraSceneObject's camera autofocus not working
I was working on a project that uses the passthrough camera heavily. Recently I switched the test device from S6 to S7. It seems the autofocus of camera does not work on S7.
The autofocus was working fine on S6. But the same code cannot get the autofocus functionality on S7. On both devices, the passthrough camera from the oculus setting/utilities can do the autofocus, so the hardware is not the problem.
By printing out the camera parameters, I found, on S7, the autofocus parameter cannot be successfully set to 'continuous-video' by the following code, which works on S6. The parameter seems locked to 'auto'
params.set("focus-mode", "continuous-video");
camera.setParameters(params);
I tweaked some code in GVRCameraSceneObject and found that if I comment out all camera.setPreviewTexture(mSurfaceTexture);
the parameter can be successfully set to 'continuous-video'. But in that case, the preview image will not be rendered.
The test code is from the gearvrf-demo (https://github.com/gearvrf/GearVRf-Demos/tree/master/gvr-sceneobjects)
I have no clue why it happens. Anyone experience the same issue on S7?
Hardware/OS
- Galaxy S6/Android 5.0.2
- Galaxy S7/Android 6.0.1
Hi, I would be curious to know what happens if you use the original GVRCameraSceneObject but in gvr-sceneobjects make the setUpCameraForVrMode(1)
call from the Android main/ui thread after 500ms delay for example.
@lxc-xx Any luck getting the continuous-video mode to work?
Sorry for late reply. I was working on other stuff these days.
Yes, it works! But 500ms is not long enough, my S7 works with 1000ms. Now it fixes the problem with my project. Do you have any idea why it happens? Seems some task on camera initilization is running in async mode?
I think we need to wait for some preview texture-related event. We need to study it more to determine a real fix but at least you have a workaround.
Definitely!
For now, I suggest keeping this issue open for the reference of other developers?
Sure. We have not fixed it.
@lxc-xx Delay for S7 is ~1s. From my experience camera in android is messed up and you will have to experiment with lots of hacks to make it work on big range of phones :)