OpenCV452 Error Assertion failed sizewidth0 && sizeheight0 in cvimshow file Cbuildmaster_winpack-build-win64-vc15opencvmoduleshighguisrcwindowcpp line 404
This error occurs when the width or height of the image passed to the cv::imshow function is zero or negative. This function is used to display an image in a window.
To fix this error, you need to make sure that the image you are trying to display has a valid width and height. Check if you have correctly loaded the image and if it has valid dimensions. You can use the cv::imread function to load an image from a file.
Here is an example of how to load and display an image using OpenCV:
#include <opencv2/opencv.hpp>
int main() {
// Load image from file
cv::Mat image = cv::imread("path/to/image.jpg");
// Check if the image was loaded successfully
if (image.empty()) {
std::cout << "Failed to load image" << std::endl;
return 1;
}
// Create a window and display the image
cv::namedWindow("Image");
cv::imshow("Image", image);
cv::waitKey(0);
return 0;
}
Make sure to replace "path/to/image.jpg" with the actual path to your image file
原文地址: http://www.cveoy.top/t/topic/hN0u 著作权归作者所有。请勿转载和采集!