Support for cameras that do not have 640x480 in USBTest0 #175
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.