1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- import unittest
- import base64
- import requests
- from pathlib import Path
- url = 'http://192.168.199.107:18099'
- def send_request(image_path):
- with open(image_path, 'rb') as f:
- img_str: str = base64.encodebytes(f.read()).decode('utf-8')
- payload = {'image': img_str, 'det': 'conv'}
- print(payload)
- r = requests.post(f'{url}/ocr_system/table', json=payload)
- print(r.json())
- return r.json()
- class TestTableOcr(unittest.TestCase):
- # def test_it_work(self):
- # pong = requests.request("GET", '/'.join([url, 'ping']))
- # self.assertEqual('"pong!"', pong.text, 'Not work')
- # def test_table_01(self):
- # print("270")
- # fn = Path(__file__).parent / '../images/01.jpeg'
- # res = send_request(fn)
- # self.assertEqual('000', res['status'], 'Not work')
- def test_table_02(self):
- print("270")
- fn = Path(__file__).parent / '../images/02.jpg'
- res = send_request(fn)
- # self.assertEqual('000', res['status'], 'Not work')
- #
- # def test_table_03(self):
- # res = send_request('./images/03.jpg')
- # self.assertEqual('000', res['status'], 'Not work')
- #
- # def test_table_04(self):
- # res = send_request('./images/04.jpg')
- # self.assertEqual('000', res['status'], 'Not work')
- #
- # def test_table_05(self):
- # res = send_request('./images/05.jpeg')
- # self.assertEqual('000', res['status'], 'Not work')
- #
- # def test_table_06(self):
- # res = send_request('./images/06.jpeg')
- # self.assertEqual('000', res['status'], 'Not work')
- #
- # def test_table_07(self):
- # res = send_request('./images/07.jpeg')
- # self.assertEqual('000', res['status'], 'Not work')
- #
- # def test_table_08(self):
- # res = send_request('./images/08.jpg')
- # self.assertEqual('000', res['status'], 'Not work')
- if __name__ == '__main__':
- unittest.main()
|