I use a webcam with default resolution of 640x480, the environment is OpenCV 4.0, visual studio 17 and win10. If I read directly from webcam everything is fine, but after I set CAP_PROP_FRAME_WIDTH and CAP_PROP_FRAME_HEIGHT, I can still get image from webcam but all pixel values become (205,205,205). The code is simple:
VideoCapture cap(0);
cap.set(CAP_PROP_FRAME_WIDTH, 320);
cap.set(CAP_PROP_FRAME_HEIGHT, 240);
Mat img;
cap.read(img);
What might cause the problem? Thank you!