New Homepage Forums Sensor Shields face detection shield

This topic contains 13 replies, has 4 voices, and was last updated by avatar Amr 1 year, 5 months ago. This post has been viewed 1259 times

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #25410
    Ahmed Ebrahem
    Participant

    I Need A Help In How To Use The Face Detection Shield In A Real Project

    #25453
    avatarEslam Ali
    Participant

    Hi Ahmed,

    What kind of project you would like to do ?

    #25465
    Ahmed Ebrahem
    Participant

    i want to make a system that detect an special person face to open a door , and if the system detects another stranger don’t open the door.

    #25468
    avatarEslam Ali
    Participant

    Am sorry to say that the shield detect faces and doesn’t recognize (that’s why it’s called face detection not face recognition) but you can still do a simple pattern using winks or smiles that can be detected by face as a password for your system.

    #25531
    Ahmed Ebrahem
    Participant

    First , Thanks Guys For The Support Iam Really Proud To Have Egyptians Like Integreight
    SECOND , Is There Any Tutorials Explaining How To Make It ?
    Thanks Guys

    #25599
    avatarEslam Ali
    Participant

    Do you mean a tutorial to build your own 1Sheeld board from scratch ? And thanks for your supporting words 🙂 .

    #25606
    Ahmed Ebrahem
    Participant

    No I Mean How To Make The System That I Talk About The Previous Comment , That Make MyOwn Pattern Of Winks Or Smilling , Things Like that .

    #25608
    avatarEslam Ali
    Participant

    Yup, you can check the official simple example in the library by clicking File >> Examples >> >> Simple >> FaceDetection 😉 .

    #117863
    avatarCPJ
    Participant

    Hi there,
    I’m using the face detector shield which is absolutely brilliant! I’m new to C++.
    I want to modify the example given by 1Sheeld to do something slightly different.
    I don’t need the wink count bit. I just need it to detect a face.
    I’m building an arduino based robot. The robot will turn slowly on it’s own axis.
    Whilst doing this I want the mobile mounted on the robot to detect a first face. At that point the robot will stop rotating and move forward towards the face. In other words my robot will detect human presence and move towards it. I will use an ultrasonic sensor to avoid objects. All I need is a bit of code based on the “if” function that will then engage the bit of the sketch which turns the motors on.
    The code I’m using for the motor control is as attached. It would be a really helpful starter for me if you could just add to this the face detector code I need – just so I can see how it works. I can develop the rest myself. Many thanks.

    #118067
    avatarAmr
    Keymaster

    Hi,

    What an awesome idea, BTW!

    to detect if there is a human face in the frame then you will use this function from the face detection shield:

    which will return the number of faces in the frame.

    You will simply make the robot go around itself 360 degrees with steps of time like 500ms then stop and call the above function. If returned any number other than (0) then make it move forward or complete the 360 degrees and continue moving toward its original direction.

    That’s a possible solution scenario. So, give it a try and let me know what do you think.

    #119131
    avatarCPJ
    Participant

    Thanks for your reply re using face detection in a robot to detect human presence and move towards them.
    I have it working to a fashion. I’ve used your example code as a starting point. The robot rotates slowly and scans for human faces.
    When detected it stops and moves forward to the person.
    However, my programming is very crude I’m a beginner). I have delays in there which I want to avoid. It has the wink counter in there which I want to remove. The rotation stops when a face is detected and moves forward but sometimes it doesn’t. I’ve added the code below
    /*

    Face Detector Shield Example

    This example shows an application on 1Sheeld’s face detector shield.

    By using this example, you can unlock a door by winking three times to
    the front camera.

    OPTIONAL:
    To reduce the library compiled size and limit its memory usage, you
    can specify which shields you want to include in your sketch by
    defining CUSTOM_SETTINGS and the shields respective INCLUDE_ define.

    */

    #define CUSTOM_SETTINGS
    #define INCLUDE_FACE_DETECTOR_SHIELD
    #define INCLUDE_TERMINAL_SHIELD
    #define INCLUDE_TEXT_TO_SPEECH_SHIELD
    #define INCLUDE_VOICE_RECOGNIZER_SHIELD

    /* Include 1Sheeld library. */
    #include <OneSheeld.h>

    /* A name for the LED on pin 13. */
    int ledPin = 13;

    /* A name for the relay on pin 12. */
    int relayPin = 12;

    /* A name for the winks counter. */
    int counter = 0;

    // MOTOR 1
    // Motor 1 PWM is connected to pin 3.

    const int pinPwm1 = 3;

    // Motor 1 DIR is connected to pin 2.

    const int pinDir1 = 2;

    // MOTOR 2
    // Motor 2 PWM is connected to pin 5.

    const int pinPwm2 = 5;

    // Motor 2 DIR is connected to pin 4.

    const int pinDir2 = 4;

    /*******************************************************************************
    * PRIVATE GLOBAL VARIABLES *
    *******************************************************************************/

    // Speed of the motor1.
    static int iSpeed1 = 0;

    // Acceleration of the motor1.
    static int iAcc1 = 1;

    // Speed of the motor2.
    static int iSpeed2 = 0;

    // Acceleration of the motor2.
    static int iAcc2 = 1;

    void setup()
    {
    /* Start communication. */
    OneSheeld.begin();
    /* Set the LED pin as output. */
    pinMode(ledPin,OUTPUT);
    /* Set the relay pin as output. */
    pinMode(relayPin,OUTPUT);

    pinMode(pinPwm1, OUTPUT);
    pinMode(pinDir1, OUTPUT);
    pinMode(pinPwm2, OUTPUT);
    pinMode(pinDir2, OUTPUT);

    }

    void loop()
    {
    /* Get the first face and check if it winks. */
    if(FaceDetector.getVisibleFace(0).getLeftEyeOpenProbability()==0)
    {
    /* Turn on the LED when winking. */
    digitalWrite(ledPin,HIGH);

    iSpeed1 = 1;
    iSpeed2 = 1;

    analogWrite(pinPwm1, iSpeed1);
    digitalWrite(pinDir1, LOW);

    analogWrite(pinPwm2, iSpeed2);
    digitalWrite(pinDir2, HIGH);

    TextToSpeech.say(“Life form detected”);

    /* Count the winks. */
    counter++;

    delay (50);

    iSpeed1 = 100;
    iSpeed2 = 100;

    analogWrite(pinPwm1, iSpeed1);
    digitalWrite(pinDir1, HIGH);

    analogWrite(pinPwm2, iSpeed2);
    digitalWrite(pinDir2, LOW);

    delay (2000);

    /* A slight delay. */
    OneSheeld.delay(1000);
    }else
    {
    /* Turn off the LED. */
    digitalWrite(ledPin,LOW);

    iSpeed1 = 50;
    iSpeed2 = 50;

    analogWrite(pinPwm1, iSpeed1);
    digitalWrite(pinDir1, HIGH);

    analogWrite(pinPwm2, iSpeed2);
    digitalWrite(pinDir2, HIGH);

    }

    /* Check the number of winks. */
    if(counter == 3)
    {
    /* Send success. */
    Terminal.println(“Success”);
    /* Open the lock. */
    digitalWrite(relayPin,HIGH);
    /* Reset counter. */
    counter=0;

    }

    }

    #120532
    avatarAmr
    Keymaster

    Hi,

    I think this code isn’t the updated one with the task of stop rotation when seeing a face, right?

    But anyway, here is a delay of total 3 seconds which I think you can remove (unless you intended to use for some reason):

    And one more thing to consider when coding for the text-to-speech shield is to add a bit longer delay after each phrase spoken so that Arduino waits for the phone to pronounce the phrase before jumping to rest of the code,
    like:

    Wrong! Not enough time ..

    Maybe a longer delay, like:

    #121516
    avatarCPJ
    Participant

    Hi there,

    I can’t work out how to change my sketch just to detect a face (no winks or smiles needed).
    Also I have tried dozens of ways to put inn some code for an SR04 sensor. This is to stop the robot if it gets to close to an object.
    Any help would be really appreciated.

    Thanks

    #121790
    avatarAmr
    Keymaster

    Hi,

    Check this simple code that just turns an LED on pin 13 once the phone detects a face. You can try it and if it worked out with you then merge it inside your full project code and let me know if all worked properly.

Viewing 14 posts - 1 through 14 (of 14 total)

You must be logged in to reply to this topic.