尝试使用OpenCV保存网络摄像头图片时出错 [英] Error while trying to save webcam picture with OpenCV

查看:97
本文介绍了尝试使用OpenCV保存网络摄像头图片时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

import cv

capture = cv.CaptureFromCAM(0)
img = cv.QueryFrame(capture)
cv.SaveImage("test.JPG", img)

我只想在Ubuntu 10上使用OpenCv和Python从网络摄像头中保存图片. OpenCv可以连接网络摄像头.

Hi, I just want to save a picture from my webcam with OpenCv and Python on my Ubuntu 10. OpenCv can connect with the webcam.

但是我得到这个错误:

OpenCV Error: Null pointer (NULL array pointer is passed) in cvGetMat, file /build/buildd/opencv-2.1.0/src/cxcore/cxarray.cpp, line 2376

Traceback (most recent call last):
  File "video.py", line 5, in <module>
    cv.SaveImage("test.JPG", img)
cv.error: NULL array pointer is passed

推荐答案

为自己节省去急诊室的旅行,并使用 SimpleCV .这是OpenCV的Python绑定和其他一些工具的Pythonic包装器(它使用Numpy,Scipy和PIL):

Save yourself a trip to the emergency room and use SimpleCV. It's a Pythonic wrapper for OpenCV's Python bindings and a few more tools (it uses Numpy, Scipy and PIL):

from SimpleCV import *

camera = Camera()
image = camera.getImage()

image.save('test.JPG')

这篇关于尝试使用OpenCV保存网络摄像头图片时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