浏览代码

Merge remote-tracking branch 'origin/master'

zeke-chin 2 年之前
父节点
当前提交
979b288058
共有 19 个文件被更改,包括 244 次插入0 次删除
  1. 二进制
      images/all/0/01.jpeg
  2. 二进制
      images/all/0/02.jpg
  3. 二进制
      images/all/0/03.png
  4. 二进制
      images/all/0/04.jpg
  5. 二进制
      images/all/0/05_0.jpg
  6. 二进制
      images/all/0/05_180.jpg
  7. 二进制
      images/all/0/05_270.jpg
  8. 二进制
      images/all/0/05_90.jpg
  9. 二进制
      images/all/1/01_0.png
  10. 二进制
      images/all/1/01_180.png
  11. 二进制
      images/all/1/01_270.png
  12. 二进制
      images/all/1/01_90.png
  13. 二进制
      images/all/1/02.jpg
  14. 二进制
      images/all/1/03.jpg
  15. 二进制
      images/all/1/04.jpg
  16. 二进制
      images/all/1/05.jpg
  17. 二进制
      images/all/1/mohu.jpg
  18. 二进制
      images/all/1/special.jpg
  19. 244 0
      testing/all_test.py

二进制
images/all/0/01.jpeg


二进制
images/all/0/02.jpg


二进制
images/all/0/03.png


二进制
images/all/0/04.jpg


二进制
images/all/0/05_0.jpg


二进制
images/all/0/05_180.jpg


二进制
images/all/0/05_270.jpg


二进制
images/all/0/05_90.jpg


二进制
images/all/1/01_0.png


二进制
images/all/1/01_180.png


二进制
images/all/1/01_270.png


二进制
images/all/1/01_90.png


二进制
images/all/1/02.jpg


二进制
images/all/1/03.jpg


二进制
images/all/1/04.jpg


二进制
images/all/1/05.jpg


二进制
images/all/1/mohu.jpg


二进制
images/all/1/special.jpg


+ 244 - 0
testing/all_test.py

