Answer to Question #43484 in Python for Adrita

Question #43484
I am new to python and OpenCV coding. I am reading a video from my webcam. I want my code to be able to capture an image when i click anywhere on the window which opens the video. This is the piece of code which reads the video. Please suggest how I can do this. cam = create_capture(video_src, fallback='synth:bg=../cpp/lena.jpg:noise=0.05') while True: ret, img = gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) gray = cv2.equalizeHist(gray) t = clock() rects = detect(gray, cascade) vis = img.copy() draw_rects(vis, rects, (0, 255, 0)) for x1, y1, x2, y2 in rects: roi = gray[y1:y2, x1:x2] vis_roi = vis[y1:y2, x1:x2] subrects = detect(roi.copy(), nested) draw_rects(vis_roi, subrects, (255, 0, 0)) dt = clock() - t draw_str(vis, (20, 20), 'time: %.1f ms' % (dt*1000)) cv2.imshow('facedetect', vis) if 0xFF & cv2.waitKey(5) == 27: break ## CODE SHOULD CAPTURE AN IMAGE ONCLICK cv2.destroyAllWindows()
Expert's answer

Not answered

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

New on Blog