| | |
| | | { |
| | | while (true) { |
| | | |
| | | |
| | | clock_t origin_start_time = clock(); |
| | | if (killRunnings[index]) |
| | | break; |
| | |
| | | list<TradeData*> resultList = captureLevel2TradeData(mat, index); |
| | | if (index == 0) |
| | | { |
| | | cout << "-----------识别时间消耗:---------- " << index << " " << clock() - start << endl; |
| | | cout << "-----------识别时间消耗:---------- " << index <<" 数量:"<< resultList.size() << " " << clock() - start << endl; |
| | | } |
| | | long processTime = clock() - origin_start_time; |
| | | start = clock(); |
| | |
| | | |
| | | } |
| | | } |
| | | Sleep(50); |
| | | Sleep(600); |
| | | } |
| | | } |
| | | |
| | |
| | | int ele_count_per_line = splitAreas.size(); |
| | | int line_number_count = ele_count_per_line * num_length_per_ele; |
| | | unsigned char* totalNumberData = (unsigned char*)malloc(sizeof(unsigned char) * (_NUMBER_GP_CODE_HEIGHT * 1) * _NUMBER_GP_CODE_WIDTH * 10 * line_number_count); |
| | | unsigned char types[] = { NUM_TYPE_NUM,NUM_TYPE_NUM,NUM_TYPE_NUM,NUM_TYPE_NUM,NUM_TYPE_NUM,NUM_TYPE_NUM,NUM_TYPE_NUM,NUM_TYPE_NUM,NUM_TYPE_NUM,NUM_TYPE_NUM,NUM_TYPE_NUM,NUM_TYPE_NUM,NUM_TYPE_NUM,NUM_TYPE_NUM,NUM_TYPE_NUM,NUM_TYPE_NUM,NUM_TYPE_NUM,NUM_TYPE_NUM }; |
| | | unsigned char types[24]; |
| | | for (int i = 0; i < 24; i++) { |
| | | types[i] = NUM_TYPE_NUM; |
| | | } |
| | | UcharDataInfo typesData = UcharDataInfo(); |
| | | typesData.length = ele_count_per_line; |
| | | typesData.data = types; |
| | |
| | | |
| | | clock_t time_2 = clock(); |
| | | |
| | | int ele_count_per_line = 7; |
| | | |
| | | |
| | | |
| | | //图像分割---开始 |
| | |
| | | free(indexs); |
| | | } |
| | | //一维按行切分图像数据 |
| | | int* rowSplitDataOneLevel = (int*)malloc(sizeof(int) * rowDataList.size() * 4 * 7); |
| | | int* rowSplitDataOneLevel = (int*)malloc(sizeof(int) * rowDataList.size() * 4 * ele_count_per_line); |
| | | try { |
| | | openCLExcuter->splitL2RowData(img, rowDataOneLevel, rowDataList.size(), rowSplitDataOneLevel); |
| | | free(rowDataOneLevel); |
| | |
| | | } |
| | | */ |
| | | |
| | | /* |
| | | |
| | | //保存分隔的图片 |
| | | if (true) { |
| | | int start = 4 * 7 * (558 - 1); |
| | | start += 4 * (2); |
| | | int startx= rowSplitDataOneLevel[start]; |
| | | int starty = rowSplitDataOneLevel[start+1]; |
| | | int endx = rowSplitDataOneLevel[start+2]; |
| | | int endy = rowSplitDataOneLevel[start+3]; |
| | | cv::imshow("价格", cv::Mat(img, cv::Rect(startx, starty, endx - startx + 1, endy - starty + 1))); |
| | | if (false) { |
| | | int start = 4 * ele_count_per_line * (138); |
| | | start += 4 * (1); |
| | | int startx = 385;//rowSplitDataOneLevel[start]; |
| | | int starty = 1071;//rowSplitDataOneLevel[start + 1]; |
| | | int endx = 389;//rowSplitDataOneLevel[start + 2]; |
| | | int endy = 1078;//rowSplitDataOneLevel[start + 3]; |
| | | cv::imwrite(string("C:\\Users\\Administrator\\Desktop\\ocr\\l2分析\\test.png"), cv::Mat(img, cv::Rect(startx, starty, endx - startx + 1, endy - starty + 1))); |
| | | } |
| | | */ |
| | | |
| | | |
| | | |
| | | |
| | |
| | | //图像识别(除开数字的部分) |
| | | |
| | | int* notNumberResult = (int*)malloc(sizeof(int) * rowDataList.size() * 3); |
| | | openCLExcuter->recognitionNotNum(img.data, img.cols, img.rows, rowSplitDataOneLevel, 7, rowDataList.size(), notNumberResult); |
| | | openCLExcuter->recognitionNotNum(img.data, img.cols, img.rows, rowSplitDataOneLevel, ele_count_per_line, rowDataList.size(), notNumberResult); |
| | | |
| | | |
| | | int i = 0; |
| | |
| | | index = 0; |
| | | for (e = rowDataList.begin(); e != rowDataList.end(); e++) { |
| | | |
| | | int startS = index * 4 * 7; |
| | | int startS = index * 4 * ele_count_per_line; |
| | | |
| | | |
| | | int start = index * 4 * 4; |
| | |
| | | if (identify == 0 && ENABLE_LOG) |
| | | std::cout << "数据准备-位置数据准备: threadid-" << std::this_thread::get_id() << " 耗时:" << time_32 - time_31 << "总耗时:" << time_32 - time_1 << endl; |
| | | |
| | | // TODO 变成全局 |
| | | 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++) |
| | |
| | | free(totalNumberData); |
| | | throw string("splitL2Num出错"); |
| | | } |
| | | |
| | | //测试,展示图像 |
| | | //cv::Mat imgTest = cv::Mat::zeros(_NUMBER_L2_HEIGHT * rowDataList.size(), _NUMBER_L2_WIDTH * 10 * _NUMBER_L2_TOTAL_NUMBER, CV_8UC1); |
| | | //imgTest.data = totalNumberData; |
| | | //cv::imwrite("C:\\Users\\Administrator\\Desktop\\ocr\\l2分析\\test1.png", imgTest); |
| | | |
| | | |
| | | |
| | | |
| | |
| | | free(totalNumberData); |
| | | free(templateNums); |
| | | throw string("创建数据模板出错"); |
| | | |
| | | } |
| | | |
| | | //ImgUtil::createTemplateNumData(data.size()); |
| | |
| | | |
| | | string cancelTime = ""; |
| | | cancelTime.append(to_string(lineData[6])).append(to_string(lineData[7])); |
| | | |
| | | |
| | | string price = ""; |
| | | price.append(to_string(lineData[6 + 2])).append(to_string(lineData[7 + 2])).append(to_string(lineData[8 + 2])).append(to_string(lineData[9 + 2])); |