OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow
2013-09-09 20:58
916 查看
刚开始学习OpenCV编程,写了一个程序:
后来运行时出现了这样的一个错误:OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file /home/fighting324/app/opencv/modules/highgui/src/window.cpp, line 261
terminate called after throwing an instance of 'cv::Exception'
what(): /home/fighting324/app/opencv/modules/highgui/src/window.cpp:261: error: (-215) size.width>0 && size.height>0 in function imshow
怎么搞都没有解决,搜索了将近一个小时之后发现了这个帖子:http://answers.opencv.org/question/18135/opencv-error-assertion-failed-sizewidth0/
我也照猫画虎,将我代码中读取图像的这一句:
#include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> void colorReduce( cv::Mat &image, int div=64 ) { int nl = image.rows; int nc = image.cols * image.channels(); for(int j=0; j<nl; j++) { uchar *data = image.ptr<uchar>(j); for( int i=0; i<nc; i++) { data[i] = data[i]/div*div + div/2; } } } int main(void) { cv::Mat image = cv::imread("/home/fighting324/Pictures/lena.jpg"); colorReduce( image ); cv::namedWindow("colorReduced", CV_WINDOW_AUTOSIZE); cv::imshow("colorReduced", image); cv::waitKey(); }
后来运行时出现了这样的一个错误:OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file /home/fighting324/app/opencv/modules/highgui/src/window.cpp, line 261
terminate called after throwing an instance of 'cv::Exception'
what(): /home/fighting324/app/opencv/modules/highgui/src/window.cpp:261: error: (-215) size.width>0 && size.height>0 in function imshow
怎么搞都没有解决,搜索了将近一个小时之后发现了这个帖子:http://answers.opencv.org/question/18135/opencv-error-assertion-failed-sizewidth0/
我也照猫画虎,将我代码中读取图像的这一句:
cv::Mat image = cv::imread("~/Pictures/lena.jpg");中的~改成了/home/fighting324,竟然就好了!
相关文章推荐
- OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow
- opencv 报错 OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow
- OpenCV Error: Assertion failed (size.width>0 && size.height>0) in cv::imshow
- 用vs2017编写opencv程序,出现下列错误OpenCV Error: Assertion failed (size.width>0 && size.height>0) in cv::imshow
- OpenCV Error: Assertion failed (size.width>0 && size.height>0) in cv::imshow
- OpenCV打开摄像头出现运行错误OpenCV Error:Assertion failed (size.width>0&&size.height>0)in cv::imshow,……
- 【已解决】error: (-215) size.width>0 && size.height>0 in function imshow
- 关于OpenCV Error: Assertion failed (size.width>0 && size.height>0)的问题
- Opencv Error:Assertion failed(size.with>0&&size.height>0) in imshow
- OpenCV Error:Assertion failed (size.width>0 && size.height>0) in cv::imshow
- 解决Opencv的error: (-215) size.width>0 && size.height>0 in function cv::imshow
- OpenCV Error: Assertion failed (size.width>0 && size.height>0) in cv::imshow
- opencv报错 error: (-215) size.width>0 && size.height>0 in function cv::imshow
- Assertion failed (size.width>0 && size.height>0)
- opencv error:assertion failed<src.cols>0&&src.rows>0>in unknown function
- 报错:OpenCV Error: Assertion failed (src.size() == dst.size() && src.type() == dst.ty pe()) in unknown function, file ..……
- error: (-215) ssize.width > 0 && ssize.height > 0 in function cv::resize
- OpenCV Error: Assertion failed (dsize.area() > 0) in cv::resize
- 【python】error: (-215) ssize.width > 0 && ssize.height > 0 in function cv::resize
- 【python】error: (-215) ssize.width > 0 && ssize.height > 0 in function cv::resize