Ask Your Question
0

Is it possible to overlay a transparent image over a live camera view, such that it is overlayed over the captured photo as well?

asked 2016-07-23 04:59:00 -0600

Solace gravatar image

updated 2016-07-23 10:27:27 -0600

The transparent image I want to overlay is just the boundary of a polygon in black color, the rest of the image is transparent. Like this:

image description

Using OpenCV4Android, I want to overlay it over live camera preview, such that it is overlayed on the image captured as well (i.e. the polygon is blended over the image captured, I mean the polygon should become a part of the image captured.)

How can I achieve that?

ADDENDUM:

I would simply add the polygon to the live camera preview by overlaying the JavaCameraView (which is the widget which displays live camera preview/frames) with an ImageView (Android's image container widget) containing the transparent image to overlay; by placing them both sequentially in a FrameLayout, which automatically Z-orders widgets added to it. Then I would separately add the image to overlay into to captured photo.

But the challenge here is:

The polygon in the live camera preview/frames is a guide. Just like the following image has a guide for positioning the face before taking the picture.

image description

Then when the photo is captured, I want the polygon to be overlayed at EXACTLY the position on which it was when the photo was captured.

So how do I achieve this?

edit retag flag offensive close merge delete

Comments

2

it's probably far easier to draw a polygon, using lines, than mixing 2 images with transparency

berak gravatar imageberak ( 2016-07-23 05:58:02 -0600 )edit

@berak I want the polygon to be at the exact same place in the captured image as it was in the live camera preview. For example, say the overlayed image was the boundary of a closed shape like a human's face (like in this image.), and in the live camera preview it is used to to guide a user where to place their face in the camera frame. Now in the image captured, I would want to merge that boundary lines into the captured image, and I would want them to be exactly where they were in the camera preview; I would not want the captured image having the face on one position, and the overlayed face-boundary displaced to somewhere else.

Solace gravatar imageSolace ( 2016-07-23 06:28:29 -0600 )edit

@berak So if I wanted to draw it separately on the captured image, I wouldn't know the exact and precise locations of points and may be sizeas well.

Solace gravatar imageSolace ( 2016-07-23 06:33:19 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-07-23 05:58:28 -0600

This can be done with cv::addweighted.

edit flag offensive delete link more

Comments

If I use addweighted method to overlay the image in the live camera preview, will the overlayed image also be added automatically to the photo I capture?

Solace gravatar imageSolace ( 2016-07-23 10:03:13 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-07-23 04:59:00 -0600

Seen: 3,299 times

Last updated: Jul 23 '16