I'm trying to use opnecv to track a red ball and print the x and y coordinates on the command line (I'm pretty new to c ++ so I do not know if there's any better place for it) I tried doing this like this:
//calcular a posição da bolinha
int posX = dM10 / dArea;
int posY = dM01 / dArea;
if (iLastX >= 0 && iLastY >= 0 && posX >= 0 && posY >= 0)
{
//Desenhar uma linha entre o ponto anterior e o ponto novo
line(imgLines, Point(posX, posY), Point(iLastX, iLastY), Scalar(255, 0, 0), 2);
}
iLastX = posX;
iLastY = posY;
}
imshow("Thresholded Image", imgThresholded); //mostrar a imagem modificada
imgOriginal = imgOriginal + imgLines;
imshow("Original", imgOriginal); // mostrar a imagem original
{
string strMytestString("Point(posX, posY)\n");//imprimir na linha de comando
cout << strMytestString;
}
But it did not work, does anyone know why?