当前位置:网站首页>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;
}
边栏推荐
- Neural Network Fundamentals (1)
- Wireshark use
- 4G module at command communication package interface designed by charging pile
- Anaconda安装包 报错packagesNotFoundError: The following packages are not available from current channels:
- Label Semantic Aware Pre-training for Few-shot Text Classification
- Dictionary tree prefix tree trie
- My notes on intelligent charging pile development (II): overview of system hardware circuit design
- Leetcode - the k-th element in 703 data flow (design priority queue)
- 『快速入门electron』之实现窗口拖拽
- 2021-11-11 standard thread library
猜你喜欢
Flutter 退出当前操作二次确认怎么做才更优雅?
What did I read in order to understand the to do list
Opencv note 21 frequency domain filtering
CV learning notes - reasoning and training
Opencv feature extraction sift
Opencv+dlib to change the face of Mona Lisa
Implementation of "quick start electronic" window dragging
Leetcode - 706 design hash mapping (Design)*
Discrete-event system
LeetCode - 508. 出现次数最多的子树元素和 (二叉树的遍历)
随机推荐
20220602 Mathematics: Excel table column serial number
Google browser plug-in recommendation
yocto 技術分享第四期:自定義增加軟件包支持
Leetcode-404: sum of left leaves
Opencv gray histogram, histogram specification
Problems encountered when MySQL saves CSV files
Adaptiveavgpool1d internal implementation
CV learning notes - scale invariant feature transformation (SIFT)
My notes on the development of intelligent charging pile (III): overview of the overall design of the system software
About windows and layout
2312、卖木头块 | 面试官与狂徒张三的那些事(leetcode,附思维导图 + 全部解法)
Opencv+dlib to change the face of Mona Lisa
Neural Network Fundamentals (1)
is_ power_ of_ 2 judge whether it is a multiple of 2
20220605数学:两数相除
Window maximum and minimum settings
Retinaface: single stage dense face localization in the wild
. DLL and Differences between lib files
3.1 Monte Carlo Methods & case study: Blackjack of on-Policy Evaluation
20220606 Mathematics: fraction to decimal