Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cv2.error: OpenCV(3.4.3) C:\projects\opencv-python\opencv\modules\core\src\matrix.cpp:235: error: (-215:Assertion failed) s >= 0 in function 'cv::setSize' #25

Open
BlackDarkZeroXX98 opened this issue Nov 26, 2018 · 0 comments

Comments

@BlackDarkZeroXX98
Copy link

Necesito ayuda con este error, al momento de cambiar de persona me marca este error no se cual sera el problema (soy muy nuevo en esto tengo)

import numpy as np
import cv2
import pickle

Face = cv2.CascadeClassifier("haarcascade_frontalface_alt2.xml ")
eye = cv2.CascadeClassifier('cascades/data/haarcascade_eye.xml')
smile = cv2.CascadeClassifier('cascades/data/haarcascade_smile.xml')

recognizer = cv2.face.LBPHFaceRecognizer_create()
recognizer.read("trainner.yml")

labelids={"person_name", 1}

with open("labels.pickle","rb")as f:
og_labelids=pickle.load(f)
labelids={v:k for k,v in og_labelids.items()}

capt = cv2.VideoCapture(0)

while(True):
ret, frame = capt.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
faces = Face.detectMultiScale(gray, scaleFactor=1.5, minNeighbors=5)
for (x, y, w, h) in faces:
#print(x, y, w, h)
gray = gray[y:y+h, x:x+w]
color = frame[y:y+h, x:x+w]
#recordar
id_, conf = recognizer.predict(gray)
if (conf>=4 and conf<=85):
#print(id_)
#print(labelids[id_])
font = cv2.FONT_HERSHEY_SIMPLEX
name= labelids[id_]
color =(255,255,255)
stroke = 2
cv2.putText(frame, name, (x,y), font, 1, color, stroke, cv2.LINE_AA)

    img_item = "My-image.png"
    cv2.imwrite(img_item, color)

    color =  (255, 0, 0) #BGR 0-255
    stroke = 2
    end_cord_y = y+h
    end_cord_x  = x+w
    cv2.rectangle(frame, (x,y),(end_cord_x, end_cord_y), color, stroke)


cv2.imshow('frame', frame)
if(cv2.waitKey(20) & 0xFF == ord('q')):
    break

capt.release()
cv2.destroyAllWindows()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant