tobby48 4 years ago
parent
commit
4e271ffe63

BIN
src/main/python/kr/co/swh/lecture/opensource/ocr_tts/data/hello.mp3 View File


+ 17
- 0
src/main/python/kr/co/swh/lecture/opensource/ocr_tts/imagesplit.py View File

@@ -0,0 +1,17 @@
1
+from PIL import Image
2
+
3
+infile = "ja.PNG"
4
+chopsize = 300
5
+
6
+img = Image.open(infile)
7
+width, height = img.size
8
+
9
+# Save Chops of original image
10
+for x0 in range(0, width, chopsize):
11
+   for y0 in range(0, height, chopsize):
12
+      box = (x0, y0,
13
+             x0+chopsize if x0+chopsize <  width else  width - 1,
14
+             y0+chopsize if y0+chopsize < height else height - 1)
15
+      print('%s %s' % (infile, box))
16
+      img.crop(box).save('C:\\Users\\tobby48\\Desktop\\지문자\\zchop.%s.x%03d.y%03d.jpg' % (infile.replace('.jpg',''), x0, y0))
17
+    

+ 1
- 1
src/main/python/kr/co/swh/lecture/opensource/ocr_tts/s1_image_to_text.py View File

@@ -1,3 +1,3 @@
1 1
 import pytesseract
2 2
 pytesseract.pytesseract.tesseract_cmd = 'C:\\Program Files\\Tesseract-OCR\\tesseract'
3
-print(pytesseract.image_to_string('data\\test4.PNG',lang='kor'))
3
+print(pytesseract.image_to_string('data\\test3.png',lang='kor'))

+ 1
- 1
src/main/python/kr/co/swh/lecture/opensource/ocr_tts/s4_image_to_text_to_voice.py View File

@@ -3,7 +3,7 @@ import pygame
3 3
 import pytesseract
4 4
 
5 5
 pytesseract.pytesseract.tesseract_cmd = 'C:\\Program Files\\Tesseract-OCR\\tesseract'
6
-text = pytesseract.image_to_string('data\\test1.PNG',lang='kor')
6
+text = pytesseract.image_to_string('data\\test2.PNG',lang='kor')
7 7
 print(text)
8 8
 tts = gTTS(text=text, lang='ko')
9 9
 tts.save("data\\hello.mp3")

+ 1
- 1
src/main/python/kr/co/swh/lecture/opensource/ocr_tts/sspecial_image_to_text.py View File

@@ -10,7 +10,7 @@ grayImage = cv2.cvtColor(originalImage, cv2.COLOR_BGR2GRAY)
10 10
 cv2.imshow('Black white image', blackAndWhiteImage)
11 11
 cv2.imshow('Original image',originalImage)
12 12
 cv2.imshow('Gray image', grayImage)
13
-# cv2.waitKey(0)
13
+cv2.waitKey(0)
14 14
 
15 15
 
16 16
 pytesseract.pytesseract.tesseract_cmd = 'C:\\Program Files\\Tesseract-OCR\\tesseract'