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