From d6fc8b7cca8acfcb351543921c4ac688860b4409 Mon Sep 17 00:00:00 2001
From: "simon.fanetti" <simon.fanetti@etu.hesge.ch>
Date: Thu, 19 Mar 2020 20:26:39 +0100
Subject: [PATCH] fixed .so and adjust files

---
 Makefile                               | 15 +++------------
 app_tools/beamer_config.sh             |  7 -------
 dep.mk                                 |  3 +++
 export.sh                              |  3 +--
 includes/controller.h                  |  8 ++++----
 includes/sandbox_setup.h               |  4 ++++
 sandbox_setup.cpp                      |  0
 src/Makefile                           | 10 +++-------
 src/common.mk                          |  2 --
 {config => src/config}/.gitkeep        |  0
 {config => src/config}/beamer.dat      |  0
 {config => src/config}/distance.dat    |  0
 {config => src/config}/matrixe.dat     |  0
 {config => src/config}/sandbox.dat     |  0
 src/lib/Makefile                       | 21 +++++++++++++++++++++
 src/{ => lib}/components/Makefile      |  3 +--
 src/{ => lib}/components/beamer.cpp    |  2 +-
 src/{ => lib}/components/calibrate.cpp |  4 ++--
 src/{ => lib}/components/camera.cpp    |  2 +-
 src/{ => lib}/controller.cpp           |  4 ++--
 src/{ => lib}/tools/Makefile           |  6 +++---
 src/{ => lib}/tools/borderedit.cpp     |  2 +-
 src/{ => lib}/tools/borderfinder.cpp   |  2 +-
 src/{ => lib}/tools/log.c              |  2 +-
 sandbox.cpp => src/sandbox.cpp         |  2 +-
 src/sandbox_setup.cpp                  |  1 +
 26 files changed, 54 insertions(+), 49 deletions(-)
 delete mode 100755 app_tools/beamer_config.sh
 create mode 100644 dep.mk
 delete mode 100644 sandbox_setup.cpp
 rename {config => src/config}/.gitkeep (100%)
 rename {config => src/config}/beamer.dat (100%)
 rename {config => src/config}/distance.dat (100%)
 rename {config => src/config}/matrixe.dat (100%)
 rename {config => src/config}/sandbox.dat (100%)
 create mode 100644 src/lib/Makefile
 rename src/{ => lib}/components/Makefile (73%)
 rename src/{ => lib}/components/beamer.cpp (99%)
 rename src/{ => lib}/components/calibrate.cpp (97%)
 rename src/{ => lib}/components/camera.cpp (99%)
 rename src/{ => lib}/controller.cpp (99%)
 rename src/{ => lib}/tools/Makefile (63%)
 rename src/{ => lib}/tools/borderedit.cpp (97%)
 rename src/{ => lib}/tools/borderfinder.cpp (98%)
 rename src/{ => lib}/tools/log.c (97%)
 rename sandbox.cpp => src/sandbox.cpp (97%)
 create mode 100644 src/sandbox_setup.cpp

diff --git a/Makefile b/Makefile
index 2eb971e..aed3072 100644
--- a/Makefile
+++ b/Makefile
@@ -1,29 +1,20 @@
 include src/common.mk
 
