未验证 提交 76204274 编写于 作者: L lijianshe02 提交者: GitHub

return rectantle box instead of circle when there is only a single face (#226)

上级 3e40542a
...@@ -154,6 +154,7 @@ class FirstOrderPredictor(BasePredictor): ...@@ -154,6 +154,7 @@ class FirstOrderPredictor(BasePredictor):
results.append({'rec': rec, 'predict': predictions}) results.append({'rec': rec, 'predict': predictions})
out_frame = [] out_frame = []
for i in range(len(driving_video)): for i in range(len(driving_video)):
frame = source_image.copy() frame = source_image.copy()
for result in results: for result in results:
...@@ -162,14 +163,17 @@ class FirstOrderPredictor(BasePredictor): ...@@ -162,14 +163,17 @@ class FirstOrderPredictor(BasePredictor):
w = x2 - x1 w = x2 - x1
out = result['predict'][i] * 255.0 out = result['predict'][i] * 255.0
out = cv2.resize(out.astype(np.uint8), (x2 - x1, y2 - y1)) out = cv2.resize(out.astype(np.uint8), (x2 - x1, y2 - y1))
patch = np.zeros(frame.shape).astype('uint8') if len(results) == 1:
patch[y1:y2, x1:x2] = out frame[y1:y2, x1:x2] = out
mask = np.zeros(frame.shape[:2]).astype('uint8') else:
cx = int((x1 + x2) / 2) patch = np.zeros(frame.shape).astype('uint8')
cy = int((y1 + y2) / 2) patch[y1:y2, x1:x2] = out
cv2.circle(mask, (cx, cy), math.ceil(h * self.ratio), mask = np.zeros(frame.shape[:2]).astype('uint8')
(255, 255, 255), -1, 8, 0) cx = int((x1 + x2) / 2)
frame = cv2.copyTo(patch, mask, frame) cy = int((y1 + y2) / 2)
cv2.circle(mask, (cx, cy), math.ceil(h * self.ratio),
(255, 255, 255), -1, 8, 0)
frame = cv2.copyTo(patch, mask, frame)
out_frame.append(frame) out_frame.append(frame)
imageio.mimsave(os.path.join(self.output, self.filename), imageio.mimsave(os.path.join(self.output, self.filename),
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册