OpenCV Error: Assertion failed (size.width>0 && size.height>0) in cv::imshow - How to Fix
This error message indicates that the width and height of the image being displayed using cv::imshow function are either zero or negative. \n\nTo fix this error, you should check the size of the image before displaying it. Ensure that the image has a valid non-zero width and height. You can use the cv::Mat::empty() function to check if the image is empty or not. \n\nHere's an example of how you can check the size of the image before displaying it:\n\ncpp\ncv::Mat image = cv::imread("image.jpg");\nif (!image.empty()) {\n cv::imshow("Image", image);\n cv::waitKey(0);\n} else {\n std::cout << "Failed to load image!" << std::endl;\n}\n\n\nMake sure to replace "image.jpg" with the path to your actual image file.
原文地址: https://www.cveoy.top/t/topic/pxb2 著作权归作者所有。请勿转载和采集!