Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
yinnxinn
chineseocr
提交
92fe49f8
C
chineseocr
项目概览
yinnxinn
/
chineseocr
与 Fork 源项目一致
从无法访问的项目Fork
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
chineseocr
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
92fe49f8
编写于
8月 06, 2019
作者:
W
wenlihaoyu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
优化代码,替换cpython\python\gpunms 为opencv dnn.nms;
上级
90fa7a4e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
48 addition
and
48 deletion
+48
-48
apphelper/redisbase.py
apphelper/redisbase.py
+48
-48
未找到文件。
apphelper/redisbase.py
浏览文件 @
92fe49f8
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Aug 4 23:30:48 2019
@author: chineseocr
"""
Created on Sun Aug 4 23:30:48 2019
@author: chineseocr
"""
import
redis
from
apphelper.image
import
PIL_to_base64
,
base64_to_PIL
pool
=
redis
.
ConnectionPool
(
host
=
'localhost'
,
port
=
6379
,
decode_responses
=
True
)
# host是redis主机,需要redis服务端和客户端都起着 redis默认端口是6379
...
...
@@ -17,8 +17,8 @@ import uuid
class
redisDataBase
:
"""
redis相关操作
"""
redis相关操作
"""
def
put_values
(
self
,
resJob
,
timeOut
=
20
):
##向队列推送PIL 并返回识别结果
timeBegin
=
time
.
time
()
...
...
@@ -31,29 +31,29 @@ class redisDataBase:
keys
.
append
(
ind
)
self
.
set_dict
(
imgStringTable
,
ind
,
value
)
self
.
set_list
(
jobListTable
,
ind
)
res
=
[
None
for
key
in
keys
]
while
time
.
time
()
-
timeBegin
<
timeOut
:
res
=
self
.
get_dict
(
resSetTable
,
keys
)
delres
=
[
x
for
x
in
res
if
x
is
not
None
]
if
len
(
delres
)
==
len
(
keys
):
break
##删除记录
for
key
in
keys
:
self
.
del_dict
(
imgStringTable
,
key
)
##删除缓存图像
self
.
del_dict
(
resSetTable
,
key
)
##删除缓存图像
for
ind
,
text
in
enumerate
(
res
):
resJob
[
ind
][
'text'
]
=
text
return
resJob
for
ind
,
text
in
enumerate
(
res
):
resJob
[
ind
][
'text'
]
=
text
return
resJob
def
get_job
(
self
,
callback
):
##获取队列中的图像
ind
=
self
.
get_list
(
jobListTable
)
...
...
@@ -70,44 +70,44 @@ return resJob
value
=
''
print
(
ind
,
value
)
self
.
set_dict
(
resSetTable
,
ind
,
value
)
##存储识别结果到set
def
set_list
(
self
,
name
,
value
):
"""
def
set_list
(
self
,
name
,
value
):
"""
向队列中推送识别值
"""
conn
.
rpush
(
name
,
value
)
def
get_list
(
self
,
name
):
conn
.
rpush
(
name
,
value
)
def
get_list
(
self
,
name
):
"""
获取队列值
"""
获取队列值
"""
value
=
conn
.
lpop
(
name
)
return
value
def
set_dict
(
self
,
name
,
key
,
value
):
"""
return
value
def
set_dict
(
self
,
name
,
key
,
value
):
"""
设置键值对
"""
conn
.
hset
(
name
,
key
,
value
)
def
get_dict
(
self
,
name
,
keys
):
conn
.
hset
(
name
,
key
,
value
)
def
get_dict
(
self
,
name
,
keys
):
"""
批量取出
"""
批量取出
"""
return
conn
.
hmget
(
name
,
keys
)
def
del_dict
(
self
,
name
,
key
):
conn
.
hdel
(
name
,
key
)
def
del_dict
(
self
,
name
,
key
):
conn
.
hdel
(
name
,
key
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录