BrandonJoffe / home_surveillance

Home surveillance system with facial recognition
1.23k stars 385 forks source link

Adding the integraed webcam as an IP camera #21

Closed AliGouta closed 7 years ago

AliGouta commented 7 years ago

Hello,

I successfully run the docker container and I have access the Home Dashboard. I am wondering if it is possible to use the webcam as an IP camera ?

I created a stream and diffused it over HTTP through VLC on my local host (the same machine running the docker container). This is my configuration: -IP adress: 192.168.0.13 -Port: 8081 -Path: stream.wmv -Transcoding option: WMV+WMA. => My integrated webcam is switched on and the stream is diffused

Then, when I put 192.168.0.13:8081/stream.wmv in the URL camera URL and then click on Add Camera, then nothing happens. Any idea ?

vahid-dan commented 7 years ago

Hi;

The short answer is yes. You can use your webcam as an IP camera. I've already done that using MJPG-Streamer. But I don't have an exact solution for your problem.

Cheers, Vahid

mathieuduperre commented 7 years ago

I'm trying something similar but the docker container runs elsewhere from my laptop. while using VLC, i'm not using HTTP but RTSP. I "think" the issue i have at the moment is related to the network but i'll keep you posted. I'm able to watch my stream using another laptop (with vlc as a client) on the same network. I was able to add an ip camera I have here (cheap one I bought from ebay).

mathieuduperre commented 7 years ago

The "secret" seems to be in the transcoding profile used in vlc for streaming btw. make sure you can watch your stream using antoher VLC (even if on the same laptop) before trying to configure your server.

AliGouta commented 7 years ago

Thank you for your answers! I installed MJPG-Streamer, and used my integrated webcam (dmesg shows it is compatible UVC). Eventhough, the webcam switches on, I still do not see the stream in the screen when connecting to http://localhost:8085. I think the problem comes from my webcam. I bought a new one and will test it tomorrow. Then, I will debug the code. I see that VideoCapture from cv2, should read the frames. I will keep you updated.

mathieuduperre commented 7 years ago

if you can't watch the stream using another instance of VLC, it is very very unlikely the homesurveillance will be able to pick it up either. good luck and keep us posted!

vahid-dan commented 7 years ago

Hi @AliGouta;

Make sure the stream URL is correct. Using MJPG-Streamer, mine was http://localhost:8080/?action=stream. Don't forget the http:// part. You should also be able to watch the stream in your web browser.

Vahid

AliGouta commented 7 years ago

Hi @vdaneshmand , Indeed putting http://localhost:8085/?action=stream in my navigator throws this:

The image "http://localhost:8085/?action=stream" can not be displayed because it contains errors.

Well, I think either my webcam or the MJPG-streamer fails to generate MJPG frames. For this reason, I bought a new camera and would test it tomorrow ;).

I will keep you posted.

vahid-dan commented 7 years ago

Hi all;

I have tried it on several machines with and without docker. Without docker, I can add cameras most of the time; But once in a while, it throws an error and I couldn't re-train the database. With docker on Ubuntu 14.04, I have never been able to add camera; But re-training the database works fine. Can anyone please tell me which application to use for streaming? I've found the MJPG-Streamer the easiest one for both laptops and RPi; But even that won't work always with home_surveillance.

Thanks, Vahid

AliGouta commented 7 years ago

Hi Vahid,

Yesterday I just got the streaming working and start seeing things working such as face capturing. Regarding your question, I am not in yet, but I will start digging it/debugging the code to understand how it works. I will keep you posted anyway. I propose to close this issue since it is more about adding a camera. I will open a new one for what concerns the training, which will be definitively my next step in this project :). Is it ok ?

vahid-dan commented 7 years ago

Hi @AliGouta;

That's your call; But I still have no clue why adding camera sometimes works and sometimes not.

Vahid

AliGouta commented 7 years ago

@vdaneshmand I actually run the code directly through the code in Pycharm. This will help me debugging the code later. Actually, I don't use the docker anymore, since my target is to make a refactoring on the code. Yesterday I succeded addind a camera follonwing these steps:

-I installed openCv 2.4.11 as you told me. -I started a video stream by executing this command:

cvlc --no-audio v4l2:///dev/video0 --v4l2-width 640 --v4l2-height 480 --v4l2-chroma MJPG --v4l2-hflip 1 --v4l2-vflip 1 --sout '#standard{access=http{mime=multipart/x-mixed-replace;boundary=--7b3cc56e5f51db803f790dad720ed50a},mux=mpjpeg,dst=:8554/stream.mjpg}' -I dummy

-This switched on the integrated webcam (I am still waiting for my new camera I purchased some days ago :) ). Then after starting the flask server (localhost:5000), I added the following link in add Camera:

http://localhost:8554/stream.mjpg

This allowed Surveillance to successfully read the frames :)

vahid-dan commented 7 years ago

Hi @AliGouta;

Thanks for your guidance. This is the first time I could successfully setup the whole application on docker without any error. Now everything works fine except it is too slow.

Thanks, Vahid

mathieuduperre commented 7 years ago

when you add your camera, make sure to use one of the last 2 modules or else it will be awfully slow.

I have this running in a docker (running in a vm) in AWS. I found why teaching wasn't working btw. I'll post on the other ticket.

vahid-dan commented 7 years ago

Hi @methodmath;

I am using the last one, "Face Recognition & Tracking" on my laptop and also on an Intel Joule 570x board and both are still too slow even with 320x240 resolution.

Vahid