Skip to content
Snippets Groups Projects
Commit 46ff164e authored by simon.fanetti's avatar simon.fanetti
Browse files

update holefilling with 1st non null neighbour

parent 1b351233
Branches custom_realsense
No related tags found
1 merge request!3Custom realsense
...@@ -87,7 +87,7 @@ void CroppingMask::init(){ ...@@ -87,7 +87,7 @@ void CroppingMask::init(){
} }
// no config found // no config found
if(rectPoints.empty() || !maskValideInFrame(&cameraColoredFrame)){ if(!maskValideInFrame(&cameraColoredFrame)){
float y = cameraColoredFrame.size().height; float y = cameraColoredFrame.size().height;
float x = cameraColoredFrame.size().width; 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) }; 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) };
......
...@@ -10,13 +10,16 @@ class Projection{ ...@@ -10,13 +10,16 @@ class Projection{
cv::Mat_<float> adjustingMatrix; cv::Mat_<float> adjustingMatrix;
float distanceTopSandbox; float distanceTopSandbox;
// resized depth frame to dst resolution
cv::Mat_<float> resized_depth; cv::Mat_<float> resized_depth;
// resized src to project to dst resolution
cv::Mat_<cv::Vec3b> resized_src; cv::Mat_<cv::Vec3b> resized_src;
// Buffer containing the pixels's new location when deprojected to beamer's POV // Buffer containing the pixels's new location when deprojected to beamer's POV
cv::Mat_<cv::Point2i> deprojectMap; 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; cv::Mat_<cv::Point2i> frameMap;
// intrinsics parameters for deprojection, which are adapted to projection's resolution
cv::Point2f fxy; cv::Point2f fxy;
cv::Point2f ppxy; cv::Point2f ppxy;
......
...@@ -172,7 +172,7 @@ void Projection::buildFrame(cv::Mat_<float> &depth, cv::Mat_<cv::Point2i> &frame ...@@ -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){ 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 ...@@ -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)){ if(frameMap.at<cv::Point2i>(i,j) == cv::Point2i(-1,-1)){
int cpt = 0; cv::Vec3b color;
int r = 0; bool found = false;
int g = 0;
int b = 0;
for(int d_y = -1; d_y <= 1; d_y++){ for(int d_y = -1; d_y <= 1 && !found; d_y++){
for(int d_x = -1; d_x <= 1; d_x++){ for(int d_x = -1; d_x <= 1 && !found; d_x++){
if(!(d_x == 0 && d_y == 0)){ if(!(d_x == 0 && d_y == 0)){
int y = i+d_y; int y = i+d_y;
int x = j+d_x; 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)) ){ 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); color = dst.at<cv::Vec3b>(y,x);
r += color[0]; found = true;
g += color[1];
b += color[2];
cpt++;
} }
} }
} }
} }
if(cpt > 0){ if(found){
r /= cpt; dst.at<cv::Vec3b>(i,j) = color;
g /= cpt;
b /= cpt;
dst.at<cv::Vec3b>(i,j) = cv::Vec3b(r,g,b);
} }
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment