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

+13-1
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

+13-1
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

+13-1
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

+13-1
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

+11-1
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

+11-1
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

+13-1
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

+13-1
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

+13-1
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

+13-1
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

dct_low_pass_filter.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,20 @@ def nothing(x):
8686

8787
# define video capture object
8888

89+
try:
90+
# to use a non-buffered camera stream (via a separate thread)
8991

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

92104
# define display window name
93105

exponential.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,20 @@ def exponential_transform(image, c, alpha):
7676

7777
# define video capture object
7878

79+
try:
80+
# to use a non-buffered camera stream (via a separate thread)
7981

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

8294
# define display window name
8395

fourier.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,20 @@
5959

6060
# define video capture object
6161

62-
cap = cv2.VideoCapture()
62+
try:
63+
# to use a non-buffered camera stream (via a separate thread)
64+
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()
6376

6477
# define display window name
6578

gamma.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,20 @@ def powerlaw_transform(image, gamma):
7878

7979
# define video capture object
8080

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

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

8496
# define display window name
8597

high_pass_filter.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,20 @@ def nothing(x):
7878

7979
# define video capture object
8080

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

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

8496
# define display window name
8597

histogram.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,20 @@ def hist_lines(hist):
8181

8282
# define video capture object
8383

84+
try:
85+
# to use a non-buffered camera stream (via a separate thread)
8486

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

8799
# define display window name
88100

histogram_equalize.py

+13-1
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,21 @@ 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
7581

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()
87+
7688
# define display window name
7789

7890
window_name1 = "Live Camera Input" # window name

hsv_viewer.py

+14-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,20 @@
5656

5757
# define video capture object
5858

59-
cap = cv2.VideoCapture()
59+
try:
60+
# to use a non-buffered camera stream (via a separate thread)
61+
62+
if not(args.video_file):
63+
import camera_stream
64+
cap = camera_stream.CameraVideoStream(use_tapi=False)
65+
else:
66+
cap = cv2.VideoCapture() # not needed for video files
67+
68+
except BaseException:
69+
# if not then just use OpenCV default
70+
71+
print("INFO: camera_stream class not found - camera input may be buffered")
72+
cap = cv2.VideoCapture()
6073

6174
# define display window name
6275

0 commit comments

Comments
 (0)