diff --git a/Makefile b/Makefile
index aed3072e4fdef71f4dc369655b3e350bb063a43e..3a783bf3e11b15a729c15fc00bcab9e03ee2e9ba 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,8 @@
 include src/common.mk
+include dep.mk
 
 OBJSALL=$(shell find src -name '*.o')
+SETUPAPP=SandboxSetupApp
 
 LIBNAME=libsandbox
 LIB_MINOR_VERS=0.0
@@ -12,6 +14,7 @@ all:
 	$(MAKE) -C src
 	$(MAKE) pack -C .
 	$(MAKE) link -C .
+	$(MAKE) app -C .
 
 pack:
 	gcc -shared -Wl,-soname,$(LIB_FULL_NAME) -o $(LIB_FULL_NAME) $(OBJSALL)
@@ -20,6 +23,14 @@ link:
 	-ln -s $(LIB_FULL_NAME) $(LIBNAME).so.$(LIB_MAJOR_VERS)
 	-ln -s $(LIB_FULL_NAME) $(LIBNAME).so
 
+app: $(SETUPAPP).o $(LIBNAME).so
+	g++ $< -o $(SETUPAPP) -L. -lsandbox $(DEP_SANDBOX)
+
+$(SETUPAPP).o: $(SETUPAPP).cpp
+	$(CCP) $(CFLAGS) -I./includes -c $< -o $@ 
+
+
 clean:
 	-rm -f *.o *.so*
+	-rm $(SETUPAPP)
 	$(MAKE) clean -C src
diff --git a/SandboxSetupApp.cpp b/SandboxSetupApp.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..fc9f5c45491d783ededcf02a971ec24811e295c9
--- /dev/null
+++ b/SandboxSetupApp.cpp
@@ -0,0 +1,38 @@
+#include "includes/sandboxSetup.h"
+
+
+int main(int argc, char *argv[]){
+    BeamerProjection projection;
+    std::cout << "Projection init" << std::endl;
+    Camera camera;
+    std::cout << "Camera init" << std::endl;
+    Beamer beamer;
+    std::cout << "Beamer init" << std::endl;
+    SandboxSetup setup;
+    std::cout << "Projection init" << std::endl;
+    SandboxConfig conf;
+
+    setup.setupProjection(&beamer, &camera, &projection);
+    setup.setupBeamerLocation(&beamer, &camera);
+    
+    // save into file
+    conf.saveAdjustingMatrix(projection.getAdjustingMatrix());
+    conf.saveCroppingMask(camera.getCroppingMask());
+    conf.saveBeamerPosition(beamer.getPosition());
+
+
+    // Debug
+    cv::Mat matRotation = projection.getAdjustingMatrix();
+    std::cout << "Adjusting Matrix" << std::endl;
+    for (int y = 0; y < matRotation.rows; y++){
+        for (int x = 0; x < matRotation.cols; x++){
+            std::cout << matRotation.at<float>(y, x) << " ";
+        }
+        std::cout << std::endl;
+    }
+
+    cv::Rect rectSandbox = camera.getCroppingMask();
+    std::cout << "Cropping Mask (base + size)" << std::endl;
+    std::cout << "(" << rectSandbox.x << "," << rectSandbox.y << ") + ";
+    std::cout << "(" << rectSandbox.width << "," << rectSandbox.height << ")" << std::endl;
+}
diff --git a/includes/beamer.h b/includes/beamer.h
index 6d24dab804af61668cea571817f463bcfd69a240..cd6d7130ad3024f98280fb7de852462186808d87 100644
--- a/includes/beamer.h
+++ b/includes/beamer.h
@@ -5,20 +5,20 @@
 
 class Beamer
 {
-
+private:
     const char *BEAMER_POSITION_FILE = "./beamer.dat";
     float solveD(cv::Vec3f v, cv::Point3f p);
     cv::Point3f intersection(cv::Vec3f v1, cv::Point3f p1, cv::Vec3f v2, cv::Point3f p2, cv::Vec3f v3, cv::Point3f p3, bool &isFound);
     std::vector<int> findCercleZ(cv::Mat &rgb);
     cv::Point3f beamerPosition;
+    int width = 1400;
+    int height = 1050;
+
 public:
     Beamer();
-    static const int width = 1400;
-    static const int height = 1050;
-    cv::Point3f getPosition()
-    {
-        return beamerPosition;
-    };
-    void findBeamer(Camera camera);
+    cv::Point3f getPosition(){ return beamerPosition; };
+    int getWidth(){ return width; };
+    int getHeight(){ return height; };
+    void findBeamerFrom(Camera camera);
 };
 #endif
