MrLunk

Rpi MJPG-streamer to ubuntu python opencv import

Oct 30th, 2018
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. I have OpenCV 3.1 installed with ffmpeg and gstreamer enabled, all compiled from source with appropriate libs.
  2. Plenty of pages out there to show you how to piece that together ;)
  3.  
  4. I used this to set up my usb c270 logitech webcam omn the Raspberry pi to stream mjpeg to my ubuntu 16.04 box.
  5. (Works!)
  6. https://iotalot.com/2016/05/28/video-streaming-using-raspberry-pi-3-and-usb-webcam/
  7.  
  8. On the Ubuntu side I catch (receive) the stream in OpenCV with the following Python code:
  9.  
  10. Python 2 Opencv 3.1 Ubuntu 16.04 mjpeg_streamer cam receiver:
  11. --------------------------------------
  12.  
  13. import numpy as np
  14. import cv2
  15.  
  16. cap = cv2.VideoCapture('http://192.168.2.62:9090/?action=stream')
  17.  
  18. while(cap.isOpened()):
  19. ret, frame = cap.read()
  20.  
  21. #gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
  22.  
  23. cv2.imshow('frame',frame)
  24. if cv2.waitKey(1) & 0xFF == ord('q'):
  25. break
  26.  
  27. cap.release()
  28. cv2.destroyAllWindows()
  29.  
  30. ------------------------------------------
  31.  
  32. #https://www.facebook.com/mrlunk
Add Comment
Please, Sign In to add comment