-
Notifications
You must be signed in to change notification settings - Fork 174
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
Setting size and subtype is ignored / Hints for a solution #6
Comments
that could be because we only do RGB output. VI can handle a range of YUV inputs but it converts them to RGB before the pixels get sent back to the user. |
I've just realized, that the code in the opencv source differs in some parts from your original. However, since the method setSizeAndSubtype looks the same in both versions, I will describe my observation: The method setSizeAndSubtype first retrieves the current format (tmpType). This always resulted in S_OK. But later, when setting the format (VD->pAmMediaType) inside the same method it always resulted in E_FAIL - also when trying all mediaSubtypes in the for-loop (1813 to 1823 in your code). So I compared the content of the retrieved tmpType and the newly created VD->pAmMediaType and found out, that the lSampleSize of the tmpType only was w_h_2. I changed the calculation of the lSampleSize of VD->pAmMediaType to w_h_2 and it works for me. This led to my assumption, that the camera itself allows only a two-byte-per-pixel format (YUY2). (The output image was and is still converted to RGB.) |
Also got another report of this in #12 - Not sure if you have a patch that figures out the Bytes Per Pixels based on media types. If you do please send a pull request - otherwise I'll put this on my todo list. |
Hi Theo,
first of all, thank you for that useful piece of code!
When I tried to set another size and another fourcc, it was always ignored and the default settings were taken.
After a while I figured out, that in the method "setSizeAndSubtype" (Line 1656) you calculate lSampleSize = attemptWidth_attemptHeight_3 (Line 1677).
It always resulted in E_FAIL when calling SetFormat (Line 1685).
The reason is that my Microsoft LifeCam Studio (only?) uses YUY2 which is 2 bytes per pixel (instead of 3). So the lSampleSize must be calculated by attemptWidth_attemptHeight_2 in this case - then it works.
A solution might be an additional array with bytes-per-pixel information for each mediatype.
Regards
Stefan
(Environment: Windows 8 / Visual Studio 2012 / x64)
The text was updated successfully, but these errors were encountered: