Skip to content

Commit

Permalink
Fix visualize utils and add scaled obj output function for 3d lines v…
Browse files Browse the repository at this point in the history
…isualization (cvg#35)

* Fix visualize utils

* Add output option for visualizing 3d lines with scaling

* change output logic, add help description

* minor.

Co-authored-by: B1ueber2y <[email protected]>
  • Loading branch information
MarkYu98 and B1ueber2y authored Dec 9, 2022
1 parent 90cc7a4 commit 745ef00
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion limap/visualize/vis_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import matplotlib
import matplotlib.pyplot as plt
import seaborn as sns

import copy

def random_color():
r = int(255 * np.random.rand())
Expand All @@ -14,6 +14,7 @@ def random_color():


def draw_points(image, points, color=None, thickness=1):
image = copy.deepcopy(image)
for p in points:
c = random_color() if color is None else color
pos_x, pos_y = int(round(p[0])), int(round(p[1]))
Expand All @@ -22,6 +23,7 @@ def draw_points(image, points, color=None, thickness=1):


def draw_segments(image, segments, color=None, thickness=1, endpoints=True):
image = copy.deepcopy(image)
for s in segments:
c = random_color() if color is None else color
p1 = (int(s[0]), int(s[1]))
Expand All @@ -36,6 +38,7 @@ def draw_segments(image, segments, color=None, thickness=1, endpoints=True):
def draw_salient_segments(image, segments, saliency, color1=(0, 255, 0), color2=(0, 0, 255), thickness=1,
endpoints=True):
assert len(segments) == len(saliency)
image = copy.deepcopy(image)
max_saliency, min_saliency = np.max(saliency), np.min(saliency)
for s, s_saliency in zip(segments, saliency):
r = (s_saliency - min_saliency) / (max_saliency - min_saliency)
Expand All @@ -52,6 +55,7 @@ def draw_salient_segments(image, segments, saliency, color1=(0, 255, 0), color2=


def draw_multiscale_segments(img, segs, color=None, endpoints=True, thickness=2):
img = copy.deepcopy(img)
for s in segs:
mycolor = random_color() if color is None else color
octave, l = s[0]
Expand Down
3 changes: 3 additions & 0 deletions visualize_3d_lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ def parse_args():
arg_parser.add_argument('--use_robust_ranges', action='store_true', help="whether to use computed robust ranges")
arg_parser.add_argument('--scale', type=float, default=1.0, help="scaling both the lines and the camera geometry")
arg_parser.add_argument('--cam_scale', type=float, default=1.0, help="scale of the camera geometry")
arg_parser.add_argument('--output_dir', type=str, default=None, help="if set, save the scaled lines in obj format")
args = arg_parser.parse_args()
return args

Expand Down Expand Up @@ -51,6 +52,8 @@ def main(args):
raise ValueError("Error! Input file {0} is not valid".format(args.imagecols))
imagecols = _base.ImageCollection(limapio.read_npy(args.imagecols).item())
vis_reconstruction(linetracks, imagecols, mode=args.mode, n_visible_views=args.n_visible_views, ranges=ranges, scale=args.scale, cam_scale=args.cam_scale)
if args.output_dir is not None:
limapio.save_obj(args.output_dir, lines)

if __name__ == '__main__':
args = parse_args()
Expand Down

0 comments on commit 745ef00

Please sign in to comment.