Skip to content

Commit

Permalink
add darknet repo as a submodule of this project.
Browse files Browse the repository at this point in the history
  • Loading branch information
zergmk2 committed Aug 23, 2018
1 parent 0ebf3a7 commit 16d7639
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "darknet"]
path = darknet
url = https://github.com/zergmk2/darknet.git
30 changes: 15 additions & 15 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@
import sys
import base64

import web
import web

web.config.debug = True
web.config.debug = True
from apphelper.image import convert_image,read_url_img,string_to_array,array_to_string,base64_to_array
import model
render = web.template.render('templates', base='base')


class OCR:
"""通用OCR识别"""
def GET(self):

def GET(self):
post = {}
post['postName'] = u'ocr'##请求地址
post['height'] = 1000
Expand All @@ -31,8 +31,8 @@ def GET(self):
post['W'] = 600
post['uuid'] = uuid.uuid1().__str__()
return render.ocr(post)
def POST(self):

def POST(self):
data = web.data()
data = json.loads(data)
imgString = data['imgString'].encode().split(b';base64,')[-1]
Expand All @@ -43,7 +43,7 @@ def POST(self):
f.write(imgString)
img = Image.open(path).convert("RGB")
W,H = img.size
_,result,angle= model.model(img,detectAngle=True,config=dict(MAX_HORIZONTAL_GAP=200,
_,result,angle= model.model(img,detectAngle=True,config=dict(MAX_HORIZONTAL_GAP=200,
MIN_V_OVERLAPS=0.6,
MIN_SIZE_SIM=0.6,
TEXT_PROPOSALS_MIN_SCORE=0.2,
Expand All @@ -55,20 +55,20 @@ def POST(self):
MIN_NUM_PROPOSALS=0,
),
leftAdjust=True,rightAdjust=True,alph=0.1)
res = map(lambda x:{'w':x['w'],'h':x['h'],'cx':x['cx'],'cy':x['cy'],'degree':x['degree'],'text':x['text']}, result)

res = map(lambda x:{'w':x['w'],'h':x['h'],'cx':x['cx'],'cy':x['cy'],'degree':x['degree'],'text':x['text']}, result)
res = list(res)

os.remove(path)
return json.dumps(res,ensure_ascii=False)




urls = (u'/ocr',u'OCR',
)
if __name__ == "__main__":
app = web.application(urls, globals())

if __name__ == "__main__":

app = web.application(urls, globals())
app.run()
2 changes: 1 addition & 1 deletion config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
darknetRoot = os.path.join("..","darknet")## yolo 安装目录
darknetRoot = os.path.join(os.path.curdir,"darknet")## yolo 安装目录
pwd = os.getcwd()
yoloCfg = os.path.join(pwd,"models","text.cfg")
yoloWeights = os.path.join(pwd,"models","text.weights")
Expand Down
1 change: 1 addition & 0 deletions darknet
Submodule darknet added at 9e406a

0 comments on commit 16d7639

Please sign in to comment.