From bcebb8f17360fab0f4d22178bef2d33851fef312 Mon Sep 17 00:00:00 2001 From: Samo Penic <samo.penic@gmail.com> Date: Fri, 30 Nov 2018 07:58:51 +0000 Subject: [PATCH] Moved the answer ROIs few pixels. Recommended threshold around 0.3 --- aoi_ocr/Ocr.py | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-) diff --git a/aoi_ocr/Ocr.py b/aoi_ocr/Ocr.py index e022ff1..99ad414 100644 --- a/aoi_ocr/Ocr.py +++ b/aoi_ocr/Ocr.py @@ -216,12 +216,12 @@ self.locateUpMarkers() self.locateRightMarkers() - roixoff = 10 - roiyoff = 5 - roiwidth = 50 + roixoff = 4 + roiyoff = 0 + roiwidth = 55 roiheight = roiwidth totpx = roiwidth * roiheight - + cimg = cv2.cvtColor(self.img, cv2.COLOR_GRAY2BGR) self.answerMatrix = [] for y in self.yMarkerLocations[0]: oneline = [] @@ -233,6 +233,8 @@ # cv2.imwrite('ans_x'+str(x)+'_y_'+str(y)+'.png',roi) black = totpx - cv2.countNonZero(roi) oneline.append(black / totpx) + cv2.rectangle(cimg, (x - roixoff,y - roiyoff), (x + int(roiwidth - roixoff),y + int(roiheight - roiyoff)), (0, 255, 255), 2) + cv2.imwrite('/tmp/debug_answers.png',cimg) self.answerMatrix.append(oneline) def get_enhanced_sid(self): @@ -307,4 +309,5 @@ output_filename=os.path.join(self.output_path, '.'.join(self.filename.split('/')[-1].split('.')[:-1])+".png") cv2.imwrite(output_filename, self.img) data['output_filename']=output_filename + print(np.array(self.answerMatrix)) return data -- Gitblit v1.9.3