Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Multiple Text Dislay on Images


I'm trying to implement multiple text in a video frame. E.g. the following code just display 1 text for an image. In this code at present I can pass one "name" at a time. I want to pass multiple names. E.g. if 2 people are detected it should pass 2 names.

video_capture = cv2.VideoCapture(0)

while True:
    # Grab a single frame of video
    ret, frame =

    # Loop through each face in this frame of video
    faces = faceCascade.detectMultiScale(
    minSize=(30, 30),

    # Draw a rectangle around the faces
    for (x, y, w, h) in faces:
        cv2.rectangle(frame, (x, y), (x+w, y+h), (0, 255, 0), 2)
        # Draw a label with a name below the face
        cv2.rectangle(frame, (left, bottom - 35), (right, bottom), (0, 0, 255), cv2.FILLED)
        font = cv2.FONT_HERSHEY_DUPLEX
        cv2.putText(frame, name, (left + 6, bottom - 6), font, 1.0, (255, 255, 255), 1)

    # Display the resulting frame
    cv2.imshow('Video', frame)

    # Hit 'q' on the keyboard to quit!
    if cv2.waitKey(1) & 0xFF == ord('q'):

# Release handle to the webcam

Thank you!