Added camera detection

main
Spagnolo Gasper 2022-11-28 15:47:06 +01:00
parent bd76aa0534
commit 55048a5eb3
1 changed files with 25 additions and 0 deletions

25
assignment4/cam.py Normal file
View File

@ -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()