How to stream from an ip camera?

asked 2018-01-22 01:52:11 -0600

student_turkey gravatar image

Guys there are a lot of codes and explanation and non of them helped me. I can not get frames from ip cameras. I can stream them with vlc player but I can't stream on my python2+opencv3 code. here is url of video= http://178.124.174.130:8080/cam_3.jpg

and here is my try " import cv2 import numpy as np cap=cv2.VideoCapture() cap.open('http://178.124.174.130:8080/cam_3.jpg') while(True): ret,frame=cap.read() cv2.imshow("",frame) if cv2.waitKey(1) & 0xff==ord('q'): break cap.release() cv2.destroyAllWindows()

"

edit retag flag offensive close merge delete

Comments

2

that is not a stream, but a single image. lookup the manual of your cam, there must be another url to get a continuous live stream

berak gravatar imageberak ( 2018-01-22 02:39:34 -0600 )edit

I tring to sya that, I can not get that image. I can not connect that camera with this code. It just doesn't connect. Where am I wrong?

student_turkey gravatar imagestudent_turkey ( 2018-01-22 02:49:41 -0600 )edit

again, you need a video url, not an image one, to connect via VideoCapture.

berak gravatar imageberak ( 2018-01-22 04:00:38 -0600 )edit
1

simply said, I do not think that a camera with a stream allows you to select a single image like you do. You should have something like http://178.124.174.130:8080/cam.mpjg which is a motionJPEG stream. Like @berak said, dig into your manual.

StevenPuttemans gravatar imageStevenPuttemans ( 2018-01-22 04:02:27 -0600 )edit
2

VideoCapture cap("http://178.124.174.130:8080/cam_3.mjpeg"); will connect successfully, but only serve a single image from last year

problem is not with opencv, but with your ipcam / url

berak gravatar imageberak ( 2018-01-22 04:11:02 -0600 )edit
1

Thank you all guys for helping me. In further part of the project I may add some more comment on this share. Have a nice day...

student_turkey gravatar imagestudent_turkey ( 2018-01-22 14:44:59 -0600 )edit

Guys, I installed python-vlc. There were many problems I faced like 64bit vlc is needed, dll i needed etc. Finally I can stream from rtsp protocol. Now my problem is, how can I take frames from that video. I mean I did:
import vlc

import cv2

p = vlc.MediaPlayer("rtsp://192.168.1.152:8554/test")

p.play()

I can take video, but I can 't take snapshots, or frames at moments, how can I do that?

student_turkey gravatar imagestudent_turkey ( 2018-01-25 05:46:09 -0600 )edit

anyone knows about it?

student_turkey gravatar imagestudent_turkey ( 2018-01-27 00:48:17 -0600 )edit