Variable monocrome in Cap_pvapi.cpp (Bug #3948)
Description
The flag monocrome is not updated properly in Cap_pvapi.cpp.
The default value is false (a color camera); this is done in function CvCaptureCAM_PvAPI().
In version 2.4.9 and below, if the camera was set to mono8 or mono16, the variable monocrome is not updated (unless a call to setProperty with CV_CAP_PROP_MONOCROME is generated). Hence, the image is treated as a colored imaged. This bug was partly obscured by another bug I've posted that merged three gray frames to a color frame. So in essence, the user gets a color frame (3 channels) but it is black and white.
The fix in version 2.4.9 is simple enough. In function CvCaptureCAM_PvAPI::open( int index ), add monorome=true after mono8 and mono16 switch:
if (strcmp(pixelFormat, "Mono8")==0) { grayframe = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_8U, 1);
change to:
if (strcmp(pixelFormat, "Mono8")==0) { monocrome = false; grayframe = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_8U, 1);
And:
else if (strcmp(pixelFormat, "Mono16")==0) { grayframe = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_16U, 1);
change to:
else if (strcmp(pixelFormat, "Mono16")==0) { monocrome = true; grayframe = cvCreateImage(cvSize((int)frameWidth, (int)frameHeight), IPL_DEPTH_16U, 1);
In version 3.0 the default behavior is setting the camera to mono8. This should arguably fix the problem since the default is OK however in case someone changes the pixel format to mono16 the bug remains. Therefore, a similar fix should be done in 3.0 in the switch case.
Associated revisions
Merge pull request #3948 from PhilLab:markdownPatch
History
Updated by Steven Puttemans over 10 years ago
Thanks for the input! Are you up in supplying a pull request yourself with the fix?
If not let me know and I will include it!
If you do, I suggest to merge it with bug #3946 and bug #3947!
- Assignee set to Shai Vaingast
- Status changed from New to Open
Updated by Steven Puttemans over 10 years ago
PR submitted!
- Pull request set to https://github.com/Itseez/opencv/pull/3322
Updated by Philip L almost 10 years ago
PR was merged and solution should also be already in OpenCV 3.0
- Status changed from Open to Done
- % Done changed from 0 to 100