Reputation: 33
How can I get characters from this photo. I tried the code, but it was still difficult for OCR to recognize
import cv2
TEXT_TOP = 680
TEXT_BOTTOM = 740
TEXT_LEFT = 280
TEXT_RIGHT = 1080
img = cv2.imread ('2.jpg')
cropped = img [TEXT_TOP: TEXT_BOTTOM, TEXT_LEFT: TEXT_RIGHT]
white_region = cv2.inRange (cropped, (200, 200, 200), (255, 255, 255))
cv2.imshow ('white_region', white_region)
cv2.waitKey (10000)
Upvotes: 2
Views: 12957
Reputation: 86
follow this link it will help you to extract text from images but as per your question ill recommend you to iterate over the frames of your image and apply the link method to extract text from entire video.But if you want to extract only subtitles then only scan for text at header and footer of the frames.
Upvotes: 3