Visual Studio 2015 OpenCV Assertion 在 cv::imshow windows 中失败 (size.width>0 && size.height>0.cp
Visual Studio 2015 OpenCV Assertion failed (size.width>0 && size.height>0) in cv::imshow windows.cpp
我最近一直在学习一些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"一起放入项目文件夹中,
- 我尝试使用"/"answers" " 列出图像的整个目录
- 我也尝试过不使用代码中的任何扩展名,但无济于事。
错误符号
感谢您的帮助:)
我总是建议这些情况相同的事情。它只需要一些横向思考。将您的代码更改为此
int main()
{
ofstream test("test.txt");
test << "I'm here!!n";
}
现在运行此程序,它将 create 一个称为test.txt
的文件。找出该文件在系统上的位置,这是您应该放置1.png
文件的地方。然后,您可以回到原始程序,确信该文件在正确的位置,其余问题都是一个不同的问题。
相关文章:
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 大于65535的C++数组[size]引发不一致的溢出
- 为什么(-1)%vector::size()总是返回0
- 在for循环中使用auto vs decltype(vec.size())来处理字符串的向量
- EASTL矢量<向量<int>>连续的
- 循环中的条件:为什么每次都调用strlen(),而vector.size()只调用一次
- 为什么这个 std::queue/指向结构的指针列表直到 List.Size() == 0 才释放内存?
- 在函数中使用 const int size 参数创建数组会在 Visual Studio 中抛出错误 C++:表达式的计
- vector.size() 在比较中意外工作
- vector.back() 和 vector[vector.size() - 1] 之间的区别?
- 返回 str vs. str.substr(0,str.size()) 在 leetcode 中给了我不同的输出
- 为什么 GCC 不能假设 std::vector::size 在这个循环中不会改变?
- 为什么"(!v.empty())"比"(v.size() >0)"好?
- 迭代器库中的 std::size() 不适用于传递给函数的 C 样式数组
- std::string.size() 未知行为
- 为什么gmp会在这里与"invalid next size"重新定位一起崩溃?
- 为什么我会"Invalid read of size 8"?(瓦尔格林德)
- 从 std::string 到 std::array<char,size> 的 memcopy 额外数据是否是一种未定义的行为?
- 使用 std::size 来自非 const 上下文
- "fast"或"normal"在"free(): invalid next size (fast)"中是什么意思?