OpenCV Video Capture corrupted color
I am trying to use VideoCapture in OpenCV to open a video stream from IDS uEye Ethernet Cameras on Windows. This is in fact known to be supported out of the box (only on Windows). My initial attempt succeeded with the video running flawlessly (for the first time). But when I modified the code to attempt to grab the time-stamp, the video started behaving weirdly and gave corrupted colors.
How the image should look like (taken using the provided software by IDS)
How the image looks like when using OpenCV VideoCapture and saving the frame
The portion of the code responsible for the video capture
int keyIn = -1;
cv::Mat frame;
cv::VideoCapture cap(1); // 0 is my webcam
// set the proper size of the image since OpenCV defaults to 640x480
cap.set(CV_CAP_PROP_FRAME_WIDTH, 1600);
cap.set(CV_CAP_PROP_FRAME_HEIGHT, 1200);
while (true)
{
cap >> frame;
cv::flip(frame, frame, 0); // the frame if captured flipped (for some reason)
cv::imshow("Feed", frame);
keyIn = cv::waitKey(60); // 60 should be enough since I am running 15 fps
if (keyIn == 27) // esc is pressed
break;
}
I also tried playing around with the the format by setting different values for CV_CAP_PROP_FORMAT but still nothing changed.
Note that running the code outputs the following in the console:
SETUP: Setting up device 1
SETUP: **Camera Info**
SETUP: Couldn't find preview pin using SmartTee
SETUP: Default Format is set to 1600x1200
SETUP: trying specified format RGB24 @ 640x480
SETUP: Capture callback set
SETUP: Device is setup and ready to capture.
SETUP: Disconnecting device 1
SETUP: freeing Grabber Callback
SETUP: freeing Grabber
SETUP: freeing Control
SETUP: freeing Media Type
SETUP: removing filter NullRenderer...
SETUP: filter removed NullRenderer
SETUP: removing filter Sample Grabber...
SETUP: filter removed Sample Grabber
SETUP: removing filter Smart Tee...
SETUP: filter removed Smart Tee
SETUP: removing filter **Camera Info**...
SETUP: filter removed **Camera Info**
SETUP: freeing Capture Graph
SETUP: freeing Main Graph
SETUP: Device 1 disconnected and freed
SETUP: Setting up device 1
SETUP: **Camera Info**
SETUP: Couldn't find preview pin using SmartTee
SETUP: Default Format is set to 640x480
SETUP: trying specified format RGB24 @ 1600x1200
SETUP: Capture callback set
SETUP: Device is setup and ready to capture.
I do not understand why OpenCV defaults to 640x480 knowing that the original size is correct at 1600x1200 (this is forcing me to set the size manually).
Any input as to where might be the problem?
Thanks to the moderator for giving me points so that I can add the images.