EbenKouao / MMM-Face-Recognition-SMAI

MagicMirror Face Recognition module recognising your profile for Raspberry Pi 4
https://smartbuilds.io/
MIT License
83 stars 49 forks source link

Autostart .py file #4

Closed thetobyde closed 1 month ago

thetobyde commented 4 years ago

Hey again, short question: what does the Face-Rec-SMAI.py file start? Is it a cronjob?

Greetings Toby :)

opdoffer commented 4 years ago

There are probably many ways to do it. But I solved It by using pm2 (also used for MM to autostart). And use a sh script started by pm2 containing the following line:

DISPLAY=:0 python3 ~/MagicMirror/modules/MMM-Face-Recognition-SMAI/MMM-Face-Recognition-SMAI.py

thetobyde commented 4 years ago

OK, make sense. Is this the .sh script? Unbenannt2

If I look at it with "sudo nano run-face-rec.sh" I only can find this: Unbenannt3

My thing is: I want to stop the Face-Rec for 20 secounds to be able to use a Selfie-Module. The cam is not able to do the 2 modules at the same time. Can you please help me bro?

Toby :)

thetobyde commented 4 years ago

@opdoffer as u can see in my post above there is an run-face-rec.sh file, but nothing is in there. The face-reg.py starts with my MM (PID 631) but now by the run-face.sh file (think so :o )

thetobyde commented 4 years ago

@EbenKouao who executes the command "python3 ~/MagicMirror/modules/MMM-Face-Recognition-SMAI/MMM-Face-Recognition-SMAI.py" ? thx

opdoffer commented 4 years ago

I solved it like this, dunno its this is the correct way but it works for me.

  1. Create a file and give it a name whatever you like: sudo nano ~/face-rec-autostart.sh
  2. Add the following line python3 ~/MagicMirror/modules/MMM-Face-Recognition-SMAI/MMM-Face-Recognition-SMAI.py
  3. Hit CTRL-X the n Yes and enter to save the file
  4. Change the flights to execute permissions: chmod +x ~/face-rec-autostart.sh
  5. Add this script to pm2 with the following command: pm2 start ~/face-rec-autostart.sh
  6. Save the pm2: pm2 save

reboot and try

In case you want to use the camera you can stop the face-rec-autostart script with the following command: pm2 stop face-rec-autostart

thetobyde commented 4 years ago

@opdoffer Thank you man! that would be great for me! But in my image the module was pre-installed and there is somewhere an ecisting thing that starts the .py file... and I dont know how I can stop it (only with "kill [PID] ) If I create a file like you, the .py script would be executed twice, doasnt it?

opdoffer commented 4 years ago

Ah so. I installed all of it manually. You used the image. Sorry my bad.

Yes if you create a file like I did then it will be executed twice and the second one will fail. Hopefully Ebenkouao will answer your question soon.

I will try the pre-installed version soon and if I found how it is configured I will let you know.

thetobyde commented 4 years ago

@opdoffer ok thank you, If you will find something with the pre-installed image let me know please <3

thetobyde commented 4 years ago

@EbenKouao I just want to deactivate the autostart of face-recognition-SMAI.py ... can u help me?

EbenKouao commented 4 years ago

Hi @thetobyde @opdoffer, Thanks for trying it out.

In order to deactivate the autostart of face-recognition-SMAI.py (in LXTerminal at boot) Go to the Pi directory, Right-click, show hidden files, and open up .bashrc

sudo nano /home/pi/.bashrc

Remove the line at the bottom. This is what autostarts at boot: sudo python3 /home/pi/dlib/build/face_recognition/examples/MMM-Face-Recognition-SMAI.py

That should avoid the camera module python script conflicts. Let me know how it goes. BTW, you can customize the python script face recognition, to include multiple profiles. As of now, it's limited to one.

Eben.

opdoffer commented 4 years ago

Thnx for the info Eben. And btw great work you’ve done! It is much fun.

Leaves me one question: when is the one user limitation resolved?

EbenKouao commented 4 years ago

Hi @opdoffer, the 'one user limitation' has been resolved. You will observe that your face can be differentiated from others. You can now develop multiple profiles as you wish. Let me know how it goes and if you develop the module further, feel free to commit to the git!

Eben.