Doubt Points Recognition with Opencv and Dlib

Asked

Viewed 123 times

0

Hi, I’m looking to do facial recognition with Dlib and Open via Webcam but I’m having a mistake with Numpy that I can’t solve, if someone can give me a hint 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 That Appears

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, 212), (391, 194), (276, 183), (284, 174), (296, 171), (309, 172), (320, 177), (341, 175), (351, 169), (362, 166), (373, 168), (381, 175), (333, 192), (334, 205), (336, 217), (338, 230), (322, 239), (330, 241), (337, 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, 275), (321, 272), (315, 265), (331, 263), (337, 263), (343, 262), (355, 262), (343, 265), (337, 267), (331, 267)] printPontos(webcam,points) File "E:/Anyaoriginal/Anyavisaorna/Anyavisionrna.py", line 6, in imprimePontos 68 cv2.Circle(webcam, (p.x, p.y), 2,(0, 255,0), 2) Typeerror: img is not a numpy array, neither a scalar

  • Note that the function is: cv2.Circle(img, center, Radius, color[, Thickness[, lineType[, shift]]]) None ////////////////////////////////////////// Logo: cv2.Circle(img, center, Radius, color, Thickness=1, lineType=8, shift=0) None

  • https://stackoverflow.com/questions/16484796/draw-a-circle-over-image-opencv?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa

1 answer

0

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

imprimePontos(imagem, pontos)    

Browser other questions tagged

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