Reputation: 131
I am developing a project in Android to Draw/Overlay/Paint flag or other image on Face. Or Draw/Overlay/Paint an Image with another image i.e. embed image into other. But the second image should be exact on the face. Take a close look below
I am using the Face Detection Vision Api of Google, and get the Landmarks and even whole face and draw a simple rectangle around using An Introduction to Face Detection on Android
But the Question is:
How to draw image on another image as shown above?
Am I on the right path i.e. Face Detection and then draw something?
Please give me some sample code that how to start with or give me some github libs if available. Thanks.
Upvotes: 0
Views: 232
Reputation: 5738
This could've been a comment, but i felt like sharing this idea as an answer.
Note that this is just an idea
I have used Google's Vision API but that was quite some time ago. As far as i remember, you can draw a rectangle over a face and get it's positions aka landmarks. You can make use of that.
Instead of writing a complicated paint
function where you have to draw a Bitmap
, rather construct a new ImageView
. Set it's height and width by calculating the position/landmark of the rectangle and also position the new ImageView
over the rectangle. Positioning the ImageView
might be relatively easier as you have the rectangles XY coordinates(i guess). Then simply set it's source as the flag image or anything you want. You can set the opacity(alpha
value) of the ImageView
to a lower value to make it blend it.
If you want to only paint the face and not create an overlay, that's a different topic. You will need to take a few pixels from the face, get their color values, then paint
the other image over that. It's not gonna be easy, but i guess this is the way to go.
Guidelines :
Upvotes: 1