Closed valemichelleee closed 9 months ago
Hi @valemichelleee
Nice that you using my module. How looks your configuration? Do you set the option "source"?
Hi thank you for responding. I didn't set up the source. I'm using Raspi Camera V2
config: {
// Logout 15 seconds after user was not detected anymore
// If they are detected within this period, the delay will start again
logoutDelay: 15000,
// How often the recognition starts in milliseconds
// With a Raspberry Pi 3+ it works well every 2 seconds
checkInterval: 1000,
// Module set used for when there is no face detected ie no one is in front of the camera
noFaceClass: 'noface',
// Module set used for when there is an unknown/unrecognised face detected
unknownClass: 'unknown',
// Module set used for when there is a known/recognised face detected
knownClass: 'known',
// Module set used for strangers and if no user is detected
defaultClass: 'default',
// Set of modules which should be shown for any user ie when there is any face detected
everyoneClass: 'everyone',
// Set of modules that are always shown - show if there is a face or no face detected
alwaysClass: 'always',
// XML to recognize with haarcascade
cascade: 'modules/MMM-Face-Reco-DNN/tools/haarcascade_frontalface_default.xml',
// Pre-encoded pickle with the faces
encodings: 'modules/MMM-Face-Reco-DNN/tools/encodings.pickle',
// Use Raspberry Pi camera or another type
// 1 = RasPi camera, 0 = other camera
usePiCamera: 1,
// Brightness, negative is darker, positive is brighter
brightness: 0,
// Contrast, positive value for more contrast
contrast: 0,
// If using another type of camera, you can choose
// i.e. 0 = /dev/video0 or 'http://link.to/live'
source: 0,
// Rotate camera
rotateCamera: 0,
// Method of facial recognition
// dnn = deep neural network, haar = haarcascade
method: 'dnn',
// Which face detection model to use
// "hog" is less accurate but faster on CPUs
// "cnn" is a more accurate deep-learning model which is GPU/CUDA accelerated
detectionMethod: 'hog',
// How long in milliseconds modules take to hide and show animationSpeed: 0,
// Path to Python to run the face recognition
// null or '' means default path
pythonPath: '/usr/bin/python3',
// Should a welcome message be shown using the MagicMirror alerts module?
welcomeMessage: true,
// Dictionary for person name mapping in welcome message
// Allows for displaying name with complex character sets in welcome message e.g. jerome => Jérôme, hideyuki => 英之
usernameDisplayMapping: null,
// Capture new pictures of recognized people, if unknown we save it in folder "unknown"
// So you can extend your dataset and retrain it afterwards for better recognitions
extendDataset: false,
// If extendDataset is true, you need to set the full path of the dataset
dataset: 'modules/MMM-Face-Reco-DNN/dataset/',
// How much distance between faces to consider it a match. Lower is more strict.
tolerance: 0.6,
// allow multiple concurrent user logins, 0=no, any other number is the maximum number of concurrent logins
multiUser: 0,
// resolution of the image
resolution: [1280, 960],
// width of the image for processing
processWidth: 500,
`
Can you try to comment out source or remove it? Because 0 is anyway default value and it seems in some version of python it has issues with the conversion. Need to check that. But can you try to adjust your settings?
I tried but nothing changed. Could you explain further which settings do I need to adjust?
simply remove the line source: 0,
in your config
Yes I removed it, but faces still unrecognized. I also tested the camera to take picture, and it's working.
But do you get the same error as above or another?
yes for facerecognition.py
and every example_modules
can you send me your complete config (please remove passwords or mail addresses before)
/* MagicMirror² Config Sample
*
* By Michael Teeuw https://michaelteeuw.nl
* MIT Licensed.
*
* For more information on how you can configure this file
* see https://docs.magicmirror.builders/configuration/introduction.html
* and https://docs.magicmirror.builders/modules/configuration.html
* and https://docs.magicmirror.builders/modules/configuration.html
*
* You can use environment variables using a `config.js.template` file instead of `config.js`
* which will be converted to `config.js` while starting. For more information
* see https://docs.magicmirror.builders/configuration/introduction.html#enviromnent-variables
*/
let config = {
address: "localhost", // Address to listen on, can be:
// - "localhost", "127.0.0.1", "::1" to listen on loopback interface
// - another specific IPv4/6 to listen on a specific interface
// - "0.0.0.0", "::" to listen on any interface
// Default, when address config is left out or empty, is "localhost"
port: 8080,
basePath: "/", // The URL path where MagicMirror² is hosted. If you are using a Reverse proxy
// you must set the sub path here. basePath must end with a /
ipWhitelist: ["127.0.0.1", "::ffff:127.0.0.1", "::1"], // Set [] to allow all IP addresses
// or add a specific IPv4 of 192.168.1.5 :
// ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.1.5"],
// or IPv4 range of 192.168.3.0 --> 192.168.3.15 use CIDR format :
// ["127.0.0.1", "::ffff:127.0.0.1", "::1", "::ffff:192.168.3.0/28"],
useHttps: false, // Support HTTPS or not, default "false" will use HTTP
httpsPrivateKey: "", // HTTPS private key path, only require when useHttps is true
httpsCertificate: "", // HTTPS Certificate path, only require when useHttps is true
language: "en",
locale: "en-US",
logLevel: ["INFO", "LOG", "WARN", "ERROR"], // Add "DEBUG" for even more logging
timeFormat: 12,
units: "metric",
modules: [
{
module: "alert",
},
{
module: "updatenotification",
position: "top_bar"
},
{
module: "clock",
classes: "always",
position: "top_center",
config: {
timeFormat: "12",
showPeriod: "true",
showWeek: "true"
}
},
{
module: "calendar",
classes: "robert_downey",
header: "holiday",
position: "top_left",
config: {
maximumEntries: "7",
calendars: [
{
symbol: "calendar-check",
url:
},
{
symbol: "calendar",
url:
}
]
}
},
{
module: "weather",
position: "top_right",
classes: "albert_einstein",
config: {
weatherProvider: "openweathermap",
type: "current",
location: "",
locationID: "", //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and find your city
apiKey: ""
}
},
{
module: "weather",
position: "top_right",
classes: "albert_einstein",
header: "Weather Forecast",
config: {
weatherProvider: "openweathermap",
type: "forecast",
location: "",
locationID: "", //ID from http://bulk.openweathermap.org/sample/city.list.json.gz; unzip the gz file and find your city
apiKey: ""
}
},
{
module: "newsfeed",
classes: "always",
position: "bottom_bar",
config: {
feeds: [
{
title: "New York Times",
url: "https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml"
}
],
showSourceTitle: true,
showPublishDate: true,
broadcastNewsFeeds: true,
broadcastNewsUpdates: true
}
},
{
module: 'MMM-Worldclock',
classes: "always",
position: 'top_center',
config: {
// See 'Configuration options' for more information.
timeFormat: 'hh:mm A', //Global time format, as defined in moment.js format()
style: 'top', // Which way do you want the flag and description from the clock? choices are 'top', 'left','right','bottom'
offsetTimezone: null, // Timezone you want to show the difference from. null, "", or omitted from config will be UTC.
clocks: [
{
title: "Home",
flag: "de",
},
{
title: "New York",
timezone: "America/New_York",
flag: "us",
},
{
title: "Tokyo",
timezone: "Asia/Tokyo",
flag: "jp",
},
{
title: "Sydney",
timezone: "Australia/Sydney",
flag: "au",
},
]
},
},
{
module: "mvgmunich",
classes: "always",
position: "bottom_left",
header: "MVG",
config: {
haltestelle: "",
maxEntries: 5,
updateInterval: 15000,
showIcons: true,
transportTypesToShow: {
"ubahn": true,
"sbahn": true,
"bus": true,
"regional_bus": true,
"tram": true
},
ignoreStations: [],
lineFiltering: {
"active": false,
},
timeToWalk: 0,
showWalkingTime: false,
showTrainDepartureTime: true,
trainDepartureTimeFormat: "relative",
walkingTimeFormat: "relative",
showInterruptions: true,
showInterruptionsDetails: false,
countInterruptionsAsItemShown: false,
}
},
{
module: 'MMM-Face-Reco-DNN',
classes: 'always',
config: {
// Logout 15 seconds after user was not detected any more
// If they are detected within this period, the delay will start again
logoutDelay: 15000,
// How often the recognition starts in milliseconds
// With a Raspberry Pi 3+ it works well every 2 seconds
checkInterval: 1000,
// Module set used for when there is no face detected ie no one is in front of the camera
noFaceClass: 'noface',
// Module set used for when there is an unknown/unrecognised face detected
unknownClass: 'unknown',
// Module set used for when there is a known/recognised face detected
knownClass: 'known',
// Module set used for strangers and if no user is detected
defaultClass: 'default',
// Set of modules which should be shown for any user ie when there is any face detected
everyoneClass: 'everyone',
// Set of modules that are always shown - show if there is a face or no face detected
alwaysClass: 'always',
// XML to recognize with haarcascade
cascade: 'modules/MMM-Face-Reco-DNN/tools/haarcascade_frontalface_default.xml',
// Pre-encoded pickle with the faces
encodings: 'modules/MMM-Face-Reco-DNN/tools/encodings.pickle',
// Use Raspberry Pi camera or another type
// 1 = RasPi camera, 0 = other camera
usePiCamera: 1,
// Brightness, negative is darker, positive is brighter
brightness: 0,
// Contrast, positive value for more contrast
contrast: 0,
// Rotate camera
rotateCamera: 0,
// Method of facial recognition
// dnn = deep neural network, haar = haarcascade
method: 'dnn',
// Which face detection model to use
// "hog" is less accurate but faster on CPUs
// "cnn" is a more accurate deep-learning model which is GPU/CUDA accelerated
detectionMethod: 'hog',
// How long in milliseconds modules take to hide and show
animationSpeed: 0,
// Path to Python to run the face recognition
// null or '' means default path
pythonPath: '/usr/bin/python3',
// Should a welcome message be shown using the MagicMirror alerts module?
welcomeMessage: true,
// Dictionary for person name mapping in welcome message
// Allows for displaying name with complex character sets in welcome message e.g. jerome => Jérôme, hideyuki => 英之
usernameDisplayMapping: null,
// Capture new pictures of recognized people, if unknown we save it in folder "unknown"
// So you can extend your dataset and retrain it afterwards for better recognitions
extendDataset: false,
// If extendDataset is true, you need to set the full path of the dataset
dataset: 'modules/MMM-Face-Reco-DNN/dataset/',
// How much distance between faces to consider it a match. Lower is more strict.
tolerance: 0.6,
// allow multiple concurrent user logins, 0=no, any other number is the maximum number of concurrent logins
multiUser: 0,
// resolution of the image
resolution: [1280, 960],
// width of the image for processing
processWidth: 500,
}
},
{
module: 'example_module',
position: 'bottom_right',
// Set your classes here seperated by a space
// Always shown
classes: 'always'
},
{
module: 'example_module_2',
position: 'bottom_right',
// Only shown for Thierry and James
classes: 'albert_einstein'
},
{
module: 'example_module_3',
position: 'bottom_right',
// Only shown for James
classes: 'robert_downey'
},
{
module: 'example_module_4',
position: 'bottom_right',
// Only shown for known (recognised users)
classes: 'known'
}
]
};
/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") {module.exports = config;}
okay thank you. sorry for the hassle, but i thought to remove source would help because in another issue the other guy did not response anymore.
so can you try something more? add source again, but instead of source: 0,
try source: '0',
sorry for late replies, I was sick last few days. I have tried it, but also no changes.... It still won't detect anything. Is there any indicator if the camera detects a unrecognised face? Because I tested my camera is working, but no text appears from your module even if it's not recognised the face.
hope you feeling better now?
actualy you can run the python script directly tools/facerecognition.py with the same arguments as in the config file and this should show you on the tv a small window with the face, and if the face has a rectangle around it has found the face.
I feel lot better thanks for asking!
yes I have tried it, and like I said on the beginning, I (still) get error when I run it with python3
{"status": "loading encodings + face detector..."}
{"status": "starting video stream..."}
Traceback (most recent call last):
File "/home/techlab/MagicMirror/modules/MMM-Face-Reco-DNN/tools/facerecognition.py", line 88, in <module>
if args["source"].isdigit():
AttributeError: 'int' object has no attribute 'isdigit'`
hmmm... which version of phyton do you have?
Python 3.9.2 I'm using Raspberry PI 4 Model B with OS 64 Bit
I use the same version, strange. if i do remove the source it works, and if i call it direcly in the console and use -s=0 it works
HI thank you for your response. I might have some updates. I've tried to add the -s option and I get the following error
{"status": "loading encodings + face detector..."}
{"status": "starting video stream..."}
{"status": [1920, 1080]}
{"status": 500}
Traceback (most recent call last):
File "/home/techlab/MagicMirror/modules/MMM-Face-Reco-DNN/tools/facerecognition.py", line 100, in <module>
vs = VideoStream(usePiCamera=True, rotation=args["rotateCamera"], resolution=resolution).start()
File "/home/techlab/.local/lib/python3.9/site-packages/imutils/video/videostream.py", line 13, in __init__
from .pivideostream import PiVideoStream
File "/home/techlab/.local/lib/python3.9/site-packages/imutils/video/pivideostream.py", line 2, in <module>
from picamera.array import PiRGBArray
File "/home/techlab/.local/lib/python3.9/site-packages/picamera/__init__.py", line 72, in <module>
from picamera.exc import (
File "/home/techlab/.local/lib/python3.9/site-packages/picamera/exc.py", line 41, in <module>
import picamera.mmal as mmal
File "/home/techlab/.local/lib/python3.9/site-packages/picamera/mmal.py", line 49, in <module>
_lib = ct.CDLL('libmmal.so')
File "/usr/lib/python3.9/ctypes/__init__.py", line 374, in __init__
self._handle = _dlopen(self._name, mode)
OSError: libmmal.so: cannot open shared object file: No such file or directory
then I found out that picamera doesn't support 64 bit and I always use libcamera to try my camera. I will try it with 32 bit
Hello, I have a good news. It works on Raspberry Pi OS 32 bit both with and without source
on config.js
. Perhaps it would be beneficial to consider adding it to your documentation, that it doesn't work for 64 bit. Nevertheless, thank you for your support and assistance. I am very glad that it works out in the end :)
Okay thanks, in this case i need a solution for 64 and 32bit
@nischi it was part of this initial request https://github.com/nischi/MMM-Face-Reco-DNN/issues/114
hi guys, i havethe raspOS 32 bit and it still doesnt work. i am using rpi camera module v3 and have the same error
AttributeError: 'int' object has no attribute 'isdigit'
I need to check this and try to reproduce it.
Should be fixed with new version 2.0
Hi, I have very similar problem with issue #18 I'm running MM on raspberry pi 4. All dependencies are installed (OCV, dlib, pip, numpy etc), but no modules appeared when i show my face. I tried to run
tools/facerecognition.py
and got error{"status": "loading encodings + face detector..."} {"status": "starting video stream..."} Traceback (most recent call last): File "/home/techlab/MagicMirror/modules/MMM-Face-Reco-DNN/tools/facerecognition.py", line 88, in <module> if args["source"].isdigit(): AttributeError: 'int' object has no attribute 'isdigit'
When I runnpm start dev
, got error for everyexample_modules
loader.js:175 Error on loading script: modules/example_module/example_module.js