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

問(wèn)題描述

我正在使用帶有 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 問(wèn)題.我試過(guò)了:

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

  • VideoCapture::open 的返回值為 1

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

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

設(shè)置窗口的尺寸

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

creating another project on Visual C++

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

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

但沒(méi)有運(yùn)氣,請(qǐng)幫忙!

這是我的代碼:

#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)我評(píng)論出來(lái)時(shí),沒(méi)有人抱怨.

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

更新:

為什么會(huì)發(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)

推薦答案

我試過(guò)你的代碼,對(duì)我來(lái)說(shuō)它有效(它可視化當(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 不會(huì)拋出錯(cuò)誤.所以希望接下來(lái)的輸入圖像不是空的.

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)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(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 中打開(kāi) avi 視頻?)
OpenCV unable to set up SVM Parameters(OpenCV 無(wú)法設(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 度的最簡(jiǎn)單方法?)
主站蜘蛛池模板: 人人玩人人干 | 国产精品视频免费观看 | 亚洲欧美视频一区 | 国产精品久久久久久久久久久久久久 | 国产精品久久久久久久 | 欧洲av一区 | 国产一级在线观看 | 波多野结衣一区二区三区在线观看 | 精品不卡| 黄色片大全在线观看 | 颜色网站在线观看 | 精品国产一区二区三区久久 | 一区二区三区在线免费 | 欧洲亚洲视频 | 成人国产精品久久 | 91人人澡人人爽 | 日韩精品视频在线免费观看 | 亚洲第一成年免费网站 | 久久久久国产 | 免费看国产一级特黄aaaa大片 | 99精品欧美一区二区三区 | a级大毛片 | 91社影院在线观看 | 国产精品一区三区 | 欧美日韩一区二区在线 | 91精品国产一区二区三区香蕉 | 日韩久久久久久 | 一区二区三区不卡视频 | 亚洲免费一区 | 久久久久久久久久久高潮一区二区 | 久久综合久 | 午夜国产一级 | 伊人精品在线视频 | 国产精品久久久久永久免费观看 | 亚洲国产精品视频一区 | 久久91精品国产一区二区三区 | 成人在线视频免费观看 | 人妖videosex高潮另类 | 三级av网址 | 成人av网站在线观看 | 一区日韩 |