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

Support for cameras that do not have 640x480 in USBTest0 #175

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

RogerHardiman
Copy link

This PR is for review.

USBTest0 (and all the other Tests) are hard coded to open the UVC Camera with the resolution 640x480.

I have a UVC camera that does not have this resolution and so all the samples fail and require code changes before they will run. The closest match for my camera is a 640x400 resolution.

I have changed USBTest0 to request a list of valid sizes from the camera. I then find the nearest match to 640x480 and use the nearest match (in my case 640x400)

The change allows USB Test 0 to work on all my UVC cameras.

I have put the 'nearest match' code in USB Test 0 and it is duplicated, one for MJPEG and one for YUV. I can move this into the UVCCamera class if required so it is in a central location.
Also I'm not sure how to fix the other examples that set the Surface aspect ratio before the camera is opened. Those samples need to have the creation of the surface delayed until after UVCCamera.Open() so for now I've just fixed Test0

Please let me know if you want to move the 'nearest match' function to the UVCcamera class and I can modify the PR.

The change also fixes a small bug.
Opening in YUV Mode used the parameter UVCCamera.DEFAULT_PREVIEW_MODE
This should be UVCCamera.FRAME_FORMAT_YUYV.
Both have a value of 0 so the sample worked but this uses the correct parameter.

Allows cameras that do not support the default width and height (840x480)
to work by the nearest valid UVC camera width and height.
@sappho192
Copy link

Hi @saki4510t , I think it is good to accept this commit.
The resolution of my testing camera is 1280 * 480 or 2560 * 960 since it is dual lens and sends two images with merged. Current source code like usbCameraTest0 doesn't handle this but the revision of @RogerHardiman does.

By the way, sometimes blink images with partial grey coloured area and partial images through camera occur. Is this out of performance issue?
My phone is Samsung Galaxy S7.
Thanks.

@sappho192
Copy link

I've applied @RogerHardiman 's code into other projects which my camera didn't work and they works!
Maybe this code should be applied to every projects in this repo.

@fengbenpaao
Copy link

but when I change to UVCCamera.FRAME_FORMAT_YUYV. my preview can not play, why ? my MJPGE is ok.

@RogerHardiman
Copy link
Author

Can you include your code change please?

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 this pull request may close these issues.

3 participants