更新sant在简单运行图像不对等显示问题
This commit is contained in:
@@ -19,32 +19,44 @@ def analyze(results, keys=None, num=0):
|
||||
#简单处理模型运行结果
|
||||
_onboard_tft = None
|
||||
|
||||
def simple_run(molde, camera, keys="len", num=0, color=0xF800, size=2, sync=True):
|
||||
def simple_run(molde, camera, keys="len", keyx=None, num=0, color=0xF800, size=2, sync=True):
|
||||
global _onboard_tft
|
||||
if _onboard_tft is None:
|
||||
from mixgo_sant import onboard_tft
|
||||
_onboard_tft = onboard_tft
|
||||
|
||||
if sync: _onboard_tft.fill(0, sync=False)
|
||||
_img = camera.capture()
|
||||
_onboard_tft.display(_img, sync=False)
|
||||
_result = molde.run(_img.image)
|
||||
_data = None
|
||||
|
||||
if _result:
|
||||
_x_of = (camera.get_pixel_width() - _onboard_tft.width) // 2
|
||||
_y_of = (camera.get_pixel_height() - _onboard_tft.height) // 2
|
||||
|
||||
for r in _result:
|
||||
x = 0
|
||||
y = 0
|
||||
|
||||
if r['box']:
|
||||
_onboard_tft.rect(r['box'][0], r['box'][1], r['box'][2], r['box'][3], color, sync=False)
|
||||
_onboard_tft.rect(r['box'][0] - _x_of, r['box'][1] - _y_of, r['box'][2], r['box'][3], color, sync=False)
|
||||
x = r['box'][0]
|
||||
y = r['box'][1] + r['box'][3]
|
||||
|
||||
if "person" in r:
|
||||
_onboard_tft.shows(r['person']['name'], x=x, y=y, size=size, center=0, color=color, sync=False)
|
||||
_onboard_tft.shows(r['person']['name'], x=x - _x_of, y=y - _y_of, size=size, center=0, color=color, sync=False)
|
||||
else:
|
||||
_onboard_tft.shows(r['data'], x=x, y=y, size=size, center=0, color=color, sync=False)
|
||||
if r['box']:
|
||||
_onboard_tft.shows(r['data'], x=x - _x_of, y=y - _y_of, size=size, center=0, color=color, sync=False)
|
||||
else:
|
||||
_onboard_tft.shows(r['data'], y=0, size=size, center=True, color=color, sync=False)
|
||||
break
|
||||
|
||||
if keys == "len":
|
||||
_data = len(_result)
|
||||
else:
|
||||
_data = _result[num][keys]
|
||||
_data = _result[num][keys] if keyx is None else _result[num][keys][keyx]
|
||||
|
||||
if sync: _onboard_tft.show()
|
||||
return _data
|
||||
|
||||
Reference in New Issue
Block a user