-SRCS=$(wildcard ./*.cpp)
-OBJS=$(SRCS:%.cpp=%.o)
-OBJSALL=$(shell find . -name '*.o')
+OBJSALL=$(shell find src -name '*.o')
+
 LIBNAME=libsandbox
 LIB_MINOR_VERS=0.0
 LIB_MAJOR_VERS=1
 LIB_VERS=$(LIB_MAJOR_VERS).$(LIB_MINOR_VERS)
 LIB_FULL_NAME=$(LIBNAME).so.$(LIB_VERS)
-path=$(shell pwd)
-ld_libs=$(shell echo $$LD_LIBRARY_PATH)
 
 all:
 	$(MAKE) -C src
-	$(MAKE) build -C .
 	$(MAKE) pack -C .
 	$(MAKE) link -C .
 
-build: $(OBJS)
-
-%.o: %.cpp 
-	$(CCP) -c $(CFLAGS) $< -o $@
-
 pack:
-	gcc -shared -Wl,-soname,$(LIB_FULL_NAME) -o $(LIB_FULL_NAME) $(OBJSALL) $(OPENCVFLAG) $(CAMERAFLAG)
+	gcc -shared -Wl,-soname,$(LIB_FULL_NAME) -o $(LIB_FULL_NAME) $(OBJSALL)
 
 link:
 	-ln -s $(LIB_FULL_NAME) $(LIBNAME).so.$(LIB_MAJOR_VERS)
diff --git a/app_tools/beamer_config.sh b/app_tools/beamer_config.sh
deleted file mode 100755
index 9e02401..0000000
--- a/app_tools/beamer_config.sh
+++ /dev/null
@@ -1,7 +0,0 @@
-SCREEN=DVI-D-0
-SCN_RES=1920x1080
-BEAMER=HDMI-0
-BM_RES=1400x1050
-
-xrandr --output $SCREEN --rate 60 --mode $SCN_RES --fb $SCN_RES --panning $SCN_RES* \
-       --output $BEAMER --mode $BM_RES --same-as $SCREEN > /dev/null
diff --git a/dep.mk b/dep.mk
new file mode 100644
index 0000000..192ea9c
--- /dev/null
+++ b/dep.mk
@@ -0,0 +1,3 @@
+OPENCVFLAG=`pkg-config --libs --cflags opencv`
+CAMERAFLAG=-lrealsense2
+DEP_SANDBOX=$(OPENCVFLAG) $(CAMERAFLAG)
\ No newline at end of file
diff --git a/export.sh b/export.sh
index 3a1d7cc..218b4d4 100644
--- a/export.sh
+++ b/export.sh
@@ -1,4 +1,3 @@
 #!/bin/bash
 
-export LD_LIBRARY_PATH=$(pwd) && \
-make link
+export LD_LIBRARY_PATH=$(pwd)
diff --git a/includes/controller.h b/includes/controller.h
index b37c8f0..501b656 100644
--- a/includes/controller.h
+++ b/includes/controller.h
@@ -34,12 +34,12 @@ class Controller
         Beamer beamer;
         void createWindowsFullScreen(char *windowName);
         void showImage(cv::Mat* image, char *windowName);
-        bool readSandboxPosition(std::vector<cv::Point> &rectPoints);
-        void writeSandboxPosition(std::vector<cv::Point> rectPoints);
+        //bool readSandboxPosition(std::vector<cv::Point> &rectPoints);
+        //void writeSandboxPosition(std::vector<cv::Point> rectPoints);
         double toDegrees(double radians);
         void sanboxBorder();
-        void sandboxBorderLoad();
-        bool configFilesFound();
+        //void sandboxBorderLoad();
+        //bool configFilesFound();
 
     
 };
diff --git a/includes/sandbox_setup.h b/includes/sandbox_setup.h
index e69de29..19caddc 100644
--- a/includes/sandbox_setup.h
+++ b/includes/sandbox_setup.h
@@ -0,0 +1,4 @@
+#ifndef SANDBOX_SETUP_H
+#define SANDBOX_SETUP_H
+
+#endif
diff --git a/sandbox_setup.cpp b/sandbox_setup.cpp
deleted file mode 100644
index e69de29..0000000
diff --git a/src/Makefile b/src/Makefile
index 4e098e6..6347fd1 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -4,18 +4,14 @@ SRCS:=$(wildcard *.cpp)
 OBJS:=$(SRCS:%.cpp=%.o)
 
 all:
-	$(MAKE) -C components
-	#$(MAKE) -C tools
+	$(MAKE) -C lib
 	$(MAKE) build -C .
 
 build: $(OBJS)
 
 %.o: %.cpp 
-	g++ $(CFLAGS) -c $< -o $@
+	$(CCP) -c $(CFLAGS) $< -o $@
 
 clean:
 	-rm -f *.o
-	$(MAKE) clean -C components
-	#$(MAKE) clean -C tools
-
-
+	$(MAKE) clean -C lib
diff --git a/src/common.mk b/src/common.mk
index dab528a..6f95981 100644
--- a/src/common.mk
+++ b/src/common.mk
@@ -1,4 +1,2 @@
 CCP=g++
 CFLAGS=-std=c++11 -Wall -Wextra -g -Ilib -fPIC
-OPENCVFLAG=`pkg-config --libs --cflags opencv`
-CAMERAFLAG=-lrealsense2
diff --git a/config/.gitkeep b/src/config/.gitkeep
similarity index 100%
rename from config/.gitkeep
rename to src/config/.gitkeep
diff --git a/config/beamer.dat b/src/config/beamer.dat
similarity index 100%
rename from config/beamer.dat
rename to src/config/beamer.dat
diff --git a/config/distance.dat b/src/config/distance.dat
similarity index 100%
rename from config/distance.dat
rename to src/config/distance.dat
diff --git a/config/matrixe.dat b/src/config/matrixe.dat
similarity index 100%
rename from config/matrixe.dat
rename to src/config/matrixe.dat
diff --git a/config/sandbox.dat b/src/config/sandbox.dat
similarity index 100%
rename from config/sandbox.dat
rename to src/config/sandbox.dat
diff --git a/src/lib/Makefile b/src/lib/Makefile
new file mode 100644
index 0000000..caad237
--- /dev/null
+++ b/src/lib/Makefile
@@ -0,0 +1,21 @@
+include ../common.mk
+
+SRCS:=$(wildcard *.cpp) 
+OBJS:=$(SRCS:%.cpp=%.o)
+
+all:
+	$(MAKE) -C components
+	$(MAKE) -C tools
+	$(MAKE) build -C .
+
+build: $(OBJS)
+
+%.o: %.cpp 
+	g++ $(CFLAGS) -c $< -o $@
+
+clean:
+	-rm -f *.o
+	$(MAKE) clean -C components
+	$(MAKE) clean -C tools
+
+
diff --git a/src/components/Makefile b/src/lib/components/Makefile
similarity index 73%
rename from src/components/Makefile
rename to src/lib/components/Makefile
index 174f235..c621ec2 100644
--- a/src/components/Makefile
+++ b/src/lib/components/Makefile
@@ -1,8 +1,7 @@
-include ../common.mk
+include ../../common.mk
 
 SRCS=$(wildcard *.cpp)
 OBJS=$(SRCS:%.cpp=%.o)
-CAMERAFLAG=-lrealsense2
 
 build: $(OBJS)
 
diff --git a/src/components/beamer.cpp b/src/lib/components/beamer.cpp
similarity index 99%
rename from src/components/beamer.cpp
rename to src/lib/components/beamer.cpp
index d953e6c..7001fb3 100644
--- a/src/components/beamer.cpp
+++ b/src/lib/components/beamer.cpp
@@ -1,4 +1,4 @@
-#include "../../includes/beamer.h"
+#include "../../../includes/beamer.h"
 
 using namespace cv;
 using namespace std;
diff --git a/src/components/calibrate.cpp b/src/lib/components/calibrate.cpp
similarity index 97%
rename from src/components/calibrate.cpp
rename to src/lib/components/calibrate.cpp
index 3b5935f..e68003e 100644
--- a/src/components/calibrate.cpp
+++ b/src/lib/components/calibrate.cpp
@@ -1,5 +1,5 @@
-#include "../../includes/calibrate.h"
-#include "../../includes/camera.h"
+#include "../../../includes/calibrate.h"
+#include "../../../includes/camera.h"
 
 using namespace cv;
 using namespace std;
diff --git a/src/components/camera.cpp b/src/lib/components/camera.cpp
similarity index 99%
rename from src/components/camera.cpp
rename to src/lib/components/camera.cpp
index 423fae0..ce694e1 100644
--- a/src/components/camera.cpp
+++ b/src/lib/components/camera.cpp
@@ -1,4 +1,4 @@
-#include "../../includes/camera.h"
+#include "../../../includes/camera.h"
 using namespace cv;
 Camera::Camera() {}
 
diff --git a/src/controller.cpp b/src/lib/controller.cpp
similarity index 99%
rename from src/controller.cpp
rename to src/lib/controller.cpp
index 1a9e6bb..bc2f818 100644
--- a/src/controller.cpp
+++ b/src/lib/controller.cpp
@@ -1,4 +1,4 @@
-#include "../includes/controller.h"
+#include "../../includes/controller.h"
 #include <numeric>
 #include <fstream>
 #include <string>
@@ -15,7 +15,7 @@ Controller::Controller(){
         // Matching cross under beamer routine
         beamer.findBeamer(camera);
     }else{
-        sandboxBorderLoad();
+        //sandboxBorderLoad();
         //beamer.findBeamerLoad(camera);
     }
     // Set full screen parameter for show function
diff --git a/src/tools/Makefile b/src/lib/tools/Makefile
similarity index 63%
rename from src/tools/Makefile
rename to src/lib/tools/Makefile
index c10d9b5..a422e9b 100644
--- a/src/tools/Makefile
+++ b/src/lib/tools/Makefile
@@ -1,4 +1,4 @@
-include ../common.mk
+include ../../common.mk
 
 SRCS_C=$(wildcard *.c) 
 OBJS_C=$(SRCS_C:%.c=%.o)
@@ -8,10 +8,10 @@ OBJS_CPP=$(SRCS_CPP:%.cpp=%.o)
 build: $(OBJS_C) $(OBJS_CPP)
 
 %.o: %.cpp 
-	g++ $(CFLAGS) $(OPENCVFLAG) -c $< -o $@
+	g++ $(CFLAGS) -c $< -o $@
 
 %.o: %.c
-	gcc -Wall -Wextra -std=gnu11 -c $< -o $@
+	gcc -Wall -Wextra -std=gnu11 -fPIC -c $< -o $@
 
 clean:
 	-rm -f *.o
diff --git a/src/tools/borderedit.cpp b/src/lib/tools/borderedit.cpp
similarity index 97%
rename from src/tools/borderedit.cpp
rename to src/lib/tools/borderedit.cpp
index 0dba3fc..4878927 100644
--- a/src/tools/borderedit.cpp
+++ b/src/lib/tools/borderedit.cpp
@@ -1,5 +1,5 @@
 #include <algorithm>
-#include "../../includes/borderedit.h"
+#include "../../../includes/borderedit.h"
 
 using namespace std;
 using namespace cv;
diff --git a/src/tools/borderfinder.cpp b/src/lib/tools/borderfinder.cpp
similarity index 98%
rename from src/tools/borderfinder.cpp
rename to src/lib/tools/borderfinder.cpp
index ba80000..c2cb5bb 100644
--- a/src/tools/borderfinder.cpp
+++ b/src/lib/tools/borderfinder.cpp
@@ -1,5 +1,5 @@
 #include <algorithm>
-#include "../../includes/borderfinder.h"
+#include "../../../includes/borderfinder.h"
 
 using namespace std;
 using namespace cv;
diff --git a/src/tools/log.c b/src/lib/tools/log.c
similarity index 97%
rename from src/tools/log.c
rename to src/lib/tools/log.c
index 6c7cab5..f7f4352 100644
--- a/src/tools/log.c
+++ b/src/lib/tools/log.c
@@ -3,7 +3,7 @@
 #include <unistd.h>
 #include <strings.h>
 #include <stdarg.h>
-#include "../../includes/log.h"
+#include "../../../includes/log.h"
 
 
 
diff --git a/sandbox.cpp b/src/sandbox.cpp
similarity index 97%
rename from sandbox.cpp
rename to src/sandbox.cpp
index 48d31da..040ccfe 100644
--- a/sandbox.cpp
+++ b/src/sandbox.cpp
@@ -1,4 +1,4 @@
-#include "includes/sandbox.h"
+#include "../includes/sandbox.h"
 
 Sandbox::Sandbox(){
     //controller = Controller();
diff --git a/src/sandbox_setup.cpp b/src/sandbox_setup.cpp
new file mode 100644
index 0000000..7ada753
--- /dev/null
+++ b/src/sandbox_setup.cpp
@@ -0,0 +1 @@
+#include "../includes/sandbox_setup.h"
-- 
GitLab