我最近一直在学习一些C ,由于某种原因,我一直在遇到相同的错误。
显然,Imshow无法找到该文件。
我的代码是
#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 filenn" ;
}
cv::namedWindow("test");
cv::imshow("test",img);
waitKey(0);
}
- 我尝试将其与" .exe"一起放入项目文件夹中,
- 我尝试使用"/"one_answers" " 列出图像的整个目录
- 我也尝试过不使用代码中的任何扩展名,但无济于事。
错误符号
感谢您的帮助:)
我总是建议这些情况相同的事情。它只需要一些横向思考。将您的代码更改为此
int main()
{
ofstream test("test.txt");
test << "I'm here!!n";
}
现在运行此程序,它将 create 一个称为test.txt
的文件。找出该文件在系统上的位置,这是您应该放置1.png
文件的地方。然后,您可以回到原始程序,确信该文件在正确的位置,其余问题都是一个不同的问题。