OCR -- seamlessClone泊松融合

版权声明:本文为博主原创文章,未经博主允许不得转载。有问题可以加微信:lp9628(注明CSDN)。 https://blog.csdn.net/u014365862/article/details/83241704

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

看到这个题目是不是很突兀啊,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)

猜你喜欢

转载自blog.csdn.net/u014365862/article/details/83241704
OCR
今日推荐