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
No related branches found
No related tags found
1 merge request!3Custom realsense
......@@ -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) };
......
......@@ -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;
......
......@@ -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;
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment