BrandonJoffe / home_surveillance

Home surveillance system with facial recognition
1.22k stars 384 forks source link

IP Cameras not loading #11

Closed gauravkaila closed 7 years ago

gauravkaila commented 7 years ago

Hi Brandon,

First of all, really good work here!

I am trying to add my own IP camera to your dashboard but not being able to do so. I have your dashboard up and running as you see here,

screen shot 2016-11-11 at 09 40 32

The CPU load is 100% and the "Add Camera" button is running for over 30 mins. Do you have any suggestion by which I can add the camera? Am I doing something wrong here?

Best,

Gaurav

BrandonJoffe commented 7 years ago

Hi Gaurav,

no problem :)

You have to use an IP camera stream URL not the IP address of the camera - the structure of this URL changes from IP camera to IP camera but you should be able to find the correct URL by looking at the product documentation.

Examples of stream URLs for different cameras:

If the add camera button hangs for longer than 30 seconds you can be certain that the system can't find the IP camera stream on the network.

The PSUTIL library is used to measure the CPU load and memory usage. Generally speaking, it gets to 100% while training the classifier, when you use more than 3 cameras or something has gone wrong...

Let me know if you get it working ok.

Brandon

gauravkaila commented 7 years ago

Hi Brandon,

Thanks for the quick reply. I got it to work. :)

Best,

Gaurav.

vahid-dan commented 7 years ago

Hi @BrandonJoffe;

I have the same issue. The CPU usage is normal, but I cannot add my camera. The camera stream URL is http://10.137.14.155:8080/?action=stream which is accessible via browser, VLC, etc. Could you please help me?

Thanks, Vahid

gauravkaila commented 7 years ago

Hi Vahid,

