Skip to content

Commit

Permalink
Move occlusion check to camera utisl
Browse files Browse the repository at this point in the history
  • Loading branch information
Ozzyz committed Feb 26, 2019
1 parent 725517d commit ef05cc8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
19 changes: 19 additions & 0 deletions camera_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,3 +116,22 @@ def draw_rect(array, pos, size, color=(255, 0, 255)):
for j in range(size):
array[int(point_0[0]+i), int(point_0[1]+j)] = color



def point_is_occluded(point, vertex_depth, depth_map):
""" Checks whether or not the four pixels directly around the given point has less depth than the given vertex depth
If True, this means that the point is occluded.
"""
y, x = map(int, point)
from itertools import product
neigbours = product((1, -1), repeat=2)
is_occluded = []
for dy, dx in neigbours:
if point_in_canvas((dy+y, dx+x)):
# If the depth map says the pixel is closer to the camera than the actual vertex
if depth_map[y+dy, x+dx] < vertex_depth:
is_occluded.append(True)
else:
is_occluded.append(False)
# Only say point is occluded if all four neighbours are closer to camera than vertex
return all(is_occluded)
17 changes: 0 additions & 17 deletions datageneration.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,23 +682,6 @@ def bbox_from_agent(agent, intrinsic_mat, extrinsic_mat, array, depth_map):



def point_is_occluded(point, vertex_depth, depth_map):
""" Checks whether or not the four pixels directly around the given point has less depth than the given vertex depth
If True, this means that the point is occluded.
"""
y, x = map(int, point)
from itertools import product
neigbours = product((1, -1), repeat=2)
is_occluded = []
for dy, dx in neigbours:
if point_in_canvas((dy+y, dx+x)):
# If the depth map says the pixel is closer to the camera than the actual vertex
if depth_map[y+dy, x+dx] < vertex_depth:
is_occluded.append(True)
else:
is_occluded.append(False)
# Only say point is occluded if all four neighbours are closer to camera than vertex
return all(is_occluded)


def calc_bbox2d_area(bbox_2d):
Expand Down

0 comments on commit ef05cc8

Please sign in to comment.