File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change 1
- /// Example code to stream mjpeg over a tcp socket
1
+ /// Example code to stream mjpeg over http
2
2
use std:: io:: Write ;
3
3
use std:: net:: { SocketAddr , TcpListener } ;
4
4
5
+ // VideoCaptureTrait doesn't get used when binding to opencv 3.4
6
+ #[ allow( unused_imports) ]
7
+ use opencv:: videoio:: VideoCaptureTrait ;
8
+
5
9
use opencv:: core:: { Mat , Vector } ;
6
10
use opencv:: imgcodecs:: { imencode, IMWRITE_JPEG_QUALITY } ;
7
- use opencv:: videoio:: { VideoCapture , VideoCaptureTrait } ;
11
+ use opencv:: videoio:: { VideoCapture , VideoCaptureTraitConst , CAP_ANY } ;
8
12
use opencv:: Result ;
9
13
10
14
const BASE_RESPONSE : & [ u8 ] = b"HTTP/1.1 200 OK\r \n Content-Type: multipart/x-mixed-replace; boundary=frame\r \n \r \n " ;
11
15
12
16
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!" ) ;
15
19
16
20
// Bind listener to a port
17
21
let address: SocketAddr = "127.0.0.1:8080" . parse ( ) ?;
You can’t perform that action at this time.
0 commit comments