Feature Request - I...
 
Notifications
Clear all

[Solved] Feature Request - IP Camera/Network Camera Stream  

Page 1 / 2
  RSS

not_5
(@not_5)
Active Member
Joined: 1 year ago
Posts: 17
December 10, 2019 11:40 pm  

Hey Kyle,

 

Wondering if it would be possible to add a network stream/IP camera to the cameras page?

I'm thinking of using mycodo as the frontend/backend of a home thermostat and I thought it would be nice to be able to switch to a camera stream (maybe door camera) through the flask web page. In terms of extensibility, IP camera streams would none-the-less be a great addition to the whole package (versus a local camera capture). 

 

Thanks!


Quote
Topic Tags
Kyle Gabriel
(@kylegabriel)
Member Admin
Joined: 5 years ago
Posts: 193
December 12, 2019 4:33 pm  

I like the idea, but I have no experience with this. Are you familiar with any methods or libraries to do this? Do you have an IP camera to test with?

Mycodo Developer


ReplyQuote
not_5
(@not_5)
Active Member
Joined: 1 year ago
Posts: 17
December 15, 2019 10:01 am  

I do have a few IP cameras to test with; however, I don't have any experience on implementing this in a browser.

The protocol that IP cams use to stream their input is called RTSP, but after some googling, it looks like that stream needs to be re-encoded into another video format in order to display it in a browser. The simplest application that comes up is using ffmpeg, but I don't think a pi has adequate processing power to perform the conversion locally without severely limiting resources available for other processes.

 

How does the current Pi Camera implementation work in mycodo? Is it refreshing frame captures or something?


ReplyQuote
Kyle Gabriel
(@kylegabriel)
Member Admin
Joined: 5 years ago
Posts: 193
January 8, 2020 4:29 pm  

The current implementation of the camera streaming code basically pulls images from the cam and serves them to the browser (see https://github.com/kizniche/Mycodo/tree/ab369c4e03ff81a83896a421b9cd64dfebc8261a/mycodo/mycodo_flask/camera) using picamera for the Raspberry Pi cameras and opencv for USB cameras. Since I don't have an IP Camera to experiment with, I can't really develop any code reliably myself. If you can find any resources demonstrating how to pull images/streams from IP cameras and serve them to a web browser, or through a Python library ( https://pypi.org/) I could potentially write some code that you could test. If you tell me your IP Cam makes/models, I might be able to do some research as well.

Mycodo Developer


ReplyQuote
not_5
(@not_5)
Active Member
Joined: 1 year ago
Posts: 17
January 8, 2020 6:40 pm  

Kyle, I can get you the IP Cam model info, but IP cameras that comply with ONVIF standard have a still image (JPEG, MJPEG, etc) that can be accessed via an HTTP link. This website http://www.crazypixels.com/support has a list of the format for some common ones... but basically it's usually a local ip address based HTTP link, and usually with credentials in the form of the USER:PASS@ prefix, similar to FTP.

I think if you just add the ability to do an HTTP GET request for a JPG, that would work.

Here's a flask implementation of using the still image stream: https://blog.miguelgrinberg.com/post/video-streaming-with-flask

This post was modified 5 months ago 2 times by not_5

ReplyQuote
Kyle Gabriel
(@kylegabriel)
Member Admin
Joined: 5 years ago
Posts: 193
April 30, 2020 8:23 pm  

As a proof of concept, I added a new camera, HTTP Address, which pulls an image from an HTTP/HTTPS address and treats it as an image capture for still or time-lapse use in Mycodo. I've disabled streaming with this module, as that functionality doesn't exist, but I think this is a good base to expand into streaming using a URL, which can be a local webcam or any other remote image (such as the current weather radar image in the screenshots, below).

Mycodo Developer


adkodak liked
ReplyQuote
Kyle Gabriel
(@kylegabriel)
Member Admin
Joined: 5 years ago
Posts: 193
April 30, 2020 8:24 pm  

Works with current dashboard widget.

Mycodo Developer


adkodak liked
ReplyQuote
Kyle Gabriel
(@kylegabriel)
Member Admin
Joined: 5 years ago
Posts: 193
April 30, 2020 9:40 pm  

I just added streaming support to the HTTP Address camera library, if you would like to upgrade to master and test it. I don't currently have a functional IP camera to test with.

Mycodo Developer


ReplyQuote
not_5
(@not_5)
Active Member
Joined: 1 year ago
Posts: 17
April 30, 2020 9:41 pm  

Awesome! Let me test this out with my ip can setup and I'll report back with some findings.

 

Really appreciate the implementation!


ReplyQuote
adkodak
(@adkodak)
Active Member
Joined: 1 month ago
Posts: 11
May 2, 2020 9:06 am  

I will give a test with a few ONVIF I have. Have a couple models sitting around in the garage spare.


ReplyQuote
not_5
(@not_5)
Active Member
Joined: 1 year ago
Posts: 17
May 2, 2020 7:52 pm  

Bit strange of an issue I have. One of the camera models I have produces an xml page that displays the JPG. The link looks like http://user:pass@ip/stream/channel1/image and therefore doesn't have an extension on the link. I think this is tripping up opencv


ReplyQuote
Kyle Gabriel
(@kylegabriel)
Member Admin
Joined: 5 years ago
Posts: 193
May 2, 2020 8:55 pm  

Can you access it via RTSP, with an address such as rtsp://username:password@192.168.1.64/1?

Mycodo Developer


ReplyQuote
not_5
(@not_5)
Active Member
Joined: 1 year ago
Posts: 17
May 3, 2020 9:24 am  

@kylegabriel Yes. RTSP streaming works beautifully with the cameras through the new feature.

Still trying to work through the still imaging. 


ReplyQuote
Kyle Gabriel
(@kylegabriel)
Member Admin
Joined: 5 years ago
Posts: 193
May 3, 2020 10:14 am  

Opencv is only used for the stream URL. urllib.request.urlretrieve is used for still URL. If you have the ability to make your IP cam publically accessible so I can test, I should be able to get it working.

https://github.com/kizniche/Mycodo/blob/7ba8a50cffa9d684551066ecb745dd8927f8257d/mycodo/devices/camera.py#L248

Mycodo Developer


ReplyQuote
not_5
(@not_5)
Active Member
Joined: 1 year ago
Posts: 17
May 3, 2020 10:56 am  

@kylegabriel Sure. I'll send you a PM with the details.


ReplyQuote
Page 1 / 2