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

Sandbox init return int status

parent dfb518d3
Branches master
No related tags found
No related merge requests found
...@@ -22,7 +22,7 @@ class Sandbox{ ...@@ -22,7 +22,7 @@ class Sandbox{
Beamer* getBeamer(){ return beamer; }; Beamer* getBeamer(){ return beamer; };
Projection* getProjection(){ return projection; }; Projection* getProjection(){ return projection; };
void init(); int init();
void captureFrame(); void captureFrame();
cv::Mat getColorFrame(); cv::Mat getColorFrame();
cv::Mat getDepthFrame(); cv::Mat getDepthFrame();
......
...@@ -32,7 +32,7 @@ Camera::~Camera(){ ...@@ -32,7 +32,7 @@ Camera::~Camera(){
int Camera::start(){ int Camera::start(){
// check for a device availible // check for a device available
if(!cfg->can_resolve(*pipe)){ if(!cfg->can_resolve(*pipe)){
//std::cout << "Error: No device found" << std::endl; //std::cout << "Error: No device found" << std::endl;
return 1; return 1;
......
#include "../../inc/projection.h" #include "../../inc/projection.h"
/*
* MAIN
*/
Projection::Projection(){ Projection::Projection(){
adjustingMatrix = cv::getRotationMatrix2D(cv::Point(0, 0), 0, 1); adjustingMatrix = cv::getRotationMatrix2D(cv::Point(0, 0), 0, 1);
distanceTopSandbox = 1.0f; distanceTopSandbox = 1.0f;
...@@ -14,8 +18,7 @@ cv::Point2i Projection::rotatePixel(cv::Point2i pixel){ ...@@ -14,8 +18,7 @@ cv::Point2i Projection::rotatePixel(cv::Point2i pixel){
return cv::Point2i(tmp.at<cv::Vec2f>(0, 0)); 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){ void Projection::adjustFrame(cv::Mat depth, cv::Mat src, cv::Mat &dst, Camera *camera, cv::Point3f beamer_pos){
cv::Rect mask = camera->getCroppingMask(); cv::Rect mask = camera->getCroppingMask();
...@@ -40,6 +43,12 @@ void Projection::adjustFrame(cv::Mat depth, cv::Mat src, cv::Mat &dst, Camera *c ...@@ -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()); 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){ 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 // Browse the depth frame matching the cropping mask
...@@ -64,6 +73,7 @@ void Projection::deprojectPixelsFromDepth(cv::Mat &depth, cv::Rect mask, Camera ...@@ -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){ void Projection::filterHighestDeprojectedPoints(cv::Mat &depth, cv::Mat &pixelsDeprojectMap, cv::Mat &pixelsDeprojectHighestMap){
for (int j = 0; j < pixelsDeprojectMap.rows; j++){ for (int j = 0; j < pixelsDeprojectMap.rows; j++){
...@@ -84,6 +94,7 @@ void Projection::filterHighestDeprojectedPoints(cv::Mat &depth, cv::Mat &pixelsD ...@@ -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){ void Projection::buildFrame(cv::Mat &depth, cv::Mat &pixelsDeprojectHighestMap, cv::Mat &src, cv::Mat &dst){
for (int j = 0; j < pixelsDeprojectHighestMap.rows; j++){ for (int j = 0; j < pixelsDeprojectHighestMap.rows; j++){
...@@ -99,6 +110,7 @@ void Projection::buildFrame(cv::Mat &depth, cv::Mat &pixelsDeprojectHighestMap, ...@@ -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 Projection::getMatchingSize(cv::Mat &src, cv::Rect base){
cv::Size bigSize; cv::Size bigSize;
bigSize.width = (src.size().width % base.width == 0) ? src.size().width : src.size().width - (src.size().width % base.width) + base.width; 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){ ...@@ -106,6 +118,7 @@ cv::Size Projection::getMatchingSize(cv::Mat &src, cv::Rect base){
return bigSize; return bigSize;
} }
// pixels coordinates are relative to the camera depth frame // 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){ 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 ...@@ -130,6 +143,7 @@ void Projection::copyPixelsInto(cv::Point2i pixel_dst, cv::Mat &dst, cv::Point2i
} }
} }
/* /*
C : Camera position C : Camera position
B : Beamer position B : Beamer position
...@@ -154,6 +168,10 @@ cv::Point2i Projection::findMatchingPixel(int i, int j, float z, Camera *camera, ...@@ -154,6 +168,10 @@ cv::Point2i Projection::findMatchingPixel(int i, int j, float z, Camera *camera,
} }
/*
* Debug
*/
void Projection::printAdjustingMatrix(){ void Projection::printAdjustingMatrix(){
cv::Mat matrix = getAdjustingMatrix(); cv::Mat matrix = getAdjustingMatrix();
......
...@@ -22,8 +22,8 @@ Sandbox::~Sandbox(){ ...@@ -22,8 +22,8 @@ Sandbox::~Sandbox(){
* PUBLIC * PUBLIC
*/ */
void Sandbox::init(){ int Sandbox::init(){
camera->start(); return camera->start();
} }
void Sandbox::captureFrame(){ void Sandbox::captureFrame(){
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment