OpenCV - Access violation reading location “somewhere in highgui lib”

▼魔方 西西 提交于 2019-12-11 06:56:13

问题


got following code:

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

using namespace cv;
using namespace std;

void captureAndThreshold();

int main() {

    captureAndThreshold();



    return 0;
}

void captureAndThreshold() {
    VideoCapture cap(0);

    if(!cap.isOpened())  // check if we succeeded
        return;
    Mat thresh, frame;
    namedWindow("Example Feed",1);

    while(true) {
        cap >> frame;

        if (!frame.empty()) {

            cvtColor(frame, thresh, CV_BGR2GRAY);
            threshold(thresh, thresh, 0, 255, CV_THRESH_OTSU);
            imshow("Example Feed", frame);
        }
        if (waitKey(30) >= 0)
            break;

    }

    cap.release();

}

This works on an other release of OpenCV. However, because I needed additional external libraries, I decided to compile the OpenCV libraries myself and include them. Doing so resulted in me having this error. What is wrong? Both versions of OpenCV use 2.4.8

来源:https://stackoverflow.com/questions/22179884/opencv-access-violation-reading-location-somewhere-in-highgui-lib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!