Jose Ramon
Jose Ramon

Reputation: 5444

Add transparency when drawing a rectangle in opencv

I am trying to paint rectangles in locations which face detection algorithm locate faces. I want to use alpha transparency in order to draw my rectangles. I have found in opencv documentation the following in here: Note The functions do not support alpha-transparency when the target image is 4-channel. In this case, the color[3] is simply copied to the repainted pixels. Thus, if you want to paint semi-transparent shapes, you can paint them in a separate buffer and then blend it with the main image.

How is it possible to blend main image with buffer image? And what exactly means with buffer image?

Upvotes: 3

Views: 6736

Answers (1)

bikz05
bikz05

Reputation: 1605

You can use the OpenCV addWeighted function to blend your image. Refer to the documentation of the function. You can provide the function with the amount of transparency you want to have.

Here is an tutorial to do so.

Upvotes: 6

Related Questions