当前位置:网站首页>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;
}
边栏推荐
- Google browser plug-in recommendation
- RESNET code details
- 1. Finite Markov Decision Process
- Opencv feature extraction sift
- yocto 技術分享第四期:自定義增加軟件包支持
- LeetCode - 919. Full binary tree inserter (array)
- CV learning notes - deep learning
- 『快速入门electron』之实现窗口拖拽
- Leetcode-513:找树的左下角值
- 20220601 Mathematics: zero after factorial
猜你喜欢
CV learning notes convolutional neural network
What can I do to exit the current operation and confirm it twice?
Leetcode-106:根据中后序遍历序列构造二叉树
Leetcode - 460 LFU cache (Design - hash table + bidirectional linked hash table + balanced binary tree (TreeSet))*
3.1 Monte Carlo Methods & case study: Blackjack of on-Policy Evaluation
2.2 DP: Value Iteration & Gambler‘s Problem
Label Semantic Aware Pre-training for Few-shot Text Classification
3.2 Off-Policy Monte Carlo Methods & case study: Blackjack of off-Policy Evaluation
Crash工具基本使用及实战分享
MySQL root user needs sudo login
随机推荐
[C question set] of Ⅵ
20220605 Mathematics: divide two numbers
20220531数学:快乐数
LeetCode - 460 LFU 缓存(设计 - 哈希表+双向链表 哈希表+平衡二叉树(TreeSet))*
LeetCode - 1670 設計前中後隊列(設計 - 兩個雙端隊列)
Yocto technology sharing phase IV: customize and add software package support
LeetCode - 673. Number of longest increasing subsequences
CV learning notes ransca & image similarity comparison hash
LeetCode - 705 设计哈希集合(设计)
LeetCode - 1172 餐盘栈 (设计 - List + 小顶堆 + 栈))
QT self drawing button with bubbles
Development of intelligent charging pile (I): overview of the overall design of the system
CV learning notes - reasoning and training
Opencv Harris corner detection
Discrete-event system
[combinatorics] combinatorial existence theorem (three combinatorial existence theorems | finite poset decomposition theorem | Ramsey theorem | existence theorem of different representative systems |
LeetCode - 900. RLE 迭代器
Basic use and actual combat sharing of crash tool
Crash工具基本使用及实战分享
What did I read in order to understand the to do list