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

The exposure settings, they do nothing. PS3Eye tracking only works in low lighting. #150

Closed
cboulay opened this issue Feb 12, 2015 · 5 comments

Comments

@cboulay
Copy link
Contributor

cboulay commented Feb 12, 2015

In OSX, pushing the globe against the iSight camera automatically lowers its exposure, so that works.

When using the PS3Eye in Windows or OSX, tracking only works in low-light conditions. I think many people get this problem. See #141

in psmove_tracker_new_with_camera(int camera), there is a call to psmove_tracker_set_exposure(tracker, Exposure_LOW);

In psmove_tracker_set_exposure(PSMoveTracker *tracker, enum PSMoveTracker_Exposure exposure), target_luminance is set depending on the exposure input, with Exposure_LOW yielding target_luminance = 0;

Then it calls
tracker->exposure = psmove_tracker_adapt_to_light(tracker, target_luminance);

That function has an algorithm to adapt the exposure setting to yield the target_luminance. When target_luminance==0, it immediately returns with minimum_exposure: 2051;

Then
camera_control_set_parameters(tracker->cc, 0, 0, 0, tracker->exposure, 0, 0xffff, 0xffff, 0xffff, -1, -1);

For reference, here's the function declaration.
camera_control_set_parameters(CameraControl* cc, int autoE, int autoG, int autoWB, int exposure, int gain, int wbRed, int wbGreen, int wbBlue, int contrast, int brightness)

That function is platform specific. In Windows, using the PSEYE, it sets a registry key with these values, then restarts camera capture with openCV. This calls cvCreateCameraCapture( cameraID );

As far as I can tell, this function does not care what's in the registry.

In OSX, we just get a warning: psmove_WARNING("Unimplemented: Setting of PS3EYEDriver parameters\n");

@cboulay
Copy link
Contributor Author

cboulay commented Feb 12, 2015

I fixed this problem for Windows in my own fork. I made quite a few changes in my own fork that I'm not sure you want to merge upstream. For example, I removed PS3EYEDriver as a submodule.

@thp
Copy link
Owner

thp commented May 25, 2015

If you have a fix, I'd still be interested in getting it merged upstream. Any chance we could do that? ;)

@peoro
Copy link

peoro commented Oct 27, 2015

I'm having a related issue on Linux. Apparently psmoveapi sets auto exposure to 0 (v4l2_set_control(fd, V4L2_CID_EXPOSURE_AUTO, autoE); in camera_control_set_parameters, called by psmove_tracker_set_exposure, psmove_tracker_new_with_camera, psmove_tracker_new).

With my camera (PS3Eye, using GSPCA/OV534 USB Camera Driver), having auto exposure set to 0 means enabling the auto exposure. I found out that V4L2_CID_EXPOSURE_AUTO needs to be set to 65535 (which is different from V4L2_EXPOSURE_MANUAL, WTF?) in order to disable auto exposure.

I don't understand what's going on, and wouldn't know how to fix this issue in a clean way.
I decided to have camera_control_set_parameters returning immediately without doing anything, and to manually control the camera settings using v4l2-ctl (v4l2-ctl -d /dev/video0 -c auto_exposure=1 to set manual exposure, v4l2-ctl -d /dev/video0 -c exposure=10 to control the exposure level etc).

Hope this can help!

@ghost
Copy link

ghost commented Feb 22, 2017

@peoronoob thanks, it did help in my case too!

@alessiodeltrecco
Copy link

alessiodeltrecco commented Dec 21, 2019

Hi, i think i've found a solution, at least for Linux it's working...
After some researches and tests, based on the infos contained in @peoro's reply, i've modified psmove_tracker.c changing all the calls to camera_control_set_parameters from:

camera_control_set_parameters(tracker->cc, 0, 0, 0, tracker->settings.camera_exposure,
		0, 0xffff, 0xffff, 0xffff, -1, -1, tracker->settings.camera_mirror);

to:

camera_control_set_parameters(tracker->cc, 65535, 0, 0, tracker->settings.camera_exposure,
		0, 0xffff, 0xffff, 0xffff, -1, -1, tracker->settings.camera_mirror);

and it worked 😍

Hope this helps and the fix could be merged upstream

Here's my modified file: psmove_tracker.zip

@thp thp closed this as completed in 40d8c06 Jan 1, 2020
thp added a commit that referenced this issue Jan 1, 2020
PSEye on Linux: Fix auto-exposure setting (Fixes #150)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants