在opencv 3.2中替换cv2.cv.fromarray是什么? [英] What is the replacement of cv2.cv.fromarray in opencv 3.2?

查看:2483
本文介绍了在opencv 3.2中替换cv2.cv.fromarray是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个面部识别程序,而我从网上获得的参考文献使用的是以前的OpenCV版本.我正在使用从源代码构建的OpenCV 3.2.0.在参考中,将名称放在视频中面部下方.我的参考代码看起来像

cv2.putText(cv2.cv.fromarray(img), str(id), (x, y + h), font, 2, 255);

我得到一个错误:

AttributeError: 'module' object has no attribute 'cv'

请帮助.

解决方案

对于OpenCV图像的Python API是numpy数组,因此不需要fromarray()(如果在cv模块中完全可用). /p>

有关示例,请参见此处.您可以将img传递给cv2.putText().

I am writing a face recognition program and the reference that I got from web was using previous OpenCV version. I am using OpenCV 3.2.0 build from source. In the reference to put the name just below the face in a video. My reference code looks like

cv2.putText(cv2.cv.fromarray(img), str(id), (x, y + h), font, 2, 255);

I get an error:

AttributeError: 'module' object has no attribute 'cv'

Please help.

解决方案

For the Python API for OpenCV images are numpy arrays so fromarray() is not required (if available at all in the cv module).

See here for an example. You can just pass img to cv2.putText().

这篇关于在opencv 3.2中替换cv2.cv.fromarray是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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