Ask Your Question
0

How to show image above your face Detect?

asked 2014-05-20 06:51:24 -0600

Nabeel Ahmed gravatar image

Hello All,

I want to show a Cap image above my face detect surface which I just detect. I searched almost all the google but couldn't find any code. Please share code which gamble me to this problem.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-05-20 07:17:24 -0600

What you want to do is first of all resize your cap image to the size of the detected face surface. Besides that it is just copying regions of interest.

// These variables should be somewhere in your code
Mat detection_image;
Rect detection_found;
Mat cap = imread('location_of_file', 1);
// Now perform the copying
Mat resized_cap;
resize(cap, resized_cap, Size(detection_found.width, detection_found.height));
Mat destination_roi = detection_image( detection_found );
resized_cap.copyTo(destination_roi);
// Visualize
imshow("result", detection_image);
waitKey(0);
edit flag offensive delete link more

Comments

Rect[] facesArray = faces.toArray();

         for (int i = 0; i < facesArray.length; i++){
            Rect r = facesArray[i];
             Core.rectangle(mGray, r.tl(), r.br(), new Scalar(0, 255, 0, 255), 3);
             Core.rectangle(mRgba, r.tl(), r.br(), new Scalar(0, 255, 0, 255), 3);

I am using this method for face rectangle.... and I want to show an image above this....

Nabeel Ahmed gravatar imageNabeel Ahmed ( 2014-05-21 01:11:46 -0600 )edit

If you do not specify you are using the Java interface, then we cannot guess this. I am not familiar with it, so will have to wait for others to respond.

StevenPuttemans gravatar imageStevenPuttemans ( 2014-05-21 02:47:29 -0600 )edit

Alright then... Can you please give me code how to Display an image at my eyes detecting... I want to display glasses at my eyes detecting point. . .

 Rect eyearea_right = new Rect(r.x +r.width/16,(int)(r.y + (r.height/4.5)),(r.width - 2*r.width/16)/2,(int)( r.height/3.0));
 Rect eyearea_left = new Rect(r.x +r.width/16 +(r.width - 2*r.width/16)/2,(int)(r.y + (r.height/4.5)),(r.width - 2*r.width/16)/2,(int)( r.height/3.0));
 Core.rectangle(mRgba,eyearea_left.tl(),eyearea_left.br() , new Scalar(255,0, 0, 255), 2); 
 Core.rectangle(mRgba,eyearea_right.tl(),eyearea_right.br() , new Scalar(255, 0, 0, 255), 2);

this is the code How I detect eyes. . .

Nabeel Ahmed gravatar imageNabeel Ahmed ( 2014-05-21 07:27:48 -0600 )edit

Question Tools

Stats

Asked: 2014-05-20 06:51:24 -0600

Seen: 250 times

Last updated: May 20 '14