Skip to content

Commit

Permalink
Update detect.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Arbitrary-2912 authored Apr 24, 2023
1 parent f2ea019 commit bb5df0f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
# Distance (object_width / detected_pixel_width * focal_length)
frame_width = 0.106 # meters (measured relay pixel correspondence / literal width of frame)
frame_height = 0.151 # meters (measured relay pixel correspondence / literal height of frame)
focal_length = 0.5 # meters (calibrated camera specific value)
focal_length = 0.5 # 0.125 # meters (calibrated camera specific value)

# Object dimensions (for distance measurement)
cube_diagonal_width = 0.34 # meters (object diagonal width, measured for cube)
Expand Down Expand Up @@ -116,9 +116,9 @@ def get_distance(id, b):
dpw = math.hypot(b.xmax - b.xmin, b.ymax - b.ymin) * frame_width
x_dist = y_dist = 0
if id == 0: # cone (labels.txt)
x_dist = cone_diagonal_width * focal_length / dpw / 4
x_dist = cone_diagonal_width * focal_length / dpw
else: # cube (labels.txt)
x_dist = cube_diagonal_width * focal_length / dpw / 4
x_dist = cube_diagonal_width * focal_length / dpw
y_dist = x_dist * math.tan(get_angles(b)[0] * math.pi / 180)
return Point(x_dist, y_dist) # meters

Expand Down

0 comments on commit bb5df0f

Please sign in to comment.