Close

Soln #3: Depth Estimation using LIDAR and PiCam

A project log for Multi-Domain Depth AI Usecases on the Edge

SLAM, ADAS-CAS, Sensor Fusion, Touch-less Attendance, Elderly Assist, Monocular Depth, Gesture & Security Cam with OpenVINO, Math & RPi

anand-uthamanAnand Uthaman 10/25/2021 at 06:190 Comments

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