Image Capture from Macbook Webcam on OS X 10.8?

asked 2013-11-27 11:57:35 -0500

cdsboy gravatar image

I'm having issues taking a picture without opening up a window on os x. If I open a window up, I can take a picture no problem, but no matter what I try without opening a window I can not get it to work.

I've tried:

import cv2
vc = cv2.VideoCapture(0)
if vc.isOpened():
  err, frame = vc.read()
  cv2.imwrite("test.png", frame)

And I've tried:

import cv2
import time

vc = cv2.VideoCapture(0)
if vc.isOpened():
  err, frame = vc.read()
  while True:
    if frame is not None:
      cv2.imwrite("test.png", frame)
      break
    err, frame = vc.read()
    time.sleep(.1)'

But those don't seem to work.

edit retag flag offensive close merge delete

Comments

Your code works for me on 10.8.5.

AlexanderShishkov gravatar imageAlexanderShishkov ( 2013-11-28 02:06:27 -0500 )edit