我正在尝试使用Python 3从Windows上的网络摄像头捕获图像。 我已经检查过openCV,但缺少对python-3的支持。
还有其他方法吗?
答案 0 :(得分:4)
与此同时,OpenCV 3.1发布并与Python 3一起使用(自OpenCV 3.0起)。可以在此处找到预编译的Windows二进制文件:http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv
答案 1 :(得分:1)
你可以试试OpenCV,SimpleCV。
using SimpleCV:
from SimpleCV import Image, Camera
cam = Camera()
img = cam.getImage()
img.save("filename.jpg")
使用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
使用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")
安装OpenCV:
install python-opencv bindings, numpy
安装SimpleCV:
install python-opencv, pygame, numpy, scipy, simplecv
获取SimpleCV
的最新版本安装pygame:
install pygame