diff --git a/includes/beamerProjection.h b/includes/beamerProjection.h
new file mode 100644
index 0000000000000000000000000000000000000000..28c11e525d0750f7da376cdc62e21d6ee8b605ff
--- /dev/null
+++ b/includes/beamerProjection.h
@@ -0,0 +1,22 @@
+#ifndef BEAMERPROJECTION_H
+#define BEAMERPROJECTION_H
+#include <opencv2/opencv.hpp>
+#include "beamer.h"
+#include "camera.h"
+
+class BeamerProjection
+{
+private:
+    const char *wndname = (char *)"Sandbox";
+    cv::Mat adjustingMatrix;
+    cv::Point2i adjustPixel(int i, int j, float z, Camera camera, cv::Point3f beamer);
+
+public:
+    BeamerProjection();
+    cv::Point2i rotatePixel(cv::Point2i pixel);
+    void adjustFrame(cv::Mat &src, cv::Mat &dst, Camera camera, cv::Point3f beamer);
+    void adjustFrame(cv::Mat &depth, cv::Mat &src, cv::Mat &dst, Camera camera, cv::Point3f beamer);
+    void setAdjustingMatrix(cv::Mat matrix){ adjustingMatrix = matrix.clone(); }
+    cv::Mat getAdjustingMatrix(){ return adjustingMatrix.clone(); }
+};
+#endif
\ No newline at end of file
diff --git a/includes/calibrate.h b/includes/calibrate.h
deleted file mode 100644
index 0715824ff217aabeac3260387f278ed3dc55f434..0000000000000000000000000000000000000000
--- a/includes/calibrate.h
+++ /dev/null
@@ -1,32 +0,0 @@
-#ifndef CALIBRATE_H
-#define CALIBRATE_H
-#include <opencv2/opencv.hpp>
-#include "beamer.h"
-#include "camera.h"
-
-class Calibrate
-{
-private:
-    const char *wndname = (char *)"Sandbox";
-    cv::Mat matRotation;
-    float distancePlan;
-
-public:
-    Calibrate();
-    cv::Point2i transformationPixel(int i, int j, float z, Camera camera, cv::Point3f beamer);
-    cv::Point2i rotatePixel(cv::Point2i pixel);
-    void transformationFrame(cv::Mat &src, cv::Mat &dst, Camera camera, cv::Point3f beamer);
-    void transformationFrame(cv::Mat &depth, cv::Mat &src, cv::Mat &dst, Camera camera, cv::Point3f beamer);
-    void setMatrixRotation(cv::Mat matrix)
-    {
-        matRotation = matrix.clone();
-    }
-    cv::Mat getMatrixRotation(){
-        return matRotation.clone();
-    }
-    void setDistancePlan(float distance)
-    {
-        distancePlan = distance;
-    }
-};
-#endif
\ No newline at end of file
diff --git a/includes/camera.h b/includes/camera.h
index 65ed09ebdde953ec0814d77978868a6fbad5eea2..e5e0dc4dd229e06d098c284633999f7a17861cec 100644
--- a/includes/camera.h
+++ b/includes/camera.h
@@ -8,12 +8,6 @@
 class Camera
 {
 private:
-    //constants in mm
-    //const float scale = rs2_get_depth_scale(sensor, NULL);
-    //static const int maxHeightSand = 400;
-    //static const int maxZ = 1120;
-    //static const int minZ = maxZ - maxHeightSand;
-
     rs2::spatial_filter spatFilter;
     rs2::temporal_filter tempFilter;
     rs2::decimation_filter decFilter;
@@ -26,6 +20,7 @@ private:
 
     cv::Mat matDepth;
     cv::Mat matRGB;
+    cv::Rect croppingMask;
 
 public:
     Camera();
@@ -41,13 +36,9 @@ public:
 
     void captureFramesAlign();
     void startAlign();
-    cv::Mat getDepthFrameAlign()
-    {
-        return matDepth;
-    }
-    cv::Mat getRGBFrameAlign()
-    {
-        return matRGB.clone();
-    }
+    cv::Mat getDepthFrameAlign(){ return matDepth; };
+    cv::Mat getRGBFrameAlign(){ return matRGB.clone(); };
+    void setCroppingMask(cv::Rect mask){ croppingMask = mask; };
+    cv::Rect getCroppingMask(){ return croppingMask; };
 };
 #endif
