Click here to Skip to main content
16,011,626 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello friends.
Now i am developing projec with using face detection.In that i have webcam image (In this face would need to detected).I can detect face from image which is an external image(jpeg)that i downloaded from google.but when i am going to detect face from webcam image i cannot able to detect face image.the code is below

C#
Bitmap imgs = (Bitmap)pictureBox1.Image.Clone();
Image<Bgr, Byte> currentframe = new Image<Bgr, byte>(imgs);
// Image<Bgr, Byte> currentframe = new Image<Bgr, byte>("D://bs//image processing//image processing//images//3.jpg");

String facefile = "haarcascade_frontalface_default.xml";
using (HaarCascade face = new HaarCascade(facefile))
{
    using (Image<Gray, Byte> grey = currentframe.Convert<Gray, Byte>())
    {
        grey._EqualizeHist();
        MCvAvgComp[] facedetected = face.Detect(grey, 1.1, 10, Emgu.CV.CvEnum.HAAR_DETECTION_TYPE.DO_CANNY_PRUNING, new Size(20, 20));
        foreach (MCvAvgComp f in facedetected)
        {
            currentframe.Draw(f.rect, new Bgr(Color.Blue), 2);
            grey.ROI = f.rect;
        }
    }


}

//  ImageViewer.Show(currentframe);
pictureBox1.Image = currentframe.ToBitmap();

// MessageBox.Show("successfully image drawed");


[edit]Changed pre-tag to c#[/edit]
Posted
Updated 27-Apr-12 2:17am
v2
Comments
Shahin Khorshidnia 27-Apr-12 9:32am    
The code is using some classes and methods that I don't see them and saying "I can not detect the face" is not an accurate pointing to the problem. I don't know the application can detect something but wrong in webcam image; or detects nothing! ... Did you trace the code?(using break point) and see what is happening to the image? Ok, I think (not sure) JPeg images are in good quality but the quality of webcam images are too low to be edge detected.
Sergey Alexandrovich Kryukov 27-Apr-12 13:14pm    
Basically agree, but not completely: there is nothing wrong about WebCam: first, the quality can be good enough, and it also depends on scene and lighting.
--SA
Shahin Khorshidnia 27-Apr-12 14:03pm    
Yes SA,
I mean the image is not clear enough to be detectd. Thank you for pointing:)
bbirajdar 27-Apr-12 10:05am    
Reason for my vote of 1
Incomplete
bbirajdar 27-Apr-12 10:06am    
Not enough information to understand your problem. Are you using any third party library?

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