简体   繁体   English

OpenCV Python - 预期整数参数,得到浮点数

[英]OpenCV Python - integer argument expected, got float

I am trying to run a Seamless Clone function from like this...我正在尝试从这样运行无缝克隆功能......

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

But it is giving me the error...但它给了我错误...

integer argument expected, got float

Any ideas how I can find out which one of the arguments it does not like?我有什么想法可以找出它不喜欢哪一个论点?

when I kept the center as integers this way of dividing by 2, it worked:-当我以这种除以 2 的方式将中心保持为整数时,它起作用了:-

center = (height>>1, width>>1)中心=(高度>>1,宽度>>1)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM