Python 3: image capture

I am trying to capture an image from my webcam in Windows using Python 3. I have already checked openCV, but python-3 support is missing.

Is there any other way to do this?

+4
source share
2 answers

Meanwhile, OpenCV 3.1 has been released and works with Python 3 (with OpenCV 3.0). Precompiled Windows binaries can be found here: http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv

+2
source

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 the latest version of SimpleCV

Install pygame:

install pygame
+1

All Articles