output = denoiseImage(input) output = rotateImage(input, 20) cv.imshow('12', output) cv.waitKey(0) cv.imwrite(GlobalParam.get_image_output(), output) ''' combine two images ''' input1 = cv.imread(GlobalParam.get_image_input(), cv.IMREAD_UNCHANGED) input2 = cv.imread(GlobalParam.get_image_output(), cv.IMREAD_UNCHANGED) output = resizeImage(combineTwoImages(input1, input2, 'portrait'), 1, 1, 2) ''' write text in image ''' # only can write ascii text input = cv.imread(GlobalParam.get_sentence_output(), cv.IMREAD_UNCHANGED) output = writeTextOnImageAscii(input, '12444', (20, 20), cv.FONT_HERSHEY_SIMPLEX, 1, (209, 80, 0, 255), 3) # write unicode text, like chinese, japanese... font_path = 'c:/windows/fonts/msyh.ttc' output = writeTextOnImageUnicode(GlobalParam.get_sentence_output(), '是否', (20, 75), font_path, 13, 'blue') ''' analyse image function ''' osuThreadHold(GlobalParam.get_image_input()) persperctiveImage(input, [[20, 17], [188, 16], [0, 80], [187, 70]], [[0, 0], [232, 0], [0, 112], [232, 112]]) detectTextAreaFromImage(input)
''' get text area, and write to file ''' input = cv.imread(GlobalParam.get_image_input(),cv.IMREAD_UNCHANGED) # showAllContours(input,detectTextAreaFromImage(input), 10, 5) input =findTextAreaContours(input,detectTextAreaFromImage(input),7,10,0,0,7,12) cv.imwrite(GlobalParam.get_image_output(),input) ''' split text area image to single character images, collect all images names and sort by names ''' getLastWordsContour(GlobalParam.get_image_output(), GlobalParam.get_character_output(), 50, 50, GlobalParam.get_sentence_output()) char_image_list=[] for i in os.listdir(GlobalParam.get_character_output()): char_image_list.append(int(i.replace('.png', ''))) char_length = len(char_image_list) char_image_list.sort() ''' get the ask questions text ''' ask_text = '' for i in char_image_list: if i < char_image_list[char_length - 2]: input1 = cv.imread(GlobalParam.get_character_output()+str(i)+'.png',cv.IMREAD_GRAYSCALE) ch1 = denoiseImage(resizeImage(input1,0.28,0.28,interpolationType[2])) ret,input1 = cv.threshold(ch1,170,255,cv.THRESH_BINARY)