File size: 870 Bytes
7d30f01
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import cv2
import pytesseract
import streamlit as st
import numpy as np

def main():
    st.title('Order ID Finder')

    uploaded_file = st.file_uploader('Upload an image', type=['png', 'jpg'])
    input_file = st.file_uploader('Upload the input file', type=['txt'])

    if uploaded_file and input_file:
        img = cv2.imdecode(np.fromstring(uploaded_file.read(), np.uint8), 1)
        gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
        text = pytesseract.image_to_string(gray)
        with input_file as file:
            file_contents = file.read()
            lines = file_contents.decode().splitlines()
            for line in lines:
                order_id, name, font = line.strip().split(',')
                if name.strip() in text:
                    st.success(f'Order ID: {order_id}')
                    break

if __name__ == '__main__':
    main()