我正在尝试从这样的方式运行Seamless Clone函数...
# Read images : src image will be cloned into dst
im = cv2.imread('background.jpg')
obj= cv2.imread('object.png')
# Create an all white mask
mask = 255 * np.ones(obj.shape, obj.dtype)
# The location of the center of the src in the dst
width, height, channels = im.shape
center = (height/2, width/2)
# Seamlessly clone src into dst and put the results in output
normal_clone = cv2.seamlessClone(obj, im, mask, center, cv2.NORMAL_CLONE)
mixed_clone = cv2.seamlessClone(obj, im, mask, center, cv2.MIXED_CLONE)
# Write results
cv2.imwrite("output_images/opencv-normal-clone-example.jpg", normal_clone)
cv2.imwrite("output_images/opencv-mixed-clone-example.jpg", mixed_clone)
但这给了我错误...
integer argument expected, got float
有什么想法可以找出不喜欢的参数之一吗?
答案 0 :(得分:0)
当我以这种除以 2 的方式将中心保持为整数时,它起作用了:-
中心=(高度>>1,宽度>>1)