File size: 1,507 Bytes
1512437
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import getopt, sys
import numpy as np
import cv2
import main

def testimg(sysargv):
	#====================================================================
	#	filename of image to load is a command line argument
	
	try:
		import RandomJunkPolygonGenerator
		for iii in range(14):
			cv2.imshow(str(iii), RandomJunkPolygonGenerator.returnImage())
		cv2.waitKey(0)
	except:
		abcdefghijklmnopqrstuvwxyz = 1 #do nothing
	
	if len(sysargv) <= 1:
		print("usage:  {image-file}  {optional:show-images?}")
		quit()
	
	filename_of_image = str(sysargv[1])
	showImages = True
	if len(sysargv) > 2:
		if int(sysargv[2]) == 0:
			showImages = False
	
	#====================================================================
	#	load the image
	
	loaded_image_mat = cv2.imread(filename_of_image)
	
	#check if it failed to load
	if np.size(loaded_image_mat) <= 1:
		print "ERROR: COULD NOT OPEN IMAGE FILE: " + filename_of_image
		return
	
	#====================================================================
	#	segmentation
	
	(c1char, c1conf, c1angle, c2char, c2conf, c2angle) = main.doOCR(loaded_image_mat, 0)
	
	#====================================================================
	#	display image and results
	
	print("top result: char == \'"+c1char+"\' at angle "+str(c1angle)+" with confidence "+str(c1conf))
	print("second-best result: char == \'"+c2char+"\' at angle "+str(c2angle)+" with confidence "+str(c2conf))
	


# execute main()... this needs to be at the end
if __name__ == "__main__":
	testimg(sys.argv)