\ No newline at end of file
diff --git a/includes/controller.h b/includes/controller.h
index 1ca73ed79ddda92a0b23c8de5922bef00863b46d..f62cbb1b382a2b8accdc713917ac25fe2c559da7 100644
--- a/includes/controller.h
+++ b/includes/controller.h
@@ -3,7 +3,7 @@
 
 #include <opencv2/opencv.hpp>
 #include "camera.h"
-#include "calibrate.h"
+#include "beamerProjection.h"
 #include "beamer.h"
 #include "borderedit.h"
 #include "borderfinder.h"
@@ -15,25 +15,16 @@ class Controller
         cv::Mat getRGBFrame();
         cv::Mat getDepthFrame(); 
         void showImage(cv::Mat* image);
-        void setupConfig();
-        
+        void initWindowsFullScreen();
+
     private:
-        const char *SANDBOX_POSITION_FILE = "./sandbox.dat";
-        const char *CALIBRATE_DISTANCE_FILE = "./distance.dat";
-        const char *CALIBRATE_MATRIX_FILE = "./matrixe.dat";
-        static const char CHAR_DELIM = ' ';
         static const int ESCAPE_CHAR = 27;
         char *defaultWindowsName = (char*) "Image";
-        cv::Rect rectSandbox;
-        Calibrate calibrate;
+        BeamerProjection projection;
         Camera camera;
         Beamer beamer;
-        void createWindowsFullScreen(char *windowName);
+        void initWindowsFullScreen(char *windowName);
         void showImage(cv::Mat* image, char *windowName);
-        double toDegrees(double radians);
-        void setupProjection(Camera *camera);
-        void setupBeamerLocation(Beamer *beamer, Camera *camera);
-
 };
 
 #endif
diff --git a/includes/sandboxConfig.h b/includes/sandboxConfig.h
new file mode 100644
index 0000000000000000000000000000000000000000..9d7cda9233827c1a59e0fb6fbd94a91beb857a2a
--- /dev/null
+++ b/includes/sandboxConfig.h
@@ -0,0 +1,23 @@
+#ifndef SANDBOXCONFIG_H
+#define SANDBOXCONFIG_H
+
+#include <opencv2/opencv.hpp>
+#include "camera.h"
+#include "beamerProjection.h"
+#include "beamer.h"
+
+class SandboxConfig
+{
+    private:
+        char *configFilePathname = (char *)"./sandbox.cfg";
+
+    public:
+        SandboxConfig();
+        void saveAdjustingMatrix(cv::Mat matrix);
+        void saveCroppingMask(cv::Rect mask);
+        void saveBeamerPosition(cv::Point3f position);
+        void load(Beamer *beamer, Camera *camera, BeamerProjection *projection);
+
+};
+
+#endif
diff --git a/includes/sandboxSetup.h b/includes/sandboxSetup.h
new file mode 100644
index 0000000000000000000000000000000000000000..01edab9ce925a44ef9bbbbd3b0b5d047e11f386e
--- /dev/null
+++ b/includes/sandboxSetup.h
@@ -0,0 +1,22 @@
+#ifndef SANDBOXSETUP_H
+#define SANDBOXSETUP_H
+
+#include <opencv2/opencv.hpp>
+#include <cstdlib>
+#include "beamer.h"
+#include "beamerProjection.h"
+#include "camera.h"
+#include "borderedit.h"
+#include "sandboxConfig.h"
+
+class SandboxSetup{
+    private:
+        double toDegrees(double radians);
+        void initWindowsFullScreen(char *windowName);
+    public:
+        SandboxSetup();
+        void setupProjection(Beamer *beamer, Camera *camera, BeamerProjection *projection);
+        void setupBeamerLocation(Beamer *beamer, Camera *camera);
+};
+
+#endif
diff --git a/includes/sandbox_setup.h b/includes/sandbox_setup.h
deleted file mode 100644
index 19caddc8c4153853d7c236d6f4253f51367e7d26..0000000000000000000000000000000000000000
--- a/includes/sandbox_setup.h
+++ /dev/null
@@ -1,4 +0,0 @@
-#ifndef SANDBOX_SETUP_H
-#define SANDBOX_SETUP_H
-
-#endif
diff --git a/src/config/.gitkeep b/src/config/.gitkeep
deleted file mode 100644
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000
diff --git a/src/config/beamer.dat b/src/config/beamer.dat
deleted file mode 100644
index 3c07edf1ff09333ff96290f48ee6a4a7739bb334..0000000000000000000000000000000000000000
--- a/src/config/beamer.dat
+++ /dev/null
@@ -1 +0,0 @@
-0.643826 0.269363 0.329644
diff --git a/src/config/distance.dat b/src/config/distance.dat
deleted file mode 100644
index 43775ad30a222d4005d87287a2c1147a63bbc584..0000000000000000000000000000000000000000
--- a/src/config/distance.dat
+++ /dev/null
@@ -1 +0,0 @@
-984.25
diff --git a/src/config/matrixe.dat b/src/config/matrixe.dat
deleted file mode 100644
index 10184f79364cf6e84ae642d9585c73a73d359546..0000000000000000000000000000000000000000
--- a/src/config/matrixe.dat
+++ /dev/null
@@ -1,3 +0,0 @@
-3 2
-0 0 0 
-0 0 0 
diff --git a/src/config/sandbox.dat b/src/config/sandbox.dat
deleted file mode 100644
index 2b6b21bd3f019ce33093448924d524391ca3fa8d..0000000000000000000000000000000000000000
--- a/src/config/sandbox.dat
+++ /dev/null
@@ -1,4 +0,0 @@
-160 120
-160 360
-480 360
-480 120
diff --git a/src/core/components/beamer.cpp b/src/core/components/beamer.cpp
index 7001fb338c1a2d56e2d5fba4adff7c4162976d49..91daf3aef4177f2123aa4b647a9b454db5fb2c83 100644
--- a/src/core/components/beamer.cpp
+++ b/src/core/components/beamer.cpp
@@ -96,7 +96,7 @@ vector<int> Beamer::findCercleZ(Mat &rgb)
     return result;
 }
 
