diff --git a/inc/sandbox.h b/inc/sandbox.h index 51800ee539e991b388753bdf129d33962c2f00b1..c517c2bf19a31cd9e19c38f0d31cea8af287e32c 100644 --- a/inc/sandbox.h +++ b/inc/sandbox.h @@ -22,7 +22,7 @@ class Sandbox{ Beamer* getBeamer(){ return beamer; }; Projection* getProjection(){ return projection; }; - void init(); + int init(); void captureFrame(); cv::Mat getColorFrame(); cv::Mat getDepthFrame(); diff --git a/src/components/camera.cpp b/src/components/camera.cpp index 26d867f03e8a3f1347e68152104f00641271f927..d75ae16ab740e09abf1bcd3e0d356a1f150de719 100644 --- a/src/components/camera.cpp +++ b/src/components/camera.cpp @@ -32,7 +32,7 @@ Camera::~Camera(){ int Camera::start(){ - // check for a device availible + // check for a device available if(!cfg->can_resolve(*pipe)){ //std::cout << "Error: No device found" << std::endl; return 1; diff --git a/src/components/projection.cpp b/src/components/projection.cpp index fe6632b9f7eca5e9e71776a2dbc3241ae5dd5cf9..bc069937ddcaf0286553fd9bfe1698606027ce95 100644 --- a/src/components/projection.cpp +++ b/src/components/projection.cpp @@ -1,6 +1,10 @@ #include "../../inc/projection.h" +/* + * MAIN + */ + Projection::Projection(){ adjustingMatrix = cv::getRotationMatrix2D(cv::Point(0, 0), 0, 1); distanceTopSandbox = 1.0f; @@ -14,8 +18,7 @@ cv::Point2i Projection::rotatePixel(cv::Point2i pixel){ return cv::Point2i(tmp.at<cv::Vec2f>(0, 0)); } - - +// Adjust the projected frame with the topology from the camera to the beamer POV void Projection::adjustFrame(cv::Mat depth, cv::Mat src, cv::Mat &dst, Camera *camera, cv::Point3f beamer_pos){ cv::Rect mask = camera->getCroppingMask(); @@ -40,6 +43,12 @@ void Projection::adjustFrame(cv::Mat depth, cv::Mat src, cv::Mat &dst, Camera *c cv::warpAffine(dst, dst, adjustingMatrix, dst.size()); } + + +/* + * PRIVATE + */ + void Projection::deprojectPixelsFromDepth(cv::Mat &depth, cv::Rect mask, Camera *camera, cv::Point3f beamer_pos, cv::Mat &pixelsDeprojectMap){ // Browse the depth frame matching the cropping mask @@ -64,6 +73,7 @@ void Projection::deprojectPixelsFromDepth(cv::Mat &depth, cv::Rect mask, Camera } } + void Projection::filterHighestDeprojectedPoints(cv::Mat &depth, cv::Mat &pixelsDeprojectMap, cv::Mat &pixelsDeprojectHighestMap){ for (int j = 0; j < pixelsDeprojectMap.rows; j++){ @@ -84,6 +94,7 @@ void Projection::filterHighestDeprojectedPoints(cv::Mat &depth, cv::Mat &pixelsD } } + void Projection::buildFrame(cv::Mat &depth, cv::Mat &pixelsDeprojectHighestMap, cv::Mat &src, cv::Mat &dst){ for (int j = 0; j < pixelsDeprojectHighestMap.rows; j++){ @@ -99,6 +110,7 @@ void Projection::buildFrame(cv::Mat &depth, cv::Mat &pixelsDeprojectHighestMap, } } + cv::Size Projection::getMatchingSize(cv::Mat &src, cv::Rect base){ cv::Size bigSize; bigSize.width = (src.size().width % base.width == 0) ? src.size().width : src.size().width - (src.size().width % base.width) + base.width; @@ -106,6 +118,7 @@ cv::Size Projection::getMatchingSize(cv::Mat &src, cv::Rect base){ return bigSize; } + // pixels coordinates are relative to the camera depth frame void Projection::copyPixelsInto(cv::Point2i pixel_dst, cv::Mat &dst, cv::Point2i pixel_src, cv::Mat &src, cv::Mat &depth){ @@ -130,6 +143,7 @@ void Projection::copyPixelsInto(cv::Point2i pixel_dst, cv::Mat &dst, cv::Point2i } } + /* C : Camera position B : Beamer position @@ -154,6 +168,10 @@ cv::Point2i Projection::findMatchingPixel(int i, int j, float z, Camera *camera, } +/* +* Debug +*/ + void Projection::printAdjustingMatrix(){ cv::Mat matrix = getAdjustingMatrix(); diff --git a/src/lib/sandbox.cpp b/src/lib/sandbox.cpp index 22b5865aab0ca4999946dc1ce509b3bdf300cfac..a39a2bb1e744c0ef790488d1bd43952fa842f851 100644 --- a/src/lib/sandbox.cpp +++ b/src/lib/sandbox.cpp @@ -22,8 +22,8 @@ Sandbox::~Sandbox(){ * PUBLIC */ -void Sandbox::init(){ - camera->start(); +int Sandbox::init(){ + return camera->start(); } void Sandbox::captureFrame(){