#include "3dReconst.h" #include "Autocalib.h" //rectifier epipolar Lines and image vector Reconst::RectificaEpipolarLines(vector image, vector > MeasureVector, vector fundMatrix) { vector outImage; vector tempImage=image; vector > tempMeasureVector=MeasureVector; cv::Mat Frect = (cv::Mat_(3,3) << 0,0,0,0,0,-1.0,0,1.0,0); cout << Frect << endl; Autocalib calib; for (int i=0;iinit(&tempImage[i],&tempImage[i+1],&fundMatrix[i],&MeasureVector[i],&MeasureVector[i+1]); rec->rectify(); cv::Mat input1, input2; rec->getResult(input1, input2,&MeasureVector[i],&MeasureVector[i+1]); outImage.push_back(input1); outImage.push_back(input2); cv::Mat retifImg; retifImg=calib.plotStereoWithEpilines(outImage[2*i],outImage[2*i+1],Frect,MeasureVector[i],MeasureVector[i+1]); cv::namedWindow( "Epipolar lines: rectified", cv::WINDOW_NORMAL ); cv::imshow("Epipolar lines: rectified", retifImg); tempMeasureVector[i+1].swap(MeasureVector[i+1]); cv::waitKey(0); } return outImage; } //get disparity map and the dense point void Reconst::disparity(vector image) { DenseMatcher DM; for (int i=0;i P, cv::Mat image ) { vector rectifiedMeseureMatrice=_densePoint; vector cameraMatrix=GetCameraMatrix(P); //cout< allPointCloud; Triangulator triang; for (int i=0;i ptCloud; ptCloud=triang.triangulatePoints_LinearLS(_densePoint[i], cameraMatrix[i]); //ptCloud.is_dense = true; int nbr=i; //save 3D point cloud in a file string name = "pointCloud"+to_string(nbr)+".pcd"; pcl::io::savePCDFileASCII (name, ptCloud); cerr << "Saved " << ptCloud.points.size () << " data points to pointCloud" < Reconst::GetCameraMatrix(vector P) { vector CameraMatrix; CameraMatrix.resize(P.size()-1); for(int i=0;i::Ptr cloud (new pcl::PointCloud); pcl::PCDWriter writer; // Fill in the cloud data pcl::PCDReader reader; // Replace the path below with the path where you saved your file reader.read (ss1.str (), *cloud); std::cerr << "Cloud before filtering: " << std::endl; std::cerr << *cloud << std::endl; // Creating the KdTree object for the search method of the extraction pcl::search::KdTree::Ptr tree (new pcl::search::KdTree); tree->setInputCloud (cloud); std::vector cluster_indices; pcl::EuclideanClusterExtraction ec; ec.setClusterTolerance (8); // 2cm ec.setMinClusterSize (30); ec.setMaxClusterSize (1000000); ec.setSearchMethod (tree); ec.setInputCloud (cloud); ec.extract (cluster_indices); if(cluster_indices.size()==0){ std::cout<<"no data"<::const_iterator it = cluster_indices.begin (); it != cluster_indices.end (); ++it) { pcl::PointCloud::Ptr cloud_cluster (new pcl::PointCloud); for (std::vector::const_iterator pit = it->indices.begin (); pit != it->indices.end (); ++pit) cloud_cluster->points.push_back (cloud->points[*pit]); //* cloud_cluster->width = cloud_cluster->points.size (); cloud_cluster->height = 1; cloud_cluster->is_dense = true; if(cloud_cluster->points.size ()>cloudSize) { std::cout << "PointCloud representing the Cluster: " << cloud_cluster->points.size () << " data points." << std::endl; std::stringstream ss2; ss2 << "pointCloud_filtered" < (ss2.str (), *cloud_cluster, false); cloudSize=cloud_cluster->points.size (); } //* } } }