75
75
config_main = {
76
76
"size": (args.width, args.height)
77
77
}
78
- if not args.no_hflip:
79
- config_main["transform"] = Transform(hflip=1)
80
78
picam2 = Picamera2()
81
79
# Not entirely sure how configurations work, preview/main etc.
82
- config = picam2.create_preview_configuration(main=config_main)
80
+ hflip_num = 1
81
+ if args.no_hflip:
82
+ hflip_num = 0
83
+ config = picam2.create_preview_configuration(main=config_main, transform=Transform(hflip=hflip_num))
83
84
picam2.configure(config)
84
85
85
86
controls_main = {
99
100
100
101
# Not entirely sure the difference between start_preview and start.
101
102
picam2.start()
102
- time. sleep(1) # let camera warm up
103
+ sleep(1) # let camera warm up
103
104
104
105
# OpenCV blob detection config
105
106
params = cv2.SimpleBlobDetector_Params()
107
+ params.filterByColor = True
108
+ params.filterByArea = True
106
109
params.blobColor = args.blob_color
110
+ params.minArea = 25
111
+ params.minThreshold = 150
112
+ params.minRepeatability = 3
113
+ params.filterByCircularity = False
114
+ params.filterByConvexity = False
115
+ params.filterByInertia = False
116
+ params.minDistBetweenBlobs = 100
107
117
detector = cv2.SimpleBlobDetector_create(params)
108
118
109
119
# Set up UDP socket to receiving computer
@@ -121,7 +131,6 @@ class PhilNav:
121
131
y = 0.0
122
132
keypoint = None # for debugging inspection
123
133
124
-
125
134
# This is where the Magic happens! The camera should pick up nothing but a white
126
135
# dot from your reflective IR sticker. I use opencv blob detection to track its
127
136
# (x, y) coordinates and send the changes to the receiving computer, which moves
@@ -183,12 +192,11 @@ def blobby(request):
183
192
sock.sendto(MESSAGE, (args.ip, args.port))
184
193
185
194
# Log once per second
186
- if PhilNav.frame_nume % args.fps == 0:
195
+ if PhilNav.frame_num % args.fps == 0:
187
196
fps = PhilNav.frame_num / (time() - PhilNav.started_at)
188
197
ms = (perf_counter() - PhilNav.frame_start) * 1000
189
198
logging.info(
190
- f"Frame: {PhilNav.frame_num}, Diff: ({int(x_diff)}, {int(y_diff)}), FPS: {
191
- int(fps)}, loc ms: {int(ms)}"
199
+ f"Frame: {PhilNav.frame_num}, Diff: ({int(x_diff)}, {int(y_diff)}), FPS: {int(fps)}, loc ms: {int(ms)}"
192
200
)
193
201
194
202
# I'm setting these at the end rather than the beginning, because I want
0 commit comments