OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow
来源:互联网 发布:阿里云 马云 王坚 编辑:程序博客网 时间:2024/09/21 09:27
刚开始学习OpenCV编程,写了一个程序:
#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 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 Error:Assertion failed (size.width>0 && size.height>0) in cv::imshow
- Opencv Error:Assertion failed(size.with>0&&size.height>0) in imshow
- OpenCV打开摄像头出现运行错误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: (-215) size.width>0 && size.height>0 in function cv::imshow
- 关于OpenCV Error: Assertion failed (size.width>0 && size.height>0)的问题
- Assertion failed (size.width>0 && size.height>0)
- 【已解决】error: (-215) size.width>0 && size.height>0 in function imshow
- OpenCV Error: Assertion failed (dsize.area() > 0) in cv::resize
- OpenCV Error: Assertion failed ( ssize.area() > 0 )
- OpenCV Error: Assertion failed (s >= 0)
- opencv error :assertion faild (src.depth()==dst.depth()&&src.size==dst.size)
- opencv error :assertion faild (src.depth()==dst.depth()&&src.size==dst.size)
- opencv error:assertion failed<src.cols>0&&src.rows>0>in unknown function
- OpenCV Error: Assertion failed (dsize.area() || (inv_scale_x > 0 && inv_scale_y > 0)) in unknown fun
- EXP-00056 解决方法之一
- Objective-C中一种消息处理方法performSelector: withObject:
- PHP是什么?生哥哥解答
- 在ARM Linux上使用OpenGL
- 粒度(granule)
- OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow
- Android EditText显示图片的两种方法
- 雪中送炭:十大前沿移动应用开发工具
- 银行业务调度系统II
- 许留山导入到SQL “文本被截断,或者一个或多个字符在目标代码页中没有匹配项”错误的解决
- 总结六年的嵌入式软件研发
- 关于MySQL的多用户问题
- String相关的面试题
- uva 437 - The Tower of Babylon(DP)