Skip to content

Commit bae43c4

Browse files
committed
add nocontrols option to run it full screen for schools demos etc
1 parent 21ae4c0 commit bae43c4

File tree

1 file changed

+21
-13
lines changed

1 file changed

+21
-13
lines changed

canny.py

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@
4949
"--fullscreen",
5050
action='store_true',
5151
help="run in full screen mode")
52+
parser.add_argument(
53+
"-nc",
54+
"--nocontrols",
55+
action='store_true',
56+
help="no onscreen controls")
5257
parser.add_argument(
5358
'video_file',
5459
metavar='video_file',
@@ -107,18 +112,19 @@ def nothing(x):
107112
# add some track bar controllers for settings
108113

109114
lower_threshold = 25
110-
cv2.createTrackbar("lower", window_name2, lower_threshold, 255, nothing)
111115
upper_threshold = 120
112-
cv2.createTrackbar("upper", window_name2, upper_threshold, 255, nothing)
113116
smoothing_neighbourhood = 3
114-
cv2.createTrackbar(
115-
"smoothing",
116-
window_name2,
117-
smoothing_neighbourhood,
118-
15,
119-
nothing)
120117
sobel_size = 3 # greater than 7 seems to crash
121-
cv2.createTrackbar("sobel size", window_name2, sobel_size, 7, nothing)
118+
119+
if (not (args.nocontrols)):
120+
cv2.createTrackbar("lower", window_name2, lower_threshold,
121+
255, nothing)
122+
cv2.createTrackbar("upper", window_name2, upper_threshold,
123+
255, nothing)
124+
cv2.createTrackbar("smoothing", window_name2, smoothing_neighbourhood,
125+
15, nothing)
126+
cv2.createTrackbar("sobel size", window_name2, sobel_size,
127+
7, nothing)
122128

123129
# override default camera resolution
124130

@@ -151,10 +157,12 @@ def nothing(x):
151157

152158
# get parameters from track bars
153159

154-
lower_threshold = cv2.getTrackbarPos("lower", window_name2)
155-
upper_threshold = cv2.getTrackbarPos("upper", window_name2)
156-
smoothing_neighbourhood = cv2.getTrackbarPos("smoothing", window_name2)
157-
sobel_size = cv2.getTrackbarPos("sobel size", window_name2)
160+
if (not (args.nocontrols)):
161+
lower_threshold = cv2.getTrackbarPos("lower", window_name2)
162+
upper_threshold = cv2.getTrackbarPos("upper", window_name2)
163+
smoothing_neighbourhood = cv2.getTrackbarPos("smoothing",
164+
window_name2)
165+
sobel_size = cv2.getTrackbarPos("sobel size", window_name2)
158166

159167
# check neighbourhood is greater than 3 and odd
160168

0 commit comments

Comments
 (0)