Home > Mobile >  Opencv, can't get destroyAllWindows to work
Opencv, can't get destroyAllWindows to work

Time:12-13

OpenCV 4.5.4, C and Win10.

Probably my syntax doesn't compute with this, but can anyone spot a fix to my problem? I can get the usb webcam window to open and it shows the stream. But I cannot close it.

This opens the window but brings no image in stream at all:

cv::imshow("Smaller", resized_down);
int c = cv::waitKey(1);
if ((char)c == 'c')
    cv::destroyAllWindows();
    break;

This works better, it shows the image stream, but by pressing C, it only freezes the image:

cv::imshow("Smaller", resized_down);
int c = cv::waitKey(1);
if ((char)c == 'c')
    break;

Please, indicate if you need to see more of my code.

CodePudding user response:

your first code should work with this fix (break; is always executing in your code!):

cv::namedWindow(“Smaller”);
while(true){
…
cv::imshow("Smaller", resized_down);
int c = cv::waitKey(1);
if ((char)c == 'c'){
    cv::destroyAllWindows();
    break;
}
…
}
  • Related