opencv:https://www.learnopencv.com/seamless-cloning-using-opencv-python-cpp/
OCR工程git:https://github.com/MachineLP/OCR_repo
看到这个题目是不是很突兀啊,OCR和泊松融合又有啥关系呢?
是这样的,因为在训练的时候需要生成训练字体,有时候需要融合不同的背景。
看一下效果:
python代码如下所示:
代码语言:javascript复制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)