# How to capture the text in OCR

**URL:** <https://forum.opencv.org/t/how-to-capture-the-text-in-ocr/11826>\
**Category:** Python\
**Tags:** programming\
**Created:** [January 31, 2023, 9:34am UTC](https://forum.opencv.org/t/how-to-capture-the-text-in-ocr/11826 "2023-01-31T09:34:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sweety](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/sweety/32/7025_2.png) [@sweety](https://forum.opencv.org/u/sweety)\
**Post date:** [January 31, 2023, 9:34am UTC](https://forum.opencv.org/t/how-to-capture-the-text-in-ocr/11826/1 "2023-01-31T09:34:52Z")

</div>

How to capture the text by pressing a key without displaying the frame in OCR.

def detect\_ocr(frame):  
if cv2.waitKey(1) & 0XFF == ord(“s”):  
text = pytesseract.image\_to\_string(frame)  
print(text)  
#cv2.imshow(“Frame”,frame)  
cv2.waitKey(1)
