Example #1
0
void Segmenter::createTrainFile()
{
  if( (!have_cloud) || (!have_cloud_l) )
  {
    char* error_message = new char[200];
    sprintf(error_message,"[%s::segment()]: I suggest you first set the point cloud.",ClassName.c_str()); // and normals
    throw std::runtime_error(error_message);
  }

  calculateNormals();
  calculatePatches();
//   v4r::View view;
  view.Reset();
  view.setPointCloud(pcl_cloud);
  view.normals = normals;
  view.setSurfaces(surfaces);
  surfaces = view.surfaces;

  view.createPatchImage();
  view.computeNeighbors();
  surfaces = view.surfaces;
  view.calculateBorders(view.cloud);
  ngbr3D_map = view.ngbr3D_map;
  ngbr2D_map = view.ngbr2D_map;
  preComputeRelations();
  initModelSurfaces();
  modelSurfaces();
  
  computeRelations();

  addGroundTruth.setInputCloud(pcl_cloud_l);
  addGroundTruth.setSurfaces(surfaces);
  addGroundTruth.setRelations(validRelations);
  addGroundTruth.compute(v4r::STRUCTURAL_RELATIONS);
  
  surfaces = addGroundTruth.getSurfaces();
  validRelations = addGroundTruth.getRelations();
  
  svmFileCreator.setSurfaces(surfaces);
  svmFileCreator.setRelations(validRelations);
  svmFileCreator.setAnalyzeOutput(false);
  
  svmFileCreator.setFeatureNumber(-1);
  svmFileCreator.setFilenameBase(train_ST_file_name);
  svmFileCreator.setFilenameAsBase(train_AS_file_name);
  svmFileCreator.process();
}
Example #2
0
void Segmenter::attentionSegmentInit()
{
  if( (!have_cloud) || (!have_saliencyMaps) )
  {
    char* error_message = new char[200];
    sprintf(error_message,"[%s::segment()]: I suggest you first set the point cloud.",ClassName.c_str()); // and normals
    throw std::runtime_error(error_message);
  }
  
  masks.resize(saliencyMaps.size());

v4r::TimeEstimationClass timeEstimationClass_All(CLOCK_THREAD_CPUTIME_ID);//CLOCK_THREAD_CPUTIME_ID);//CLOCK_PROCESS_CPUTIME_ID
v4r::TimeEstimationClass timeEstimationClass_Custom(CLOCK_THREAD_CPUTIME_ID);

timeEstimationClass_All.countingStart();
  
timeEstimationClass_Custom.countingStart();
  calculateNormals();
timeEstimationClass_Custom.countingEnd();
timeEstimates.time_normalsCalculation = timeEstimationClass_Custom.getWorkTimeInNanoseconds();

timeEstimationClass_Custom.countingStart();
  calculatePatches();
timeEstimationClass_Custom.countingEnd();
timeEstimates.time_patchesCalculation = timeEstimationClass_Custom.getWorkTimeInNanoseconds();

timeEstimationClass_Custom.countingStart();
  view.Reset();
  view.setPointCloud(pcl_cloud);
  view.normals = normals;
  view.setSurfaces(surfaces);
  surfaces = view.surfaces;
  
  view.createPatchImage();
timeEstimationClass_Custom.countingEnd();
timeEstimates.time_patchImageCalculation = timeEstimationClass_Custom.getWorkTimeInNanoseconds();

timeEstimationClass_Custom.countingStart();
  view.computeNeighbors();
timeEstimationClass_Custom.countingEnd();
timeEstimates.time_neighborsCalculation = timeEstimationClass_Custom.getWorkTimeInNanoseconds();

timeEstimationClass_Custom.countingStart();
  surfaces = view.surfaces;
  view.calculateBorders(view.cloud);
  ngbr3D_map = view.ngbr3D_map;
  ngbr2D_map = view.ngbr2D_map;
timeEstimationClass_Custom.countingEnd();
timeEstimates.time_borderCalculation = timeEstimationClass_Custom.getWorkTimeInNanoseconds();

timeEstimationClass_Custom.countingStart();
  preComputeRelations();
timeEstimationClass_Custom.countingEnd();
timeEstimates.time_relationsPreComputation = timeEstimationClass_Custom.getWorkTimeInNanoseconds();

timeEstimationClass_Custom.countingStart();
  initModelSurfaces();
timeEstimationClass_Custom.countingEnd();
timeEstimates.time_initModelSurfaces = timeEstimationClass_Custom.getWorkTimeInNanoseconds();

timeEstimates.times_saliencySorting.resize(saliencyMaps.size());
timeEstimates.times_surfaceModelling.resize(saliencyMaps.size());
timeEstimates.times_relationsComputation.resize(saliencyMaps.size());
timeEstimates.times_graphBasedSegmentation.resize(saliencyMaps.size());
timeEstimates.times_maskCreation.resize(saliencyMaps.size());
timeEstimates.times_neigboursUpdate.resize(saliencyMaps.size());
timeEstimates.time_totalPerSegment.resize(saliencyMaps.size());

  if(saliencyMaps.size() == 1)
  {
v4r::TimeEstimationClass timeEstimationClass_CustomLoop(CLOCK_THREAD_CPUTIME_ID);
timeEstimationClass_CustomLoop.countingStart();
    view.setSaliencyMap(saliencyMaps.at(0));
//     cv::imshow("saliencyMaps.at(i)",saliencyMaps.at(i));
//     cv::waitKey(-1);
    view.sortPatches();
    surfaces = view.surfaces;
    
    for(size_t j = 0; j < surfaces.size(); j++)
    {
      surfaces.at(j)->selected = false;
      surfaces.at(j)->isNew = false;
    }
timeEstimationClass_CustomLoop.countingEnd();
timeEstimates.times_saliencySorting.at(0) = timeEstimationClass_CustomLoop.getWorkTimeInNanoseconds();
  }
  
timeEstimationClass_All.countingEnd();
timeEstimates.time_total = timeEstimationClass_All.getWorkTimeInNanoseconds();
  
}
Example #3
0
void Segmenter::segment()
{
  if( (!have_cloud) )//|| (!have_normals) )
  {
    char* error_message = new char[200];
    sprintf(error_message,"[%s::segment()]: I suggest you first set the point cloud.",ClassName.c_str()); // and normals
    throw std::runtime_error(error_message);
  }

v4r::TimeEstimationClass timeEstimationClass_All(CLOCK_THREAD_CPUTIME_ID);
v4r::TimeEstimationClass timeEstimationClass_Custom(CLOCK_THREAD_CPUTIME_ID);

timeEstimationClass_All.countingStart();

timeEstimationClass_Custom.countingStart();
  calculateNormals();
timeEstimationClass_Custom.countingEnd();
timeEstimates.time_normalsCalculation = timeEstimationClass_Custom.getWorkTimeInNanoseconds();

timeEstimationClass_Custom.countingStart();
  calculatePatches();
timeEstimationClass_Custom.countingEnd();
timeEstimates.time_patchesCalculation = timeEstimationClass_Custom.getWorkTimeInNanoseconds();

timeEstimationClass_Custom.countingStart();
//   v4r::View view;
  view.Reset();
  view.setPointCloud(pcl_cloud);
  view.normals = normals;
  view.setSurfaces(surfaces);
  surfaces = view.surfaces;

  view.createPatchImage();
timeEstimationClass_Custom.countingEnd();
timeEstimates.time_patchImageCalculation = timeEstimationClass_Custom.getWorkTimeInNanoseconds();

timeEstimationClass_Custom.countingStart();
  view.computeNeighbors();
timeEstimationClass_Custom.countingEnd();
timeEstimates.time_neighborsCalculation = timeEstimationClass_Custom.getWorkTimeInNanoseconds();

timeEstimationClass_Custom.countingStart();
  surfaces = view.surfaces;
  view.calculateBorders(view.cloud);
  ngbr3D_map = view.ngbr3D_map;
  ngbr2D_map = view.ngbr2D_map;
timeEstimationClass_Custom.countingEnd();
timeEstimates.time_borderCalculation = timeEstimationClass_Custom.getWorkTimeInNanoseconds();

timeEstimationClass_Custom.countingStart();
  preComputeRelations();
timeEstimationClass_Custom.countingEnd();
timeEstimates.time_relationsPreComputation = timeEstimationClass_Custom.getWorkTimeInNanoseconds();

timeEstimationClass_Custom.countingStart();
  initModelSurfaces();
timeEstimationClass_Custom.countingEnd();
timeEstimates.time_initModelSurfaces = timeEstimationClass_Custom.getWorkTimeInNanoseconds();

timeEstimationClass_Custom.countingStart();
  modelSurfaces();
timeEstimationClass_Custom.countingEnd();
timeEstimates.times_surfaceModelling.clear();
timeEstimates.times_surfaceModelling.push_back(timeEstimationClass_Custom.getWorkTimeInNanoseconds());

timeEstimationClass_Custom.countingStart();
  computeRelations();
timeEstimationClass_Custom.countingEnd();
timeEstimates.times_relationsComputation.clear();
timeEstimates.times_relationsComputation.push_back(timeEstimationClass_Custom.getWorkTimeInNanoseconds());

timeEstimationClass_Custom.countingStart();
  graphBasedSegmentation();
timeEstimationClass_Custom.countingEnd();
timeEstimates.times_graphBasedSegmentation.clear();
timeEstimates.times_graphBasedSegmentation.push_back(timeEstimationClass_Custom.getWorkTimeInNanoseconds());

timeEstimationClass_Custom.countingStart();
  createMasks();
timeEstimationClass_Custom.countingEnd();
timeEstimates.times_maskCreation.clear();
timeEstimates.times_maskCreation.push_back(timeEstimationClass_Custom.getWorkTimeInNanoseconds());

timeEstimationClass_All.countingEnd();
timeEstimates.time_total = timeEstimationClass_All.getWorkTimeInNanoseconds();
  
}
PatchesRegularScaleScan::PatchesRegularScaleScan (Rect imageROI, Rect validROI, Size patchSize, float relOverlap, float scaleStart, float scaleEnd, float scaleFactor)
{
	calculatePatches (imageROI, validROI, patchSize, relOverlap, scaleStart, scaleEnd, scaleFactor);
}
PatchesRegularScan::PatchesRegularScan (Rect imageROI, Rect validROI, Size patchSize, float relOverlap)
{
	calculatePatches (imageROI, validROI, patchSize, relOverlap);
}