forked from nebgnahz/cv-rs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
video_capture.rs
38 lines (35 loc) · 1.08 KB
/
video_capture.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// The following code closely resembles the equivalent C code capture live video
// #include "opencv2/opencv.hpp"
// using namespace cv;
// int main(int, char**)
// {
// VideoCapture cap(0); // open the default camera
// if(!cap.isOpened()) // check if we succeeded
// return -1;
// Mat edges;
// namedWindow("edges",1);
// for(;;)
// {
// Mat frame;
// cap >> frame; // get a new frame from camera
// cvtColor(frame, edges, COLOR_BGR2GRAY);
// GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5);
// Canny(edges, edges, 0, 30, 3);
// imshow("edges", edges);
// if(waitKey(30) >= 0) break;
// }
// // the camera will be deinitialized automatically in VideoCapture
// // destructor
// return 0;
// }
extern crate cv;
use cv::highgui::*;
use cv::videoio::VideoCapture;
fn main() {
let cap = VideoCapture::new(0);
assert!(cap.is_open());
highgui_named_window("Window", WindowFlag::Autosize).unwrap();
while let Some(image) = cap.read() {
image.show("Window", 30).unwrap();
}
}