Étape 2: Comment ça marche ?
La meilleure façon de faire, c' est d’utiliser le téléphone android avec app spéciale qui vérifier la vue de la caméra reconnaît la position de couleur rouge et l’envoie à l’arduino via bluetooth. App utilise la bibliothèque openCV pour traitement de l’image. Il calculer la moyenne arithmétique pour vérifier où est de couleur rouge. Ci-dessous, j’ai ajouté du code android pour voir comment cela fonctionne :
image bitmap = Bitmap.createBitmap(mRgba.cols(), mRgba.rows(), Bitmap.Config.ARGB_8888) ; Utils.matToBitmap (mRgba, bitmap) ;
int x = 0 ;
int y = 0 ;
int all_x = 0 ;
int all_y = 0 ;
while(x < 176) {}
alors que {(y < 144)
int pixel = bitmap.getPixel (x, y) ;
int redValue = Color.red(pixel) ;
int blueValue = Color.blue(pixel) ;
int greenValue = Color.green(pixel) ;
Si (redValue > 200 & & blueValue < 70 & & greenValue < 70) {}
points ++ ;
all_x = all_x + x ;
all_y = all_y + y ;
}
y ++ ;
}
x ++ ;
y = 0 ;
}
y = 0 ;
x = 0 ;
centre_x = all_x / pointe ;
centre_y = all_y / pointe ;