Skip to content

Commit 8bb9f43

Browse files
tidelytwistedfall
authored andcommitted
Fix example for opencv 3.4
1 parent 1f28830 commit 8bb9f43

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

examples/video_capture_http_stream.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
/// Example code to stream mjpeg over a tcp socket
1+
/// Example code to stream mjpeg over http
22
use std::io::Write;
33
use std::net::{SocketAddr, TcpListener};
44

5+
// VideoCaptureTrait doesn't get used when binding to opencv 3.4
6+
#[allow(unused_imports)]
7+
use opencv::videoio::VideoCaptureTrait;
8+
59
use opencv::core::{Mat, Vector};
610
use opencv::imgcodecs::{imencode, IMWRITE_JPEG_QUALITY};
7-
use opencv::videoio::{VideoCapture, VideoCaptureTrait};
11+
use opencv::videoio::{VideoCapture, VideoCaptureTraitConst, CAP_ANY};
812
use opencv::Result;
913

1014
const BASE_RESPONSE: &[u8] = b"HTTP/1.1 200 OK\r\nContent-Type: multipart/x-mixed-replace; boundary=frame\r\n\r\n";
1115

1216
fn main() -> Result<(), Box<dyn std::error::Error>> {
13-
// Select camera
14-
let mut cam = VideoCapture::new_def(0)?;
17+
let mut cam = VideoCapture::new(0, CAP_ANY)?;
18+
assert!(cam.is_opened()?, "Unable to open default camera!");
1519

1620
// Bind listener to a port
1721
let address: SocketAddr = "127.0.0.1:8080".parse()?;

0 commit comments

Comments
 (0)