Development of the ocr part of AOI
Samo Penic
2018-11-30 bcebb8f17360fab0f4d22178bef2d33851fef312
Moved the answer ROIs few pixels. Recommended threshold around 0.3
2 files modified
13 ■■■■■ changed files
aoiOcr.py 2 ●●● patch | view | raw | blame | history
aoi_ocr/Ocr.py 11 ●●●●● patch | view | raw | blame | history
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)
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