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
No related branches found
No related tags found
No related merge requests found
......@@ -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();
......
......@@ -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;
......
#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();
......
......@@ -22,8 +22,8 @@ Sandbox::~Sandbox(){
* PUBLIC
*/
void Sandbox::init(){
camera->start();
int Sandbox::init(){
return camera->start();
}
void Sandbox::captureFrame(){
......
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