python - OpenCV Python - 需要整数参数,得到浮点数
问题描述
我正在尝试像这样运行无缝克隆功能......
# 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
有什么想法可以找出它不喜欢的论点之一吗?
解决方案
当我以这种除以2的方式将中心保持为整数时,它起作用了:-
中心=(高度>>1,宽度>>1)
推荐阅读
- javascript - 如何通过角度检查空格键键事件?
- animation - three.js:使用骨骼动画获取更新的顶点?
- python - 如何从 HTTP 响应接收 zip 文件
- python - 将与不同值关联的重复条目转换为包含这些值列表的条目?
- c# - 如何使用 ASP.NET Core 下载 png 文件
- continuous-integration - 对于无法打开 GL 库 libGLESv2.so 的 Espresso 测试,CircleCI 启动模拟器步骤失败
- r - 选择从 ggmap 的 revgeocode 返回的地址格式
- javascript - 根据 Adonis.js 中数据库的结果更改 HTML 标记
- bash - 如何删除之间具有特定数字模式的行
- groovy - 我需要从我的网络文件资源管理器访问日志文件并写入输出