![](/img/trans.png)
[英]trying to use VideoCapture and imshow(), raises Assertion failed (size.width>0 && size.height>0) in cv::imshow
[英]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 file\n\n" ;
}
cv::namedWindow("test");
cv::imshow("test",img);
waitKey(0);
}
謝謝你幫助你們:)
對於這些情況,我總是建議同樣的事情。 它只需要一點橫向思維。 將您的代碼更改為此
int main()
{
ofstream test("test.txt");
test << "I'm here!!\n";
}
現在運行這個程序,它會創建一個名為test.txt
的文件。 找出該文件在您的系統上的位置,以及您應該將1.png
文件放置的1.png
。 然后您可以返回到您的原始程序,確信該文件位於正確的位置,並且任何剩余的問題都是不同的問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.