Ask Your Question

henrique lobato's profile - activity

2019-03-31 05:06:22 -0600 received badge  Famous Question (source)
2018-08-16 04:57:35 -0600 received badge  Notable Question (source)
2018-05-09 07:58:11 -0600 received badge  Popular Question (source)
2017-07-20 07:30:49 -0600 received badge  Enthusiast
2017-07-16 18:46:55 -0600 commented question Mp3 Header missing

r00tuzr, did you solve the problem?

2017-07-16 16:31:14 -0600 asked a question [mp3 @ 0xe6b3c0] Header missing

Im trying to get some pictures with facedetection with my raspberry with the code below

import cv2
import time

count = 0
faceCascade = cv2.CascadeClassifier('/home/pi/haarcascade_frontalface_alt.xml')
cv2.VideoCapture('http://***/videostream.cgiuser=**&pwd=**&resolution=32&rate=0')

while True:
 ret, frame = video_capture.read()

 gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

 faces = faceCascade.detectMultiScale(
    gray,
    scaleFactor=1.1,
    minNeighbors=5,
    minSize=(30, 30),
    flags=cv2.CASCADE_SCALE_IMAGE
)

 for (x, y, w, h) in faces:
    cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2)
    file_name = '/home/pi/faces_detected/frame%s_%s.png' %(count, str(time.time())[11:])
    cv2.imwrite(file_name, frame)
    count += 1

 if cv2.waitKey(1) & 0xFF == ord('q'):
    break

when I run with python, i got the error several times

[mp3 @ 0xe6b3c0] Header missing
[mp3 @ 0xe6b3c0] Header missing
[mp3 @ 0xe6b3c0] Header missing
[mp3 @ 0xe6b3c0] Header missing
[mp3 @ 0xe6b3c0] Header missing

I do not use any audio on the code, why I got this error?

2017-07-16 11:24:31 -0600 commented answer faces = face_cascade.detectMultiScale(gray, 1.3, 5)

Here is how the problem was solved

I dont know why windows did not recognized the .xml file at first, so I changed for the xml file from the opencv-master folder

It worked. Thanks for the answer berak

2017-07-16 00:26:13 -0600 asked a question faces = face_cascade.detectMultiScale(gray, 1.3, 5)

About the code below:

import cv2

face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_alt.xml')

img = cv2.imread('2.jpg')

gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
faces = face_cascade.detectMultiScale(gray, 1.3, 5)

Im getting the following error

Traceback (most recent call last):
File "C:\Users\henri\.p2\pool\plugins\org.python.pydev_5.8.0.201706061859\pysrc\pydevd.py", line 1557, in <module>
cv2.error: C:\projects\opencv-python\opencv\modules\objdetect\src\cascadedetect.cpp:1681: error: (-215) !empty() in function cv::CascadeClassifier::detectMultiScale

Things I tried without success:

  • The whole path in the xml file im using
  • Put explicit parameters like img=something

Obs: The dtype of variable gray its already uint8