//OCR
tesseract::TessBaseAPI api;
api.Init("D:\\tesseract302\\tesseract302\\tessdata", "chi_sim1");
//OpenCV Process
IplImage *frame = cvCreateImage(cvSize(640, 480), IPL_DEPTH_8U, 3);
cvZero(frame);
char key = 0;
p0.x = p0.y = 0;
p1.x = p1.y = 0;
fingertip.x = fingertip.y = 0;
while (key != ' ')
{
p0 = p1;
p1 = fingertip;
if (p0.x & p0.y & p1.x & p1.y)
cvDrawLine(frame, p1, p0, cvScalar(255, 255, 255), 2);
//std::cout << p0.x << p0.y << p1.x << p1.y<<endl;
cvShowImage("ShowImage", frame);
key = cvWaitKey(10);
if (key == 's')
{
cvSaveImage("frame.jpg", frame);
api.SetImage((unsigned char*)(frame->imageData), frame->width, frame->height, frame->nChannels, frame->widthStep);
char* text = api.GetUTF8Text();
cout << text << endl;
cout << "Press any key to continue..." << endl;
key = cvWaitKey(0);
}
1 个解决方案
#1
加一个utf8转ansi的函数。我之前也是这个问题研究了好久,最后用notepad改了改编码发现了。c的输入默认是ansi编码的,这个识别出来的是utf8
#1
加一个utf8转ansi的函数。我之前也是这个问题研究了好久,最后用notepad改了改编码发现了。c的输入默认是ansi编码的,这个识别出来的是utf8