7 Replies Latest reply on Apr 27, 2015 7:51 AM by nemam

    face tracking intel Galileo

    nemam

      Hi guys!

      I am trying a face tracking with Intel galileo: first by the sketch in the Intel Galileo

      And then run the script from cmd window:

      1. Reconocimientorostro.py

      I get the values but the servos do not move and do not know why?

      Somebody give me some idea?

      Thanks! Mamen

       

      foto1.jpg

      foto2.jpg

        • 1. Re: face tracking intel Galileo
          CMata_Intel

          Hi nemam

           

          Some suggestions

          Start debugging your code section by section by testing in the Serial Monitor the lectures from servo.read after you are definitely sure that you have good and readable values then you can start using operations to re-calculate the angle.

          Are you receiving good values?

          Are the servos working ok (by using servo.write())?

          I will try to replicate your code with a servo, are you using a Galileo Gen1 or Galileo Gen2?

           

          Regards;

          CMata

          • 2. Re: face tracking intel Galileo
            CMata_Intel

            Hi nemam

             

            I tested this code:

            #include <Servo.h> 
            
            
            Servo myservo;
            int posx = 0;
            int valx=0;
            const int screenmaxx=640;
            int incx=10;
            const int distancex=1;
            const int servomaxx=180;
            
            void setup() {
               Serial.begin(9600);
               myservo.attach(9,600,2300);
               myservo.write(90);
            }
            
            void loop() {
              posx=myservo.read();
              Serial.println(posx);
               if(valx < (screenmaxx/2 - incx)){
                  if( posx >= incx ) posx += distancex; //Update the pan position variable to move the servo to the left.
                }
                //Find out if the X component of the face is to the right of the middle of the screen.
                else if(valx > screenmaxx/2 + incx){
                  if(posx <= servomaxx-incx) posx -=distancex; //Update the pan position variable to move the servo to the right.
                }
               myservo.write(posx);
            }
            

             

            The servo was working and I was reading posx = 90 in the Serial Monitor. Could you check if this sketch works for you too?

            I was using a Galileo Gen1 with the IoT image.

             

            Regards;

            CMata

            • 3. Re: face tracking intel Galileo
              nemam

              Hi! CMata_Intel
              Thanks for your answer, I Try this way but it does not work.
              I try another way to move the servos as a function of x, y coordinates of the rectangle that is drawn to detect my face.

              You can give me your opinion to see how you think.

              The coordinates x, y pass from python to the sketch in this way, for example: X320Y200Z.


              #include <Servo.h>

               

               

              Servo servox;

              Servo servoy;

              const int pinservox =9;

              const int pinservoy=10;

              const int baudrate=9600;

              const int pulsomin=600;

              const int pulsomax=2300;

              const int servocentro=90;

              const int servomaxx=180;

              const int servominx=0;

              int valx=0;

              int valy=0;

              int servoX=0;

              int servoY=0;

              int posx=0;

              int posy=0;

               

               

              void setup() {

                  Serial.begin(9600);

                  servox.attach(pinservox,pulsomin,pulsomax);

                  servoy.attach(pinservoy,pulsomin,pulsomax);

                 

                  servox.write(servocentro);

                  delay(2000);

                  servoy.write(servocentro);

                  delay(2000);

                 

              }

               

               

              void loop() {

                  if (Serial.available() > 0) {

                      if (Serial.read() == 'X') {

                          valx = Serial.parseInt();

                          Serial.println("El valor centro X");

                          Serial.println(valx);

                          int servoX= map(valx,0,640,180,0);

                          Serial.println("El valor para el servo en X corresponde a:");

                          Serial.println(servoX);

                          if (Serial.read() == 'Y') {

                              valy = Serial.parseInt();

                              Serial.println("El valor centro Y");

                              Serial.println(valy);

                              int servoY=map(valy,0,480,180,0);

                              Serial.println("El valor para el servo en Y corresponde a:");

                              Serial.println(servoY);

                              servox.write(servoX);

                              servoy.write(servoY);

                              posx=servox.read();

                              posy=servoy.read();

                              Serial.println(posx);

                              Serial.println(posy);

                             

                             

                           }

                      }

                 

                      while (Serial.available() > 0) {

                          Serial.read();

                      }       

                  }

              }

               

               

               




              • 4. Re: face tracking intel Galileo
                nemam

                Yes, I use Galileo Gen 1, and the values are correct but the servos not move.

                • 5. Re: face tracking intel Galileo
                  CMata_Intel

                  Hi nemam

                   

                  Have you tested the servos without the extra code? The code that I posted should test this, if you run the sketch and attach the servo to pin 9 and use VCC as 5V, you should be able to move the servos. Try to test them before in order to discard an issue with the servos and start testing the rest of the code

                   

                  Regards;

                  CMata

                  • 6. Re: face tracking intel Galileo
                    CMata_Intel

                    Hi nemam

                     

                    Have you tested the servos without the extra code? The code that I posted should test this, if you run the sketch and attach the servo to pin 9 and use VCC as 5V, you should be able to move the servos. Try to test them in order to discard an issue with the servos and not with the code.

                     

                    Regards;

                    CMata