MCPcopy Create free account
hub / github.com/dkpython7/open-cv-projects- / run

Method run

GYM/main.py:147–188  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

145 return image
146
147 def run(self):
148 cap = cv2.VideoCapture(0)
149
150 cap.set(cv2.CAP_PROP_FRAME_WIDTH, 1280)
151 cap.set(cv2.CAP_PROP_FRAME_HEIGHT, 720)
152
153 print("=" * 50)
154 print("Pull-Up Counter Started!")
155 print("=" * 50)
156 print("Instructions:")
157 print("- Position yourself so camera can see your hands and head")
158 print("- Start from hanging position (arms extended)")
159 print("- Pull up until head goes above hand level")
160 print("- Lower down to complete one rep")
161 print()
162 print("Controls:")
163 print("- Press 'q' to quit")
164 print("- Press 'r' to reset counter")
165 print("=" * 50)
166
167 while cap.isOpened():
168 ret, frame = cap.read()
169 if not ret:
170 print("Failed to grab frame")
171 break
172
173 frame = cv2.flip(frame, 1)
174
175 output_frame = self.process_frame(frame)
176
177 cv2.imshow('Pull-Up Counter', output_frame)
178
179 key = cv2.waitKey(10) & 0xFF
180 if key == ord('q'):
181 break
182 elif key == ord('r'):
183 self.counter = 0
184 self.stage = None
185 print("Counter reset!")
186
187 cap.release()
188 cv2.destroyAllWindows()
189
190if __name__ == "__main__":
191 counter = PullUpCounter()

Callers 1

main.pyFile · 0.45

Calls 1

process_frameMethod · 0.95

Tested by

no test coverage detected