You can try passing the rtsp stream and see if it works. For my stream ( http://10.106.156.83), I used rtsp;//10.106.156.83/StreamId=2.

On Mon, Jan 23, 2017 at 3:45 PM Vahid Daneshmand notifications@github.com wrote:

Hi;

I have the same issue. The CPU usage is normal, but I cannot add my camera. The camera stream URL is http://10.137.14.155:8080/?action=stream. Could you please help me?

Thanks, Vahid

— You are receiving this because you modified the open/close state.

Reply to this email directly, view it on GitHub https://github.com/BrandonJoffe/home_surveillance/issues/11#issuecomment-274523512, or mute the thread https://github.com/notifications/unsubscribe-auth/APU8mQ3diiFoJQgSIq_VTALdI775ORvEks5rVMshgaJpZM4KvlOk .

vahid-dan commented 7 years ago

Hi @gauravkaila;

Thanks for your quick response. I am streaming from my Raspberry Pi Camera Module v2 on rtsp://10.244.19.153:8554/ and can watch the stream on the network using VLC. But still cannot add the camera. Do you have any idea?

Thanks again for your time.

Cheers, Vahid

vahid-dan commented 7 years ago

When I click "Add Camera" button to add my camera from rtsp://10.244.19.153:8554, I see this error message in red between the log messages on the screen: [rtsp @ 0x7fd5840278a0] method DESCRIBE failed: 404 Client error

vahid-dan commented 7 years ago

If I add a "/' ath the end of the stream URL so it becomes "rtsp://10.244.19.153:8554/", I get a new error message: [rtsp @ 0x7fd58c0b5b00] method SETUP failed: 461 Client error

BrandonJoffe commented 7 years ago

Hi @vdaneshmand,

I never actually tested with the RPI camera, but its quite strange that you can access the video stream in your browser using the mjpeg stream and it doesn't work. Are you using mjpeg-streamer?

Also did you get any errors when you tried to load the mjpeg stream( http://10.137.14.155:8080/?action=stream), or did it just hang?

Brandon

vahid-dan commented 7 years ago

Hi @BrandonJoffe;

Thanks a lot for your reply. I am using MJPG-Streamer. While trying to add a camera, t just keeps showing "Adding Camera" on the button forever.

Thanks again for your attention.

Cheers, Vahid

vahid-dan commented 7 years ago

I found these lines in the log messages on the screen which might be useful to debug the problem:

('Loading Stream From IP Camera ', u'http://10.137.14.155:8080/?action=stream')
...
(Thread-1700) Exception on /add_camera [POST]
Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1817, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1477, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1381, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1475, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1461, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "WebApp.py", line 148, in add_camera
    HomeSurveillance.add_camera(SurveillanceSystem.Camera.IPCamera(camURL,application,detectionMethod))
  File "/host/vd/home_surveillance/system/Camera.py", line 85, in __init__
    self.video.open()
TypeError: Required argument 'device' (pos 1) not found
...
BrandonJoffe commented 7 years ago

Ok, this is a little interesting.

When you say it works in a web browser can you type in the camera stream URL, load the page and see the feed?

vahid-dan commented 7 years ago

Brandon,

Yes; Exactly.

vahid-dan commented 7 years ago

Brandon,

You may want to take a look at this page: http://formulapi.com/node/34

bcm2835-v4l2 module is needed to be enabled on the RPi to stream using RTSP protocol, but has to be disabled to stream using MJPG-Streamer. Otherwise, the stream doesn't start.

Thanks, Vahid

BrandonJoffe commented 7 years ago

Thanks @vdaneshmand,

I'm curious as to why its not working since both your RTSP and MPEG streams are working perfectly and the VideoCapture function has no problem capturing either of those codecs. It may, in fact, have something to do with the ports not open in the docker container, but this even seems like a long shot.

Maybe try:

docker run -v /Users/:/host -p 80:80 -p 8080:8080 -p 5000:5000 -t -i bjoffe/openface_flask_v2 /bin/bash

I wish I could be more help, the error you posted above generally happens when VideoCapture can't find the stream (either the url is incorrect or the camera has been disconnected which is not the issue in this case).

Let me know if you get it working, Brandon

gauravkaila commented 7 years ago

This might be completely wrong, but try this:

docker run -v /Users/:/host -p 80:80 -p 8080:8080 -p 5000:5000 --device /dev/video0:/dev/video0 -t -i bjoffe/openface_flask_v2 /bin/bash

or

docker run -v /Users/:/host -p 80:80 -p 8080:8080 -p 5000:5000 --privileged -v /dev/video0:/dev/video0 -t -i bjoffe/openface_flask_v2 /bin/bash

This passes your onboard RPi camera module to the docker container. Once you have that, run

ls /dev/video*

and let me us know the output?

On Mon, Jan 23, 2017 at 8:06 PM Brandon Joffe notifications@github.com wrote:

Thanks @vdaneshmand https://github.com/vdaneshmand,

I'm curious as to why its not working since both your RTSP and MPEG streams are working perfectly and the VideoCapture function has no problem capturing either of those codecs. It may, in fact, have something to do with the ports not open in the docker container, but this even seems like a long shot.

Maybe try:

docker run -v /Users/:/host -p 80:80 -p 8080:8080 -p 5000:5000 -t -i bjoffe/openface_flask_v2 /bin/bash

I wish I could be more help, the error you posted above generally happens when VideoCapture can't find the stream (either the url is incorrect or the camera has been disconnected which is not the issue in this case).

Let me know if you get it working, Brandon

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/BrandonJoffe/home_surveillance/issues/11#issuecomment-274601444, or mute the thread https://github.com/notifications/unsubscribe-auth/APU8mVCariLwOZsp9DBwtJ9AU5varea3ks5rVQg0gaJpZM4KvlOk .

vahid-dan commented 7 years ago

Hi Brandon;

That didn't work. The same error message. In the error messages on the screen, there is something which may be informative:

(alarmstate_process_thread_) e492a5987ae548af92124d13500b80ff: Client is gone, closing socket
Client disconnected

p.s: I'm running the home_surveillance application on my Ubuntu 16.10 laptop and the camera is streaming from a Raspberry Pi 3 in the same network.

Thanks, Vahid

vahid-dan commented 7 years ago

Hi Gaurav;

You mean I run this code on my laptop; Right? I did that and /dev/video0 was available. But on my RPi, there is no /dev/video0 device. If I add this device by running sudo modprobe bcm2835-v4l2, MJPG-Streamer won't work. But for RTSP streaming, it was enabled. Note that i2c-dev module is already enabled on my RPi. I have noticed that enabled modules and even the order of them may affect the RPi camera.

Thanks, Vahid

vahid-dan commented 7 years ago

I just tried again with a USB camera instead of RPi camera. The streaming is fine, but still no success to add the camera.

vahid-dan commented 7 years ago

I also tried it with my laptop webcam and a USB webcam connected to my laptop. None of them worked even though the streamings were fine. So probably the problem has nothing to do with RPi.

vahid-dan commented 7 years ago

Hi @BrandonJoffe;

I tried it with a USB camera on another Ubuntu laptop. Still has the same problem. I guess you haven't tested it on Linux, yet. I am thinking maybe the problem is with the docker. I wanna try it directly on Ubuntu without docker. Do you have instructions for that?

Thanks for your time. Vahid

vahid-dan commented 7 years ago

@BrandonJoffe and @gauravkaila

I finally made it work. The problem was with the docker. I installed the dependencies manually and run it directly on Ubuntu without docker and that worked.

Thanks a lot for your time and guidance. :-)

Cheers, Vahid

BrandonJoffe commented 7 years ago

Hi Vahid,

I was just responding to your last thread :)

Really glad you got it working and great job on the manual install its not always easy!

Cheers, Brandon

