使用Python OpenCV将图像捕获为数组 [英] Capture Image as Array with Python OpenCV

查看:216
本文介绍了使用Python OpenCV将图像捕获为数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经从示例中看到了如何显示网络摄像头中的图像,但是如何将图像捕获为数组?

I've seen from the sample how to display an image from the webcam, but how do I get the image captured as an array?

import cv

capture = cv.CaptureFromCAM(0)
img = cv.QueryFrame(capture)

img.tostring()给了我怪异的角色. 谢谢.

img.tostring() gives me weird caracters. Thanks in adv.

推荐答案

我认为这是您要寻找的:

I think this is what you're looking for:

img=cv.LoadImage("asd.png")
mat=cv.GetMat(img)
mat[3,1]
(83.0, 88.0, 89.0)

无论如何,您应该检查opencv python 食谱用于PIL和NUMPY软件包.

anyway, you should check opencv python cookbook for use with PIL and NUMPY packages.

这篇关于使用Python OpenCV将图像捕获为数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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