paviro / mmm-facial-recognition-tools Goto Github PK
View Code? Open in Web Editor NEWTools to setup and train the facial recognition module for the MagicMirror.
Tools to setup and train the facial recognition module for the MagicMirror.
Hi. I've been having the same problem others have been having, and even after installing future, the exact same problem continues. Reboots and reinstalls don't help either.
Traceback (most recent call last): File "capture.py", line 18, in <module> import lib.capture as capture File "/home/pi/MMM-Facial-Recognition-Tools/lib/capture.py", line 12, in <module> from builtins import input ImportError: No module named builtins
I read about raspi 3 is not supported (April last year). Has this fact changed over the last month or is support for raspi3 working again? If raspi 3 ist supported, can give some additionals details on the eroors, I encounter.
Best regards.
Hello,
I realized that I used a different route than "MMM-Facial- Recognition" to get this working.....
Everything works at command and I get recognized. My problem is that now I have no idea how to create a module for config.js !!!
Can someone help please
I used this thread: https://noahingham.com/blog/facerec-python.html
Thank you
Hi! I have cloned modules into modules folder. But while capturing the image for training_data it's showing an error. I installed opencv as given in dependencies using (sudo apt-get install libopencv-dev python-opencv). I enabled the camera in 'raspi-config' but it says it is off and after pressing 'Enter' for capturing image it displays the error like this...
$ python capture.py
What do you want to do?
[1] Capture training images from webcam
[2] Convert '*.jpg' pictures from other cameras to training images
--> 1
Enter the name of the person you want to capture or convert images for.
--> AKHIL
Images will be placed in ./training_data/AKHIL
Starting process...
Picam selected...
Capturing positive training images.
Press enter to capture an image.
Press Ctrl-C to quit.
mmal: mmal_vc_component_create: failed to create component 'vc.ril.camera' (1:ENOMEM)
mmal: mmal_component_create_core: could not create component 'vc.ril.camera' (1)
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/home/pi/MagicMirror/modules/tools/facetrainer/lib/picam.py", line 24, in run
with picamera.PiCamera() as camera:
File "/usr/lib/python2.7/dist-packages/picamera/camera.py", line 431, in init
self._init_camera(camera_num, stereo_mode, stereo_decimate)
File "/usr/lib/python2.7/dist-packages/picamera/camera.py", line 460, in _init_camera
"Camera is not enabled. Try running 'sudo raspi-config' "
PiCameraError: Camera is not enabled. Try running 'sudo raspi-config' and ensure that the camera has been enabled.
Capturing image...
OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cvtColor, file /build/opencv-ISmtkH/opencv-2.4.9.1+dfsg/modules/imgproc/src/color.cpp, line 3737
Traceback (most recent call last):
File "capture.py", line 35, in
capture.capture()
File "/home/pi/MagicMirror/modules/tools/facetrainer/lib/capture.py", line 57, in capture
image = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
cv2.error: /build/opencv-ISmtkH/opencv-2.4.9.1+dfsg/modules/imgproc/src/color.cpp:3737: error: (-215) scn == 3 || scn == 4 in function cvtColor
Help me how to resolve this error
I re-installed opencv2
what am I doing wrong, also if I capture images manually and save it in a folder will the train.py still work?
Images will be placed in ./training_data/d
Starting process...
Capturing positive training images.
Type c (and press enter) to capture an image.
Press Ctrl-C to quit.
Traceback (most recent call last):
File "capture.py", line 18, in
capture.capture()
File "C:\Users\Animesh\Downloads\MMM-Facial-Recognition-Tools-master\facetrainer\lib\capture.py", line 56, in capture
if is_letter_input('c'):
File "C:\Users\Animesh\Downloads\MMM-Facial-Recognition-Tools-master\facetrainer\lib\capture.py", line 24, in is_letter_input
if select.select([sys.stdin, ], [], [], 0.0)[0]:
select.error: (10038, 'An operation was attempted on something that is not a socket')
It seems like camera.read()
isn't able to read images. It results in 0x0 images which cause the cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)
to crash with:
Loading training data...
ALGORITHM: LBPH
Training data loaded!
--------------------
Picam ausgewählt...
OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cvtColor, file /build/opencv-ISmtkH/opencv-2.4.9.1+dfsg/modules/imgproc/src/color.cpp, line 3737
Traceback (most recent call last):
File "facerecognition.py", line 45, in <module>
image = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)
cv2.error: /build/opencv-ISmtkH/opencv-2.4.9.1+dfsg/modules/imgproc/src/color.cpp:3737: error: (-215) scn == 3 || scn == 4 in function cvtColor
I am using the Raspberry Pi 3 with v2 NoIR camera. Facetrainer does capturing well.
I cannot run this line:
pip install -r requirements.txt
I get the following error:
Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt' Storing debug log for failure in /home/pi/.pip/pip.log
I can capture and train with the camera. But whenever I run
python facerecognition.py
I get the following error:
pi@raspberrypi:~/MagicMirror/modules/MMM-Facial-Recognition-Tools $ export FACE_ALGORITHM=1
pi@raspberrypi:~/MagicMirror/modules/MMM-Facial-Recognition-Tools $ export FACE_USERS=Skippy
pi@raspberrypi:~/MagicMirror/modules/MMM-Facial-Recognition-Tools $ python facerecognition.py
['Skippy']
Using FACE_ALGORITM: 1
Loading training data...
Training data loaded!
Xlib: extension "RANDR" missing on display ":10.0".
(Facial recognition:3900): GdkGLExt-WARNING **: Window system doesn't support OpenGL.
When it runs, the preview pops-up on the hdmi connected screen. Whenever it is done loading the the training data it immediately crashes.
Could this be because i cannot run the requirements.txt python line? Or is something else missing?
Kind of new to these things and i have reread the tutorials multiple times and tried to google extensively.
How to train for Multiple Users?
I am using this on a lap top to experiment with it. No magic mirror.
python3 capture.py
seemed to work ok
Then I tried
python3 train.py
This the results
Using FACE_ALGORITM: 1
Which algorithm do you want to use?
[1] LBPHF (recommended)
[2] Fisherfaces
[3] Eigenfaces
--> 1
Reading training images...
--------------------
Assign label 1 to Klint
--------------------
Read 18 positive images and 400 negative images.
18 images from subject Klint
--------------------
Training model type 1 with threshold 80
Traceback (most recent call last):
File "train.py", line 115, in <module>
model = config.model(config.RECOGNITION_ALGORITHM, config.POSITIVE_THRESHOLD)
File "/root/MMM-Facial-Recognition-Tools/lib/config.py", line 134, in model
model = cv2.face.createLBPHFaceRecognizer(threshold=thresh)
AttributeError: module 'cv2.cv2' has no attribute 'face'
Do I have to make some file that come with MagicMirror?
When I run capture.py
on my pi3 with the old pi camera, I get a cryptic error:
python capture.py
['Martin', 'Vivi']
Using FACE_ALGORITM: 1
What do you want to do?
[1] Capture training images from webcam
[2] Convert '*.jpg' pictures from other cameras to training images
--> 1
Enter the name of the person you want to capture or convert images for.
--> Martin
Images will be placed in ./training_data/Martin
--------------------
Starting process...
Capturing positive training images.
Press enter to capture an image.
Press Ctrl-C to quit.
Traceback (most recent call last):
File "capture.py", line 38, in <module>
capture.capture(preview)
File "/home/pi/git/MMM-Facial-Recognition-Tools/lib/capture.py", line 54, in capture
input()
File "<string>", line 0
^
SyntaxError: unexpected EOF while parsing
Any idea what that could be? (btw, awesome project)
After having installed the facetrainer and taking some photo's of me, I've tried the face recognition Test tool. When I run python facerecognition.py I get two camera screens. One in a window (with the recognition testing tool) and one screen which is shown in the center of my monitor. I can't get rid of this screen, it stays in front of all other windows. Even Alt-Tab doesn't work. Perhabs it is my fault, but I don't know where I went wrong so please help.
I thinkt that the screen for the facetrainer tool is also shown....
Hi, I seem to be having an issue when trying to implement the face recognition tester. When I run the tester on the file I am getting an error, I cannot seem to resolve it.
This is what displays in terminal:
Loading training data...
ALGORITHM: LBPH
Training data loaded!
Picam selected...
Traceback (most recent call last):
File "facerecognition.py", line 61, in <module>
label, confidence = model.predict(crop)
TypeError: 'int' object is not iterable
My picamera stays active but I can see that it has stopped on my face in the background, Do you have any idea how to resolve this issue, as I am at a loss here.
Hi,
when I try to start the training for my images I choose the "LBPHF (recommended)" option after that it reads my images but chrashes with:
Training model... Traceback (most recent call last): File "train.py", line 104, in <module> model = cv2.createLBPHFaceRecognizer() AttributeError: 'module' object has no attribute 'createLBPHFaceRecognizer'
Am I missing dependencies?
Hy,
when i run capture.py I've got the following error,
Does anyone have an idea?
geert@PI3:~/MagicMirror/modules/MMM-Facial-Recognition-Tools-master$ python capture.py
Remember to set the name list environment variable FACE_USERS
Using default FACE_ALGORITM: 1
What do you want to do?
[1] Capture training images from webcam
[2] Convert '*.jpg' pictures from other cameras to training images
--> 1
Enter the name of the person you want to capture or convert images for.
--> Geert
Images will be placed in ./training_data/Geert
Starting process...
Capturing positive training images.
Press enter to capture an image.
Press Ctrl-C to quit.
Traceback (most recent call last):
File "capture.py", line 38, in
capture.capture(preview)
File "/home/geert/MagicMirror/modules/MMM-Facial-Recognition-Tools-master/lib/capture.py", line 54, in capture
input()
File "", line 0
^
SyntaxError: unexpected EOF while parsing
In an attempt to fix a prior issue (not able to use my USB webcam), I installed the full version of OpenCV following instructions here: https://www.pyimagesearch.com/2017/09/04/raspbian-stretch-install-opencv-3-python-on-your-raspberry-pi/
Unfortunately, that seems to have caused another issue. When I run capture.py now, it's giving me an error about needing more than 3 values to unpack.
pi@raspberrypi:~/MagicMirror/modules/MMM-Facial-Recognition-Tools $ python capture.py
Traceback (most recent call last):
File "capture.py", line 18, in <module>
import lib.capture as capture
File "/home/pi/MagicMirror/modules/MMM-Facial-Recognition-Tools/lib/capture.py", line 21, in <module>
from . import config
File "/home/pi/MagicMirror/modules/MMM-Facial-Recognition-Tools/lib/config.py", line 15, in <module>
(CV_MAJOR_VER, CV_MINOR_VER, mv1, mv2) = cv2.__version__.split(".")
ValueError: need more than 3 values to unpack
When I enter python on its own and run the following commands, here is the output that I get:
pi@raspberrypi:~/MagicMirror/modules/MMM-Facial-Recognition-Tools $ python
Python 2.7.13 (default, Nov 24 2017, 17:33:09)
[GCC 6.3.0 20170516] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> (CV_MAJOR_VER, CV_MINOR_VER, mv1, mv2) = cv2.__version__.split(".")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'cv2' is not defined
>>> import inspect
>>> import os
>>> import platform
>>> import cv2
>>> (CV_MAJOR_VER, CV_MINOR_VER, mv1, mv2) = cv2.__version__.split(".")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ValueError: need more than 3 values to unpack
I know just enough to get myself into more trouble! :) Any advice that could help me fix this? Thanks!
On a Pi3, I run into the following problem:
I have two faces, Alice and Bob, with around 30 positive pics each.
I use algorithm 1 and export:
export FACE_USERS=Alice,Bob
Now if either Alice or Bob stand in front of the camera, it will always detect Alice (with low confidence if its actually Bob). If I export
export FACE_USERS=Bob,Alice
it always detects Bob. Any idea what might go wrong here?
I have installed open cv3
line 18 error is occurring again.
Not getting anything online for these errors. :(
Capturing positive training images.
Type c (and press enter) to capture an image.
Press Ctrl-C to quit.
Traceback (most recent call last):
File "capture.py", line 18, in
capture.capture()
File "C:\Users\Animesh\Downloads\MMM-Facial-Recognition-Tools-master\facetrainer\lib\capture.py", line 56, in capture
if is_letter_input('c'):
File "C:\Users\Animesh\Downloads\MMM-Facial-Recognition-Tools-master\facetrainer\lib\capture.py", line 24, in is_letter_input
if select.select([sys.stdin, ], [], [], 0.0)[0]:
select.error: (10038, 'An operation was attempted on something that is not a socket')
I got the following mistake after execute ther 4. step of the recognition-test-tool introduction
4. Enter the tools/facerecognition_tester directory from a terminal and run python facerecognition.py.
pi@raspberrypi:~/MagicMirror/modules/MMM-Facial-Recognition-Tools/facerecognition_tester $ python facerecognition.py
Loading training data...
ALGORITHM: LBPH
Training data loaded!
libv4l2: error setting pixformat: Device or resource busy
HIGHGUI ERROR: libv4l unable to ioctl S_FMT
libv4l2: error setting pixformat: Device or resource busy
libv4l1: error setting pixformat: Device or resource busy
HIGHGUI ERROR: libv4l unable to ioctl VIDIOCSPICT
OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cvtColor, file /build/opencv-ISmtkH/opencv-2.4.9.1+dfsg/modules/imgproc/src/color.cpp, line 3737
Traceback (most recent call last):
File "facerecognition.py", line 42, in <module>
image = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)
cv2.error: /build/opencv-ISmtkH/opencv-2.4.9.1+dfsg/modules/imgproc/src/color.cpp:3737: error: (-215) scn == 3 || scn == 4 in function cvtColor
Do somebody know why?
Followed the instructions, All pre-req's are installed: When I run capture.py I get these messages:
python capture.py
Traceback (most recent call last):
File "capture.py", line 18, in
import lib.capture as capture
File "/home/pi/MagicMirror/modules/MMM-Facial-Recognition-Tools/lib/capture.py", line 21, in
from . import config
File "/home/pi/MagicMirror/modules/MMM-Facial-Recognition-Tools/lib/config.py", line 15, in
(CV_MAJOR_VER, CV_MINOR_VER, mv1, mv2) = cv2.version.split(".")
ValueError: need more than 3 values to unpack
What am I missing?
Hello,
I am trying to run:
python capture.py
in pi@raspberrypi:~/MMM-Facial-Recognition-Tools and i get the following error:
Traceback (most recent call last):
File "capture.py", line 18, in <module>
import lib.capture as capture
File "/home/pi/MMM-Facial-Recognition-Tools/lib/capture.py", line 12, in <module>
from builtins import input
ImportError: No module named builtins
Is there a specific place where i need to git clone this tool? what am i doing wrong? I am currently trying to set this up with a magicmirror.
thanks.
I generated train data, set the FACE_ALGORITM and the FACE_USERS but got a crash when I test with facerecognition.py:
Remember to set the name list environment variable FACE_USERS
Using default FACE_ALGORITM: 1
Loading training data...
Training data loaded!
Strong:User1
No windowing system, writing face.jpg image
Traceback (most recent call last):
File "facerecognition.py", line 153, in
clean_shutdown()
TypeError: clean_shutdown() takes exactly 2 arguments (0 given)
Tried on RPi Model 3b+
Hope you can help me??
I am using a USB camera and when I try to run python facerecognition.py
I get this:
Loading training data...
mmal: mmal_vc_component_create: failed to create component 'vc.ril.camera' (1:ENOMEM)
mmal: mmal_component_create_core: could not create component 'vc.ril.camera' (1)
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/home/pi/MMM-Facial-Recognition-Tools/lib/picam.py", line 27, in run
with picamera.PiCamera() as camera:
File "/usr/lib/python2.7/dist-packages/picamera/camera.py", line 431, in __init__
self._init_camera(camera_num, stereo_mode, stereo_decimate)
File "/usr/lib/python2.7/dist-packages/picamera/camera.py", line 460, in _init_camera
"Camera is not enabled. Try running 'sudo raspi-config' "
PiCameraError: Camera is not enabled. Try running 'sudo raspi-config' and ensure that the camera has been enabled.
Training data loaded!
OpenCV Error: Assertion failed (scn == 3 || scn == 4) in cvtColor, file /build/opencv-ISmtkH/opencv-2.4.9.1+dfsg/modules/imgproc/src/color.cpp, line 3737
Traceback (most recent call last):
File "facerecognition.py", line 58, in <module>
image = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)
cv2.error: /build/opencv-ISmtkH/opencv-2.4.9.1+dfsg/modules/imgproc/src/color.cpp:3737: error: (-215) scn == 3 || scn == 4 in function cvtColor
any help?
Hi there. I recently re-installed Raspbian Stretch and Magic Mirror then reconfigured most of the modules I was using before. I'm having a problem with this one again though.
When I attempt to run python capture.py
, I get the following:
pi@raspberrypi:~/MagicMirror/modules/MMM-Facial-Recognition-Tools $ python capture.py
Traceback (most recent call last):
File "capture.py", line 18, in
import lib.capture as capture
File "/home/pi/MagicMirror/modules/MMM-Facial-Recognition-Tools/lib/capture.py", line 12, in
from builtins import input
ImportError: No module named builtins
As stated this is a fresh install of the mirror and I've installed the opencv dependencies. Anyone have an idea of what I'm doing wrong here? Thanks!
Hi! i have used these tools and working well individually but i want to include these tools and camera module together in my Magic Mirror project not able to make it work any possibility of making them work. please help me.thanks
traceback (most recent call last):
File "capture.py", line 18, in
capture.capture()
File "/home/pi/Downloads/MMM-Facial-Recognition-Tools-master/facetrainer/lib/capture.py", line 40, in capture
camera = config.get_camera()
File "/home/pi/Downloads/MMM-Facial-Recognition-Tools-master/facetrainer/lib/config.py", line 32, in get_camera
return webcam.OpenCVCapture(device_id=0)
File "/home/pi/Downloads/MMM-Facial-Recognition-Tools-master/facetrainer/lib/webcam.py", line 29, in init
self._camera.open()
TypeError: Required argument 'device' (pos 1) not found
Hi,
I get the following error as soon as a face is recognized in the tester module:
Traceback (most recent call last):
File "/home/pi/MMM-Facial-Recognition-Tools-master/facerecognition_tester/facerecognition.py", line 67, in
cv2.putText(frame, config.personen[label - 1], (x - 3, y - 8), cv2.FONT_HERSHEY_SIMPLEX, 1.5, (255, 255, 255), 1)
IndexError: list index out of range
All is working camera is working using fswebcam. Module is starting capture.py, but after pressing enter it says can not capture single face.. ? any help pleas
I tried also LBPHFaceRecognizer_create
instead of createLBPHFaceRecognizer
with no success.
I use ocv 3.3.0.10 because other versions dont seem to work on my macos 10.11.6
('Read', 6, 'positive images and', 400, 'negative images.') 6 images from subject xy
Training model type 1 with threshold 80 Traceback (most recent call last): File "train.py", line 115, in <module> model = config.model(config.RECOGNITION_ALGORITHM, config.POSITIVE_THRESHOLD) File "/Users/ruben/MMM-Facial-Recognition-Tools/lib/config.py", line 135, in model model = cv2.createLBPHFaceRecognizer(threshold=thresh) AttributeError: 'module' object has no attribute 'createLBPHFaceRecognizer'
AttributeError: 'module' object has no attribute 'createLBPHFaceRecognizer'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.