diff --git a/ROS/gesture_based_control/src/math.hpp b/ROS/gesture_based_control/src/math.hpp new file mode 120000 index 0000000..64b24f7 --- /dev/null +++ b/ROS/gesture_based_control/src/math.hpp @@ -0,0 +1 @@ +/home/guillaume/Documents/3A_supelec/miniprojet/tests/src/math.hpp \ No newline at end of file diff --git a/rapport/images/test-contour/contour_20.png b/rapport/images/test-contour/contour_20.png new file mode 100644 index 0000000..a4f7d7a Binary files /dev/null and b/rapport/images/test-contour/contour_20.png differ diff --git a/rapport/images/test-contour/raw_image.png b/rapport/images/test-contour/raw_image.png new file mode 100644 index 0000000..a401528 Binary files /dev/null and b/rapport/images/test-contour/raw_image.png differ diff --git a/rapport/images/test-filter/binary_10.png b/rapport/images/test-filter/binary_10.png new file mode 100644 index 0000000..ef3a6e6 Binary files /dev/null and b/rapport/images/test-filter/binary_10.png differ diff --git a/rapport/images/test-filter/binary_15.png b/rapport/images/test-filter/binary_15.png new file mode 100644 index 0000000..a00ea08 Binary files /dev/null and b/rapport/images/test-filter/binary_15.png differ diff --git a/rapport/images/test-filter/binary_20.png b/rapport/images/test-filter/binary_20.png new file mode 100644 index 0000000..90a7ad5 Binary files /dev/null and b/rapport/images/test-filter/binary_20.png differ diff --git a/rapport/images/test-filter/binary_25.png b/rapport/images/test-filter/binary_25.png new file mode 100644 index 0000000..d096434 Binary files /dev/null and b/rapport/images/test-filter/binary_25.png differ diff --git a/rapport/images/test-filter/binary_30.png b/rapport/images/test-filter/binary_30.png new file mode 100644 index 0000000..e2688d9 Binary files /dev/null and b/rapport/images/test-filter/binary_30.png differ diff --git a/rapport/images/test-filter/binary_40.png b/rapport/images/test-filter/binary_40.png new file mode 100644 index 0000000..6d58055 Binary files /dev/null and b/rapport/images/test-filter/binary_40.png differ diff --git a/rapport/images/test-filter/binary_50.png b/rapport/images/test-filter/binary_50.png new file mode 100644 index 0000000..379fb59 Binary files /dev/null and b/rapport/images/test-filter/binary_50.png differ diff --git a/rapport/images/test-filter/raw_image.png b/rapport/images/test-filter/raw_image.png new file mode 100644 index 0000000..a401528 Binary files /dev/null and b/rapport/images/test-filter/raw_image.png differ diff --git a/tests/examples/test-contour.cpp b/tests/examples/test-contour.cpp new file mode 100644 index 0000000..1af85fe --- /dev/null +++ b/tests/examples/test-contour.cpp @@ -0,0 +1,44 @@ +#include + +int main(int argc, char** argv) { + std::string imagename = ""; + int threshold = 25; + std::string save_path = "."; + + if (argc > 3) { + imagename = argv[1]; + threshold = atoi(argv[2]); + save_path = argv[3]; + } else { + std::cout << "Invalid number of arguments: test-descripteurs []" << std::endl; + return 0; + } + + cv::namedWindow("Image", CV_WINDOW_AUTOSIZE); + cv::namedWindow("Contour", CV_WINDOW_AUTOSIZE); + + cv::Mat image = cv::imread(imagename, CV_LOAD_IMAGE_COLOR); + cv::Mat binary(image.rows, image.cols, CV_8UC1); + cv::Mat contour(image.rows, image.cols, CV_8UC1); + + cv::GaussianBlur(image, image, cv::Size(7,7), 1.5, 1.5); + math::filter(image, binary, threshold); + + std::vector> contours; + std::vector hierarchy; + cv::findContours(binary, contours, hierarchy, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE); + + if (contours.size() != 0) { + int id = math::max_cont(contours); + cv::drawContours(contour, contours, id, 255, 4); + } + + cv::imshow("Image", image); + cv::imshow("Contour", contour); + + cv::imwrite(save_path+"/raw_image.png", image); + cv::imwrite(save_path+"/contour_"+std::to_string(threshold)+".png", contour); + + cv::waitKey(0); + return 0; +} diff --git a/tests/examples/test-filter.cpp b/tests/examples/test-filter.cpp new file mode 100644 index 0000000..c4add31 --- /dev/null +++ b/tests/examples/test-filter.cpp @@ -0,0 +1,34 @@ +#include + +int main(int argc, char** argv) { + std::string imagename = ""; + int threshold = 25; + std::string save_path = "."; + + if (argc > 3) { + imagename = argv[1]; + threshold = atoi(argv[2]); + save_path = argv[3]; + } else { + std::cout << "Invalid number of arguments: test-descripteurs []" << std::endl; + return 0; + } + + cv::namedWindow("Image", CV_WINDOW_AUTOSIZE); + cv::namedWindow("Binary", CV_WINDOW_AUTOSIZE); + + cv::Mat image = cv::imread(imagename, CV_LOAD_IMAGE_COLOR); + cv::Mat binary(image.rows, image.cols, CV_8UC1); + + cv::GaussianBlur(image, image, cv::Size(7,7), 1.5, 1.5); + math::filter(image, binary, threshold); + + cv::imshow("Image", image); + cv::imshow("Binary", binary); + + cv::imwrite(save_path+"/raw_image.png", image); + cv::imwrite(save_path+"/binary_"+std::to_string(threshold)+".png", binary); + + cv::waitKey(0); + return 0; +} diff --git a/tests/src/CMakeLists.txt b/tests/src/CMakeLists.txt index 73854df..80aaa9f 100644 --- a/tests/src/CMakeLists.txt +++ b/tests/src/CMakeLists.txt @@ -5,3 +5,6 @@ find_package(Boost COMPONENTS system filesystem REQUIRED) add_executable(knn knn.cpp) target_link_libraries(knn ${OpenCV_LIBS} ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY}) + +add_executable(neural_network neural_network.cpp) +target_link_libraries(neural_network ${OpenCV_LIBS} ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY}) diff --git a/tests/src/neural_network.cpp b/tests/src/neural_network.cpp new file mode 100644 index 0000000..7f43564 --- /dev/null +++ b/tests/src/neural_network.cpp @@ -0,0 +1,5 @@ +#include "math.hpp" + +int main(int argc, char** argv) { + return 0; +}