diff --git a/app/SandboxSetup/croppingmask.cpp b/app/SandboxSetup/croppingmask.cpp index 11f0af135a1bf16fa175efef0e5d3122c4472231..71b138c27c8016245e9cf4d6c27030b0b80117dc 100644 --- a/app/SandboxSetup/croppingmask.cpp +++ b/app/SandboxSetup/croppingmask.cpp @@ -87,7 +87,7 @@ void CroppingMask::init(){ } // no config found - if(rectPoints.empty() || !maskValideInFrame(&cameraColoredFrame)){ + if(!maskValideInFrame(&cameraColoredFrame)){ float y = cameraColoredFrame.size().height; float x = cameraColoredFrame.size().width; rectPoints = std::vector<cv::Point2i>{ cv::Point2i(1.0/4*x, 1.0/4*y), cv::Point2i(1.0/4*x, 3.0/4*y), cv::Point2i(3.0/4*x, 3.0/4*y), cv::Point2i(3.0/4*x, 1.0/4*y) }; diff --git a/inc/projection.h b/inc/projection.h index 8e02ba3e83ff168904efe37050b6f5f6ed7ae302..f088b89e5b7b7815f9ec4f0879970d2abaaf1d8d 100644 --- a/inc/projection.h +++ b/inc/projection.h @@ -10,13 +10,16 @@ class Projection{ cv::Mat_<float> adjustingMatrix; float distanceTopSandbox; + // resized depth frame to dst resolution cv::Mat_<float> resized_depth; + // resized src to project to dst resolution cv::Mat_<cv::Vec3b> resized_src; // Buffer containing the pixels's new location when deprojected to beamer's POV cv::Mat_<cv::Point2i> deprojectMap; - // Buffer indicating from where to get the pixels in the source frame + // Buffer indicating from where to get the pixels in the source frame to build the output cv::Mat_<cv::Point2i> frameMap; + // intrinsics parameters for deprojection, which are adapted to projection's resolution cv::Point2f fxy; cv::Point2f ppxy; diff --git a/src/components/projection.cpp b/src/components/projection.cpp index 95dad2c73d65cc7dcccb0fb94f6cc5fce67bb5f3..196dd55fcd4c7f0706376326067bca892b7bee1c 100644 --- a/src/components/projection.cpp +++ b/src/components/projection.cpp @@ -172,7 +172,7 @@ void Projection::buildFrame(cv::Mat_<float> &depth, cv::Mat_<cv::Point2i> &frame } /* - average of non null neighbours + fill with value of the 1st non null neighbour */ void Projection::holeFilling(cv::Mat_<cv::Vec3b> &dst, cv::Mat_<cv::Point2i> &frameMap){ @@ -181,34 +181,26 @@ void Projection::holeFilling(cv::Mat_<cv::Vec3b> &dst, cv::Mat_<cv::Point2i> &fr if(frameMap.at<cv::Point2i>(i,j) == cv::Point2i(-1,-1)){ - int cpt = 0; - int r = 0; - int g = 0; - int b = 0; + cv::Vec3b color; + bool found = false; - for(int d_y = -1; d_y <= 1; d_y++){ - for(int d_x = -1; d_x <= 1; d_x++){ + for(int d_y = -1; d_y <= 1 && !found; d_y++){ + for(int d_x = -1; d_x <= 1 && !found; d_x++){ if(!(d_x == 0 && d_y == 0)){ int y = i+d_y; int x = j+d_x; if( ((0 <= x && x < dst.cols) && (0 <= y && y < dst.rows)) && (frameMap.at<cv::Point2i>(y,x) != cv::Point2i(-1,-1)) ){ - cv::Vec3b color = dst.at<cv::Vec3b>(y,x); - r += color[0]; - g += color[1]; - b += color[2]; - cpt++; + color = dst.at<cv::Vec3b>(y,x); + found = true; } } } } - if(cpt > 0){ - r /= cpt; - g /= cpt; - b /= cpt; - dst.at<cv::Vec3b>(i,j) = cv::Vec3b(r,g,b); + if(found){ + dst.at<cv::Vec3b>(i,j) = color; } } }