-void Beamer::findBeamer(Camera camera)
+void Beamer::findBeamerFrom(Camera camera)
 {
     char wname[] = "FindBeamer";
     namedWindow(wname, CV_WINDOW_NORMAL);
diff --git a/src/core/components/calibrate.cpp b/src/core/components/beamerProjection.cpp
similarity index 68%
rename from src/core/components/calibrate.cpp
rename to src/core/components/beamerProjection.cpp
index faeb8c8c6cbfa53c8d5fc1720752648bb4a42234..fc66a89e62e3b5283272df68d078c2b88cb5be62 100644
--- a/src/core/components/calibrate.cpp
+++ b/src/core/components/beamerProjection.cpp
@@ -1,22 +1,21 @@
-#include "../../../includes/calibrate.h"
-#include "../../../includes/camera.h"
+#include "../../../includes/beamerProjection.h"
 
 using namespace cv;
 using namespace std;
 
-Calibrate::Calibrate()
+BeamerProjection::BeamerProjection()
 {
-    matRotation = getRotationMatrix2D(Point(0, 0), 0, 1);
+    adjustingMatrix = getRotationMatrix2D(Point(0, 0), 0, 1);
 }
 
-Point2i Calibrate::rotatePixel(Point2i pixel)
+Point2i BeamerProjection::rotatePixel(Point2i pixel)
 {
     Mat tmp = (Mat_<Vec2f>(1, 1) << Vec2f(pixel.x, pixel.y));
-    transform(tmp, tmp, matRotation);
+    transform(tmp, tmp, adjustingMatrix);
     return Point2i(tmp.at<Vec2f>(0, 0));
 }
 
-Point2i Calibrate::transformationPixel(int i, int j, float z, Camera camera, Point3f beamer)
+Point2i BeamerProjection::adjustPixel(int i, int j, float z, Camera camera, Point3f beamer)
 {
     //pixel to point 3d
     float coord[2] = {static_cast<float>(j), static_cast<float>(i)};
@@ -31,7 +30,7 @@ Point2i Calibrate::transformationPixel(int i, int j, float z, Camera camera, Poi
     return camera.projectPointToPixel(p);
 }
 
-void Calibrate::transformationFrame(cv::Mat &src, cv::Mat &dst, Camera camera, Point3f beamer)
+void BeamerProjection::adjustFrame(cv::Mat &src, cv::Mat &dst, Camera camera, Point3f beamer)
 {
     //int64_t t1 = getTickCount();
     //transformation on all pixel
@@ -40,18 +39,18 @@ void Calibrate::transformationFrame(cv::Mat &src, cv::Mat &dst, Camera camera, P
         for (int j = 0; j < src.cols; j++)
         {
             Point pixelIJ(j, i);
-            Point pixel = transformationPixel(i, j, static_cast<float>(src.at<uint16_t>(pixelIJ)), camera, beamer);
+            Point pixel = adjustPixel(i, j, static_cast<float>(src.at<uint16_t>(pixelIJ)), camera, beamer);
             if (pixel.x < dst.cols && pixel.y < dst.rows && pixel.x >= 0 && pixel.y >= 0)
                 dst.at<uint16_t>(pixel) = src.at<uint16_t>(pixelIJ);
         }
     }
     //cout << "temps de calcul: " << (getTickCount() - t1) / getTickFrequency() << endl;
 
-    warpAffine(dst, dst, matRotation, dst.size());
+    warpAffine(dst, dst, adjustingMatrix, dst.size());
     // medianBlur(dst, dst, 3);
 }
 
-void Calibrate::transformationFrame(cv::Mat &depth, cv::Mat &src, cv::Mat &dst, Camera camera, Point3f beamer)
+void BeamerProjection::adjustFrame(cv::Mat &depth, cv::Mat &src, cv::Mat &dst, Camera camera, Point3f beamer)
 {
     int nbChannel = src.channels();
     //transformation on all pixel
@@ -61,7 +60,7 @@ void Calibrate::transformationFrame(cv::Mat &depth, cv::Mat &src, cv::Mat &dst,
         for (int j = 0; j < src.cols; j++)
         {
             Point pixelIJ(j, i);
-            Point pixel = transformationPixel(i, j, static_cast<float>(depth.at<uint16_t>(pixelIJ)), camera, beamer);
+            Point pixel = adjustPixel(i, j, static_cast<float>(depth.at<uint16_t>(pixelIJ)), camera, beamer);
             if (pixel.x < dst.cols && pixel.y < dst.rows && pixel.x >= 0 && pixel.y >= 0)
             {
                 if (nbChannel == 1)
@@ -72,7 +71,7 @@ void Calibrate::transformationFrame(cv::Mat &depth, cv::Mat &src, cv::Mat &dst,
         }
     }
     //cout << "temps de calcul: " << (getTickCount() - t1) / getTickFrequency() << endl;
-    warpAffine(dst, dst, matRotation, dst.size());
+    warpAffine(dst, dst, adjustingMatrix, dst.size());
     dilate(dst, dst, Mat(), Point(-1, -1), 2, 1, 1);
     erode(dst, dst, Mat(), Point(-1, -1), 2, 1, 1);
 }
diff --git a/src/core/controller.cpp b/src/core/controller.cpp
index 232e090f3b6a6283efd910f8044a73472ef9f0f2..fcca50c810db22a7d53a5595b8160689262351ff 100644
--- a/src/core/controller.cpp
+++ b/src/core/controller.cpp
@@ -4,7 +4,6 @@
 #include <string>
 
 using namespace std;
-using namespace cv;
 
 
 /*
@@ -20,114 +19,44 @@ Controller::Controller(){
  *   PUBLIC
  */
 
-Mat Controller::getRGBFrame(){
+cv::Mat Controller::getRGBFrame(){
     camera.captureFramesAlign();
-    return camera.getRGBFrameAlign()(rectSandbox);
+    return camera.getRGBFrameAlign()(camera.getCroppingMask());
 }
 
-Mat Controller::getDepthFrame(){
+cv::Mat Controller::getDepthFrame(){
     camera.captureFramesAlign();
-    return camera.getDepthFrameAlign()(rectSandbox);
+    return camera.getDepthFrameAlign()(camera.getCroppingMask());
 }
 
 void Controller::showImage(cv::Mat* image){
     showImage(image, defaultWindowsName);
 }
 
-void Controller::setupConfig(){
-    // Blue screen and edit colored frame routine
-    setupProjection(&camera);
-    // Matching cross under beamer routine
-    setupBeamerLocation(&beamer, &camera);
-    createWindowsFullScreen(defaultWindowsName);
-
-
-    // Debug
-    Mat matRotation = calibrate.getMatrixRotation();
-    cout << "Adjusting Matrix" << endl;
-    for (int y = 0; y < matRotation.rows; y++){
-        for (int x = 0; x < matRotation.cols; x++){
-            cout << matRotation.at<float>(y, x) << " ";
-        }
-        cout << endl;
-    }
-
-    cout << "Cropping Mask (base + size)" << endl;
-    cout << "(" << rectSandbox.x << "," << rectSandbox.y << ") + ";
-    cout << "(" << rectSandbox.width << "," << rectSandbox.height << ")" << endl;
-}
-
 
 /*
  *   PRIVATE
  */
 
 void Controller::showImage(cv::Mat* image, char *windowName){
-    static Mat frameBeamer(Size(Beamer::width, Beamer::height), CV_8UC3);
+    static cv::Mat frameBeamer(cv::Size(beamer.getWidth(), beamer.getHeight()), CV_8UC3);
     camera.captureFramesAlign();
-    Mat depth = camera.getDepthFrameAlign()(rectSandbox);
+    cv::Mat depth = camera.getDepthFrameAlign()(camera.getCroppingMask());
     resize(*image, *image, depth.size());
-    Mat imageCalibrate(depth.size(), CV_8UC3, Scalar(0, 0, 0));
-    calibrate.transformationFrame(depth, *image, imageCalibrate, camera, beamer.getPosition());
+    cv::Mat imageCalibrate(depth.size(), CV_8UC3, cv::Scalar(0, 0, 0));
+    projection.adjustFrame(depth, *image, imageCalibrate, camera, beamer.getPosition());
     //flip to align frame with beamer
-    flip(imageCalibrate, imageCalibrate, 1);
-    flip(imageCalibrate, imageCalibrate, 0);
-    resize(imageCalibrate, frameBeamer, frameBeamer.size());
-    imshow(windowName, frameBeamer);
-}
-
-double Controller::toDegrees(double radians){
-    return radians * (180.0 / M_PI);
-}
-
-void Controller::createWindowsFullScreen(char *windowName){
-    namedWindow(windowName, CV_WINDOW_NORMAL);
-    setWindowProperty(windowName, CV_WND_PROP_FULLSCREEN, CV_WINDOW_FULLSCREEN);
+    cv::flip(imageCalibrate, imageCalibrate, 1);
+    cv::flip(imageCalibrate, imageCalibrate, 0);
+    cv::resize(imageCalibrate, frameBeamer, frameBeamer.size());
+    cv::imshow(windowName, frameBeamer);
 }
 
-
-
-
-
-void Controller::setupBeamerLocation(Beamer *beamer, Camera *camera){
-    beamer->findBeamer(*camera);
+void Controller::initWindowsFullScreen(char *windowName){
+    cv::namedWindow(windowName, CV_WINDOW_NORMAL);
+    cv::setWindowProperty(windowName, CV_WND_PROP_FULLSCREEN, CV_WINDOW_FULLSCREEN);
 }
 
-void Controller::setupProjection(Camera *camera){   
-
-    // Blue screen 
-    char windowName[] = "border";
-    createWindowsFullScreen(windowName);
-    Mat frameBeamer(Size(Beamer::width, Beamer::height), CV_8UC3, Scalar(255, 0, 0));
-    imshow(windowName, frameBeamer);
-    waitKey(100);
-
-    // Take picture
-    camera->startAlign(); // 1 seconde of warming up
-    camera->captureFramesAlign();
-    Mat frameData = camera->getDepthFrameAlign();
-    Mat coloredFrame = camera->getRGBFrameAlign();
-    Size s = frameData.size();
-    Point center(s.width / 2, s.height / 2);
-    destroyAllWindows();
-
-    // Edit projection
-    float y = coloredFrame.size().height;
-    float x = coloredFrame.size().width;
-    vector<Point> rectPoints{ Point(1.0/4*x, 1.0/4*y), Point(1.0/4*x, 3.0/4*y), Point(3.0/4*x, 3.0/4*y), Point(3.0/4*x, 1.0/4*y) };
-    cout << "Edit Rectangle" << endl;
-    BorderEdit::edit(coloredFrame, &rectPoints); // edit projected frame
-
-    // Set adjusting matrix for the projection
-    int widthTop = rectPoints[3].x - rectPoints[0].x;
-    double angle1 = atan((double)(rectPoints[3].y - rectPoints[0].y) / widthTop);
-    cout << "Calibrate Rotation Matrixe" << endl;
-    Mat matRotation = getRotationMatrix2D(center, toDegrees(angle1), 1); // adjustingMatrix
-    calibrate.setMatrixRotation(matRotation);
-
-    // Set cropping mask
-    Size rectSize = Size(widthTop, cvRound(widthTop / 1.33333) + 5);
-    Point p = calibrate.rotatePixel(rectPoints[0]);
-    rectSandbox = Rect(p, rectSize); // coppingMask
-    destroyAllWindows();
+void Controller::initWindowsFullScreen(){
+    initWindowsFullScreen(defaultWindowsName);
 }
\ No newline at end of file
diff --git a/src/core/tools/borderedit.cpp b/src/core/tools/borderedit.cpp
index 4878927feecd844dbaac76d344df75f8729f000e..35caa4c239d0cb1e4630d86f8248f3dad1e5ac98 100644
--- a/src/core/tools/borderedit.cpp
+++ b/src/core/tools/borderedit.cpp
@@ -44,9 +44,9 @@ void BorderEdit::mouseHandler(int event, int x, int y, int, void *param)
             posSandbox[selectedPoint].x = x;
             posSandbox[selectedPoint].y = y;
             BorderEdit::drawSquare(&posSandbox[0], (int)posSandbox.size());
-            Rect r = boundingRect(posSandbox);
-            double f = (double)r.width / (double)r.height;
-            cout << 4.0 / 3.0 << " == " << f << endl;
+            //Rect r = boundingRect(posSandbox);
+            //double f = (double)r.width / (double)r.height;
+            //cout << 4.0 / 3.0 << " == " << f << endl;
         }
         break;
     }
diff --git a/src/core/tools/sandboxConfig.cpp b/src/core/tools/sandboxConfig.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..95fdd951d3a3adbbf127d4e8834f45de4d0a6882
--- /dev/null
+++ b/src/core/tools/sandboxConfig.cpp
@@ -0,0 +1,23 @@
+#include "../../../includes/sandboxConfig.h"
+
+
+
+SandboxConfig::SandboxConfig(){
+
+}
+
+void SandboxConfig::saveAdjustingMatrix(cv::Mat matrix){
+
+}
+
+void SandboxConfig::saveCroppingMask(cv::Rect mask){
+
+}
+
+void SandboxConfig::saveBeamerPosition(cv::Point3f position){
+
+}
+
+void SandboxConfig::load(Beamer *beamer, Camera *camera, BeamerProjection *projection){
+
+}
\ No newline at end of file
diff --git a/src/sandbox.cpp b/src/sandbox.cpp
index ce810ce3c99b02100dc1b3b8ed617ce46a0f1875..d3fa57e52263e700190e9504f95a53788391d52f 100644
--- a/src/sandbox.cpp
+++ b/src/sandbox.cpp
@@ -1,7 +1,7 @@
 #include "../includes/sandbox.h"
 
 Sandbox::Sandbox(){
-    controller.setupConfig();
+    controller.initWindowsFullScreen();
 }
 
 cv::Mat Sandbox::getRGBFrame(){
@@ -14,50 +14,4 @@ cv::Mat Sandbox::getDepthFrame(){
 
 void Sandbox::showImage(cv::Mat* image){
     controller.showImage(image);
-}
-
-/*
-void sendAnswer(request_t *req, matrixPayload_t *payload, int socket)
-{
-    answer_t ans;
-    matrixPayload_t payloadAnswer;
-    ans.id = req->id;
-    cv::Mat matrix;
-    switch (req->idAction)
-    {
-    case 0: //show
-        mylog(LOG_DEBUG, "Request: show image\n");
-        if (req->lengthPayload)
-        {
-            payloadToMatrix(&matrix, *payload);
-            sandbox->showImage(matrix);
-            waitKey(1);
-        }
-        else
-        {
-            mylog(LOG_ERROR, "No matrix found\n");
-            ans.error = -1;
-        }
-        break;
-    case 1:
-        mylog(LOG_DEBUG, "Request: get RGB frame\n");
-        sandbox->getRGBFrame().copyTo(matrix);
-        matrixToPayload(matrix, &payloadAnswer);
-        ans.lengthPayload = calculateSizeMatrix(payloadAnswer);
-        break;
-    case 2:
-        mylog(LOG_DEBUG, "Request: get DEPTH frame\n");
-        sandbox->getDepthFrame().copyTo(matrix);
-        matrixToPayload(matrix, &payloadAnswer);
-        ans.lengthPayload = calculateSizeMatrix(payloadAnswer);
-        break;
-    }
-
-    write(socket, &ans, sizeof(answer_t));
-    //send the matrix without the pointer
-    write(socket, &payloadAnswer, matrixSize);
-    if (ans.lengthPayload)
-        write(socket, payloadAnswer.data, ans.lengthPayload);
-    mylog(LOG_DEBUG, "Answer sent\n");
-}
-*/
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/src/sandboxSetup.cpp b/src/sandboxSetup.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..bebf6ad5610aaa01755ef5668a60acf84c945153
--- /dev/null
+++ b/src/sandboxSetup.cpp
@@ -0,0 +1,60 @@
+#include "../includes/sandboxSetup.h"
+
+
+
+SandboxSetup::SandboxSetup(){
+    
+}
+
+void SandboxSetup::setupBeamerLocation(Beamer *beamer, Camera *camera){
+    beamer->findBeamerFrom(*camera);
+}
+
+void SandboxSetup::setupProjection(Beamer *beamer, Camera *camera, BeamerProjection *projection){   
+
+    // Blue screen 
+    char windowName[] = "border";
+    initWindowsFullScreen(windowName);
+    cv::Mat frameBeamer(cv::Size(beamer->getWidth(), beamer->getHeight()), CV_8UC3, cv::Scalar(255, 0, 0));
+    cv::imshow(windowName, frameBeamer);
+    cv::waitKey(100);
+
+    // Take picture
+    camera->startAlign(); // 1 seconde of warming up
+    camera->captureFramesAlign();
+    cv::Mat frameData = camera->getDepthFrameAlign();
+    cv::Mat coloredFrame = camera->getRGBFrameAlign();
+    cv::Size s = frameData.size();
+    cv::Point center(s.width / 2, s.height / 2);
+    cv::destroyAllWindows();
+
+    // Edit projection
+    float y = coloredFrame.size().height;
+    float x = coloredFrame.size().width;
+    std::vector<cv::Point> rectPoints{ cv::Point(1.0/4*x, 1.0/4*y), cv::Point(1.0/4*x, 3.0/4*y), cv::Point(3.0/4*x, 3.0/4*y), cv::Point(3.0/4*x, 1.0/4*y) };
+    std::cout << "Edit Rectangle" << std::endl;
+    BorderEdit::edit(coloredFrame, &rectPoints); // edit projected frame
+
+    // Set adjusting matrix for the projection
+    int widthTop = rectPoints[3].x - rectPoints[0].x;
+    double angle1 = atan((double)(rectPoints[3].y - rectPoints[0].y) / widthTop);
+    std::cout << "Calibrate Rotation Matrixe" << std::endl;
+    cv::Mat matRotation = cv::getRotationMatrix2D(center, toDegrees(angle1), 1); // adjustingMatrix
+    projection->setAdjustingMatrix(matRotation);
+
+    // Set cropping mask
+    cv::Size rectSize = cv::Size(widthTop, cvRound(widthTop / 1.33333) + 5);
+    cv::Point p = projection->rotatePixel(rectPoints[0]);
+    camera->setCroppingMask(cv::Rect(p, rectSize)); // croppingMask
+    cv::destroyAllWindows();
+}
+
+
+double SandboxSetup::toDegrees(double radians){
+    return radians * (180.0 / M_PI);
+}
+
+void SandboxSetup::initWindowsFullScreen(char *windowName){
+    cv::namedWindow(windowName, CV_WINDOW_NORMAL);
+    cv::setWindowProperty(windowName, CV_WND_PROP_FULLSCREEN, CV_WINDOW_FULLSCREEN);
+}
diff --git a/src/sandbox_setup.cpp b/src/sandbox_setup.cpp
deleted file mode 100644
index 7ada7536ea38c8cf00cd64be96a031922bddb803..0000000000000000000000000000000000000000
--- a/src/sandbox_setup.cpp
+++ /dev/null
@@ -1 +0,0 @@
-#include "../includes/sandbox_setup.h"