1 | initial version |
I think problem in waitKey(0). AsI have the same issue. Don't use waitKey(0), use waitKey(1); Yes, FPS will little slow but no problem with Keys.
2 | No.2 Revision |
I think problem in waitKey(0). AsI As I have the same issue. Don't use waitKey(0), use waitKey(1); Yes, FPS will little slow but no problem with Keys.
3 | No.3 Revision |
I think problem in waitKey(0). As I have the same issue. Don't use waitKey(0), use waitKey(1); Yes, FPS will little slow but no problem with Keys.Keys. If it don't work please, use destroyWindow after all functions which assosiated with waitKey(0). Or use namedWindow("Frame",WINDOW_AUTOSIZE) before imshow;
4 | No.4 Revision |
I think problem in waitKey(0). As I have the same issue. Don't use waitKey(0), use waitKey(1); Yes, FPS will little slow but no problem with Keys. If it don't work please, use destroyWindow after all functions which assosiated with waitKey(0). Or use namedWindow("Frame",WINDOW_AUTOSIZE) before imshow;imshow;
And why you are doing poliphormism. As you convert waitKey() value to Char, then to the Integer and then in if you using char->to int and then == 27) Why? Use waitKey as int and dont convert to char as you don't need in:
Use this code:
int main()
{
cv::VideoCapture cap(1);
cv::Mat frame;
if (!cap.isOpened())
{
std::cout << "Error opening video capture." << std::endl;
return -1;
}
while (1) {
cap >> frame;
if (frame.empty())
break;
cv::imshow("Frame", frame);
int c = cv::waitKey(0);
std::cout << (c << std::endl;
if (c == 27)
break;
}
cap.release();
cv::destroyAllWindows();
return 0;
}