Skip to content

Instantly share code, notes, and snippets.

@DharmarajX24
Created March 19, 2023 16:49
Show Gist options
  • Save DharmarajX24/9db4e4a766b5c863af5f8b55a9181628 to your computer and use it in GitHub Desktop.
Save DharmarajX24/9db4e4a766b5c863af5f8b55a9181628 to your computer and use it in GitHub Desktop.
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()
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