Display text in python application

Asked

Viewed 314 times

1

I’m developing an application that makes people count by video, but it is showing the count by the terminal, how do I display "Found N people" on the video screen? follows my code:

print help_message

hog = cv2.HOGDescriptor()
hog.setSVMDetector( cv2.HOGDescriptor_getDefaultPeopleDetector() )


capture = cv2.VideoCapture(0)
while(True):

  ret, img = capture.read()
# img = cv.fromarray(img)

  found, w = hog.detectMultiScale(img, winStride=(8,8), padding=(32,32), scale=1.05)
  found_filtered = []
  for ri, r in enumerate(found):
for qi, q in enumerate(found):
  if ri != qi and inside(r, q):
    break
  else:
    found_filtered.append(r)
  draw_detections(img, found)
  draw_detections(img, found_filtered, 3)
  print ' (%d) Pessoas na imagem' %  (len(found))
  font = cv2.FONT_HERSHEY_SIMPLEX
    cv2.putText(img,'OpenCV',(10,500), font, 4,(255,255,255),2,cv2.LINE_AA)

  cv2.imshow('TELA DE CAPTURA', img)
  ch = 0xFF & cv2.waitKey(1)
  if ch == 27:
break
capture.release()
cv2.destroyAllWindows()
  • 1

    I won’t answer because I don’t use Opencv in Python (and an answer would deserve at least a short example). But, you can use the function putText to do what you need.

  • 1

    Ah, I found an example in this reply from Soen: http://stackoverflow.com/a/34273603/2896619

  • 1

    Hello @gabra. You’re absolutely right. But like I said, I don’t use Opencv in Python, so I don’t even have the test to prepare a response. Anyway, feel free to put the answer if you wish/can do it in my place. No problem at all. :)

  • I had forgotten this question, and ended up posting an answer that serves in this other: http://answall.com/a/168383/73

  • 3
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.