33#
44# Copyright (c) 2025 SparkFun Electronics
55#-------------------------------------------------------------------------------
6- # ex05_detect_sfe_logo .py
6+ # ex06_detect_sfe_logo .py
77#
88# This example demonstrates a basic vision processing pipeline. A pipeline is
99# just a sequence of steps used to extract meaningful data from an image. The
@@ -136,15 +136,18 @@ def my_pipeline(frame):
136136 center_x = left + width // 2
137137 center_y = top + height // 2
138138
139- # Now we could use this data for some task! For example, if we had
140- # a robot that needed to drive up to the logo , we could turn to face
141- # the logo with the center point, then drive towards it until the
142- # size is big enough.
143- #
139+ # Now we could use this data for some task! For example, if we were
140+ # detecting an object that a robot needs to drive in front of , we
141+ # could turn to face it with the center point, then drive forwards
142+ # until the size is big enough (meaning we're close enough to it) .
143+ #
144144 # This example doesn't actually make use of the data, so we'll just
145- # draw the bounding box and center of the logo for visualization
145+ # draw the bounding box and center of the logo for visualization,
146+ # and add text of the position and size of the logo
146147 frame = cv .rectangle (frame , (left , top ), (left + width , top + height ), (255 , 0 , 0 ), 2 )
147- frame = cv .circle (frame , (center_x , center_y ), 5 , (0 , 255 , 0 ), - 1 )
148+ frame = cv .circle (frame , (center_x , center_y ), 3 , (0 , 255 , 0 ), - 1 )
149+ frame = cv .putText (frame , f"({ center_x } , { center_y } )" , (center_x - 45 , center_y - 10 ), cv .FONT_HERSHEY_SIMPLEX , 0.5 , (0 , 255 , 0 ), 2 )
150+ frame = cv .putText (frame , f"{ width } x{ height } " , (left , top - 10 ), cv .FONT_HERSHEY_SIMPLEX , 0.5 , (255 , 0 , 0 ), 2 )
148151
149152# Initialize a loop timer to calculate processing speed in FPS
150153loop_time = time .ticks_us ()
@@ -168,7 +171,7 @@ def my_pipeline(frame):
168171
169172 # All processing is done! Calculate the frame rate and display it
170173 current_time = time .ticks_us ()
171- fps = 1000000 / (current_time - loop_time )
174+ fps = 1_000_000 / (current_time - loop_time )
172175 loop_time = current_time
173176 frame = cv .putText (frame , f"FPS: { fps :.2f} " , (40 , 30 ), cv .FONT_HERSHEY_SIMPLEX , 1 , (0 , 0 , 255 ), 2 )
174177
0 commit comments