Hey, j'utilise JavaCV de cette bibliothèque org.bytedeco.javacpp.opencv_core
dans la version 1.3.2 comme une dépendance de gradle.obtenir les coordonnées des coins lors de l'appel findChessboardCorners
Je suis en cours d'exécution de ce code pour obtenir les coins sur l'échiquier mais j'ai du mal à obtenir les coordonnées de chacun des coins détectés:
Mat imageCorners = new Mat();
Size boardSize = new Size(9,6);
boolean found = findChessboardCorners(capturedFrame,boardSize,imageCorners,CV_CALIB_CB_ADAPTIVE_THRESH+CV_CALIB_CB_NORMALIZE_IMAGE);
Mais pour les 54 coins de la méthode détecte, la matrice qui stocke les coins ont juste une taille de 54x1.
if (found) {
FloatRawIndexer sI = imageCorners.createIndexer();
for (int y = 0; y < imageCorners.rows(); y++) {
for (int x = 0; x < imageCorners.cols(); x++) {
logger.debug("Row: " + y + " Column " + x);
logger.debug(sI.get(y, x));
}
}
}
Le fichier journal ressemble à ceci:
14:57:50.057 [main] DEBUG JavaCVTransformation2 - Row: 0 Column 0
14:57:50.059 [main] DEBUG JavaCVTransformation2 - 164.02007
14:57:50.059 [main] DEBUG JavaCVTransformation2 - Row: 1 Column 0
14:57:50.059 [main] DEBUG JavaCVTransformation2 - 224.07906
14:57:50.059 [main] DEBUG JavaCVTransformation2 - Row: 2 Column 0
14:57:50.059 [main] DEBUG JavaCVTransformation2 - 283.54288
14:57:50.059 [main] DEBUG JavaCVTransformation2 - Row: 3 Column 0
14:57:50.059 [main] DEBUG JavaCVTransformation2 - 343.4154
14:57:50.060 [main] DEBUG JavaCVTransformation2 - Row: 4 Column 0
14:57:50.060 [main] DEBUG JavaCVTransformation2 - 402.7718
14:57:50.060 [main] DEBUG JavaCVTransformation2 - Row: 5 Column 0
14:57:50.060 [main] DEBUG JavaCVTransformation2 - 462.38278
14:57:50.060 [main] DEBUG JavaCVTransformation2 - Row: 6 Column 0
14:57:50.060 [main] DEBUG JavaCVTransformation2 - 522.2342
14:57:50.060 [main] DEBUG JavaCVTransformation2 - Row: 7 Column 0
14:57:50.060 [main] DEBUG JavaCVTransformation2 - 580.99805
14:57:50.061 [main] DEBUG JavaCVTransformation2 - Row: 8 Column 0
14:57:50.061 [main] DEBUG JavaCVTransformation2 - 640.7774
14:57:50.061 [main] DEBUG JavaCVTransformation2 - Row: 9 Column 0
14:57:50.061 [main] DEBUG JavaCVTransformation2 - 151.04564
Dessin cela fonctionne parfaitement bien, donc quelque part il doit y avoir deux coordonnées à chaque coin, je pense.
drawChessboardCorners(capturedFrame, boardSize, imageCorners, found);
Y at-il un moyen d'obtenir les coordonnées des coins lors de l'appel findChessboardCorners()
?
En C++ la sortie '' imageCorners'' est un '' vecteur '' accessible avec '' imageCorners [i] .x'' et '' imageCorners [i] .y''. Cela vous aide-t-il? –
Phann