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 --- aoiOcr.py | 2 +- aoi_ocr/Ocr.py | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/aoiOcr.py b/aoiOcr.py index d1f7584..d09df59 100644 --- a/aoiOcr.py +++ b/aoiOcr.py @@ -28,7 +28,7 @@ "processed_scans/20160510075445995_0026.tif", ] # p=Paper(filename=pa[9], sid_classifier=classifier, settings=settings) -p = Paper(filename="sizif-test.tif", sid_classifier=classifier, settings=settings) +p = Paper(filename="sizif-test000.tif", sid_classifier=classifier, settings=settings) # print(p.QRData) # print(p.errors) 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