I am working on a project involving a face tracker able to follow my face, printing the X-axis coordinate wherever I am on the screen. I have figured out how to get the bounding box to follow my face but have been struggling, with being able to print the X-axis coordinate. So far I haven't gotten anything to work, I thought this might be a good place to ask. If anyone knows how I would approach this problem that would be much appreciated thank you.
import cv2
from cvzone.FaceDetectionModule import FaceDetector
cap=cv2.VideoCapture(0)
detector=FaceDetector()
while True:
ret,img=cap.read()
img, bboxs=detector.findFaces(img)
cv2.imshow('webcam',img)
k=cv2.waitKey(1)
if k==27:
break;
In the given code, you are not extracting any values from bboxs paramerter. I visited their GitHub repository and detector.findFaces(img)
function returns only "id","bbox","score","center"
.
If you scroll a little bit on their repository, then you will find this method of drawing rectangle
# Draw Corner Rectangle
cvzone.cornerRect(img, bbox)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.