提交 c0eef572 编写于 作者: W wenlihaoyu

web页面显示OCR识别时间

上级 d0c41f60
......@@ -43,6 +43,7 @@ class OCR:
f.write(imgString)
img = Image.open(path).convert("RGB")
W,H = img.size
timeTake = time.time()
_,result,angle= model.model(img,detectAngle=True,config=dict(MAX_HORIZONTAL_GAP=200,
MIN_V_OVERLAPS=0.6,
MIN_SIZE_SIM=0.6,
......@@ -56,12 +57,13 @@ class OCR:
textmodel = 'opencv_dnn_detect'
),
leftAdjust=True,rightAdjust=True,alph=0.1)
timeTake = time.time()-timeTake
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)
return json.dumps({'res':res,'timeTake':round(timeTake,4)},ensure_ascii=False)
......
......@@ -12,7 +12,9 @@ function postImg(){
          success:function(d){
loadingGif('loadingGif');
imgJson['num']=0;//防止重复提交
imgJson["result"] = JSON.parse(d);
res = JSON.parse(d);
imgJson["result"] = res['res'];
imgJson["timeTake"] = res['timeTake'];
getChildDetail();
W = imgJson["width"];
H = imgJson["height"];
......@@ -75,7 +77,7 @@ function FunimgPreview(avatarSlect,avatarPreview,myCanvas) {
function getChildDetail(){
jQuery("#billmodeltable").remove();
childResult = imgJson["result"];
createTable(childResult);//新建table
createTable(childResult,imgJson['timeTake']);//新建table
}
......@@ -83,19 +85,19 @@ function getChildDetail(){
//根据获取的数据,创建table
//创建table
function createTable(result){
function createTable(result,timeTake){
//根据获取的数据,创建table
jQuery("#mytable").empty();
var jsObject = result;
//var jsObject = [{"name":10,"value":20},{"name":10,"value":20}];
var p = "<h2>识别结果为:</h2>"
var tableString = "<table id='billmodeltable' class='gridtable'><tr><th>序号</th><th>值</th></tr>"
var p = "<h3>耗时:"+timeTake+"秒 ,识别结果为:</h3>";
var tableString =p+ "<table id='billmodeltable' class='gridtable'><tr><th>序号</th><th>值</th></tr>"
for(var i=0;i<jsObject.length;i++){
tableString+="<tr><td><p>"+i+"</p></td><td><p contenteditable='true'>"+jsObject[i]["text"]+"</p></td></tr>";
}
tableString+="</table>";
jQuery("#mytable").append(p);
//jQuery("#mytable").append(p);
jQuery("#mytable").append(tableString);
}
......
......@@ -40,9 +40,9 @@ table.gridtable td {
imgJson = {"imgString":"",
"num":0,
"url":"",
"result":""
"result":"",
"timeTake":0.0
};
</script>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册