OpenCv的CreateImage功能不起作用 [英] OpenCv CreateImage Function isn't working

查看:234
本文介绍了OpenCv的CreateImage功能不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to create an image using opencv v 2.1, but I get this error:

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

AttributeError:模块"对象没有属性"CreateImage"

AttributeError: 'module' object has no attribute '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()

推荐答案

您正在写名称空间.仅使用import cv,而不使用其他

You are writing over the name space. Only use the import cv, not the other ones.

>>> 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 )>

这篇关于OpenCv的CreateImage功能不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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