Error CreatImage()-opencv



我收到这个错误

imageResized=cv.CreateImage((64,64),8, 1) NameError: name 'cv' is not defined

这是我的代码:

import numpy
import cv2

cap = cv2.VideoCapture(0)
while(True): 
retval, frame = cap.read() 
cv2.imshow("frame",frame) cv2.waitKey(10) 
a = (200,80)#(x,y) 
b = (450,400)#(x,y) 
cv2.rectangle(frame,a, b, (0,255,0),3) 
crop_frame=frame[80:400,200:450] #y,x
cv2.imwrite("face.jpg", frame)
frame=cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)   
imageResized=cv.CreateImage((64,64),8, 1)
cv.Resize(cv.fromarray(frame), imageResized)
vector = numpy.asarray(frame)
print vector

我已更改为cv2.CreateImage,并得到此:"AttributeError: 'module' object has no attribute 'CreateImage'"

你们能帮我吗?感谢

您可以执行以下任一操作:

>>> import cv
>>> cv.CreateImage
<built-in function CreateImage>

>>> import cv2
>>> cv2.cv.CreateImage
<built-in function CreateImage>

相关内容

  • 没有找到相关文章

最新更新