Sending webcam stream remotely for use in Python OpenCV

asked 2014-02-08 20:11:08 -0500

J4G gravatar image

updated 2014-02-08 21:03:11 -0500

Hey, I'm trying to send a webcam stream to a remote computer for image processing. I would do the processing directly on the webcam computer, but it's ARM and pretty slow. Right now I have mjpg-streamer set up, which allows me to remotely access image files and a network stream. Originally I intended just to get a stream of individual images with an HTTP Request, but I'd like to use background subtraction which if I understand correctly requires a video stream.

Here's what I currently have, but it's pretty crude.

while(1):
    urllib.urlretrieve("http://192.168.2.20:8080/?action=snapshot", "test.jpg")

    im = Image.open('test.jpg')
    im.save('test.jpg')

    frame = cv2.imread('test.jpg')

    fgmask = fgbg.apply(frame)
    fgmask = cv2.morphologyEx(fgmask, cv2.MORPH_OPEN, kernel)

    cv2.imshow('frame',fgmask)
    k = cv2.waitKey(30) & 0xff
    if k == 27:
        break

I have to convert the image to another jpeg or else OpenCV thinks the jpeg data is corrupted.

I'm an OpenCV / Python novice, so any help would be appreciated!

edit retag flag offensive close merge delete