From c699b06ff750003b81315009e80617041748d799 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 02 八月 2022 18:06:16 +0800 Subject: [PATCH] '完善' --- ConsoleApplication/kernel.cl | 43 +++++++++++++++++++++++++------------------ 1 files changed, 25 insertions(+), 18 deletions(-) diff --git a/ConsoleApplication/kernel.cl b/ConsoleApplication/kernel.cl index 70c52f8..c698be0 100644 --- a/ConsoleApplication/kernel.cl +++ b/ConsoleApplication/kernel.cl @@ -51,7 +51,7 @@ } //分隔板块数字 -__kernel void split_plate_num(__global const unsigned char* img_in, __global const int* pos_in, __global const unsigned char* zero, __global const unsigned char* types, int width, int num_width, int num_height, int ele_count_per_line,int length_per_num, +__kernel void split_plate_num(__global const unsigned char* img_in, __global const int* pos_in, __global const unsigned char* zero, __global const unsigned char* types, int width, int num_width, int num_height, int ele_count_per_line, int length_per_num, __global unsigned char* result) { int index = get_global_id(0); @@ -142,7 +142,7 @@ temp[8] = get_binary_value(img_in[get_one_level_position(width, startx + i - 2, endy - 2)]); temp[9] = get_binary_value(img_in[get_one_level_position(width, startx + i - 3, endy - 2)]); if (temp[3] > 0 && temp[2] > 0 && temp[6] > 0 && temp[7] > 0) { - int t = temp[0] + temp[1] + temp[4] + temp[5]+ temp[8]+ temp[9]; + int t = temp[0] + temp[1] + temp[4] + temp[5] + temp[8] + temp[9]; if (t == 0) { m1_s = i - 5; m1_e = i; @@ -170,7 +170,7 @@ temp[8] = get_binary_value(img_in[get_one_level_position(width, startx + i + 2, endy - 2)]); temp[9] = get_binary_value(img_in[get_one_level_position(width, startx + i + 3, endy - 2)]); if (temp[2] > 0 && temp[3] > 0 && temp[6] > 0 && temp[7] > 0) { - int t = temp[0] + temp[1] + temp[4] + temp[5]+ temp[8] + temp[9]; + int t = temp[0] + temp[1] + temp[4] + temp[5] + temp[8] + temp[9]; if (t == 0) { m2_s = i; m2_e = i + 5; @@ -194,7 +194,8 @@ nps[9] = -1; nps[10] = -1; nps[11] = -1; - }else { + } + else { //3个时间的坐标 nps[0] = startx; nps[1] = starty; @@ -334,7 +335,8 @@ nps[5] = -1; nps[6] = -1; nps[7] = -1; - }else { + } + else { nps[0] = startx; nps[1] = starty; nps[2] = startx + m_s - 1; @@ -347,7 +349,7 @@ } - + } @@ -429,8 +431,8 @@ } } - //代码 - else if (type == 3) { + //代码与数字 + else if (type == 3 || type == 4) { //手数 nps[0] = startx; nps[1] = starty; @@ -452,7 +454,7 @@ //最大分割20个数 int numCount = 0; //记录分割得到的数据 - int numberCols[20*2]; + int numberCols[20 * 2]; int i; for (i = 0;i < 3;i++) { @@ -566,7 +568,7 @@ int index_1 = r * (num_width * 10 * num_count); for (int c = 0;c < num_width;c++) { int findex = index_0 + index_1 + index_2 + index_3 + c; - //printf("index:%d-findex:%d value:%d \n", index, findex, numData[r * num_width + c]); + //printf("index:%d-findex:%d value:%d \n", index, findex, numData[r * num_width + c]); result[findex] = numData[r * num_width + c]; } } @@ -950,8 +952,8 @@ } } - //代码 - else if (type == 3) { + //代码与数字 + else if (type == 3 || type == 4) { //手数 nps[0] = startx; nps[1] = starty; @@ -973,7 +975,7 @@ //最大分割20个数 int numCount = 0; //记录分割得到的数据 - int numberCols[20*2]; + int numberCols[20 * 2]; int i; for (i = 0;i < 3;i++) { @@ -2064,7 +2066,7 @@ __global int* result) { int index = get_global_id(0); int start = index * 4; - int startx = rowIndexs[start+0]; + int startx = rowIndexs[start + 0]; int starty = rowIndexs[start + 1]; int endx = rowIndexs[start + 2]; int endy = rowIndexs[start + 3]; @@ -2080,15 +2082,20 @@ } } if (empty) { - unit_start = i+1; + unit_start = i + 1; break; } } + //printf("index:%d unit_start:%d\n", index, unit_start); + int count = 0; - for (int c = unit_start;c <= endx;c++) { - for (int y = starty;y <= endy;y++) { - count+=(get_binary_value(imgs[get_one_level_position(width, c, y)]) > 0 ? 1 : 0); + if (unit_start > -1) + { + for (int c = unit_start;c <= endx;c++) { + for (int y = starty;y <= endy;y++) { + count += (get_binary_value(imgs[get_one_level_position(width, c, y)]) > 0 ? 1 : 0); + } } } if (count >= 48) { -- Gitblit v1.8.0