nischi / MMM-Face-Reco-DNN

Face recognition with opencv and deep neural network
MIT License
91 stars 46 forks source link

Video streams stays open when restarting MM #7

Closed ivanovd closed 4 years ago

ivanovd commented 5 years ago

If you restart MagicMirror with

pm2 restart mm

pm2 starts another process, however, the video stream is not closed in the previous process and stays open, thus, the new process cannot start its own video stream and recognize faces in it because there is already another stream opened and not closed, therefore in the new instance of MagicMirror no face recognition is happening.

That is very evident with external USB cameras that have a usage LED. It stays lit even after you close MagicMirror. The issue is resolved when you restart the Raspberry.

nischi commented 5 years ago

Thanks a lot for this issue. I need to test that as well on my mirror. Could be that pm2 not send the close command correctly. And because it is in a thread i will try something different.

ivanovd commented 5 years ago

Hi @nischi , were you able to replicate that on your setup?

nischi commented 5 years ago

Yes, i will try to fix it.

Sent with GitHawk

ivanovd commented 5 years ago

I see that you made some changes and I pulled the update, however it still fails to close the stream. No rush, I just thought I can give some feedback :)

nischi commented 5 years ago

@ivanovd thanks. yes i'm investigating. do not find a solution yet, strange ist that sometimes they close the stream and sometimes not.

SdeGeata commented 4 years ago

Ah, i thought that was just my set-up doing that. I am relieved to know its not just me. A reboot fixes it every time though. I wonder if we couldn’t just add a kill command to the pm2 mm.sh?

hknozturk commented 4 years ago

Hey guys, changing from stream import VideoStream to from imutils.video import VideoStream and vs.stop() to if args["usePiCamera"] >= 1: vs.stop() else: vs(src=0).stop() helped me to solve the problem.

nischi commented 4 years ago

@hknozturk awesome, thanks for the hint. is it maybe possible for you to do a pull request?