Click here to Skip to main content
15,867,835 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi, i am working on project. I am using webcam to detect faces in c#, using emgucv.
Every thing is working fine,like when i run application it starts webcam then it starts detecting faces..
But now i want to do is, that when it detects faces , it should blur the face only,not the whole webcam video. or it show some other image instead of detected face.
And i am showing the face detected video in picturebox.
this is my code, i have done so far..

C#
Image<Bgr, byte> ImageFrame = capture.QueryFrame();


            if (ImageFrame != null)
            {
                //convert the image to gray scale
                Image<Gray, byte> grayframe = ImageFrame.Convert<Gray, byte>();

                //detect faces from the gray-scale image and store into an array of type 'var'
                var faces = grayframe.DetectHaarCascade(haar, 1.4, 0,
                                                       HAAR_DETECTION_TYPE.DEFAULT,
                                                       new Size(25, 25))[0];


            

            
                //draw a green rectangle on each detected face in image
                foreach (var face in faces)
                {

                    ImageFrame.Draw(face.rect, new Bgr(Color.Green), 2);

                   
                }

                
            }

            camimagebox.Image = ImageFrame;




Now i just want to blur the detected face, thats it..kindly help me as soon as you can..
I also used:

ImageFrame.SmoothBlur(face.rect.Width, face.rect.Height)

but nothing happened...
Posted
Comments
BillW33 30-Aug-12 9:05am    
If a solution has answered your question please accept a solution, so that this question goes off the unanswered list or if you are still having problems, ask.

If you are using EMGU, as it says in your tag, you can call cvSmooth. I have discussed the parameters below and shown an example of the call.

C#
Image<Gray, float> inputImage;
//Set inputImage to whatever image you want to smooth

Image<Gray, float> smoothedImage = new Image<Gray, float>(inputImage.Width, inputImage.Height);

//You can use whichever smooth type you need, gaussian is fairly common, but not the only way to do it.

int apertureWidth = 10;
int apertureHeight = 10;
//The aperture is the size of the smoothing window
//The smoothing window is typically a square that is a few pixels wide; a 10x10 square is a good place to start.

//if you set parameter3 and 4 to zero it will use default values.

cvSmooth(inputImage.Ptr, smoothedImage.Ptr, SMOOTH_TYPE.CV_GAUSSIAN, apertureWidth , apertureHeight , 0, 0);


Look here for an explanation of the call to cvSmooth.

You will need to select the smooth type as explained here.

Also read this[^] on openCV Image Filtering, cvSmooth is about 3/4 of the way down the page.
 
Share this answer
 
v6
Comments
Member 9357064 28-Aug-12 12:23pm    
BUT I DIDNT get it, can u insert it in my code, to show how??
BillW33 28-Aug-12 12:59pm    
I updated my answer to give more detail on how to use it. I also added a link which provides more explanation of cvSmooth.
BillW33 29-Aug-12 11:31am    
Did this help you to figure it out or do you still have questions?
We have no idea what library you're using. My articles include instructions on how to blur an image, you could use that code with the areas you're detecting to blur an area.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900