Asked — Edited
Resolved Resolved by ptp!

How Could I Use Ez Face Detection In My Vs Application

Hello everyone especially @ptp,

I need to know how to use the ez face detection method in my vs app

i try this code but it didn't work

ValuePair vp = (ValuePair)cbVideoDevices.SelectedItem; camera.StartCamera(vp, pictureBox1, 640, 480);

            camera.CameraFaceDetection.GetFaceDetection();  

all I need is to use ez face detection as emgu face detection doesn't work with ez camera , even i try to implement it on my jd camera it throw an exception that it can't implicit emgu quary frame to ez camera . get current bitmap

also i try this code

            ValuePair videocamera = (ValuePair)cbVideoDevices.SelectedItem;
            camera.StartCamera(videocamera, pictureBox1, 640, 480);

            //==============================================


            //Bitmap bmpImage = this.camera.GetCurrentBitmap;
            //if (this.camera.GetCurrentBitmap == null)
            //{
            //    MessageBox.Show("Error");
            //}

            //wait 10 seconds for the first camera frame
            Image ImageFrame = null;
            EventWaitHandle startEvent;
            startEvent = new EventWaitHandle(false, EventResetMode.AutoReset);

               
             //   Bitmap bmapImageOutput = this.camera.GetCurrentBitmap;
              //  pictureBox1.Image = bmapImageOutput;
                //ImageFrame = new Image(this.camera.GetCurrentBitmap);
        

            if (ImageFrame != null)
            {
            
                Image grayImage = ImageFrame.Convert();
                var faces = grayImage.DetectHaarCascade(facedetection, 1.4, 4,
                            HAAR_DETECTION_TYPE.DO_CANNY_PRUNING,
                          new Size(20, 20))[0];
                foreach (var face in faces)
                {
                    //draw the face detected in the 0th (gray) ch
                    ImageFrame.Draw(face.rect, new Bgr(Color.Blue), 3);
                    Bitmap c = ImageFrame.ToBitmap();
                    Bitmap bmp = new Bitmap(face.rect.Width, face.rect.Height);
                    g = Graphics.FromImage(bmp);
                    g.DrawImage(c, 0, 0, face.rect, GraphicsUnit.Pixel);
                    MessageBox.Show("Showing Image in PicBox2");
               
                }
                MessageBox.Show("FD Code didn't RUN");
                pictureBox1.Image = ImageFrame.ToBitmap();
                //===========================


ARC Pro

Upgrade to ARC Pro

Unleash your creativity with the power of easy robot programming using Synthiam ARC Pro

PRO
USA
#1  

please use the code format tags before and after your c# fragment code, it makes a huge difference when reading code.

The EZB SDK method:

camera.CameraFaceDetection.GetFaceDetection() 

is very similar to the :


ObjectLocation objectLocation = _camera.CameraCustomColorDetection.GetObjectLocationByColor(
          Invokers.GetCheckedValue(cbPreviewDetect),
          Invokers.GetTrackBarValue(tbMinObjectSize),
          huePicker1.Min,
          huePicker1.Max,
          scSatMin.Value,
          scSatMax.Value,
          scLumMin.Value,
          scLumMax.Value);

How to start:

  1. you will need to get familiar how it works inside ARC. There is at least one tutorial:

https://synthiam.com/Tutorials/UserTutorials/23/1 but there's more information/help inside ARC (i.e. Blue Question mark in controls)

  1. EZ-B SDK example c# code has a project: Tutorial 11 - Color Vision Tracking

which uses the CameraCustomColorDetection.GetObjectLocationByColor

I think if you master the above two points (ColorDetection) you can do other camera Detection methods.

PRO
USA
#2  

@shaimaabes,

I just open visual studio and is really very simple to detect a Face.


private void CameraOnOnNewFrame()
        {
            this.frameEventObject.Set();
            this.pictureBox1.Invoke(new EventHandler(delegate { this.pictureBox1.Image = this.camera.GetCurrentBitmap; }));
            Interlocked.Increment(ref this.fpsCounter);

            if (this.fpsCounter == 1)
            {
                var objectLocation = this.camera.CameraFaceDetection.GetFaceDetection();
                if (objectLocation.IsObjectFound)
                {
                    WriteDebug(string.Format("Face detected at H:{0} V:{1}", objectLocation.HorizontalLocation, objectLocation.VerticalLocation));
                }
            }

        }

the code runs every 1 st video frame per second.

#3  

@ptp Your consistent guidance helps me to increase my potential in work . You show the path of brighter world , which makes me able grasp my aims . Thankful to dear Boss ^_^

PRO
USA
#4  

@shaimabes,

Thanks for kind words, but do not forget:

Quote:

Give a Man a Fish, and You Feed Him for a Day. Teach a Man To Fish, and You Feed Him for a Lifetime

you are using a EZ-Robot software, it's very important to get familiar with the "user" tool, before embracing the SDK, some functionalities are easy to see working in the ARC side, there are a lot of tutorials, and posts where you can learn more.

PRO
Synthiam
#6  

The camera.GetCurrentBitmap() is only available within the CameraOnOnNewFrame() event. Because until CameraOnOnNewFrame() is raised, there are no images to "get".

#8  

thanks @DJ Sures alot for ur replay

@ptp would u contact me on my email or send me ur email I've made it using haar cascade & i want to share it with u & to get ur feedback of it would u give me that chance please . my email (shaimaabes@yahoo.com)