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

cleaning + fixe beamer localisation and cropping mask calculation

parent ede48885
Branches
No related tags found
No related merge requests found
...@@ -24,7 +24,7 @@ BeamerLocationGui::BeamerLocationGui(SandboxSetup *_setup, MonitorGui *_mg, QWid ...@@ -24,7 +24,7 @@ BeamerLocationGui::BeamerLocationGui(SandboxSetup *_setup, MonitorGui *_mg, QWid
mut = new QMutex(); mut = new QMutex();
myThread = new RefreshFrame(this); myThread = new RefreshFrame(this);
timer = new QTimer(this); timer = new QTimer(this);
connect(timer, &QTimer::timeout, this, &BeamerLocationGui::refreshRoutine); connect(timer, &QTimer::timeout, this, &BeamerLocationGui::tickRoutine);
} }
BeamerLocationGui::~BeamerLocationGui() BeamerLocationGui::~BeamerLocationGui()
...@@ -62,7 +62,7 @@ void BeamerLocationGui::closeEvent(QCloseEvent *e){ ...@@ -62,7 +62,7 @@ void BeamerLocationGui::closeEvent(QCloseEvent *e){
QWidget::closeEvent(e); QWidget::closeEvent(e);
} }
void BeamerLocationGui::refreshRoutine(){ void BeamerLocationGui::tickRoutine(){
myThread->start(); myThread->start();
} }
......
...@@ -48,21 +48,19 @@ private: ...@@ -48,21 +48,19 @@ private:
}; };
Ui::BeamerLocationGui *ui; Ui::BeamerLocationGui *ui;
QtFullScreen *winFullScreen;
SandboxSetup *setup; SandboxSetup *setup;
Beamer *beamer; Beamer *beamer;
Camera *camera; Camera *camera;
FrameProcessProfil *profil; FrameProcessProfil *profil;
MonitorGui *mg; MonitorGui *mg;
int keypressed = -1; QtFullScreen *winFullScreen;
bool isFullScreenInit = false; bool isFullScreenInit = false;
bool isWaiting = true;
std::vector<cv::Point2i> crosses; std::vector<cv::Point2i> crosses;
std::vector<cv::Point3d> directions; std::vector<cv::Point3d> directions;
std::vector<cv::Point3d> bases; std::vector<cv::Point3d> bases;
std::vector<cv::Point3f> capturedPoints; std::vector<cv::Point3f> capturedPoints;
cv::Mat depth; cv::Mat_<float> depth;
cv::Mat rgb; cv::Mat_<cv::Vec3b> rgb;
QMutex *mut; QMutex *mut;
std::vector<cv::Point3i> circles; std::vector<cv::Point3i> circles;
int stepCross = 0; int stepCross = 0;
...@@ -72,7 +70,7 @@ private: ...@@ -72,7 +70,7 @@ private:
void startRoutine(); void startRoutine();
void userValidePoint(); void userValidePoint();
void endRoutine(); void endRoutine();
void refreshRoutine(); void tickRoutine();
void updateLabelSteps(); void updateLabelSteps();
}; };
......
...@@ -51,8 +51,8 @@ void CroppingMask::showEvent(QShowEvent *event){ ...@@ -51,8 +51,8 @@ void CroppingMask::showEvent(QShowEvent *event){
QWidget::showEvent(event); QWidget::showEvent(event);
// show blue screen // show blue screen
if(!blueScreenInitilized){ if(!blueScreenInitialized){
blueScreenInitilized = true; blueScreenInitialized = true;
blueScreen->editGeometry(mg->getResolution()); blueScreen->editGeometry(mg->getResolution());
} }
cv::Mat blueMat = cv::Mat(1, 1, CV_8UC3, cv::Scalar(0, 0, 255)); cv::Mat blueMat = cv::Mat(1, 1, CV_8UC3, cv::Scalar(0, 0, 255));
...@@ -73,7 +73,7 @@ void CroppingMask::init(){ ...@@ -73,7 +73,7 @@ void CroppingMask::init(){
// load from config // load from config
if(rectPoints.empty()){ if(rectPoints.empty()){
if(!setup->loadCroppingMask()){ if(!setup->loadCroppingMaskAndAdjustingMatrix()){
cv::Rect mask = setup->getCamera()->getCroppingMask(); cv::Rect mask = setup->getCamera()->getCroppingMask();
std::vector<cv::Point2i> pts = { cv::Point2i(mask.x, mask.y), std::vector<cv::Point2i> pts = { cv::Point2i(mask.x, mask.y),
cv::Point2i(mask.x, mask.y+mask.height), cv::Point2i(mask.x, mask.y+mask.height),
...@@ -102,7 +102,7 @@ void CroppingMask::refreshFrame(){ ...@@ -102,7 +102,7 @@ void CroppingMask::refreshFrame(){
maskEdit->updateFrame(&cameraColoredFrame); maskEdit->updateFrame(&cameraColoredFrame);
} }
bool CroppingMask::maskValideInFrame(cv::Mat *rgb){ bool CroppingMask::maskValideInFrame(cv::Mat_<cv::Vec3b> *rgb){
if(rectPoints.empty()) if(rectPoints.empty())
return false; return false;
......
...@@ -39,15 +39,15 @@ private: ...@@ -39,15 +39,15 @@ private:
SandboxSetup *setup; SandboxSetup *setup;
std::vector<cv::Point2i> rectPoints; std::vector<cv::Point2i> rectPoints;
std::vector<cv::Point2i> loadedMask; std::vector<cv::Point2i> loadedMask;
cv::Mat cameraColoredFrame; cv::Mat_<cv::Vec3b> cameraColoredFrame;
MaskEdit *maskEdit; MaskEdit *maskEdit;
MonitorGui *mg; MonitorGui *mg;
QtFullScreen *blueScreen; QtFullScreen *blueScreen;
bool blueScreenInitilized = false; bool blueScreenInitialized = false;
bool maskUpdated = false; bool maskUpdated = false;
QTimer *timer; QTimer *timer;
bool maskValideInFrame(cv::Mat *rgb); bool maskValideInFrame(cv::Mat_<cv::Vec3b> *rgb);
void refreshFrame(); void refreshFrame();
void init(); void init();
}; };
......
...@@ -18,7 +18,7 @@ MaskEdit::~MaskEdit() ...@@ -18,7 +18,7 @@ MaskEdit::~MaskEdit()
} }
void MaskEdit::updateFrame(cv::Mat *frame, std::vector<cv::Point> *points){ void MaskEdit::updateFrame(cv::Mat_<cv::Vec3b> *frame, std::vector<cv::Point2i> *points){
capture = frame; capture = frame;
rectPoints = points; rectPoints = points;
if(frame != nullptr && points != nullptr){ if(frame != nullptr && points != nullptr){
...@@ -28,11 +28,11 @@ void MaskEdit::updateFrame(cv::Mat *frame, std::vector<cv::Point> *points){ ...@@ -28,11 +28,11 @@ void MaskEdit::updateFrame(cv::Mat *frame, std::vector<cv::Point> *points){
update(); update();
} }
void MaskEdit::updateFrame(cv::Mat *frame){ void MaskEdit::updateFrame(cv::Mat_<cv::Vec3b> *frame){
updateFrame(frame, rectPoints); updateFrame(frame, rectPoints);
} }
void MaskEdit::updateFrame(std::vector<cv::Point> *points){ void MaskEdit::updateFrame(std::vector<cv::Point2i> *points){
updateFrame(capture, points); updateFrame(capture, points);
} }
...@@ -85,7 +85,7 @@ bool MaskEdit::eventFilter(QObject *object, QEvent *ev) ...@@ -85,7 +85,7 @@ bool MaskEdit::eventFilter(QObject *object, QEvent *ev)
QMouseEvent* eMouse = (QMouseEvent*)ev; QMouseEvent* eMouse = (QMouseEvent*)ev;
if (eMouse->type() == QMouseEvent::MouseMove){ if (eMouse->type() == QMouseEvent::MouseMove){
UpdateSelectedCornerPosition(eMouse); updateSelectedCornerPosition(eMouse);
} }
} }
...@@ -125,7 +125,7 @@ int MaskEdit::selectCorner(QMouseEvent* eMouse){ ...@@ -125,7 +125,7 @@ int MaskEdit::selectCorner(QMouseEvent* eMouse){
} }
void MaskEdit::UpdateSelectedCornerPosition(QMouseEvent* eMouse){ void MaskEdit::updateSelectedCornerPosition(QMouseEvent* eMouse){
if(capture != nullptr && rectPoints != nullptr){ if(capture != nullptr && rectPoints != nullptr){
if(selectedCornerIndex != -1){ if(selectedCornerIndex != -1){
......
...@@ -18,15 +18,15 @@ class MaskEdit : public QFrame ...@@ -18,15 +18,15 @@ class MaskEdit : public QFrame
public: public:
explicit MaskEdit(const QRect geo, QWidget *parent = 0); explicit MaskEdit(const QRect geo, QWidget *parent = 0);
~MaskEdit(); ~MaskEdit();
void updateFrame(cv::Mat *frame, std::vector<cv::Point> *points); void updateFrame(cv::Mat_<cv::Vec3b> *frame, std::vector<cv::Point2i> *points);
void updateFrame(cv::Mat *frame); void updateFrame(cv::Mat_<cv::Vec3b> *frame);
void updateFrame(std::vector<cv::Point> *points); void updateFrame(std::vector<cv::Point2i> *points);
virtual bool eventFilter(QObject *object, QEvent *ev) override; virtual bool eventFilter(QObject *object, QEvent *ev) override;
private: private:
Ui::MaskEdit *ui; Ui::MaskEdit *ui;
cv::Mat *capture = nullptr; cv::Mat_<cv::Vec3b> *capture = nullptr;
std::vector<cv::Point> *rectPoints = nullptr; std::vector<cv::Point2i> *rectPoints = nullptr;
int selectedCornerIndex = -1; int selectedCornerIndex = -1;
// relative to the captured frame, not the UI // relative to the captured frame, not the UI
...@@ -34,7 +34,7 @@ private: ...@@ -34,7 +34,7 @@ private:
float ratioY = 1.0f; float ratioY = 1.0f;
int selectCorner(QMouseEvent* eMouse); int selectCorner(QMouseEvent* eMouse);
void UpdateSelectedCornerPosition(QMouseEvent* eMouse); void updateSelectedCornerPosition(QMouseEvent* eMouse);
protected: protected:
void paintEvent(QPaintEvent* event); void paintEvent(QPaintEvent* event);
......
...@@ -33,7 +33,7 @@ class Projection{ ...@@ -33,7 +33,7 @@ class Projection{
Projection(); Projection();
void setAdjustingMatrix(cv::Mat_<float> matrix){ adjustingMatrix = matrix; } void setAdjustingMatrix(cv::Mat_<float> matrix){ adjustingMatrix = matrix; }
cv::Mat getAdjustingMatrix(){ return adjustingMatrix; } cv::Mat_<float> getAdjustingMatrix(){ return adjustingMatrix; }
void setDistanceTopSandbox(float dist){ distanceTopSandbox = dist; }; void setDistanceTopSandbox(float dist){ distanceTopSandbox = dist; };
float getDistanceTopSandbox(){ return distanceTopSandbox; }; float getDistanceTopSandbox(){ return distanceTopSandbox; };
......
...@@ -30,7 +30,7 @@ class Sandbox{ ...@@ -30,7 +30,7 @@ class Sandbox{
cv::Mat_<cv::Vec3b> adjustProjection(cv::Mat_<cv::Vec3b> &frame); 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_<float> &depth);
int loadConfig(); int loadConfig();
int loadConfigFrom(char *path); int loadConfig(char *path);
}; };
......
...@@ -19,19 +19,19 @@ class SandboxConfig{ ...@@ -19,19 +19,19 @@ class SandboxConfig{
SandboxConfig(){}; SandboxConfig(){};
public: public:
static int saveAdjustingMatrixInto(char *path, cv::Mat matrix); static int saveAdjustingMatrixInto(char *path, cv::Mat_<float> matrix);
static int saveDistanceToSandboxTop(char *path, float distance); static int saveDistanceToSandboxTopInto(char *path, float distance);
static int saveCroppingMaskInto(char *path, cv::Rect mask); static int saveCroppingMaskInto(char *path, cv::Rect mask);
static int saveBeamerPositionInto(char *path, cv::Point3f position); static int saveBeamerPositionInto(char *path, cv::Point3f position);
static int saveBeamerResolutionInto(char *path, cv::Size resolution); static int saveBeamerResolutionInto(char *path, cv::Size resolution);
static int saveFrameProcessProfil(char *path, FrameProcessProfil profil); static int saveFrameProcessProfilInto(char *path, FrameProcessProfil profil);
static int loadAdjustingMatrixFrom(char *path, Projection *projection); static int loadAdjustingMatrixFrom(char *path, Projection *projection);
static int loadDistanceToSandboxTop(char *path, Projection *projection); static int loadDistanceToSandboxTopFrom(char *path, Projection *projection);
static int loadCroppingMaskFrom(char *path, Camera *camera); static int loadCroppingMaskFrom(char *path, Camera *camera);
static int loadBeamerPositionFrom(char *path, Beamer *beamer); static int loadBeamerPositionFrom(char *path, Beamer *beamer);
static int loadBeamerResolutionFrom(char *path, Beamer *beamer); static int loadBeamerResolutionFrom(char *path, Beamer *beamer);
static int loadFrameProcessProfil(char *path, FrameProcessProfil *profil); static int loadFrameProcessProfilFrom(char *path, FrameProcessProfil *profil);
}; };
......
...@@ -26,17 +26,17 @@ class SandboxSetup{ ...@@ -26,17 +26,17 @@ class SandboxSetup{
// save config in file => persistant // save config in file => persistant
int saveConfigInto(char *path); int saveConfig(char *path);
int saveConfig(); int saveConfig();
int loadFrameProcessProfilFrom(char *path); int loadFrameProcessProfil(char *path);
int loadFrameProcessProfil(); int loadFrameProcessProfil();
int loadCroppingMask(char *path); int loadCroppingMaskAndAdjustingMatrix(char *path);
int loadCroppingMask(); int loadCroppingMaskAndAdjustingMatrix();
// edit variables of config => not persistant // edit variables of config => not persistant
void setupAdjustMatrix(std::vector<cv::Point> rectPoints, cv::Point center); void setupAdjustMatrix(std::vector<cv::Point2i> rectPoints, cv::Point2i center);
void setupCroppingMask(std::vector<cv::Point> rectPoints); void setupCroppingMask(std::vector<cv::Point2i> rectPoints);
}; };
#endif #endif
#include "../../inc/beamer.h" #include "../../inc/beamer.h"
/*
* Main
*/
Beamer::Beamer(){ Beamer::Beamer(){
...@@ -13,24 +16,6 @@ Beamer::~Beamer(){ ...@@ -13,24 +16,6 @@ Beamer::~Beamer(){
} }
/*
* Global purpose
*/
cv::Point3f Beamer::deprojectPixel(cv::Point2i circle, cv::Mat *depth, Camera *camera){
float coord[2] = {(float)circle.x, (float)circle.y};
float z = depth->at<float>(circle.y, circle.x);
return camera->deprojectPixelToPoint(coord, z);
}
void Beamer::printPosition(){
cv::Point3f pos = getPosition();
std::cout << "(" << pos.x << "," << pos.y << "," << pos.z << ")" << std::endl;
}
/* /*
...@@ -126,10 +111,8 @@ void Beamer::findLinearLineFrom(std::vector<cv::Point3f> *capturedPoints, std::v ...@@ -126,10 +111,8 @@ void Beamer::findLinearLineFrom(std::vector<cv::Point3f> *capturedPoints, std::v
cv::Vec6f line; cv::Vec6f line;
cv::fitLine(*capturedPoints, line, CV_DIST_L2, 0, 0.01, 0.01); cv::fitLine(*capturedPoints, line, CV_DIST_L2, 0, 0.01, 0.01);
cv::Point3d base = cv::Point3d(line[0], line[1], line[2]); cv::Point3d direction = cv::Point3d(line[0], line[1], line[2]);
cv::Point3d direction = cv::Point3d( LINEAR_REGRESSION_FACT * line[3], cv::Point3d base = cv::Point3d(line[3], line[4], line[5]);
LINEAR_REGRESSION_FACT * line[4],
LINEAR_REGRESSION_FACT * line[5] );
bases->push_back(base); bases->push_back(base);
directions->push_back(direction); directions->push_back(direction);
...@@ -199,7 +182,7 @@ int Beamer::LineLineIntersect( ...@@ -199,7 +182,7 @@ int Beamer::LineLineIntersect(
return (true); return (true);
} }
/*
cv::Point3d Beamer::approximatePosition(std::vector<cv::Point3d> *bases, std::vector<cv::Point3d> *directions){ cv::Point3d Beamer::approximatePosition(std::vector<cv::Point3d> *bases, std::vector<cv::Point3d> *directions){
cv::Point3d pa, pb; cv::Point3d pa, pb;
...@@ -225,4 +208,50 @@ cv::Point3d Beamer::approximatePosition(std::vector<cv::Point3d> *bases, std::ve ...@@ -225,4 +208,50 @@ cv::Point3d Beamer::approximatePosition(std::vector<cv::Point3d> *bases, std::ve
beamerPoint /= (double)beamerPoints.size(); beamerPoint /= (double)beamerPoints.size();
return beamerPoint; return beamerPoint;
} }
\ No newline at end of file */
cv::Point3d Beamer::approximatePosition(std::vector<cv::Point3d> *bases, std::vector<cv::Point3d> *directions){
cv::Point3d pa, pb;
double mua;
double mub;
std::vector<cv::Point3d> beamerPoints;
int selected[3][2] = { {0,1}, {0,2}, {1,2} };
for(int i=0; i < 3; i++){
LineLineIntersect( bases->at(selected[i][0]),
bases->at(selected[i][0]) + directions->at(selected[i][0]),
bases->at(selected[i][1]),
bases->at(selected[i][1]) + directions->at(selected[i][1]),
&pa, &pb, &mua, &mub);
beamerPoints.push_back(pa);
beamerPoints.push_back(pb);
}
cv::Point3d beamerPoint(0.0, 0.0, 0.0);
for (unsigned int i = 0; i < beamerPoints.size(); i++){
beamerPoint += beamerPoints[i];
}
beamerPoint /= (double)beamerPoints.size();
return beamerPoint;
}
cv::Point3f Beamer::deprojectPixel(cv::Point2i circle, cv::Mat *depth, Camera *camera){
float coord[2] = {(float)circle.x, (float)circle.y};
float z = depth->at<float>(circle.y, circle.x);
return camera->deprojectPixelToPoint(coord, z);
}
/*
* Debug
*/
void Beamer::printPosition(){
cv::Point3f pos = getPosition();
std::cout << "(" << pos.x << "," << pos.y << "," << pos.z << ")" << std::endl;
}
...@@ -32,6 +32,24 @@ cv::Point2i Projection::revertRotatePixel(cv::Point2i pixel){ ...@@ -32,6 +32,24 @@ cv::Point2i Projection::revertRotatePixel(cv::Point2i pixel){
*/ */
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){
// deallocate and reallocate buffers if 1st pass
// or dst.size changed, since for all buffers :
// buff.size == dst.size
// try
if(deprojectMap.size() != dst.size()){
std::vector<cv::Point2f> profil = camera->getAdaptedIntrinsics(dst);
fxy = profil.at(0);
ppxy = profil.at(1);
}
// do nothing if contains matrix with same size
// otherwise => release => allocate
deprojectMap.create(dst.rows, dst.cols);
frameMap.create(dst.rows, dst.cols);
resized_depth.create(dst.rows, dst.cols);
resized_src.create(dst.rows, dst.cols);
/*
// default
if(deprojectMap.empty() || deprojectMap.size() != dst.size()){ if(deprojectMap.empty() || deprojectMap.size() != dst.size()){
if(!deprojectMap.empty()){ if(!deprojectMap.empty()){
deprojectMap.release(); deprojectMap.release();
...@@ -48,7 +66,7 @@ void Projection::adjustFrame(cv::Mat_<float> &depth, cv::Mat_<cv::Vec3b> &src, c ...@@ -48,7 +66,7 @@ void Projection::adjustFrame(cv::Mat_<float> &depth, cv::Mat_<cv::Vec3b> &src, c
fxy = profil.at(0); fxy = profil.at(0);
ppxy = profil.at(1); ppxy = profil.at(1);
} }
*/
deprojectMap = cv::Point2i(-1,-1); deprojectMap = cv::Point2i(-1,-1);
frameMap = cv::Point2i(-1,-1); frameMap = cv::Point2i(-1,-1);
......
...@@ -61,11 +61,11 @@ cv::Mat_<cv::Vec3b> Sandbox::adjustProjection(cv::Mat_<cv::Vec3b> &frame){ ...@@ -61,11 +61,11 @@ cv::Mat_<cv::Vec3b> Sandbox::adjustProjection(cv::Mat_<cv::Vec3b> &frame){
return adjustProjection(frame, depth); return adjustProjection(frame, depth);
} }
int Sandbox::loadConfigFrom(char *path){ int Sandbox::loadConfig(char *path){
int err = SandboxConfig::loadAdjustingMatrixFrom(path, projection); int err = SandboxConfig::loadAdjustingMatrixFrom(path, projection);
if(err){ return err; } if(err){ return err; }
err = SandboxConfig::loadDistanceToSandboxTop(path, projection); err = SandboxConfig::loadDistanceToSandboxTopFrom(path, projection);
if(err){ return err; } if(err){ return err; }
err = SandboxConfig::loadCroppingMaskFrom(path, camera); err = SandboxConfig::loadCroppingMaskFrom(path, camera);
if(err){ return err; } if(err){ return err; }
...@@ -78,5 +78,5 @@ int Sandbox::loadConfigFrom(char *path){ ...@@ -78,5 +78,5 @@ int Sandbox::loadConfigFrom(char *path){
int Sandbox::loadConfig(){ int Sandbox::loadConfig(){
return loadConfigFrom(defaultConfigFilePath); return loadConfig(defaultConfigFilePath);
} }
...@@ -19,11 +19,11 @@ SandboxSetup::~SandboxSetup(){ ...@@ -19,11 +19,11 @@ SandboxSetup::~SandboxSetup(){
// return 1 when config can't be saved in file // return 1 when config can't be saved in file
int SandboxSetup::saveConfigInto(char *path){ int SandboxSetup::saveConfig(char *path){
if(SandboxConfig::saveAdjustingMatrixInto(path, projection->getAdjustingMatrix())) if(SandboxConfig::saveAdjustingMatrixInto(path, projection->getAdjustingMatrix()))
return 1; return 1;
if(SandboxConfig::saveDistanceToSandboxTop(path, projection->getDistanceTopSandbox())) if(SandboxConfig::saveDistanceToSandboxTopInto(path, projection->getDistanceTopSandbox()))
return 1; return 1;
if(SandboxConfig::saveCroppingMaskInto(path, camera->getCroppingMask())) if(SandboxConfig::saveCroppingMaskInto(path, camera->getCroppingMask()))
...@@ -35,7 +35,7 @@ int SandboxSetup::saveConfigInto(char *path){ ...@@ -35,7 +35,7 @@ int SandboxSetup::saveConfigInto(char *path){
if(SandboxConfig::saveBeamerPositionInto(path, beamer->getPosition())) if(SandboxConfig::saveBeamerPositionInto(path, beamer->getPosition()))
return 1; return 1;
if(SandboxConfig::saveFrameProcessProfil(path, *beamer->getProfil())) if(SandboxConfig::saveFrameProcessProfilInto(path, *beamer->getProfil()))
return 1; return 1;
return 0; return 0;
...@@ -43,23 +43,26 @@ int SandboxSetup::saveConfigInto(char *path){ ...@@ -43,23 +43,26 @@ int SandboxSetup::saveConfigInto(char *path){
int SandboxSetup::saveConfig(){ int SandboxSetup::saveConfig(){
return saveConfigInto(defaultConfigFilePath); return saveConfig(defaultConfigFilePath);
} }
int SandboxSetup::loadCroppingMask(char *path){ int SandboxSetup::loadCroppingMaskAndAdjustingMatrix(char *path){
return SandboxConfig::loadCroppingMaskFrom(path, camera); int err = SandboxConfig::loadAdjustingMatrixFrom(path, projection);
if(err){ return err; }
err = SandboxConfig::loadCroppingMaskFrom(path, camera);
return err;
} }
int SandboxSetup::loadCroppingMask(){ int SandboxSetup::loadCroppingMaskAndAdjustingMatrix(){
return loadCroppingMask(defaultConfigFilePath); return loadCroppingMaskAndAdjustingMatrix(defaultConfigFilePath);
} }
int SandboxSetup::loadFrameProcessProfilFrom(char *path){ int SandboxSetup::loadFrameProcessProfil(char *path){
return SandboxConfig::loadFrameProcessProfil(path, beamer->getProfil()); return SandboxConfig::loadFrameProcessProfilFrom(path, beamer->getProfil());
} }
int SandboxSetup::loadFrameProcessProfil(){ int SandboxSetup::loadFrameProcessProfil(){
return loadFrameProcessProfilFrom(defaultConfigFilePath); return loadFrameProcessProfil(defaultConfigFilePath);
} }
...@@ -71,7 +74,7 @@ int SandboxSetup::loadFrameProcessProfil(){ ...@@ -71,7 +74,7 @@ int SandboxSetup::loadFrameProcessProfil(){
* *
* center : center of the rotation in the projected frame * center : center of the rotation in the projected frame
*/ */
void SandboxSetup::setupAdjustMatrix(std::vector<cv::Point> rectPoints, cv::Point center){ void SandboxSetup::setupAdjustMatrix(std::vector<cv::Point2i> rectPoints, cv::Point2i center){
// Set adjusting matrix for the projection // Set adjusting matrix for the projection
int widthTop = rectPoints[3].x - rectPoints[0].x; int widthTop = rectPoints[3].x - rectPoints[0].x;
...@@ -90,14 +93,15 @@ void SandboxSetup::setupAdjustMatrix(std::vector<cv::Point> rectPoints, cv::Poin ...@@ -90,14 +93,15 @@ void SandboxSetup::setupAdjustMatrix(std::vector<cv::Point> rectPoints, cv::Poin
void SandboxSetup::setupCroppingMask(std::vector<cv::Point2i> rectPoints){ void SandboxSetup::setupCroppingMask(std::vector<cv::Point2i> rectPoints){
// Set cropping mask // Set cropping mask
int widthTop = rectPoints[3].x - rectPoints[0].x; cv::Point2i ptl = projection->rotatePixel(rectPoints[0]);
cv::Point2i pbl = projection->rotatePixel(rectPoints[1]); cv::Point2i pbl = projection->rotatePixel(rectPoints[1]);
cv::Point2i pbr = projection->rotatePixel(rectPoints[2]); cv::Point2i pbr = projection->rotatePixel(rectPoints[2]);
cv::Point2i ptr = projection->rotatePixel(rectPoints[3]);
cv::Point2i pbot = (pbl.y < pbr.y) ? pbl : pbr; cv::Point2i pbot = (pbl.y < pbr.y) ? pbl : pbr;
cv::Point2i ptop = projection->rotatePixel(rectPoints[0]); int widthTop = ptr.x - ptl.x;
cv::Size rectSize = cv::Size(widthTop, pbot.y - rectPoints[0].y); cv::Size rectSize = cv::Size(widthTop, pbot.y - rectPoints[0].y);
camera->setCroppingMask(cv::Rect(ptop, rectSize)); // croppingMask camera->setCroppingMask(cv::Rect(ptl, rectSize)); // croppingMask
} }
......
...@@ -3,13 +3,13 @@ ...@@ -3,13 +3,13 @@
static int saveConfigIn(char *path, YAML::Node config); static int saveConfigIn(char *path, YAML::Node config);
int SandboxConfig::saveAdjustingMatrixInto(char *path, cv::Mat matrix){ int SandboxConfig::saveAdjustingMatrixInto(char *path, cv::Mat_<float> matrix){
// convert matrix into a one layer vector // convert matrix into a one layer vector
YAML::Node vec = YAML::Load("[]"); YAML::Node vec = YAML::Load("[]");
for (int y = 0; y < matrix.rows; y++){ for (int y = 0; y < matrix.rows; y++){
for (int x = 0; x < matrix.cols; x++){ for (int x = 0; x < matrix.cols; x++){
vec.push_back((float)matrix.at<float>(y, x)); vec.push_back(matrix.at<float>(y, x));
} }
} }
...@@ -32,7 +32,7 @@ int SandboxConfig::saveAdjustingMatrixInto(char *path, cv::Mat matrix){ ...@@ -32,7 +32,7 @@ int SandboxConfig::saveAdjustingMatrixInto(char *path, cv::Mat matrix){
} }
int SandboxConfig::saveDistanceToSandboxTop(char *path, float distance){ int SandboxConfig::saveDistanceToSandboxTopInto(char *path, float distance){
YAML::Node val; YAML::Node val;
...@@ -114,7 +114,7 @@ int SandboxConfig::saveBeamerResolutionInto(char *path, cv::Size res){ ...@@ -114,7 +114,7 @@ int SandboxConfig::saveBeamerResolutionInto(char *path, cv::Size res){
} }
int SandboxConfig::saveFrameProcessProfil(char *path, FrameProcessProfil profil){ int SandboxConfig::saveFrameProcessProfilInto(char *path, FrameProcessProfil profil){
YAML::Node val; YAML::Node val;
...@@ -190,7 +190,7 @@ int SandboxConfig::loadAdjustingMatrixFrom(char *path, Projection *projection){ ...@@ -190,7 +190,7 @@ int SandboxConfig::loadAdjustingMatrixFrom(char *path, Projection *projection){
} }
int SandboxConfig::loadDistanceToSandboxTop(char *path, Projection *projection){ int SandboxConfig::loadDistanceToSandboxTopFrom(char *path, Projection *projection){
YAML::Node config; YAML::Node config;
...@@ -311,7 +311,7 @@ int SandboxConfig::loadBeamerResolutionFrom(char *path, Beamer *beamer){ ...@@ -311,7 +311,7 @@ int SandboxConfig::loadBeamerResolutionFrom(char *path, Beamer *beamer){
} }
int SandboxConfig::loadFrameProcessProfil(char *path, FrameProcessProfil *profil){ int SandboxConfig::loadFrameProcessProfilFrom(char *path, FrameProcessProfil *profil){
YAML::Node config; YAML::Node config;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment