OpenCv的CreateImage功能不起作用

发布于 2021-01-29 18:01:28

我正在尝试使用opencv v 2.1创建图像,但出现此错误:

image=cv.CreateImage((w,h),no_of_bits,channels)

AttributeError:“模块”对象没有属性“ CreateImage”

该代码是

#!/usr/bin/python

import cv 
from opencv import *
from opencv.cv import *
from opencv.highgui import *
import sys

import PIL

w=500
h=500
no_of_bits=8
channels=3
image=cv.CreateImage((w,h),no_of_bits,channels)

cv.ShowImage('WindowName',image) 
cvWaitKey()
关注者
0
被浏览
164
1 个回答
  • 面试哥
    面试哥 2021-01-29
    为面试而生,有面试问题,就找面试哥。

    您正在覆盖名称空间。仅使用import cv,而不使用其他。

    >>> import cv 
    >>> w=500
    >>> no_of_bits=8
    >>> channels=3
    >>> h=500
    >>> image=cv.CreateImage((w,h),no_of_bits,channels) 
    >>> print image
    <iplimage(nChannels=3 width=500 height=500 widthStep=1500 )>
    


知识点
面圈网VIP题库

面圈网VIP题库全新上线,海量真题题库资源。 90大类考试,超10万份考试真题开放下载啦

去下载看看