Die Größe eines Bildes Bevore Overlay verursacht ProblemePython

Python-Programme
Anonymous
 Die Größe eines Bildes Bevore Overlay verursacht Probleme

Post by Anonymous »

Ich habe den folgenden Code: < /p>
# frame = cv2.resize(frame, (0,0), fx=scaleFactor, fy=scaleFactor)
overlay = frame.copy()
for idx, detection in enumerate(extracted_boxes, 1):
bbox, text, confidence = detection
cv2.rectangle(overlay, (self.scoreBoxCoords['x']+int(bbox[0][0]), self.scoreBoxCoords['y']+int(bbox[0][1])),
(self.scoreBoxCoords['x']+int(bbox[2][0]), self.scoreBoxCoords['y']+int(bbox[2][1])), (255, 0, 0), thickness=2)
cv2.putText(overlay, str(text), (int(self.scoreBoxCoords['x']+int(bbox[0][0])), int(self.scoreBoxCoords['y']+int(bbox[0][1])-8)),
cv2.FONT_HERSHEY_PLAIN, 1.5, (0, 0, 255), 1, cv2.LINE_AA)

# Blend the overlay with the original frame
alpha = 0.6 # Transparency factor
frame = cv2.addWeighted(overlay, alpha, frame, 1 - alpha, 0)

# Show the frame with text overlay
cv2.imshow("Video Text Overlay", frame)
< /code>
Es funktioniert gut mit einer Einschränkung: Die Ergebnisse sind für ein skaliertes Bild. Wenn jedoch der Kommentar in der ersten Zeile entfernt wird, wird nur das Bild angezeigt und kein Overlay sichtbar. Was ist der Grund dafür?
Danke für deine Hilfe! < /P>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post