I am trying to take mediapipes detection.score
as a float value, however, I am unsure how to convert it to that. I am trying to compare detection.score
with a float number. Check code below:
imgRGB = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
self.results = self.faceDetection.process(imgRGB)
bboxs = []
if self.results.detections:
for id, detection in enumerate(self.results.detections):
#Creating the rectangle for drawing
bboxC = detection.location_data.relative_bounding_box
imgH, imgW, imgC = frame.shape
bbox = int(bboxC.xmin * imgW), int(bboxC.ymin * imgH),
int(bboxC.width * imgW), int(bboxC.height * imgH)
bboxs.append([bbox, detection.score])
if draw:
cv2.rectangle(frame, bbox, (255, 0, 255), 2)
cv2.putText(frame, f'{int(detection.score[0]*100)}%',
(bbox[0], bbox[1]-20), cv2.FONT_HERSHEY_PLAIN,
2, (255, 0, 255), 2)
print(type(detection.score))
if detection.score > 0.95:
#print("Good image")
else:
#print("Bad image")
The print for the type of detection.score
outputs as: <class 'google.protobuf.pyext._message.RepeatedScalarContainer'>
. I am trying to convert this to a float value.
Tried using float(detection.score)
. Tried looking through documentation, but could not find anything.