|
19 | 19 |
|
20 | 20 | if __name__ == '__main__': |
21 | 21 | if len(sys.argv) < 2: |
22 | | - print "You must give an argument to open a video stream." |
23 | | - print " It can be a number as video device, e.g.: 0 would be /dev/video0" |
24 | | - print " It can be a url of a stream, e.g.: rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov" |
25 | | - print " It can be a video file, e.g.: myvideo.mkv" |
| 22 | + print("You must give an argument to open a video stream.") |
| 23 | + print(" It can be a number as video device, e.g.: 0 would be /dev/video0") |
| 24 | + print(" It can be a url of a stream, e.g.: rtsp://wowzaec2demo.streamlock.net/vod/mp4:BigBuckBunny_115k.mov") |
| 25 | + print(" It can be a video file, e.g.: myvideo.mkv") |
26 | 26 | exit(0) |
27 | 27 |
|
28 | 28 | resource = sys.argv[1] |
|
32 | 32 | resource = int(resource) |
33 | 33 | else: |
34 | 34 | resource_name = resource |
35 | | - print "Trying to open resource: " + resource_name |
| 35 | + print("Trying to open resource: ", resource_name) |
36 | 36 | cap = cv2.VideoCapture(resource) |
37 | 37 | if not cap.isOpened(): |
38 | | - print "Error opening resource: " + str(resource) |
39 | | - print "Maybe opencv VideoCapture can't open it" |
| 38 | + print("Error opening resource: " + str(resource)) |
| 39 | + print("Maybe opencv VideoCapture can't open it") |
40 | 40 | exit(0) |
41 | 41 |
|
42 | | - print "Correctly opened resource, starting to show feed." |
| 42 | + print("Correctly opened resource, starting to show feed.") |
43 | 43 | rval, frame = cap.read() |
44 | 44 | while rval: |
45 | 45 | cv2.imshow("Stream: " + resource_name, frame) |
|
50 | 50 | if key == 27 or key == 1048603: |
51 | 51 | break |
52 | 52 | cv2.destroyWindow("preview") |
53 | | - |
0 commit comments