Skip to content

Commit 1c20a4f

Browse files
committed
initial add of camera_stream object to all examples - without T-API enabled
1 parent c71531e commit 1c20a4f

28 files changed

+363
-28
lines changed

abs_difference.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,20 @@ def nothing(x):
6161

6262
# define video capture object
6363

64+
try:
65+
# to use a non-buffered camera stream (via a separate thread)
6466

65-
cap = cv2.VideoCapture()
67+
if not(args.video_file):
68+
import camera_stream
69+
cap = camera_stream.CameraVideoStream(use_tapi=False)
70+
else:
71+
cap = cv2.VideoCapture() # not needed for video files
72+
73+
except BaseException:
74+
# if not then just use OpenCV default
75+
76+
print("INFO: camera_stream class not found - camera input may be buffered")
77+
cap = cv2.VideoCapture()
6678

6779
# define display window name
6880

bilateral_filter.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,20 @@ def nothing(x):
5959

6060
# define video capture object
6161

62+
try:
63+
# to use a non-buffered camera stream (via a separate thread)
6264

63-
cap = cv2.VideoCapture()
65+
if not(args.video_file):
66+
import camera_stream
67+
cap = camera_stream.CameraVideoStream(use_tapi=False)
68+
else:
69+
cap = cv2.VideoCapture() # not needed for video files
70+
71+
except BaseException:
72+
# if not then just use OpenCV default
73+
74+
print("INFO: camera_stream class not found - camera input may be buffered")
75+
cap = cv2.VideoCapture()
6476

6577
# define display window name
6678

butterworth_high_pass_filter.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,20 @@ def reset_butterworth_filter(_):
102102

103103
# define video capture object
104104

105+
try:
106+
# to use a non-buffered camera stream (via a separate thread)
105107

106-
cap = cv2.VideoCapture()
108+
if not(args.video_file):
109+
import camera_stream
110+
cap = camera_stream.CameraVideoStream(use_tapi=False)
111+
else:
112+
cap = cv2.VideoCapture() # not needed for video files
113+
114+
except BaseException:
115+
# if not then just use OpenCV default
116+
117+
print("INFO: camera_stream class not found - camera input may be buffered")
118+
cap = cv2.VideoCapture()
107119

108120
# define display window name
109121

butterworth_low_pass_filter.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,20 @@ def reset_butterworth_filter(_):
102102

103103
# define video capture object
104104

105+
try:
106+
# to use a non-buffered camera stream (via a separate thread)
105107

106-
cap = cv2.VideoCapture()
108+
if not(args.video_file):
109+
import camera_stream
110+
cap = camera_stream.CameraVideoStream(use_tapi=False)
111+
else:
112+
cap = cv2.VideoCapture() # not needed for video files
113+
114+
except BaseException:
115+
# if not then just use OpenCV default
116+
117+
print("INFO: camera_stream class not found - camera input may be buffered")
118+
cap = cv2.VideoCapture()
107119

108120
# define display window name
109121

capture_camera.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,17 @@
4141

4242
# define video capture object
4343

44-
cap = cv2.VideoCapture()
44+
try:
45+
# to use a non-buffered camera stream (via a separate thread)
46+
47+
import camera_stream
48+
cap = camera_stream.CameraVideoStream(use_tapi=False)
49+
50+
except BaseException:
51+
# if not then just use OpenCV default
52+
53+
print("INFO: camera_stream class not found - camera input may be buffered")
54+
cap = cv2.VideoCapture()
4555

4656
# define display window name
4757

capture_video.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,17 @@
4747

4848
# define video capture object
4949

50-
cap = cv2.VideoCapture()
50+
try:
51+
# to use a non-buffered camera stream (via a separate thread)
52+
53+
import camera_stream
54+
cap = camera_stream.CameraVideoStream(use_tapi=False)
55+
56+
except BaseException:
57+
# if not then just use OpenCV default
58+
59+
print("INFO: camera_stream class not found - camera input may be buffered")
60+
cap = cv2.VideoCapture()
5161

5262
# define display window name
5363

clahe_equalization.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,20 @@ def nothing(x):
7979

8080
# define video capture object
8181

82+
try:
83+
# to use a non-buffered camera stream (via a separate thread)
8284

83-
cap = cv2.VideoCapture()
85+
if not(args.video_file):
86+
import camera_stream
87+
cap = camera_stream.CameraVideoStream(use_tapi=False)
88+
else:
89+
cap = cv2.VideoCapture() # not needed for video files
90+
91+
except BaseException:
92+
# if not then just use OpenCV default
93+
94+
print("INFO: camera_stream class not found - camera input may be buffered")
95+
cap = cv2.VideoCapture()
8496

8597
# define display window name
8698

colour_object_tracking.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,20 @@ def nothing(x):
9999

100100
# define video capture object
101101

102+
try:
103+
# to use a non-buffered camera stream (via a separate thread)
102104

103-
cap = cv2.VideoCapture()
105+
if not(args.video_file):
106+
import camera_stream
107+
cap = camera_stream.CameraVideoStream(use_tapi=False)
108+
else:
109+
cap = cv2.VideoCapture() # not needed for video files
110+
111+
except BaseException:
112+
# if not then just use OpenCV default
113+
114+
print("INFO: camera_stream class not found - camera input may be buffered")
115+
cap = cv2.VideoCapture()
104116

105117
# define display window name
106118

contrast_stretching.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,20 @@ def hist_lines(hist):
7070

7171
# define video capture object
7272

73+
try:
74+
# to use a non-buffered camera stream (via a separate thread)
7375

74-
cap = cv2.VideoCapture()
76+
if not(args.video_file):
77+
import camera_stream
78+
cap = camera_stream.CameraVideoStream(use_tapi=False)
79+
else:
80+
cap = cv2.VideoCapture() # not needed for video files
81+
82+
except BaseException:
83+
# if not then just use OpenCV default
84+
85+
print("INFO: camera_stream class not found - camera input may be buffered")
86+
cap = cv2.VideoCapture()
7587

7688
# define display window name
7789

correlation_template_matching.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,20 @@ def on_mouse(event, x, y, flags, params):
8989

9090
# define video capture object
9191

92+
try:
93+
# to use a non-buffered camera stream (via a separate thread)
9294

93-
cap = cv2.VideoCapture()
95+
if not(args.video_file):
96+
import camera_stream
97+
cap = camera_stream.CameraVideoStream(use_tapi=False)
98+
else:
99+
cap = cv2.VideoCapture() # not needed for video files
100+
101+
except BaseException:
102+
# if not then just use OpenCV default
103+
104+
print("INFO: camera_stream class not found - camera input may be buffered")
105+
cap = cv2.VideoCapture()
94106

95107
# define display window name
96108

0 commit comments

Comments
 (0)