Welcome new user! You can search existing questions and answers without registering, but please register to post new questions and receive answers. Note that due to large amounts of spam attempts, your first three posts will be manually moderated, so please be patient.
We have moved to a new forum at http://jevois.usc.edu, please check it out. The forum at jevois.org/qa will not allow new user registrations but is maintained alive for its useful past questions and answers.
Welcome to JeVois Tech Zone, where you can ask questions and receive answers from other members of the community.

How can we get the category using DarknetSaliency module? [closed]

+1 vote
Hello,

I would like to use the demo DarknetSaliency module  to get the category , the confidence, the x an y position of the found object on a arduino application. Basically I want to read the serial output of JeVois with an arduino and make something when a certain object is detected in a certain spot.

I get all that information plus frame number to which I don't know yet what use to make for it but I don't get the category. I always have 0 but when I check with video output I clearly see different object detected.

Here is the part of the program I use to change modes on Jevois with an Arduino Mega:

JeVois is attached to Serial1 port. Serial port is used to print out on Arduino monitor.

// Buffer for received serial port bytes:
#define INLEN 128
char instr[INLEN + 1];
bool change_JeVoismode=false;
int Mode=0;
// #########################
void setup()
{
 Serial1.setTimeout(50);
 Serial1.begin(115200);
 Serial1.setTimeout(50);
 Serial.begin(115200);
 change_JeVoismode=false;
 Serial1.println("setpar serlog None");
 Serial1.println("setpar serout Hard");
}

void Serial_modechange()
{
 int numero;
      numero = Serial.parseInt();
      Serial.setTimeout(4);
      Serial.println(numero);
      Serial1.println("streamoff");
      delay(100);
 
 if(numero==110)
   {
    delay(100);
    Serial1.println("setmapping 10");
    delay(100);
    Serial1.println("setpar serout Hard");   delay(100);
    Serial1.println("streamon");    delay(100);
    Serial.println("DarknetSaliency");    delay(200);
    change_JeVoismode=false;
    Mode=110;
   }     
}

void DarknetSaliency()
{
  byte len = Serial1.readBytesUntil('\n', instr, INLEN);   
  instr[len] = 0;
  //Serial.print(instr);  Serial.println("  ");  //for debug
  char *tok = strtok(instr, " \r\n");
  int state = 0; int targx = 0, targy = 0 ;
  unsigned int category = 0,  frame=0;
  float confidence =0;
  //Serial.print("  "); Serial.print(tok); Serial.print("  "); Serial.println(len);  // print raw serial for debug

 while (tok)
  {
    switch (state)
    {     
      case 0:
       if (strcmp(tok, "DKS") == 0) state = 1;
         else if (strcmp(tok, "T2") == 0) state = 2;
         else if (strcmp(tok, "DKR") == 0) state = 4;
         else state = 1000;
         break;        
      case 1: frame = atoi(tok);
        Serial.print(" frame: ");   Serial.print(frame);            
        state=0;
        break;
      case 2: targx = atoi(tok);
        Serial.print(" targx ");   Serial.print(targx);
        state = 3; break;
      case 3: targy = atoi(tok);
        Serial.print(" targy ");   Serial.print(targy);
        state = 0; break;
        case 4: category = atoi(tok);
        Serial.print(" category ");   Serial.print(category);
        state = 5; break;
        case 5: confidence = atof(tok);
        Serial.print(" confidence ");   Serial.println(confidence);
        state = 6; break;     
      default: break; // Skip any additional tokens     
    }
    tok = strtok(0, " \r\n");
  }

void loop()
{
 if (Serial.available()>0)
  {     
   char Ch = Serial.read();
   if (Ch == 'M')   
    {
     change_JeVoismode=true;
     Serial.print(Ch);
    }    
   else
    {
      change_JeVoismode=false;
    }
  }
if(change_JeVoismode==true)
 {
    Serial_modechange();
 }
if(change_JeVoismode==false)
  }  
    if(Mode==110)
    {
      DarknetSaliency();
    }
  }

The result is something like this: here below It should recognize a person.

 frame: 753 targx -150 targy 350 category 0 confidence 25.90

 frame: 754 targx -50 targy 300 category 0 confidence 53.10

 frame: 755 targx -350 targy 350 category 0 confidence 0.00

 frame: 756 targx -50 targy 300 category 0 confidence 70.20

Or here below should detect a ball pen (or sometimes a screwdriver :) )

 frame: 1161 targx 375 targy -275 category 0 confidence 42.40

 frame: 1162 targx 375 targy -275 category 0 confidence 40.80

 frame: 1163 targx -25 targy -325 category 0 confidence 37.50

Anyway the category is always 0.  I am not sure if I used the correct method to read the serial data and surely I will appreciate some help.

Thank you!
closed with the note: this is a duplicate and was answered
asked Nov 11, 2017 in User questions by DT (310 points)
closed Nov 28, 2017 by DT

1 Answer

0 votes
I use that code following the below by "JeVois RoadNavigation".

void setup() {
  Serial.begin(57600);
  HWSERIAL.begin(115200);
  Serial.println("Let's go!");
  delay(2000);
  HWSERIAL.println("setpar serlog None");
  HWSERIAL.println("setpar serout Hard");
  //HWSERIAL.println("setmapping2 YUYV 320 240 30.0 JeVois RoadNavigation");
  HWSERIAL.println("setmapping2 YUYV 320 240 5.0 JeVois DarknetSaliency"); //I haven't try yet.
  HWSERIAL.println("streamon");
  HWSERIAL.println("setcam brightness 2");
  HWSERIAL.println("setcam contrast 6");
  HWSERIAL.println("setcam sharpness 28");
  HWSERIAL.println("setcam autogain 1");
  //HWSERIAL.println("setcam gain 400");
  HWSERIAL.println("setcam redbal 180");
  HWSERIAL.println("setcam bluebal 180");

}
answered Nov 15, 2017 by motomi (300 points)
edited Nov 15, 2017 by motomi
Thank you for your suggestion @motomi. Though is not solving my problem. Is interesting to aknoledge the method you used to acces the JeVois modes.
By the way I figured that I double posted my question and I was put on the right direction to solve my problem on the second post of my same question.
...