| | |
| | | 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 = [] |
| | |
| | | # 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): |
| | |
| | | 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 |