Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/145.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/opencv/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 在C/C+中将int转换为ASCII+;_C++_Opencv_Path_Ascii_Yaml - Fatal编程技术网

C++ 在C/C+中将int转换为ASCII+;

C++ 在C/C+中将int转换为ASCII+;,c++,opencv,path,ascii,yaml,C++,Opencv,Path,Ascii,Yaml,我有一个非常简单的问题,我陷入其中。基本上,我有一个字母表数据库,我想一个接一个地访问每个字母。例如,要访问字母A的图像,我必须- ReadImg["A"] >> Letter; 我需要扫描所有的字母,因此我将增加int x。问题在于ASCII转换。当我以“(char)x”的形式放置一个字母时,编译器将“(char)x”视为(char)x,而不是将其视为字母(例如“a”)。有人能指出一个可能的解决办法吗 void ReadDatabase(Mat &Letter, int

我有一个非常简单的问题,我陷入其中。基本上,我有一个字母表数据库,我想一个接一个地访问每个字母。例如,要访问字母A的图像,我必须-

ReadImg["A"] >> Letter; 
我需要扫描所有的字母,因此我将增加int x。问题在于ASCII转换。当我以“(char)x”的形式放置一个字母时,编译器将“(char)x”视为(char)x,而不是将其视为字母(例如“a”)。有人能指出一个可能的解决办法吗

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();
}
提前感谢

您可以尝试以下方法:

ReadImg[string(1,(char)x)] >> Letter;
它会将变量
x
转换为相应的字符,并将其转换为字符串

ReadImg[ cv::format("%c",x) ] >> Letter;