@@ -0,0 +1,244 @@
+import unittest
+import base64
+from dataclasses import dataclass
+from pathlib import Path
+
+import requests
+
+# url = 'http://localhost:8080'
+url = 'http://192.168.199.107:48080'
+
+# header = {
+#     'Authorization': 'Bearer 9679c2b3-b90b-4029-a3c7-f347b4d242f7'
+# }
+
+# 带线框识别比较差 例:6.27_02.png
+
+def send_request(image_path, image_type='0'):
+    with open(image_path, 'rb') as f:
+        img_str: str = base64.encodebytes(f.read()).decode('utf-8')
+        r = requests.post(f'{url}/ocr_system/regbook', json={'image': img_str, 'image_type': image_type})
+        print(r.json())
+        return r.json()
+
+
+@dataclass
+class ResultItem0:
+    status: str
+    orientation: int
+    name: str
+    id: str
+    gender: str
+    birthplace: str
+    native_place: str
+    blood_type: str
+    religion: str
+
+@dataclass
+class ResultItem1:
+    status: str
+    orientation: int
+    type: str
+    address: str
+
+
+class TestSchoolCertOcr(unittest.TestCase):
+    def _helper0(self, image_path, item: ResultItem0, image_type='0'):
+        root = Path(__file__).parent
+        image_path = str(root / image_path)
+        r = send_request(image_path, image_type)
+        self.assertEqual(item, ResultItem0(status=r['status'],
+                                           orientation=r['result']['orientation'],
+                                           name=r['result']['name']['text'],
+                                           id=r['result']['id']['text'],
+                                           gender=r['result']['gender']['text'],
+                                           birthplace=r['result']['birthplace']['text'],
+                                           native_place=r['result']['native_place']['text'],
+                                           blood_type=r['result']['blood_type']['text'],
+                                           religion=r['result']['religion']['text']
+                                           ))
+
+    def _helper1(self, image_path, item: ResultItem1, image_type='1'):
+        root = Path(__file__).parent
+        image_path = str(root / image_path)
+        r = send_request(image_path, image_type)
+        self.assertEqual(item, ResultItem1(status=r['status'],
+                                           orientation=r['result']['orientation'],
+                                           type=r['result']['type']['text'],
+                                           address=r['result']['address']['text']
+                                           ))
+
+    # 0测试
+
+    # 方向、专业识别错误
+    def test_0_01(self):
+        image_path = '../images/all/0/01.jpeg'
+        self._helper0(image_path, ResultItem0(status='000',
+                                              orientation=0,
+                                              name='孙也桐',
+                                              id='230125199603270066',
+                                              gender='女',
+                                              birthplace='黑龙江省宾县',
+                                              native_place='黑龙江省宾县',
+                                              blood_type='',
+                                              religion=''))
+
+    def test_0_02(self):
+        image_path = '../images/all/0/02.jpg'
+        self._helper0(image_path, ResultItem0(status='000',
+                                              orientation=0,
+                                              name='宋国军',
+                                              id='152125610820051',
+                                              gender='男',
+                                              birthplace='内蒙古',
+                                              native_place='河南省陕县',
+                                              blood_type='A型',
+                                              religion='无'))
+
+    def test_0_03(self):
+        image_path = '../images/all/0/03.png'
+        self._helper0(image_path, ResultItem0(status='000',
+                                              orientation=0,
+                                              name='严倩文',
+                                              id='360502199810130927',
+                                              gender='女',
+                                              birthplace='江西省新余市渝水区',
+                                              native_place='江西省新余市渝水区',
+                                              blood_type='不明',
+                                              religion=''))
+
+    def test_0_04(self):
+        image_path = '../images/all/0/04.jpg'
+        self._helper0(image_path, ResultItem0(status='000',
+                                              orientation=0,
+                                              name='李晓令',
+                                              id='45212219940905067x',
+                                              gender='男',
+                                              birthplace='广西横县',
+                                              native_place='广西横县',
+                                              blood_type='',
+                                              religion='无宗教信仰'))
+
+    def test_0_05_0(self):
+        image_path = '../images/all/0/05_0.jpg'
+        self._helper0(image_path, ResultItem0(status='000',
+                                              orientation=0,
+                                              name='马宁',
+                                              id='64038219981016341x',
+                                              gender='男',
+                                              birthplace='宁夏灵武市无吴四队',
+                                              native_place='宁夏',
+                                              blood_type='B型',
+                                              religion=''))
+
+    def test_0_05_90(self):
+        image_path = '../images/all/0/05_90.jpg'
+        self._helper0(image_path, ResultItem0(status='000',
+                                              orientation=1,
+                                              name='马宁',
+                                              id='64038219981016341x',
+                                              gender='男',
+                                              birthplace='宁夏灵武市无吴四队',
+                                              native_place='宁夏',
+                                              blood_type='B型',
+                                              religion=''))
+
+    def test_0_05_180(self):
+        image_path = '../images/all/0/05_180.jpg'
+        self._helper0(image_path, ResultItem0(status='000',
+                                              orientation=2,
+                                              name='马宁',
+                                              id='64038219981016341x',
+                                              gender='男',
+                                              birthplace='宁夏灵武市无吴四队',
+                                              native_place='宁夏',
+                                              blood_type='B型',
+                                              religion=''))
+
+    def test_0_05_270(self):
+        image_path = '../images/all/0/05_270.jpg'
+        self._helper0(image_path, ResultItem0(status='000',
+                                              orientation=3,
+                                              name='马宁',
+                                              id='64038219981016341x',
+                                              gender='男',
+                                              birthplace='宁夏灵武市无吴四队',
+                                              native_place='宁夏',
+                                              blood_type='B型',
+                                              religion=''))
+
+
+
+
+    def test_1_01_0(self):
+        image_path = '../images/all/1/01_0.png'
+        self._helper1(image_path, ResultItem1(status='000',
+                                              orientation=0,
+                                              type='居民家庭户口',
+                                              address='江西省新余市渝水区胜利南路183号1栋1单元1402室'))
+
+    def test_1_01_90(self):
+        image_path = '../images/all/1/01_90.png'
+        self._helper1(image_path, ResultItem1(status='000',
+                                              orientation=1,
+                                              type='居民家庭户口',
+                                              address='江西省新余市渝水区胜利南路183号1栋1单元1402室'))
+
+    def test_1_01_180(self):
+        image_path = '../images/all/1/01_180.png'
+        self._helper1(image_path, ResultItem1(status='000',
+                                              orientation=2,
+                                              type='居民家庭户口',
+                                              address='江西省新余市渝水区胜利南路183号1栋1单元1402室'))
+
+    def test_1_01_270(self):
+        image_path = '../images/all/1/01_270.png'
+        self._helper1(image_path, ResultItem1(status='000',
+                                              orientation=3,
+                                              type='居民家庭户口',
+                                              address='江西省新余市渝水区胜利南路183号1栋1单元1402室'))
+
+    def test_1_02(self):
+        image_path = '../images/all/1/02.jpg'
+        self._helper1(image_path, ResultItem1(status='000',
+                                              orientation=0,
+                                              type='非农业家庭户口',
+                                              address='东岭东委9组东岭南街解困小区9栋1门201号'))
+
+    def test_1_03(self):
+        image_path = '../images/all/1/03.jpg'
+        self._helper1(image_path, ResultItem1(status='000',
+                                              orientation=0,
+                                              type='居民户口',
+                                              address='黑龙江省桦川县东河乡兴安村1组'))
+
+    def test_1_04(self):
+        image_path = '../images/all/1/04.jpg'
+        self._helper1(image_path, ResultItem1(status='000',
+                                              orientation=0,
+                                              type='乡村家庭户',
+                                              address='宁夏吴忠市利通区金积镇丁家湾子村18040号'))
+
+    def test_1_05(self):
+        image_path = '../images/all/1/05.jpg'
+        self._helper1(image_path, ResultItem1(status='000',
+                                              orientation=0,
+                                              type='乡村家庭户',
+                                              address='宁夏吴忠市利通区郭家桥乡吴桥村四队88号'))
+
+    def test_1_mohu(self):
+        image_path = '../images/all/1/mohu.jpg'
+        self._helper1(image_path, ResultItem1(status='000',
+                                              orientation=0,
+                                              type='家庭户',
+                                              address='甘肃省林洮县康家集乡大头山村羊角湾社'))
+
+    def test_1_special(self):
+        image_path = '../images/all/1/special.jpg'
+        self._helper1(image_path, ResultItem1(status='000',
+                                              orientation=0,
+                                              type='居民家庭户',
+                                              address='安徽省马鞍山市花山区湖北东路479号4栋405室'))
+
+if __name__ == '__main__':
+    unittest.main()