Gab Hum
Gab Hum

Reputation: 75

noise in webcam frames Python + Opencv

I'm using Opencv 2.4.5 with python 2.7 to track people in video surveillance. At the beginning I used .avi and .mpeg videos to test my code, now I want to use a hcv-m100c camera. I am using a simple difference between frames (an initial frame compared with each frame) to identify the objects in movement, It works very well with the .avi and .mpeg videos I have, but when I use the camera the results are so bad because a lot of noise and stains appear in my video. I thought that the problem was my camera, but I made an .avi video with the same camera and I tested that video with my code and it works fine. Now, I'm using the cv2.BackgroundSubtractorMOG but the problem is still there. So, I think I need to do a pre-processing when I use the camera

Upvotes: 0

Views: 2672

Answers (1)

dilbert
dilbert

Reputation: 3098

Just for completeness:

Solution concept:

Possibly you could stream the video camera with something like ffmpeg which can transcode as well and then use OpenCV to read the network stream. It might be easier to use VLC to stream instead.

Solution detail:

VLC Stream code (Shell):

vlc "http://192.168.180.60:82/videostream.cgi?user=admin&pwd=" --sout "#transcode{vcodec=mp2v,vb=800,scale=1,acodec=mpga,ab=128,channels=2,samplerate=??44100}:duplicate{dst=rtp{sdp=rtsp://:8554/output.mpeg},dst=display}" --sout-keep

OpenCV Code (Python):

cap=cv2.VideoCapture("rtsp://:8554/output.mpeg")

Upvotes: 1

Related Questions