I have a circle like this:
circle
and I want to insert an image to inside of this circle. I have checked most of the contents regarding this subject in the internet but I couldn’t find anything.
Do you know how to do this? thank you.
I have a circle like this:
circle
and I want to insert an image to inside of this circle. I have checked most of the contents regarding this subject in the internet but I couldn’t find anything.
Do you know how to do this? thank you.
Hi
you can use cv.copyTo with a mask
@laurent.berger , “Is there any sample code that would guide me about how to apply such feature in opencv python”?
Because I couldn’t find a solid example that will help me to understand and apply this feature with a sample example, thank you.
You can find issue here
and example
import numpy as np
import cv2 as cv
lena = cv.imread('g:/lib/opencv/samples/data/lena.jpg')
mask = np.zeros(shape=(lena.shape[0], lena.shape[1]),dtype=np.uint8)
mask = cv.circle(mask,(250,250),40,255,-1)
dst = cv.copyTo(lena,mask)
cv.imshow("copyTo",dst)
cv.waitKey()
so we are not directly insert an external image (like overlay) to the background, but getting that position only.
@laurent.berger friend, what if I want to add an external (2nd image) inside of the circle (something similar to addweight function but with a better way, or what ever way is better and possible) while keeping the background image still, how would we achieve such feature? thank you very much.
as already directed, please look at the documentation for cv::Mat::copyTo
. you will see that you can use it to copy parts of one image into another as well.