Advertisement
Guest User

Untitled

a guest
Jul 21st, 2019
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. image = cv2.imread(args["image"])
  2. gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
  3. gray = cv2.resize(gray, None, fx=2, fy=2, interpolation=cv2.INTER_CUBIC)
  4.  
  5. if args["preprocess"] == "thresh":
  6. gray = cv2.threshold(gray, 0, 255,
  7. cv2.THRESH_BINARY | cv2.THRESH_OTSU)[1]
  8.  
  9. elif args["preprocess"] == "blur":
  10. gray = cv2.medianBlur(gray, 3)
  11. filename = "Screens/{}.png".format(os.getpid())
  12.  
  13. cv2.imwrite(filename, gray)
  14. text = pytesseract.image_to_string(Image.open(filename), lang='vie')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement