Lenotary b8acbe6833 first commit | 2 yıl önce | |
---|---|---|
.idea | 2 yıl önce | |
cmake-build-debug | 2 yıl önce | |
dat | 2 yıl önce | |
images | 2 yıl önce | |
src | 2 yıl önce | |
CMakeLists.txt | 2 yıl önce | |
README.md | 2 yıl önce |
This Project present how to associate regions in a camera image with Lidar points in 3D space.
For more details, please check my blog.
-D OPENCV_ENABLE_NONFREE=ON
cmake flag for testing the SIFT and SURF detectors.Clone this repo.
Make a build directory in the top level project directory: mkdir build && cd build
Compile: cmake .. && make
Run it: ./project_lidar_to_camera
.
The code below shows how a filter can be applied to remove Lidar points that do not satisfy a set of constraints, i.e. they are …
for(auto it=lidarPoints.begin(); it!=lidarPoints.end(); ++it) {
float maxX = 25.0, maxY = 6.0, minZ = -1.4;
if(it->x > maxX || it->x < 0.0 || abs(it->y) > maxY || it->z < minZ || it->r<0.01 )
{
continue; // skip to next point
}
}
Convert current Lidar point into homogeneous coordinates and store it in the 4D variable X.
X.at<double>(0, 0) = it->x;
X.at<double>(1, 0) = it->y;
X.at<double>(2, 0) = it->z;
X.at<double>(3, 0) = 1;
Then, apply the projection equation to map X onto the image plane of the camera and Store the result in Y.
Y = P_rect_00 * R_rect_00 * RT * X;
Once this is done, transform Y back into Euclidean coordinates and store the result in the variable pt.
cv::Point pt;
pt.x = Y.at<double>(0, 0) / Y.at<double>(0, 2);
pt.y = Y.at<double>(1, 0) / Y.at<double>(0, 2);