Browse Source

Update 'Business_cards/Business_cards.py'

SadhulaSaiKumar 1 year ago
parent
commit
263cc92ae5
1 changed files with 55 additions and 51 deletions
  1. 55
    51
      Business_cards/Business_cards.py

+ 55
- 51
Business_cards/Business_cards.py View File

@@ -64,13 +64,13 @@ def card():
64 64
     return render_template('card.html')
65 65
 
66 66
 
67
-
68 67
 @app.route('/upload_BusinessCards', methods=["POST"])
69 68
 # @app.route('/multiplecards', methods=["POST"])
70 69
 def multiplecards():
71 70
     # print('################## multiple card detection #######################')
72 71
     # print(Dataset)
73 72
     datalist=[]
73
+    zlist=[]
74 74
     Dataset = request.get_json()
75 75
     # print(data)
76 76
     #datalist.append(Dataset)
@@ -161,7 +161,7 @@ def multiplecards():
161 161
                 import pytesseract as tess
162 162
                 from PIL import Image
163 163
 
164
-                tess.pytesseract.tesseract_cmd = r"C:\Program Files\Tesseract-OCR\tesseract.exe"
164
+                tess.pytesseract.tesseract_cmd = r"C:\\Program Files (x86)\\Tesseract-OCR\\tesseract.exe"
165 165
                 pdf = tess.image_to_pdf_or_hocr(fname, extension="pdf")
166 166
                 with open("demo.pdf", "w+b", ) as f:
167 167
                     f.write(pdf)
@@ -406,21 +406,18 @@ def multiplecards():
406 406
         verticaltext = x
407 407
         htext = x
408 408
         # print('------------------------------------------------')
409
-        print(
410
-            '############################################################# this is verticaltext #################################################################')
411
-        print(verticaltext)
409
+        #print('############################################################# this is verticaltext #################################################################')
410
+       # print(verticaltext)
412 411
         htext = htext.replace('\n', ' ')
413
-        print(
414
-            '############################################################# this is htext #############################################################')
415
-        print(htext)
412
+       # print('############################################################# this is htext #############################################################')
413
+        #print(htext)
416 414
         y = x.replace('\n', ',')
417 415
         y = y.replace('  ', ' ')
418 416
         # y = y.replace(".", " .")
419 417
         horizontaltext = y
420 418
         # print('------------------------------------------------')
421
-        print(
422
-            '############################################################# this is horizontaltext #############################################################')
423
-        print(horizontaltext)
419
+        #print('############################################################# this is horizontaltext #############################################################')
420
+        #print(horizontaltext)
424 421
 
425 422
         textfile = open("test123456.txt", "w")
426 423
         a = textfile.write(verticaltext)
@@ -960,7 +957,7 @@ def multiplecards():
960 957
 
961 958
         # print(addrespinlst)
962 959
         import pgeocode
963
-        print(line12)
960
+        #print(line12)
964 961
         import re
965 962
         matche1 = re.findall(r'-\d{6}|\b\d{6}\b|\b\d{3}  \d{3}\b|-\d{3} \d{3}|\b\d{3} \d{3}\b', line12)
966 963
         for i in matche1:
@@ -1062,51 +1059,58 @@ def multiplecards():
1062 1059
         z.update(y)
1063 1060
         # the result is a JSON string:
1064 1061
         # print(json.dumps(z))
1065
-        zlist=[]
1062
+        
1066 1063
         zlist.append(z)
1067 1064
         #############################################creating csv#####################################
