OpenCV错误:断言失败(size.width> 0&& size.height> 0) [英] OpenCV Error: Assertion failed (size.width>0 && size.height>0)

查看:135
本文介绍了OpenCV错误:断言失败(size.width> 0&& size.height> 0)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我按照官方教程以及以下链接 opencv-installation编译并安装了OpenCV库。



我使用eclipse cdt使用了官方教程中提供的示例代码

  #include< cv.h> 
#include< highgui.h>

使用命名空间cv;

int main(int argc,char ** argv)
{
Mat图像;
image = imread(argv [1],1);

if(argc!= 2 ||!image.data)
{
printf(无图像数据\n);
返回-1;
}

namedWindow( Display Image,CV_WINDOW_AUTOSIZE);
imshow( Display Image,image);

waitKey(0);

返回0;
}

编译后出现以下错误:

  OpenCV错误:在imshow文件/ home / hp / apps / opencv-中断言失败(size.width> 0&&& amp;& amp; amp; amp;& amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; quot;容量> 0) 2.4.6.1/modules/highgui/src/window.cpp,第261行
在抛出'cv :: Exception'实例后终止终止

what():/ home / hp / apps / opencv-2.4.6.1 / modules / highgui / src / window.cpp:261:错误:(-215)size.width> 0&&函数imsize中的size.height> 0表示

预先感谢

  VideoCapture上限; 
cap.set(CV_CAP_PROP_FRAME_WIDTH,640);
cap.set(CV_CAP_PROP_FRAME_HEIGHT,480);

cap.read(image);


I compiled and installed the OpenCV libraries as per the official tutorial as well as the following link opencv-installation

I used the sample code provided in the official tutorial using eclipse cdt

#include <cv.h>
#include <highgui.h>

using namespace cv;

int main( int argc, char** argv )
{
  Mat image;
  image = imread( argv[1],1 );

  if( argc != 2 || !image.data )
  {
     printf( "No image data \n" );
     return -1;
  }

   namedWindow( "Display Image", CV_WINDOW_AUTOSIZE );
   imshow( "Display Image", image );

   waitKey(0);

   return 0;
}

Upon compiling i get the following error:

OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file /home/hp/apps/opencv-2.4.6.1/modules/highgui/src/window.cpp, line 261
terminate called after throwing an instance of 'cv::Exception'

what(): /home/hp/apps/opencv-2.4.6.1/modules/highgui/src/window.cpp:261: error: (-215) size.width>0 && size.height>0 in function imshow

Thanks in advance

解决方案

I had similar problem .You can add similar this code, maybe solve it. Because capture size cause this problem

VideoCapture cap;
cap.set(CV_CAP_PROP_FRAME_WIDTH, 640);
cap.set(CV_CAP_PROP_FRAME_HEIGHT, 480); 

cap.read(image);

这篇关于OpenCV错误:断言失败(size.width&gt; 0&amp;&amp; size.height&gt; 0)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