On Jan 25, 2017, at 5:55 PM, Vahid Daneshmand notifications@github.com wrote:

@BrandonJoffe https://github.com/BrandonJoffe and @gauravkaila https://github.com/gauravkaila I finally made it work. The problem was with the docker. I installed the dependencies manually and run it directly on Ubuntu without docker and that worked.

Thanks a lot for your time and guidance. :-)

Cheers, Vahid

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/BrandonJoffe/home_surveillance/issues/11#issuecomment-275146321, or mute the thread https://github.com/notifications/unsubscribe-auth/ATLLiYUx2CAIafnjILtsDitnUXfHzQ_zks5rV3BYgaJpZM4KvlOk.

vahid-dan commented 7 years ago

Thanks, Brandon! It's a really interesting application and you have done a great job. I will keep in touch in case I encountered any problem using the application. :-)

Cheers, Vahid

shineway commented 7 years ago

@vdaneshmand Hi Vahid,

Would you so kind to give me some advice on how to install the dependencies manually and run it directly on Ubuntu without docker?

Cheers, Shineway

vahid-dan commented 7 years ago

Hi @shineway;

In the installation document, just skip the steps related to the docker and do the rest:

1) Clone Repo git clone https://github.com/BrandonJoffe/home_surveillance.git

2) Navigate to the home_surveillance project inside the volume within your Docker container Move into the system directory cd system

3) Run WebApp.py python WebApp.py

You probably will get error messages about missing dependencies. Try to find the missing dependencies and install them and run the python WebApp.py again and again till you get no error. Then:

Visit localhost:5000 Login Username: admin Password admin

I need to do it again today. So I will add more details here about the installation process soon.

Cheers, Vahid

vahid-dan commented 7 years ago

Hi @gauravkaila;

Could you please confirm that it is actually working? I have tested it on 4 different machines, with Ubuntu and MacOS, with and without Docker, and still cannot train it with my own photos.

Thanks a lot; Vahid

shineway commented 7 years ago

Hi @vdaneshmand ,

Thanks a lot for your quick reply. I did as you adviced and finally can run WebApp.py successfully.

vahid-dan commented 7 years ago

@shineway,

You're welcome. Could you successfully add your camera and train the classifier to recognize you?

Vahid

gauravkaila commented 7 years ago

Hi Vahid,

I can confirm that it works on Mac OS with Docker. Have not tried it without docker.

Best,

Gaurav

On Feb 7, 2017 6:43 PM, "Vahid Daneshmand" notifications@github.com wrote:

Hi @gauravkaila https://github.com/gauravkaila;

Could you please confirm that it is actually working? I have tested it on 4 different machines, with Ubuntu and MacOS, with and without Docker, and still cannot train it with my own photos.

Thanks a lot; Vahid

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/BrandonJoffe/home_surveillance/issues/11#issuecomment-278100137, or mute the thread https://github.com/notifications/unsubscribe-auth/APU8mbsuHyfaT2ioMiw2UxMteeLBWDTlks5raLtfgaJpZM4KvlOk .

shineway commented 7 years ago

Hi @vdaneshmand ,

In docker? Until now NO. Still fighting...

matthew-syd commented 5 years ago

Hi Brendan, My IP camera could not load in the web even though it can load from other openface flask project

Here is my added code: self.cameras.append(Camera.IPCamera("http://admin:password@192.168.0.104:8080/stream/video/mjpeg","detect_recognise_track",False,0)) self.cameras.append(Camera.IPCamera("http://admin:password@192.168.0.102:8080/stream/video/mjpeg","detect_recognise_track",False,0))

This is the log file:

Exception in thread frame_process_thread_0: Traceback (most recent call last): File "/usr/lib/python3.6/threading.py", line 916, in _bootstrap_inner self.run() File "/usr/lib/python3.6/threading.py", line 864, in run self._target(*self._args, **self._kwargs) File "/home/lient/projects/home_surveillance-master/system/SurveillanceSystem.py", line 198, in process_frame if frame == None or np.array_equal(frame, camera.tempFrame): # Checks to see if the new frame is the same as the previous frame ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

====

Not sure the ValueError has anything to do with camera loading

Please advise. Lien Tran

Papaass commented 5 years ago

Hello @matthew-syd, How did you solved this problem. I got the same. Need Help

Thx

kshamap commented 3 years ago

Hello @matthew-syd @Papaass Were you able to solve this problem. Need Help THANKS

Papaass commented 3 years ago

Hello @kshamap Change this code : if frame == None or np.array_equal(frame, camera.tempFrame) by this if frame is None or np.all(frame == camera.tempFrame)

kshamap commented 3 years ago

Hello @kshamap Change this code : if frame == None or np.array_equal(frame, camera.tempFrame) by this if frame is None or np.all(frame == camera.tempFrame)

Thank you @Papaass it worked