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

debug

parent bbf24a10
No related branches found
No related tags found
1 merge request!3Custom realsense
......@@ -7,7 +7,7 @@
class Projection{
private:
cv::Mat adjustingMatrix;
cv::Mat_<float> adjustingMatrix;
float distanceTopSandbox;
cv::Mat_<float> resized_depth;
......@@ -28,14 +28,14 @@ class Projection{
public:
Projection();
void setAdjustingMatrix(cv::Mat matrix){ adjustingMatrix = matrix; }
void setAdjustingMatrix(cv::Mat_<float> matrix){ adjustingMatrix = matrix; }
cv::Mat getAdjustingMatrix(){ return adjustingMatrix; }
void setDistanceTopSandbox(float dist){ distanceTopSandbox = dist; };
float getDistanceTopSandbox(){ return distanceTopSandbox; };
cv::Point2i rotatePixel(cv::Point2i pixel);
cv::Point2i revertRotatePixel(cv::Point2i pixel);
void adjustFrame(cv::Mat_<float> depth, cv::Mat_<cv::Vec3b> src, cv::Mat_<cv::Vec3b> &dst, Camera *camera, cv::Point3f beamer_pos);
void adjustFrame(cv::Mat_<float> &depth, cv::Mat_<cv::Vec3b> &src, cv::Mat_<cv::Vec3b> &dst, Camera *camera, cv::Point3f beamer_pos);
void printAdjustingMatrix();
};
......
......@@ -13,6 +13,7 @@ class Sandbox{
Projection *projection;
Camera *camera;
Beamer *beamer;
cv::Mat_<cv::Vec3b> projectedFrame;
public:
Sandbox();
......@@ -26,8 +27,8 @@ class Sandbox{
void captureFrame();
cv::Mat_<cv::Vec3b> getColorFrame();
cv::Mat_<float> getDepthFrame();
cv::Mat_<cv::Vec3b> adjustProjection(cv::Mat_<cv::Vec3b> frame);
cv::Mat_<cv::Vec3b> adjustProjection(cv::Mat_<cv::Vec3b> frame, cv::Mat_<float> depth);
cv::Mat_<cv::Vec3b> adjustProjection(cv::Mat_<cv::Vec3b> &frame);
cv::Mat_<cv::Vec3b> adjustProjection(cv::Mat_<cv::Vec3b> &frame, cv::Mat_<float> &depth);
int loadConfig();
int loadConfigFrom(char *path);
......
#include "../../inc/projection.h"
#include <chrono>
/*
* MAIN
......@@ -30,15 +30,16 @@ cv::Point2i Projection::revertRotatePixel(cv::Point2i pixel){
/*
Adjust the projected frame with the topology from the camera to the beamer POV
*/
void Projection::adjustFrame(cv::Mat_<float> depth, cv::Mat_<cv::Vec3b> src, cv::Mat_<cv::Vec3b> &dst, Camera *camera, cv::Point3f beamer_pos){
void Projection::adjustFrame(cv::Mat_<float> &depth, cv::Mat_<cv::Vec3b> &src, cv::Mat_<cv::Vec3b> &dst, Camera *camera, cv::Point3f beamer_pos){
if(deprojectMap.empty() || deprojectMap.size() != depth.size()){
if(deprojectMap.empty() || deprojectMap.size() != dst.size()){
if(!deprojectMap.empty()){
deprojectMap.release();
frameMap.release();
resized_depth.release();
resized_src.release();
}
std::cout << "Create" << std::endl;
deprojectMap.create(dst.rows, dst.cols);
frameMap.create(dst.rows, dst.cols);
resized_depth.create(dst.rows, dst.cols);
......@@ -57,9 +58,25 @@ void Projection::adjustFrame(cv::Mat_<float> depth, cv::Mat_<cv::Vec3b> src, cv:
cv::resize(src, resized_src, dst.size());
cv::resize(depth, resized_depth, dst.size());
// 75 ms
//std::chrono::milliseconds start_ms = std::chrono::duration_cast< std::chrono::milliseconds >( std::chrono::system_clock::now().time_since_epoch() );
deprojectPixelsFromDepth(resized_depth, camera, camera->getCroppingMask() , beamer_pos, deprojectMap, fxy, ppxy);
//std::chrono::milliseconds now_ms = std::chrono::duration_cast< std::chrono::milliseconds >( std::chrono::system_clock::now().time_since_epoch() );
//std::cout << "Deproject : " << (now_ms - start_ms).count() << std::endl;
// 18-19 ms
//start_ms = std::chrono::duration_cast< std::chrono::milliseconds >( std::chrono::system_clock::now().time_since_epoch() );
filterLowestDeprojectedPoints(resized_depth, deprojectMap, frameMap);
//now_ms = std::chrono::duration_cast< std::chrono::milliseconds >( std::chrono::system_clock::now().time_since_epoch() );
//std::cout << "Filter : " << (now_ms - start_ms).count() << std::endl;
// 14-15 ms
//start_ms = std::chrono::duration_cast< std::chrono::milliseconds >( std::chrono::system_clock::now().time_since_epoch() );
buildFrame(resized_depth, frameMap, resized_src, dst);
//now_ms = std::chrono::duration_cast< std::chrono::milliseconds >( std::chrono::system_clock::now().time_since_epoch() );
//std::cout << "Build : " << (now_ms - start_ms).count() << std::endl;
cv::warpAffine(dst, dst, adjustingMatrix, dst.size());
}
......
......@@ -38,20 +38,23 @@ cv::Mat_<float> Sandbox::getDepthFrame(){
return camera->getDepthFrame()(camera->getCroppingMask());
}
cv::Mat_<cv::Vec3b> Sandbox::adjustProjection(cv::Mat_<cv::Vec3b> frame, cv::Mat_<float> depth){
cv::Mat_<cv::Vec3b> Sandbox::adjustProjection(cv::Mat_<cv::Vec3b> &frame, cv::Mat_<float> &depth){
static cv::Mat_<cv::Vec3b> imageCalibrate = cv::Mat_<cv::Vec3b>(cv::Size(beamer->getWidth(), beamer->getHeight()));
imageCalibrate = cv::Vec3b(0, 0, 0);
projection->adjustFrame(depth, frame, imageCalibrate, camera, beamer->getPosition());
if(projectedFrame.empty()){
projectedFrame.create(beamer->getHeight(), beamer->getWidth());
}
projectedFrame = cv::Vec3b(0, 0, 0);
projection->adjustFrame(depth, frame, projectedFrame, camera, beamer->getPosition());
// frame after process
//cv::dilate(imageCalibrate, imageCalibrate, cv::Mat(), cv::Point(-1, -1), 2, 1, 1);
//cv::erode(imageCalibrate, imageCalibrate, cv::Mat(), cv::Point(-1, -1), 2, 1, 1);
//cv::dilate(projectedFrame, projectedFrame, cv::Mat(), cv::Point(-1, -1), 2, 1, 1);
//cv::erode(projectedFrame, projectedFrame, cv::Mat(), cv::Point(-1, -1), 2, 1, 1);
return imageCalibrate;
return projectedFrame;
}
cv::Mat_<cv::Vec3b> Sandbox::adjustProjection(cv::Mat_<cv::Vec3b> frame){
cv::Mat_<cv::Vec3b> Sandbox::adjustProjection(cv::Mat_<cv::Vec3b> &frame){
captureFrame();
cv::Mat_<float> depth = getDepthFrame();
......
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