1068
-        print(final)
1069
-        print(imagelist)
1070
-        final.append('image--' + str(imagelist))
1071
-        import requests
1072
-        import json
1073
-        url = "https://anwi.bizgaze.app/apis/v4/bizgaze/integrations/businesscards/create/list" #dev
1074
-        # url = "https://qa.bizgaze.app/apis/v4/bizgaze/integrations/businesscards/create" #testing
1075
-        # url = "https://test.bizgaze.app/apis/v4/bizgaze/integrations/businesscards/create" # test
1076
-        # url='http://localhost:3088/apis/v4/bizgaze/integrations/businesscards/create'
1077
-        # url = 'https://c01.bizgaze.app/apis/v4/bizgaze/integrations/businesscards/create'  # C01
1078
-        payload1 = json.dumps(zlist)
1079
-        # print('--------------------------------------------------------------------------')
1080
-        #print(payload1)
1081
-        headers = {
1082
-            #'Authorization': 'stat 1a936137490040c997928f485e3cdd7a',   #dev
1083
-            'Authorization': 'stat 16516391d0074f4c8a15ea16fb49470b',#testing
1084
-            # 'Authorization': 'stat 08e55fcfbaa940c8ab8145a074c444d1',
1085
-            # 'Authorization': 'stat f7cdb402e01e44e5842878653946168f',  # c01
1086
-            # 'Authorization': 'Stat c3e11b2fcbfe455b86a1fe6efde02a69',#demo
1087
-            'Content-Type': 'application/json'
1088
-        }
1089
-        response = requests.request("POST", url, headers=headers, data=payload1)
1090
-        # print("##############################################################")
1091
-
1092
-        #print(payload1)
1093
-        print(response.text)
1094
-        import os
1095
-        if 'BusinessCards Created Successfully' in response.text:
1096
-            print('present')
1097
-            os.remove(found)
1098
-        else:
1099
-            print('not present')
1100
-
1101
-        df1.to_json('visitingcard.json')
1102
-        data = df1.to_json('visiting.json', orient='records')
1103
-        print(data)
1065
+        #print(final)
1066
+        #print(imagelist)
1067
+        #final.append('image--' + str(imagelist))
1068
+       #  import requests
1069
+       #  import json
1070
+
1071
+       # # url = "https://anwi.bizgaze.app/apis/v4/bizgaze/integrations/businesscards/create/list" #dev
1072
+       #  url = "https://qa.bizgaze.com/apis/v4/bizgaze/integrations/businesscards/create/list" #testing
1073
+       #  # url = "https://test.bizgaze.app/apis/v4/bizgaze/integrations/businesscards/create" # test
1074
+       #  # url='http://localhost:3088/apis/v4/bizgaze/integrations/businesscards/create'
1075
+       #  # url = 'https://c01.bizgaze.app/apis/v4/bizgaze/integrations/businesscards/create'  # C01
1076
+       #  payload1 = json.dumps(zlist)
1077
+       #  # print('--------------------------------------------------------------------------')
1078
+       #  #print(payload1)
1079
+       #  headers = {
1080
+       #      #'Authorization': 'stat 1a936137490040c997928f485e3cdd7a',   #dev
1081
+       #      # 'Authorization': 'stat 16516391d0074f4c8a15ea16fb49470b',#testing
1082
+       #      # 'Authorization': 'stat 08e55fcfbaa940c8ab8145a074c444d1',
1083
+       #      # 'Authorization': 'stat f7cdb402e01e44e5842878653946168f',  # c01
1084
+       #      #'Authorization': 'Stat c3e11b2fcbfe455b86a1fe6efde02a69',#demo
1085
+       #      'Authorization':'Stat e5bc6ad08f2c42feb5f98a2a521d00af',
1086
+
1087
+
1088
+       #      'Content-Type': 'application/json'
1089
+       #  }
1090
+       #  response = requests.request("POST", url, headers=headers, data=payload1)
1091
+       #  # print("##############################################################")
1092
+
1093
+       #  print(payload1)
1094
+       #  #print(zlist)
1095
+       #  # import os
1096
+       #  # if 'BusinessCards Created Successfully' in response.text:
1097
+       #  #     print('present')
1098
+       #  #     os.remove(found)
1099
+       #  # else:
1100
+       #  #     print('not present')
1101
+
1102
+       #  df1.to_json('visitingcard.json')
1103
+       #  data = df1.to_json('visiting.json', orient='records')
1104
+       #  print(data)
1104 1105
 
1105 1106
         #return render_template('index.html')
1106 1107
        
1107 1108
 
1108
-    return response.text
1109
-    # return 'done'
1109
+    #return response.text
1110
+    #return z
1111
+    return zlist
1112
+
1113
+
1110 1114
 
1111 1115
 
1112 1116
 if __name__ == "__main__":

Loading…
Cancel
Save