在opencv 3.2中替换cv2.cv.fromarray是什么? [英] What is the replacement of cv2.cv.fromarray in opencv 3.2?
问题描述
我正在编写一个面部识别程序,而我从网上获得的参考文献使用的是以前的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屋!