[英]Visual Studio 2015 OpenCV Assertion failed (size.width>0 && size.height>0) in cv::imshow windows.cpp
I've been learning a bit of c++ lately and i keep getting the same error for some reason.我最近一直在学习一些 C++,但由于某种原因,我不断收到同样的错误。
Apparently, imshow isn't able to find the file.显然, imshow 无法找到该文件。
My codes are我的代码是
#include "stdafx.h"
#include<opencv2/opencv.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include<iostream>
#include <conio.h>
using namespace std;
using namespace cv;
int main()
{
cv::Mat img;
img = imread("1.png");
if (img.empty())
{
cout << "can't find da file\n\n" ;
}
cv::namedWindow("test");
cv::imshow("test",img);
waitKey(0);
}
Thanks for helping you guys :)谢谢你帮助你们:)
I always advise the same thing for these cases.对于这些情况,我总是建议同样的事情。 It just needs a little lateral thinking.它只需要一点横向思维。 Change your code to this将您的代码更改为此
int main()
{
ofstream test("test.txt");
test << "I'm here!!\n";
}
Now run this program, it will create a file called test.txt
.现在运行这个程序,它会创建一个名为test.txt
的文件。 Find out where that file is on your system and that's where you should put your 1.png
file.找出该文件在您的系统上的位置,以及您应该将1.png
文件放置的1.png
。 Then you can go back to your original program confident that the file is in the right place and any remaining issues are a different problem.然后您可以返回到您的原始程序,确信该文件位于正确的位置,并且任何剩余的问题都是不同的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.