4

I am trying to capture an image from my web camera on windows using Python 3. I checked already openCV, but the support of python-3 is missing.

Is there any other way to do so?

Bechir
  • 987
  • 10
  • 26
  • 1
    [opencv 3.0 supports Python 3](https://github.com/Itseez/opencv/tree/3.0.0-alpha) (final release should be available in the next year). You don't need opencv to get a picture from your webcam. – jfs Oct 27 '14 at 10:29
  • 1
    possible duplicate of [taking webcam photos in python 3 and windows](http://stackoverflow.com/questions/23175486/taking-webcam-photos-in-python-3-and-windows) – jfs Oct 27 '14 at 10:30
  • 1
    Following J.F. Sebastian's comment, I can offer an update that [as of 4 June 2015](http://opencv.org/opencv-3-0.html), a production version of OpenCV with Python 3.x bindings is at last available. – Michael Currie Jun 06 '15 at 19:51

2 Answers2

4

In the meantime, OpenCV 3.1 was released and works with Python 3 (since OpenCV 3.0). Pre-compiled Windows binaries can be found here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv

bastelflp
  • 9,362
  • 7
  • 32
  • 67
1

you can try OpenCV, SimpleCV.

using SimpleCV:

from SimpleCV import Image, Camera

cam = Camera()
img = cam.getImage()
img.save("filename.jpg")

using OpenCV:

from cv2 import *
# initialize the camera
cam = VideoCapture(0)   # 0 -> index of camera
s, img = cam.read()
if s:    # frame captured without any errors
    namedWindow("cam-test",CV_WINDOW_AUTOSIZE)
    imshow("cam-test",img)
    waitKey(0)
    destroyWindow("cam-test")
    imwrite("filename.jpg",img) #save image

using pygame:

import pygame
import pygame.camera

pygame.camera.init()
pygame.camera.list_camera() #Camera detected or not
cam = pygame.camera.Camera("/dev/video0",(640,480))
cam.start()
img = cam.get_image()
pygame.image.save(img,"filename.jpg")

Install OpenCV:

install python-opencv bindings, numpy

Install SimpleCV:

install python-opencv, pygame, numpy, scipy, simplecv

get latest version of SimpleCV

Install pygame:

install pygame
G.Nader
  • 847
  • 7
  • 9
  • 3
    I am using windows. I tried `SimpleCV`, but could not install it `pip3 install -U SimpleCV` says that it was successfully installed, but when importing it I got `SyntaxError: Missing parentheses in call to 'print'` – Bechir Oct 27 '14 at 15:08