| | |
| | | |
| | | //图像识别的数字准备 |
| | | |
| | | unsigned char* totalNumberData = (unsigned char*)malloc(sizeof(unsigned char) * (ImgUtil::NUM_HEIGHT * rowDataList.size()) * ImgUtil::NUM_WIDTH * 10 * 17); |
| | | unsigned char* totalNumberData = (unsigned char*)malloc(sizeof(unsigned char) * (_NUMBER_L2_HEIGHT * rowDataList.size()) * _NUMBER_L2_WIDTH * 10 * _NUMBER_L2_TOTAL_NUMBER); |
| | | |
| | | |
| | | |
| | |
| | | clock_t time_32 = clock(); |
| | | std::cout << "数据准备-位置数据准备: threadid-" << std::this_thread::get_id() << " 耗时:" << time_32 - time_31 << endl; |
| | | |
| | | unsigned char* zeroData = (unsigned char*)malloc(sizeof(unsigned char) * 5 * 8); |
| | | for (int r = 0;r < 8;r++) { |
| | | for (int c = 0;c < 5;c++) |
| | | unsigned char* zeroData = (unsigned char*)malloc(sizeof(unsigned char) * _NUMBER_L2_WIDTH * _NUMBER_L2_HEIGHT); |
| | | for (int r = 0;r < _NUMBER_L2_HEIGHT;r++) { |
| | | for (int c = 0;c < _NUMBER_L2_WIDTH;c++) |
| | | { |
| | | zeroData[r * 5 + c] = ImgUtil::NUMS[0].data.ptr<uchar>(r)[c]; |
| | | zeroData[r * _NUMBER_L2_WIDTH + c] = ImgUtil::NUMS_LEVEL2[0].data.ptr<uchar>(r)[c]; |
| | | } |
| | | } |
| | | |
| | | clock_t time_33 = clock(); |
| | | std::cout << "数据准备-0数据准备: threadid-" << std::this_thread::get_id() << " 耗时:" << time_33 - time_32 << endl; |
| | | |
| | | openCLExcuter->splitNum(imgData, img.cols, img.rows, pos, 3 * rowDataList.size(), zeroData, totalNumberData); |
| | | openCLExcuter->splitNum(imgData, img.cols, img.rows, pos, 3 * rowDataList.size(), zeroData, _NUMBER_L2_WIDTH, _NUMBER_L2_HEIGHT, _NUMBER_L2_TOTAL_NUMBER, totalNumberData); |
| | | |
| | | free(pos); |
| | | free(zeroData); |
| | |
| | | std::cout << "数据准备-数字分隔完成: threadid-" << std::this_thread::get_id() << " 耗时:" << time_34 - time_33 << endl; |
| | | |
| | | //准备模板数字 |
| | | uchar* templateNums = (unsigned char*)malloc(sizeof(unsigned char) * (ImgUtil::NUM_HEIGHT * rowDataList.size()) * ImgUtil::NUM_WIDTH * 10 * 17); |
| | | uchar* templateNums = (unsigned char*)malloc(sizeof(unsigned char) * (_NUMBER_L2_HEIGHT * rowDataList.size()) * _NUMBER_L2_WIDTH * 10 * _NUMBER_L2_TOTAL_NUMBER); |
| | | |
| | | openCLExcuter->createNumberTemplates(rowDataList.size(), templateNums); |
| | | openCLExcuter->createNumberTemplates(rowDataList.size(), _NUMBER_L2_WIDTH, _NUMBER_L2_HEIGHT, _NUMBER_L2_TOTAL_NUMBER, ImgUtil::numsOneLevel_level2 ,templateNums); |
| | | |
| | | //ImgUtil::createTemplateNumData(data.size()); |
| | | clock_t time_4 = clock(); |
| | |
| | | std::cout << "非数字数据识别完成: threadid-" << std::this_thread::get_id() << " 耗时:" << time_5 - time_4 << endl; |
| | | |
| | | //数字识别 |
| | | uchar** numberResult = openCLExcuter->recognition_numbers(totalNumberData, templateNums, rowDataList.size() * ImgUtil::NUM_HEIGHT, ImgUtil::NUM_WIDTH * 10 * 17); |
| | | uchar** numberResult = openCLExcuter->recognition_numbers(totalNumberData, templateNums, rowDataList.size() * _NUMBER_L2_HEIGHT, _NUMBER_L2_WIDTH * 10 * _NUMBER_L2_TOTAL_NUMBER, _NUMBER_L2_WIDTH, _NUMBER_L2_HEIGHT, _NUMBER_L2_TOTAL_NUMBER); |
| | | //释放内存 |
| | | free(totalNumberData); |
| | | free(templateNums); |