opencv例程之打开摄像头
#include <iostream>
#include <opencv2/opencv.hpp>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
using namespace cv;
int main() {
VideoCapture cap(0);
if (!cap.isOpened()) {
return -1;
}
Mat frame;
Mat edges;
bool stoped = false;
while (!stoped) {
cap >> frame;
cvtColor(frame, edges, CV_BGR2GRAY);
imshow("The Video Now!", frame);
if (waitKey(10) >= 0) {
stoped = true;
}
}
return 0;
}
VideoCapture cap(0);
if (!cap.isOpened()) {
return -1;
}
Mat frame;
Mat edges;
bool stoped = false;
while (!stoped) {
cap >> frame;
cvtColor(frame, edges, CV_BGR2GRAY);
imshow("The Video Now!", frame);
if (waitKey(10) >= 0) {
stoped = true;
}
}
return 0;
}