Skip to content

Commit 99503b8

Browse files
committed
Added logic to release the webcam
1 parent 3d3c2d9 commit 99503b8

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed
474 Bytes
Binary file not shown.

commands/mouse_movement.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ async def monitor_mouse_movement(client, config, starting_mouse_position):
4545
except (FileNotFoundError, json.JSONDecodeError, discord.NotFound, ValueError):
4646
pass
4747

48-
webcam = cv2.VideoCapture(0) # Initialize webcam capture
49-
5048
while True:
5149
current_mouse_position = pyautogui.position()
5250

@@ -65,9 +63,11 @@ async def monitor_mouse_movement(client, config, starting_mouse_position):
6563
continue # Skip the rest of the loop iteration if there's an error
6664

6765
# Capture webcam image
66+
webcam = cv2.VideoCapture(0) # Initialize webcam capture
6867
ret, frame = webcam.read()
6968
if ret:
7069
cv2.imwrite(WEBCAM_CAPTURE_PATH, frame)
70+
webcam.release() # Release the webcam capture
7171

7272
# Load the screenshot and webcam capture images
7373
screenshot = cv2.imread(SCREENSHOT_PATH)

0 commit comments

Comments
 (0)