我使用的是python 2.7和opencv。
我试图使用:
Object.defineProperty(vm.allFiles[key], 'size', {
value: value.fileSize
});
取自here。但是当我运行此代码时,我得到cv2.resize(src, dst, Size(), 0.5, 0.5, interpolation=cv2.INTER_LINEAR);
你能帮我吗?
答案 0 :(得分:5)
您可能正在查看resize
方法的C ++ API。
python API看起来像这样:
dst = cv2.resize(src, dsize)
其中
src - Original image
dsize - a tuple defining the final size of the image.
如果要传递其他参数,则可以使用API的命名参数:
dst = cv2.resize(src, dsize, fx = 0.5, fy=0.5, interpolation = cv2.INTER_LINEAR)
由于dsize是必需参数,但如果您仍希望resize
方法为您计算dsize
,则可以将参数作为None
传递。
dst = cv2.resize(src, None, fx = 0.5, fy=0.5)
答案 1 :(得分:0)
之前的答案还可以,但我想重用存储 - 调整image
的大小以适应现有存储resized
(两个三维uint8
numpy数组),我需要使用
ret = cv2.resize(image, dsize=resized.shape[:2][::-1], dst=resized)
请注意,dsize参数是向后的 - 它不是(行,列),而是(宽度,高度),因此是[::-1]
。
我只返回ret
确认确实(ret == resized).all()
。
答案 2 :(得分:0)
# lets doubled the size of our image/ increasing the size...
img_double_scaled = cv2.resize(img, None, fx = 1.5, fy = 1.5, interpolation = cv2.INTER_CUBIC)