We need to find out the distance to the person from the door. This can be estimated using a proximity sensor or by using LIDAR along with the subtending angles. As we have already integrated LIDAR for other solutions, here we intend to estimate depth using LIDAR by computing the median distance of LIDAR laser points between two subtending angles, based on LIDAR - Picam position (triangulation)
def getObjectDistance (angle_min, angle_max):
minDist = 0
lidar = RPLidar(None, PORT_NAME)
try:
for scan in lidar_scans(lidar):
for (_, angle, distance) in scan:
scan_data[min([359, floor(angle)])] = distance
# fetching all non zero distance values between subtended angles
allDists = [scan_data[i] for i in range(360)
if i >= angle_min and i <= angle_max and scan_data[i] > 0]
# if half the distance values are filled in then break
if (2 * len(allDists) > angle_max - angle_min):
minDist = np.min(allDists)
lidar.stop()
lidar.disconnect()
return minDist
except KeyboardInterrupt:
print('Stoping LIDAR Scan')
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.