久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

斷言失敗(size.width>0 && size.height&g

Assertion failed (size.widthgt;0 amp;amp; size.heightgt;0)(斷言失敗(size.width0 amp;amp; size.height0))
本文介紹了斷言失敗(size.width>0 && size.height>0)的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

我正在使用帶有 OpenCV 2.4.7 的 Visual Studio Express 2013,遵循此 教程.

I'm using Visual Studio Express 2013 with OpenCV 2.4.7, following this tutorial.

我花了幾個小時在網(wǎng)上搜索解決方案,包括所有相關的 SO 問題.我試過了:

I have spent hours searching the web for solutions, including all of the relevant SO questions. I have tried:

  • VideoCapture::open 的返回值為 1

將 waitKey() 延遲延長至 50 毫秒,然后延長至 500 毫秒

extending the waitKey() delay to 50ms and later 500ms

設置窗口的尺寸

在 Visual C++ 上創(chuàng)建另一個項目

creating another project on Visual C++

打開現(xiàn)有圖像而不是從相機讀取(同樣的錯誤)

opening an existing image instead of reading from camera (same error)

但沒有運氣,請幫忙!

這是我的代碼:

#include <opencv/cv.h>
#include <opencv/highgui.h>
#include <iostream>

using namespace std;
using namespace cv;

int main() {
    Mat image;

    VideoCapture cap;
    int camOpen = cap.open(CV_CAP_ANY);

    namedWindow("window", CV_WINDOW_AUTOSIZE);

    while (true) {
        cap >> image;

        imshow("window", image);

    // delay 33ms
    waitKey(33);        
    }

}

當我編譯并運行它時,出現(xiàn)以下錯誤:

As I compiled and ran it, I got the following error:

OpenCV 錯誤:斷言失敗 (size.width>0 && size.height>0) in cv::imshow, file ........opencvmoduleshighguisrcwindow.cpp,第 261 行

OpenCV Error: Assertion failed (size.width>0 && size.height>0) in cv::imshow, file ........opencvmoduleshighguisrcwindow.cpp, line 261

錯誤發(fā)生在 imshow("window", image); 行.當我評論出來時,沒有人抱怨.

Error occurs at the line imshow("window", image);. When I commented it out, there are no complaints.

更新:

為什么會發(fā)生此錯誤的合理解釋是我的網(wǎng)絡攝像頭需要時間才能啟動,這就是為什么 image.empty() 最初為 true,因此調(diào)用 abort() 函數(shù)退出程序.

A plausible explanation of why this error occured was that my webcam takes time to start, which is why image.empty() is true initially, hence the abort() function was called to exit the program.

用代碼

if (!image.empty()) {
    imshow("window", image);
}

我們可以等待相機啟動

推薦答案

我試過你的代碼,對我來說它有效(它可視化當前的網(wǎng)絡攝像頭輸入)!
我在帶有 OpenCV 2.4.7 的 Visual Studio 2012 Ultimate 上運行它.
...
出現(xiàn)錯誤是因為圖片為空,所以試試這個:

I tried your code and for me it works (it visualizes the current webcam input)!
I ran it on Visual Studio 2012 Ultimate with OpenCV 2.4.7.
...
The error occurs because the image is empty, so try this:

while (true) {
    cap >> image;

    if(!image.empty()){
        imshow("window", image);
    }

// delay 33ms
waitKey(33);        
}

也許您從網(wǎng)絡攝像頭收到的第一張圖片是空的.在這種情況下 imshow 不會拋出錯誤.所以希望接下來的輸入圖像不是空的.

Maybe the first image you receive from your webcam is empty. In this case imshow will not throw an error. So hopefully the next input images are not empty.

這篇關于斷言失敗(size.width>0 &amp;&amp; size.height>0)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

相關文檔推薦

Rotate an image in C++ without using OpenCV functions(在 C++ 中旋轉(zhuǎn)圖像而不使用 OpenCV 函數(shù))
OpenCV: process every frame(OpenCV:處理每一幀)
Why can#39;t I open avi video in openCV?(為什么我不能在 openCV 中打開 avi 視頻?)
OpenCV unable to set up SVM Parameters(OpenCV 無法設置 SVM 參數(shù))
Convert a single color with cvtColor(使用 cvtColor 轉(zhuǎn)換單一顏色)
Easiest way to rotate by 90 degrees an image using OpenCV?(使用 OpenCV 將圖像旋轉(zhuǎn) 90 度的最簡單方法?)
主站蜘蛛池模板: 久久国产精品-久久精品 | 亚洲国产一区二区三区 | 中文字幕视频在线观看 | www.中文字幕 | 久草视频观看 | 国产精品久久一区二区三区 | 日日骚视频 | 成人乱人乱一区二区三区软件 | 久久69精品久久久久久久电影好 | 亚洲国产成人精品久久 | 欧美日韩国产在线 | 日韩久久网 | 国产一区二区免费在线 | 天天射夜夜操 | 二区在线观看 | 国产综合av | 欧美一级黄色免费看 | 欧美一区二区三区在线观看视频 | 欧美一区视频 | 天天影视网天天综合色在线播放 | 中文字幕av亚洲精品一部二部 | 欧美激情一区二区三区 | 国产精品乱码一区二区三区 | 在线视频 亚洲 | 在线观看亚洲 | 色免费在线视频 | 国产小视频在线看 | 国产精品乱码一区二区三区 | 精品国产一区一区二区三亚瑟 | 国产精品久久a | 日本黄色影片在线观看 | 国产麻豆乱码精品一区二区三区 | 久久最新网址 | 激情五月激情综合网 | av片免费观看 | 日本免费黄色 | 国产一区二区三区精品久久久 | 欧美视频在线观看 | 国产在线观看一区 | 亚洲综合色网站 | 久亚州在线播放 |