Advertisement
Guest User

Untitled

a guest
Jan 18th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.95 KB | None | 0 0
  1. // TODO handle case were no face could be projected
  2. if (visibility.size () - cpt_invisible !=0)
  3. {
  4. //create kdtree
  5. pcl::KdTreeFLANN<pcl::PointXY> kdtree;
  6. kdtree.setInputCloud (projections);
  7.  
  8.  
  9. // af first (idx_pcan < current_cam), check if some of the faces attached to previous cameras occlude the current faces
  10. // then (idx_pcam == current_cam), check for self occlusions. At this stage, we skip faces that were already marked as occluded
  11. cpt_invisible = 0;
  12. for (int idx_pcam = 0 ; idx_pcam <= current_cam ; ++idx_pcam)
  13. {
  14. // project all faces
  15. #pragma omp parallel for shared(visibility,cpt_invisible)
  16. for (int idx_face = 0; idx_face < static_cast<int> (mesh.tex_polygons[idx_pcam].size ()); ++idx_face)
  17. {
  18. std::vector<int> idxNeighbors;
  19. std::vector<float> neighborsSquaredDistance;
  20.  
  21. if (idx_pcam == current_cam && !visibility[idx_face])
  22. {
  23. // we are now checking for self occlusions within the current faces
  24. // the current face was already declared as occluded.
  25. // therefore, it cannot occlude another face anymore => we skip it
  26. continue;
  27. }
  28.  
  29. // project each vertice, if one is out of view, stop
  30. pcl::PointXY uv_coord1;
  31. pcl::PointXY uv_coord2;
  32. pcl::PointXY uv_coord3;
  33.  
  34. if (isFaceProjected (cameras[current_cam],
  35. camera_cloud->points[mesh.tex_polygons[idx_pcam][idx_face].vertices[0]],
  36. camera_cloud->points[mesh.tex_polygons[idx_pcam][idx_face].vertices[1]],
  37. camera_cloud->points[mesh.tex_polygons[idx_pcam][idx_face].vertices[2]],
  38. uv_coord1,
  39. uv_coord2,
  40. uv_coord3))
  41. {
  42. // face is in the camera's FOV
  43. //get its circumsribed circle
  44. double radius;
  45. pcl::PointXY center;
  46. // getTriangleCircumcenterAndSize (uv_coord1, uv_coord2, uv_coord3, center, radius);
  47. getTriangleCircumcscribedCircleCentroid(uv_coord1, uv_coord2, uv_coord3, center, radius); // this function yields faster results than getTriangleCircumcenterAndSize
  48.  
  49. // get points inside circ.circle
  50. if (kdtree.radiusSearch (center, radius, idxNeighbors, neighborsSquaredDistance) > 0 )
  51. {
  52. // for each neighbor
  53. for (size_t i = 0; i < idxNeighbors.size (); ++i)
  54. {
  55. if (std::max (camera_cloud->points[mesh.tex_polygons[idx_pcam][idx_face].vertices[0]].z,
  56. std::max (camera_cloud->points[mesh.tex_polygons[idx_pcam][idx_face].vertices[1]].z,
  57. camera_cloud->points[mesh.tex_polygons[idx_pcam][idx_face].vertices[2]].z))
  58. < camera_cloud->points[indexes_uv_to_points[idxNeighbors[i]].idx_cloud].z)
  59. {
  60. // neighbor is farther than all the face's points. Check if it falls into the triangle
  61. if (checkPointInsideTriangle(uv_coord1, uv_coord2, uv_coord3, projections->points[idxNeighbors[i]]))
  62. {
  63. // current neighbor is inside triangle and is closer => the corresponding face
  64. #pragma omp critical(dataupdate)
  65. {
  66. visibility[indexes_uv_to_points[idxNeighbors[i]].idx_face] = false;
  67. cpt_invisible++;
  68. }
  69. //TODO we could remove the projections of this face from the kd-tree cloud, but I fond it slower, and I need the point to keep ordered to querry UV coordinates later
  70. }
  71. }
  72. }
  73. }
  74. }
  75. }
  76. }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement