Replies: 1 comment 1 reply
-
|
Hi @Sajjan-ak, i hope my answer is helpful. def findEncoding(images):
encoding_list = []
for img in images:
resized_img = resize(img, 1)
bgr_img = cv2.cvtColor(resized_img, cv2.COLOR_RGB2BGR)
encodeimg = fr.face_encodings(bgr_img)[0]
encoding_list.append(encodeimg)
return encoding_list
encode_list = findEncoding(studentImg)
vid = cv2.VideoCapture(0)
while True:
success, frame = vid.read()
frames = cv2.resize(frame, (0, 0), None, 0.25, 0.25)
rgb_frames = cv2.cvtColor(frames, cv2.COLOR_BGR2RGB)
faces_in_frame = fr.face_location(rgb_frames)
encode_in_frame = fr.face.face_encoding(rgb_frames, faces_in_frame) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
import cv2
import numpy as np
import face_recognition as fr
import os
fuctions
def resize(img, size):
width = int(img.shape[1]* size)
height = int(img.shape[0]* size)
dimension = (width, height)
return cv2.resize(img, dimension, interpolation = cv2.INTER_NEAREST)
path = 'student_images'
studentImg = []
studentName = []
myList = os.listdir(path)
print(myList)
for cl in myList:
curImg = cv2.imread(f'{path}{cl}') # Student_images/dkshivu.jpg
studentImg.append(curImg)
studentName.append(os.path.splitext(cl)[0])
print(studentName)
def findEncoding(images):
encoding_list = []
for img in images:
img = resize(img, 1)
img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR())
encodeimg = fr.face_encodings(img)[0]
encoding_list.append(encodeimg)
return encoding_list
Encode_list = findEncoding(studentImg)
vid = cv2.VideoCapture(0)
while True:
sucess, frame = vid.read()
frames = cv2.resize(frame, (0, 0), None, 0.25, 0.25)
frames = cv2.cvtColor(frames, cv2.COLOR_BGR2RGB)
faces_in_frame = fr.face_location(frames)
encode_in_frame = fr.face.face_encoding(frames, faces_in_frame)
I am getting Error:
C:\Users\Viper_Akash\PycharmProjects\newpythonProject\venv\Scripts\python.exe
C:\Users\Viper_Akash\PycharmProjects\newpythonProject\smart_attendence_system_program.py
Traceback (most recent call last):
File "C:\Users\Viper_Akash\PycharmProjects\newpythonProject\smart_attendence_system_program.py", line 37, in
Encode_list = findEncoding(studentImg)
File "C:\Users\Viper_Akash\PycharmProjects\newpythonProject\smart_attendence_system_program.py", line 31, in findEncoding
img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR())
TypeError: 'int' object is not callable
Beta Was this translation helpful? Give feedback.
All reactions