
Since only one barcode label was being recognised at the time, the calculation was very simple - just subtract the actual camera y coordinate from the desired coordinate. The same is true for the upgraded camera, where it is detecting the coordinate position of the individual crops, except that there's normally going to be about 6 plants and some of them might not be recognised properly or might just have died or been eaten by a pigeon!
The principle is exactly the same as for the Pixy2 and the solution is equally simple - just add up the individual 'deviances', divide by the number of plants detected and then subtract from the desired coordinate. The main difference is that the same type of calculation is going to be used for both the x and y axes.
The calculations themselves are made on the Jetson TX2 during detection itself and then output via I2C to an Arduino Nano intermediate as simple steering or drive commands eg integer '3' means 'stop dead'.
The following code uses the term 'nonant' which refers to a 3 x 3 matrix but really should really be called 'sextant' as the matrix currently detected is 3 x 2. I'm just too lazy to change the name just yet
//printf(" Box Area (%i) = %i \n",n,myBoxArea[n]); // Print the area (size) of the box.
//printf(" Box Centre (x,%i) = %i \n",n,myBoxCentreX[n]); // Print the box centre (x) coordinate.
//printf(" Box Centre (y,%i) = %i \n",n,myBoxCentreY[n]); // Print the box centre (y) coordinate.
// Divide up into 'Nonants' (the 9 version of quadrants). // 1200/3 = 400, 720/3 = 240.
// Or divide into sextants eg 1920/3 = 640:
if (( myBoxCentreX[n] <= 640 ) && ( myBoxCentreY[n] <= 540 ))
{
nonant = 0;
nonantDevianceX[0] = myBoxCentreX[n] -320;
nonantDevianceY[0] = myBoxCentreY[n] -270;
//printf(" Nonant (%i) = %i \n",n,nonant);
}
if (( myBoxCentreX[n] >= 641 ) && ( myBoxCentreX[n] <= 1280 ) && ( myBoxCentreY[n] <= 540 ))
{
nonant = 1;
nonantDevianceX[1] = myBoxCentreX[n] -960;
nonantDevianceY[1] = myBoxCentreY[n] -270;
//printf(" Nonant (%i) = %i \n",n,nonant);
}
if (( myBoxCentreX[n] >= 1281 ) && ( myBoxCentreY[n] <= 540 ))
{
nonant = 2;
nonantDevianceX[2] = myBoxCentreX[n] -1600;
nonantDevianceY[2] = myBoxCentreY[n] -270;
//printf(" Nonant (%i) = %i \n",n,nonant);
}
if (( myBoxCentreX[n] <= 640 ) && ( myBoxCentreY[n] >= 541 ))
{
nonant = 3;
nonantDevianceX[3] = myBoxCentreX[n] -320;
nonantDevianceY[3] = myBoxCentreY[n] -810;
//printf(" Nonant (%i) = %i \n",n,nonant);
}
if (( myBoxCentreX[n] >= 641 ) && ( myBoxCentreX[n] <= 1281 ) && ( myBoxCentreY[n] >= 541 ))
{
nonant = 4;
nonantDevianceX[4] = myBoxCentreX[n] -960;
nonantDevianceY[4] = myBoxCentreY[n] -810;
//printf(" Nonant (%i) = %i \n",n,nonant);
}
if (( myBoxCentreX[n] >= 1281 ) && ( myBoxCentreY[n] >= 541 ))
{
nonant = 5;
nonantDevianceX[5] = myBoxCentreX[n] -1600;
nonantDevianceY[5] = myBoxCentreY[n] -810;
//printf(" Nonant (%i) = %i \n",n,nonant);
}
//printf(" Nonant (%i) = %i \n",n,nonant);
//printf("..................................................... \n");
//I2CDataHandler();
}
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.