我有这条线使用OpenCV:
xsize = random.uniform(params['reshape_x_limits'][0],params['reshape_x_limits'][1])
ysize = random.uniform(params['reshape_x_limits'][0],params['reshape_x_limits'][1])
cv2.resize(fg,0,fg,xsize,ysize)
这给出了错误
SystemError: new style getargs format but argument is not a tuple
但是根据文档:https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#resize
所有参数都不应该是元组。导致此错误的原因是什么?我使用的是Python 2.7和OpenCV 3.3.0.10。
从您发布的文档中,您可以看到示例:
resize(src, dst, Size(), 0.5, 0.5, interpolation);
参数Size()
是一个元组(width, length)
另一个例子你可以find in this tutorial about geometric transformations,例如:
res = cv2.resize(img,(2*width, 2*height), interpolation = cv2.INTER_CUBIC)
根据documentation,dsize是必需参数,因此必须提供。奇怪的是,d = 0给了我与你相同的错误。指定dsize = None解决了我的问题。以下是片段:
a=cv2.imread('lighthouse2.bmp',0)
b=cv2.resize(a,None,fx=0.5,fy=0.5,interpolation=cv2.INTER_AREA)
cv2.imshow('',b)
cv2.waitKey(0)
我正在使用Python 3.6和OpenCv 4.0.0