久久久久久久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)的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

問題描述

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

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

我花了幾個(gè)小時(shí)在網(wǎng)上搜索解決方案,包括所有相關(guān)的 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

設(shè)置窗口的尺寸

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

creating another project on Visual C++

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

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

但沒有運(yùn)氣,請幫忙!

這是我的代碼:

#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);        
    }

}

當(dāng)我編譯并運(yùn)行它時(shí),出現(xiàn)以下錯(cuò)誤:

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

OpenCV 錯(cuò)誤:斷言失敗 (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

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

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

更新:

為什么會發(fā)生此錯(cuò)誤的合理解釋是我的網(wǎng)絡(luò)攝像頭需要時(shí)間才能啟動(dò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);
}

我們可以等待相機(jī)啟動(dòng)

推薦答案

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

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)絡(luò)攝像頭收到的第一張圖片是空的.在這種情況下 imshow 不會拋出錯(cuò)誤.所以希望接下來的輸入圖像不是空的.

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.

這篇關(guān)于斷言失敗(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)系我們刪除處理,感謝您的支持!

相關(guā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 無法設(shè)置 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 度的最簡單方法?)
主站蜘蛛池模板: 欧美在线视频一区 | 精品久久一区二区 | 国产精品成人一区二区 | 久久久精彩视频 | 婷婷狠狠 | 中文字幕在线免费播放 | hdxxxxhd100%| 国产精品91在线 | 露出调教羞耻91九色 | 深夜福利视频在线观看 | 久久精品在线 | 男女啪啪免费网站 | 国产一区2区 | 天天操天天操天天操 | 国产乱人伦 | 国产日韩在线视频 | 精品亚洲国产成人av制服丝袜 | 成年免费视频黄网站在线观看 | 国产黄色一区 | 国产精品国产精品国产专区不卡 | www视频在线观看 | 精品欧美一区二区三区久久久 | 久久久久一区 | 亚洲精品久久久 | 狠狠狠干 | 青青草成人在线 | 好吊妞这里只有精品 | 亚洲午夜精品一区二区三区 | 黄色三级av| 91成人在线 | 天天干夜夜操 | 欧美日韩国产在线观看 | 激情综合网五月 | 欧美在线视频免费观看 | 国产又黄又爽视频 | 长河落日| 91亚洲成人| 亚洲性视频 | www.伊人| 91久久久久久久久久 | 欧美手机在线 |