OCR -- seamlessClone泊松融合

opencv:https://www.learnopencv.com/seamless-cloning-using-opencv-python-cpp/

OCR工程git:https://github.com/MachineLP/OCR_repo

看到这个题目是不是很突兀啊,OCR和泊松融合又有啥关系呢?

是这样的,因为在训练的时候需要生成训练字体,有时候需要融合不同的背景。

看一下效果:

python代码如下所示:

import cv2
import numpy as np

# Read images : src image will be cloned into dst
im = cv2.imread("bg.jpg")
obj= cv2.imread("lp.jpg")

# 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("opencv-normal-clone-example.jpg", normal_clone)
cv2.imwrite("opencv-mixed-clone-example.jpg", mixed_clone)

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

扫码关注云+社区

领取腾讯云代金券