当前位置:网站首页>OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow
OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow
2022-07-03 10:17:00 【DadongDer】
QT Creator End of configuration OpenCV Then use the display picture demo When testing :
#include "mainwindow.h"
#include <QApplication>
#include <opencv2/opencv.hpp>
using namespace cv;
int main(int argc, char *argv[])
{
Mat myImage = imread(":/left3.jpg"); // Added to the resource file + Relative paths
perhaps
Mat myImage = imread("E:\\left3.jpg"); Put it in E The absolute path under the disk + No resource file added
perhaps
Mat myImage = imread("E:\\ picture \\left3.jpg"); Put it in E The absolute path under the disk + No resource file added + Path contains Chinese
namedWindow("DEMO",CV_WINDOW_AUTOSIZE);
imshow("DEMO",myImage);
waitKey(0);
return 0;
}
The following error has been reported :
OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file E:\Opencv3.1.0\Windows\opencv\sources\modules\highgui\src\window.cpp, line 289
terminate called after throwing an instance of 'cv::Exception' what(): E:\Opencv3.1.0\Windows\opencv\sources\modules\highgui\src\window.cpp:289: error: (-215) size.width>0 && size.height>0 in function imshow
Here are the following points :
| Code | features | Whether it is right |
|---|---|---|
| Mat myImage = imread(“E:\MyQtProject\demo\left3.jpg”); | Added to the resource file + Absolute path | yes |
| Mat myImage = imread(":/left3.jpg"); | Added to the resource file + Relative paths | no |
| Mat myImage = imread(“E:\left3.jpg”); | Put it in E The absolute path under the disk + No resource file added | no |
| Mat myImage = imread(“E:\ picture \left3.jpg”); | Put it in E The absolute path under the disk + No resource file added + Path contains Chinese | no |
The following code runs correctly :
#include "mainwindow.h"
#include <QApplication>
#include <opencv2/opencv.hpp>
using namespace cv;
int main(int argc, char *argv[])
{
Mat myImage = imread("E:\\MyQtProject\\demo\\left3.jpg"); Added to the resource file + Absolute path
namedWindow("DEMO",CV_WINDOW_AUTOSIZE);
imshow("DEMO",myImage);
waitKey(0);
return 0;
}
边栏推荐
- Toolbutton property settings
- Swing transformer details-2
- 20220603数学:Pow(x,n)
- Leetcode-106:根据中后序遍历序列构造二叉树
- Leetcode interview question 17.20 Continuous median (large top pile + small top pile)
- Opencv feature extraction sift
- Leetcode-513:找树的左下角值
- Neural Network Fundamentals (1)
- Markdown latex full quantifier and existential quantifier (for all, existential)
- 『快速入门electron』之实现窗口拖拽
猜你喜欢

一步教你溯源【钓鱼邮件】的IP地址

LeetCode - 900. RLE 迭代器

Label Semantic Aware Pre-training for Few-shot Text Classification

Retinaface: single stage dense face localization in the wild

Opencv note 21 frequency domain filtering

LeetCode - 900. RLE iterator

LeetCode - 5 最长回文子串

CV learning notes - clustering

『快速入门electron』之实现窗口拖拽

Implementation of "quick start electronic" window dragging
随机推荐
Opencv interview guide
Yocto Technology Sharing Phase 4: Custom add package support
20220601数学:阶乘后的零
Leetcode 300 最长上升子序列
LeetCode - 1670 设计前中后队列(设计 - 两个双端队列)
CV learning notes - scale invariant feature transformation (SIFT)
LeetCode - 1670 設計前中後隊列(設計 - 兩個雙端隊列)
波士顿房价预测(TensorFlow2.9实践)
Retinaface: single stage dense face localization in the wild
20220609 other: most elements
【毕业季】图匮于丰,防俭于逸;治不忘乱,安不忘危。
Problems encountered when MySQL saves CSV files
Opencv notes 17 template matching
openCV+dlib实现给蒙娜丽莎换脸
Opencv histogram equalization
20220603 Mathematics: pow (x, n)
20220608其他:逆波兰表达式求值
Deep learning by Pytorch
The underlying principle of vector
One click generate traffic password (exaggerated advertisement title)