Reputation: 4480
I am new to opencv and am making an application that recognizes person's face and then displays their id and asks them to confirm it by nodding their head or to cancel the recognized face by shaking their head. If the user confirms, their id, name and timestamp is pushed to a database and if they cancel the loop starts the recognition process again. I want to display a success message temporarily in the cv2 window using puttext method for 2 seconds before removing it. What would be the best way to go about displaying this message? This is how i am currently displaying messages on the screen. Please let me know if you need any more information.
if not gesture: cv2.putText(frame, 'detected:', (50, 50), self.font, 0.8, (0, 0, 0), 2)
Upvotes: 2
Views: 4273
Reputation: 150735
OpenCV does not have that feature. You can implement something like:
import cv2
from datetime import datetime
last_detected = datetime.now()
while True:
ret, frame = video.read()
if not ret:
break
# detect gesture here
gesture = detect_gesture()
if gesture:
last_detected = datetime.now()
else:
if (datetime.now() - last_detected).total_seconds() < 2:
cv2.putText(frame, 'detected:', (50, 50), self.font, 0.8, (0, 0, 0), 2)
cv2.imshow("frame", frame)
cv2.waitKey(1)
Upvotes: 3