Changed visualization

This commit is contained in:
charlesbvll 2021-05-01 17:25:13 +02:00
parent 40eddd66e4
commit a68699db62
3 changed files with 39 additions and 34 deletions

View File

@ -24,8 +24,10 @@ def cli():
help='what to output: json keypoints skeleton for Pifpaf'
'json bird front or multi for MonStereo')
predict_parser.add_argument('--no_save', help='to show images', action='store_true')
predict_parser.add_argument('--hide_distance', help='to not show the absolute distance of people from the camera',
default=False, action='store_true')
predict_parser.add_argument('--dpi', help='image resolution', type=int, default=150)
predict_parser.add_argument('--long-edge', default=None, type=int,
predict_parser.add_argument('--long_edge', default=None, type=int,
help='rescale the long side of the image (aspect ratio maintained)')
predict_parser.add_argument('--white-overlay',
nargs='?', default=False, const=0.8, type=float,
@ -60,7 +62,6 @@ def cli():
predict_parser.add_argument('--dropout', type=float, help='dropout parameter', default=0.2)
predict_parser.add_argument('--show_all', help='only predict ground-truth matches or all', action='store_true')
predict_parser.add_argument('--webcam', help='monstereo streaming', action='store_true')
predict_parser.add_argument('--scale', default=0.2, type=float, help='change the scale of the webcam image')
predict_parser.add_argument('--focal', help='focal length in mm for a sensor size of 7.2x5.4 mm. (nuScenes)',
type=float, default=5.7)

View File

@ -65,6 +65,7 @@ class Printer:
self.save = not args.no_save and not self.webcam
self.plt_close = not self.webcam
self.activities = args.activities
self.hide_distance = args.hide_distance
# define image attributes
self.attr = image_attributes(args.dpi, args.output_types)
@ -184,22 +185,22 @@ class Printer:
keypoint_sets, _ = get_pifpaf_outputs(annotations)
keypoint_painter = KeypointPainter(show_box=False, y_scale=self.y_scale)
if not self.hide_distance:
scores = self.dd_pred
else:
scores=None
if activities:
keypoint_painter.keypoints(
axis, keypoint_sets, size=self.im.size,
scores=self.dd_pred, colors=colors, activities=activities, dic_out=dic_out)
scores=scores, colors=colors, activities=activities, dic_out=dic_out)
if 'social_distance' in activities:
draw_orientation(axis, self.centers,
sizes, self.angles, colors, mode='front')
else:
keypoint_painter.keypoints(
axis, keypoint_sets, size=self.im.size, scores=self.dd_pred)
axis, keypoint_sets, size=self.im.size, colors=colors, scores=scores)
def _activities_bird(self, axis, colors, activities):
if 'social_distance' in activities:
draw_orientation(axis, self.xz_centers, [], self.angles, colors, mode='bird')
draw_orientation(axis, self.centers,
sizes, self.angles, colors, mode='front')
def _front_loop(self, iterator, axes, number, colors, annotations, dic_out):
@ -218,8 +219,7 @@ class Printer:
def _bird_loop(self, iterator, axes, colors, number):
for idx in iterator:
if any(xx in self.output_types for xx in ['bird', 'multi']) and self.zz_pred[idx] > 0:
if self.activities:
self._activities_bird(axes[1], colors, self.activities)
draw_orientation(axes[1], self.xz_centers, [], self.angles, colors, mode='bird')
# Draw ground truth and uncertainty
self._draw_uncertainty(axes, idx)
@ -231,9 +231,8 @@ class Printer:
def draw(self, figures, axes, image, dic_out=None, annotations=None):
colors = []
if self.activities:
colors = ['deepskyblue' for _ in self.uv_heads]
if self.activities:
if 'social_distance' in self.activities:
colors = social_distance_colors(colors, dic_out)
@ -291,6 +290,7 @@ class Printer:
x_t = x0 - 1.5
y_t = y1 + self.attr['y_box_margin']
if y_t < (self.height-10):
if not self.hide_distance:
ax.annotate(
text,
(x_t, y_t),
@ -429,13 +429,14 @@ class Printer:
else:
uv_max = [0., float(self.height)]
xyz_max = pixel_to_camera(uv_max, self.kk, self.z_max)
x_max = max(abs(xyz_max[0]), 6) # shortcut to avoid oval circles in case of different kk
x_max = abs(xyz_max[0]) # shortcut to avoid oval circles in case of different kk
corr = round(float(x_max / 3))
ax.plot([0, x_max], [0, self.z_max], 'k--')
ax.plot([0, -x_max], [0, self.z_max], 'k--')
ax.set_xlim(-x_max + corr, x_max - corr)
ax.set_ylim(0, self.z_max + 1)
ax.set_xlabel("X [m]")
ax.set_box_aspect(.8)
plt.xticks(fontsize=self.attr['fontsize_ax'])
plt.yticks(fontsize=self.attr['fontsize_ax'])
return ax

View File

@ -55,6 +55,8 @@ def factory_from_args(args):
args.no_save = True
args.batch_size = 1
if args.long_edge is None:
args.long_edge = 144
# Make default pifpaf argument
args.force_complete_pose = True
LOG.info("Force complete pose is active")
@ -88,7 +90,8 @@ def webcam(args):
while True:
start = time.time()
ret, frame = cam.read()
image = cv2.resize(frame, None, fx=args.scale, fy=args.scale)
scale = (args.long_edge)/frame.shape[0]
image = cv2.resize(frame, None, fx=scale, fy=scale)
height, width, _ = image.shape
print('resized image size: {}'.format(image.shape))
image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)