you may try this:
ReadImg[string(1,(char)x)] >> Letter;
it will convert your variable x
to a respective char and convert it to string..
Pregunta
I have a very simple problem in which i got stuck. Basically, I have an Alphabet database in which I want to access each letter one by one. For example, to access the image of letter A, I have to write -
ReadImg["A"] >> Letter;
I need all the letters to be scanned, therefore I will increment int x. The problem is in the ASCII conversion. When I am putting a letter in the form of "(char)x", the compiler is looking at "(char)x" as (char)x instead of looking at it as a letter (e.g. 'A'). Can anyone point out a possible solution please?
void ReadDatabase(Mat &Letter, int x = 65)
{
cv::FileStorage ReadImg("Alphabet.yml", FileStorage::READ);
ReadImg["(char)x"] >> Letter;
ReadImg.release();
cv::namedWindow("Letter");
cv::imshow("Letter",Letter);
cv::waitKey();
}
Thanks in advance
Solución
you may try this:
ReadImg[string(1,(char)x)] >> Letter;
it will convert your variable x
to a respective char and convert it to string..
Otros consejos
ReadImg[ cv::format("%c",x) ] >> Letter;