Created
March 19, 2023 16:49
-
-
Save DharmarajX24/9db4e4a766b5c863af5f8b55a9181628 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import pytesseract | |
camera = cv2.VideoCapture(0) | |
cv2.namedWindow("Image Capture") | |
def capture_image_and_extract_text(): | |
ret, image = camera.read() | |
text = pytesseract.image_to_string(image) | |
print(text) | |
def button_click_event(event, x, y, flags, param): | |
if event == cv2.EVENT_LBUTTONDOWN: | |
capture_image_and_extract_text() | |
while True: | |
ret, image = camera.read() | |
cv2.imshow("Image Capture", image) | |
cv2.setMouseCallback("Image Capture", button_click_event) | |
if cv2.waitKey(1) == ord("q"): | |
break | |
# release camera | |
camera.release() | |
cv2.destroyAllWindows() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
import pytesseract | |
image = cv2.imread("image.png") | |
text = pytesseract.image_to_string(image) | |
print(text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment