Skip to content

Instantly share code, notes, and snippets.

@yoelk
Created June 25, 2018 23:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yoelk/f9c6b0aada610391127fffa488afa7df to your computer and use it in GitHub Desktop.
Save yoelk/f9c6b0aada610391127fffa488afa7df to your computer and use it in GitHub Desktop.
Small sample code that uses OpenCV to show images from a camera. If an mp.Manager is created, the code stops working. Commenting the line fixes it but why???
import cv2
import multiprocessing as mp
cap = cv2.VideoCapture(0)
manager = mp.Manager() # Comment this line to make the code work
with mp.Lock():
cap.set(6, cv2.VideoWriter_fourcc(*list('MJPG')))
ESC = 27
while(True):
ret, frame = cap.read()
cv2.imshow('frame', frame)
if cv2.waitKey(1) & 0xFF == ESC:
break
cap.release()
cv2.destroyAllWindows()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment