From 55048a5eb3e14df273b81af6ce4122433dda3479 Mon Sep 17 00:00:00 2001 From: Spagnolo Gasper Date: Mon, 28 Nov 2022 15:47:06 +0100 Subject: [PATCH] Added camera detection --- assignment4/cam.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 assignment4/cam.py diff --git a/assignment4/cam.py b/assignment4/cam.py new file mode 100644 index 0000000..3fd4942 --- /dev/null +++ b/assignment4/cam.py @@ -0,0 +1,25 @@ +import cv2 + + +def start_realtime_keypoint_detection(): + cap = cv2.VideoCapture(0) + scaling_factor = 1 + + while True: + ret, frame = cap.read() + frame = cv2.resize(frame, None, fx=scaling_factor, fy=scaling_factor, interpolation=cv2.INTER_AREA) + imagegray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) + features = cv2.SIFT_create() + keypoints = features.detect(imagegray, None) + output_image = cv2.drawKeypoints(frame, keypoints, 0, (0, 255, 0),flags=cv2.DRAW_MATCHES_FLAGS_DRAW_RICH_KEYPOINTS) + + cv2.imshow('Webcam', output_image) + c = cv2.waitKey(1) + if c == 27: + break + + cap.release() + cv2.destroyAllWindows() + +if __name__ == '__main__': + start_realtime_keypoint_detection() \ No newline at end of file