implémentation de knn + ajout d'images et d'exemples
1
ROS/gesture_based_control/src/math.hpp
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
/home/guillaume/Documents/3A_supelec/miniprojet/tests/src/math.hpp
|
BIN
rapport/images/test-contour/contour_20.png
Normal file
After Width: | Height: | Size: 3.9 KiB |
BIN
rapport/images/test-contour/raw_image.png
Normal file
After Width: | Height: | Size: 172 KiB |
BIN
rapport/images/test-filter/binary_10.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
rapport/images/test-filter/binary_15.png
Normal file
After Width: | Height: | Size: 3 KiB |
BIN
rapport/images/test-filter/binary_20.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
rapport/images/test-filter/binary_25.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
rapport/images/test-filter/binary_30.png
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
rapport/images/test-filter/binary_40.png
Normal file
After Width: | Height: | Size: 4.2 KiB |
BIN
rapport/images/test-filter/binary_50.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
rapport/images/test-filter/raw_image.png
Normal file
After Width: | Height: | Size: 172 KiB |
44
tests/examples/test-contour.cpp
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
#include <math.hpp>
|
||||||
|
|
||||||
|
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 <path_to_image> [<threshold>]" << 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<std::vector<cv::Point>> contours;
|
||||||
|
std::vector<cv::Vec4i> 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;
|
||||||
|
}
|
34
tests/examples/test-filter.cpp
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
#include <math.hpp>
|
||||||
|
|
||||||
|
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 <path_to_image> [<threshold>]" << 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;
|
||||||
|
}
|
|
@ -5,3 +5,6 @@ find_package(Boost COMPONENTS system filesystem REQUIRED)
|
||||||
|
|
||||||
add_executable(knn knn.cpp)
|
add_executable(knn knn.cpp)
|
||||||
target_link_libraries(knn ${OpenCV_LIBS} ${Boost_FILESYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY})
|
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})
|
||||||
|
|
5
tests/src/neural_network.cpp
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
#include "math.hpp"
|
||||||
|
|
||||||
|
int main(int argc, char** argv) {
|
||||||
|
return 0;
|
||||||
|
}
|