Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ipcam and stream on web page #1

Open
devileye1 opened this issue Mar 31, 2019 · 12 comments
Open

Add ipcam and stream on web page #1

devileye1 opened this issue Mar 31, 2019 · 12 comments

Comments

@devileye1
Copy link

devileye1 commented Mar 31, 2019

Hi,
Great work I really like that I m just enthusiastic about ML , can you give me advice how I can add ipcam (multiple if possible) and stream on web page.
Thnx

@tamerthamoqa
Copy link
Owner

tamerthamoqa commented Apr 1, 2019

Hi devileye1,

I am planning to look into how to do that as this project is a prototype for a graduation project that will use IP cameras as a home surveillance system. Hopefully will get back to you relatively soon on this issue.

Best regards.

@devileye1
Copy link
Author

Thanks for quick reply I m trying with https://github.com/BrandonJoffe/home_surveillance it’s good but if we use facenet( triplets loss) instead of dilb n openface that’s will be super cool...

@tamerthamoqa
Copy link
Owner

I think openface uses facenet models trained using triplet loss judging by their code here https://github.com/cmusatyalab/openface/blob/master/training/train.lua and their performances on the Labeled Faces in the Wild dataset is pretty good https://cmusatyalab.github.io/openface/models-and-accuracies/ so if it is possible to use openface in your project I think I would go for it.

@devileye1
Copy link
Author

Ya, I agree but I have only one picture of per person and in my class we have to enter gates above I mentioned Brandon joffe works but in this project we need 20-25 pictures of one person and I like GUI interface of this project give a try use docker and see...

@tamerthamoqa
Copy link
Owner

I see. I will try out Brandon Joffe's project soon and see how the IP cameras' integration works and hopefully get back to you on this soon.

@tamerthamoqa
Copy link
Owner

Apologies for taking some time, I got an IP camera for testing purposes but it proved to be problematic so will get another, as for getting a stream from an IP camera using opencv apparently you just need to change the parameter inside the capture = cv2.VideoCapture() object instantiation call to include the IP address of the IP camera in the local network with relevant user and password information like explained here: https://stackoverflow.com/questions/49978705/access-ip-camera-in-python-opencv and the Brandon Joffe project does the same here: https://github.com/BrandonJoffe/home_surveillance/blob/master/system/Camera.py#L86

I guess if you have multiple cameras then you will have to deal with multiple capture objects (capture1, capture2, etc), or you can do Camera objects like that project as well.

As for having the web GUI itself stream the livefeed from the cameras I guess you could do it like this: https://github.com/BrandonJoffe/home_surveillance/blob/master/system/WebApp.py#L115 where you get the frame from the camera and return it as an HTTP response to be rendered on the web page.

Hopefully this helped, good luck.

@devileye1
Copy link
Author

devileye1 commented Apr 6, 2019

Hi
Thanks for this(. self.video = cv2.VideoCapture(camURL) ), I did some search on Brandon works I find he used js and some other script, I m not good at other programming languages (I m new) so I try to create a button in HTML for add ip camera using RTSP method and I succeed works well with your program now I m trying whenever we click on live cam not open ip cam or web cam as a pop windo stream in HTML page here is example
https://github.com/mrxmamun/live-stream-face-detection I m trying this method to add with your work if you give me some advice about that it’s really helpful

@tamerthamoqa
Copy link
Owner

tamerthamoqa commented Apr 9, 2019

1- Since the code returns image HTTP responses, you need to have a < img > tag with its src attribute set to the URL of the function generating the responses in order to have the < img > tag be the output of the images. What I did is that I created a new HTML file in the templates folder called 'livefeed.html' and copy pasted this HTML code into it https://github.com/mrxmamun/live-stream-face-detection/blob/master/templates/index.html

2- Delete the face_detect_live() code in server.py and replace it with the code here https://gist.github.com/tamerthamoqa/384e01d8d081a7d20d4a609bff649085
I edited the previous code of face_detect_live() to return .jpg image bytes like in the repository you linked and added an HTTP response generator function gen_frame() and edited the face_detect_live URL to generate the new HTML page in step 1.

As far as I know, by using the jinja engine in flask (the {{ }} stuff in the HTML files), you can set a for loop inside the HTML page so you can render as many < img > tags as there are registered cameras, so you can set each < img > tag to receive frames from a certain camera by changing the src attribute of each tag to the URL of a function generating images from that camera, but to be honest with you I still don't have an idea on how to implement that yet. Also keep in mind the framerate is horrible :P

@devileye1
Copy link
Author

Hi
Thnx for help but that code not working it’s showing in web big empty frame that’s it don’t worry about I m looking around for livedeed in web can you please tell me how I can broadcast frame by frame not just when human face detected...... and also I m trying with sql lite show I can make(known and unknown person ) reports if you have any suggestions about reports please tell me thnx again

@devileye1
Copy link
Author

Name error ‘response ‘ is not defined

@devileye1
Copy link
Author

I just import response from flask and all fine and you say frame rate is not good I think we need tf-GPU or other TPU which one you suggest??

@tamerthamoqa
Copy link
Owner

tamerthamoqa commented Apr 18, 2019

In the gist code I linked it should still broadcast frames even when no faces are detected, unless I made an error.

Installing tensorflow-gpu==1.5 using pip (if you have tensorflow version 1.5 installed) should automatically load the models to the Nvidia GPU you have at your disposal when you start the server, but even with that it would have slow performance but far better than only using the CPU of course.

I am not sure about reports yet because you would need to implement a timer (sleep function in python for like 15 seconds after the first face detection and identification) so you would avoid filling up the sqlite table quickly, as for the table I would suggest a timestamp column (not sure what the datatype for it in sqlite is though) as a primary key and a column for the identity of the detected person, not sure if you need more columns but I need to fiddle around with it to see for certain.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants