Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/144.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ OpenCV-访问冲突读取位置“highgui库中的某处”_C++_Opencv_Access Violation - Fatal编程技术网

C++ OpenCV-访问冲突读取位置“highgui库中的某处”

C++ OpenCV-访问冲突读取位置“highgui库中的某处”,c++,opencv,access-violation,C++,Opencv,Access Violation,获得以下代码: #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();

获得以下代码:

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

}
这适用于OpenCV的其他版本。然而,因为我需要额外的外部库,我决定自己编译OpenCV库并包含它们。这样做导致我犯了这个错误。怎么了?OpenCV的两个版本都使用2.4.8