Doubts Points Recognition with OpenCv and Dlib

0

Hello, I want to do facial recognition with Dlib and Open through WebCam but I'm having a Numpy error that I can not solve, if anyone can give me a hint it would be of great help.

My Code.

import cv2
import dlib

def imprimePontos (webcam, pontosFaciais):
    for p in pontosFaciais.parts():
        cv2.circle(webcam, (p.x, p.y), 2,(0, 255,0), 2)

fonte = cv2.FONT_HERSHEY_COMPLEX_SMALL
webcam = cv2.VideoCapture(0)
detectorFace = dlib.get_frontal_face_detector()
detectorPontosFaciais = dlib.shape_predictor("shape_predictor_68_face_landmarks.dat")

conectado, imagem = webcam.read()

while (True):
    conectado, imagem = webcam.read()
    facesDetectadas = detectorFace(imagem, 2)
for face in facesDetectadas:
    pontos = detectorPontosFaciais(imagem, face)
    print(pontos.parts())
    print(len(pontos.parts()))
    imprimePontos(webcam,pontos)
cv2.imshow('Pontos Faciais', imagem)
if cv2.waitKey(1) & 0xFF == 27:
   break
webcam.release()
cv2.destroyAllWindows()

Error Appearing

C: \ Users \ jhona \ Anaconda3 \ envs \ dlib \ python.exe E: /AnyaOriginal/AnyaVisaoRNA/AnyaVisionRNA.py Traceback (most recent call last):   File "E: /AnyaOriginal/AnyaVisaoRNA/AnyaVisionRNA.py", line 23, in points (260, 203), (262, 222), (266,240), (271,257), (279,273), (291,286), (305,297), (321,304), (337, 305), (352, 302), (365, 292), (375,279), (383,264), (389,247), (391,229), (392,122), (391 , 194), 276, 183, 284, 174, 296, 171, 309, 172, 320, 177, 341, 175, 351, (333,216), (333, 168), (381,175), (333,192), (334,205), (336,217), (338,230), (322,239), (330,241), (297, 243), (344,240), (350,237), (290,197), (298,192), (307,191), (315,197), (307,199), (298 , 200), (346, 195), (354,188), (363,187), (370,191), (364,195), (355,196), (310,265), (321,259 ), (331, 257), (337, 258), (343, 256), (351, 257), (359,261), (352,270), (344,274), (338,276), (331, 263), (333, 263), (343, 262), (355, 262), (343, 265), (331, 275), (321, 272), (315, 265), , 267), (331, 267)]     printStages (webcam, dots)   File "E: /AnyaOriginal/AnyaVisaoRNA/AnyaVisionRNA.py", line 6, in printStages 68     cv2.circle (webcam, (p.x, p.y), 2, (0, 255,0), 2) TypeError: img is not a numpy array, neither a scalar

    
asked by anonymous 02.06.2018 / 22:02

1 answer

0

The error is in the parameter you are passing to the function, instead of passing the variable webcam you must pass the variable image as below:

imprimePontos(imagem, pontos)    
    
19.06.2018 / 04:38