commit bf4a35f2c89976448158841232b36d0262b1c166 Author: Guillaume Courrier Date: Tue Oct 29 10:37:01 2019 +0100 Initial Commit diff --git a/enonce.pdf b/enonce.pdf new file mode 100644 index 0000000..0af5709 Binary files /dev/null and b/enonce.pdf differ diff --git a/opencv/.detection.cpp.swp b/opencv/.detection.cpp.swp new file mode 100644 index 0000000..52c4366 Binary files /dev/null and b/opencv/.detection.cpp.swp differ diff --git a/opencv/detection b/opencv/detection new file mode 100755 index 0000000..ea7cdbc Binary files /dev/null and b/opencv/detection differ diff --git a/opencv/detection.cpp b/opencv/detection.cpp new file mode 100644 index 0000000..2ce495b --- /dev/null +++ b/opencv/detection.cpp @@ -0,0 +1,64 @@ +#include "opencv2/opencv.hpp" + +using namespace cv; +using namespace std; + +int main(int, char**) +{ + int seuil=80; + char detect; + VideoCapture cap(0); + if(!cap.isOpened()) + return -1; + namedWindow("Image",1); + namedWindow("Detection",1); + namedWindow("Contours",1); + for(;;) { + int X,Y,DIM,index,indexNB; + unsigned int numc; + uchar R,G,B; + vector > contours; + vector hierarchy; + Mat frame; + cap >> frame; + X=frame.rows; + Y=frame.cols; + Mat Binaire(X,Y,CV_8UC1); + imshow("Image", frame); + GaussianBlur(frame, frame, Size(7,7), 1.5, 1.5); + X=frame.rows; + Y=frame.cols; + DIM=frame.channels(); + for (index=0,indexNB=0;indexG) && (R>B)) + if (((R-B)>=seuil) || ((R-G)>=seuil)) + detect=1; + if (detect==1) + Binaire.data[indexNB]=255; + else + Binaire.data[indexNB]=0; + } + imshow("Detection", Binaire); + findContours(Binaire, contours, hierarchy, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE); + Mat Dessin = Mat::zeros(X,Y, CV_8UC1); + unsigned int max = 0; + int id = 0; + for(numc = 0; numc max) { + max = contours[numc].size(); + id = numc; + } + } + drawContours(Dessin, contours, id, 255); + imshow("Contours", Dessin); + if(waitKey(30) == 27) { + break; + } + } + return 0; +} diff --git a/opencv/exemplepython.jpg b/opencv/exemplepython.jpg new file mode 100644 index 0000000..a5c9b8b Binary files /dev/null and b/opencv/exemplepython.jpg differ diff --git a/opencv/genere b/opencv/genere new file mode 100755 index 0000000..1e3578c --- /dev/null +++ b/opencv/genere @@ -0,0 +1 @@ +g++ -Wall `pkg-config --cflags --libs opencv` test.cpp -o test \ No newline at end of file diff --git a/opencv/genere_detection b/opencv/genere_detection new file mode 100755 index 0000000..21c6c59 --- /dev/null +++ b/opencv/genere_detection @@ -0,0 +1 @@ +g++ -Wall detection.cpp `pkg-config --cflags --libs opencv` -o detection diff --git a/opencv/genere_lireimage b/opencv/genere_lireimage new file mode 100755 index 0000000..291981c --- /dev/null +++ b/opencv/genere_lireimage @@ -0,0 +1 @@ +g++ -Wall lireimage.cpp `pkg-config --cflags --libs opencv` -o lireimage diff --git a/opencv/genere_lpe_col b/opencv/genere_lpe_col new file mode 100755 index 0000000..8eec544 --- /dev/null +++ b/opencv/genere_lpe_col @@ -0,0 +1 @@ +g++ -Wall lpe_col.cpp `pkg-config --cflags --libs opencv` -o lpe_col diff --git a/opencv/genere_testcam b/opencv/genere_testcam new file mode 100755 index 0000000..ba84cb6 --- /dev/null +++ b/opencv/genere_testcam @@ -0,0 +1 @@ +g++ -Wall testcam.cpp `pkg-config --cflags --libs opencv` -o testcam diff --git a/opencv/lireimage b/opencv/lireimage new file mode 100755 index 0000000..d73bc0d Binary files /dev/null and b/opencv/lireimage differ diff --git a/opencv/lireimage.cpp b/opencv/lireimage.cpp new file mode 100644 index 0000000..46a4c1d --- /dev/null +++ b/opencv/lireimage.cpp @@ -0,0 +1,30 @@ +#include +#include +#include + +using namespace cv; +using namespace std; + +int main( int argc, char** argv ) +{ + if( argc != 2) + { + cout <<" Usage: display_image ImageToLoadAndDisplay" << endl; + return -1; + } + + Mat image; + image = imread(argv[1], CV_LOAD_IMAGE_COLOR); // Read the file + + if(! image.data ) // Check for invalid input + { + cout << "Could not open or find the image" << std::endl ; + return -1; + } + + namedWindow( "Display window", WINDOW_AUTOSIZE );// Create a window for display. + imshow( "Display window", image ); // Show our image inside it. + + waitKey(0); // Wait for a keystroke in the window + return 0; +} \ No newline at end of file diff --git a/opencv/lpe_col.cpp b/opencv/lpe_col.cpp new file mode 100644 index 0000000..bfc13c6 --- /dev/null +++ b/opencv/lpe_col.cpp @@ -0,0 +1,85 @@ +#include "opencv2/opencv.hpp" + +using namespace cv; +using namespace std; + +int Traitement(VideoCapture cap,int seuil,Vec3b couleur) +{ + Mat trame,gris,flou,contx,conty,cont,contbin; + vector > contours; + vector hierarchy; + int X,Y,x,y,k,nbcont,numc,index; + cap>>trame; + X=trame.rows; + Y=trame.cols; + namedWindow("Image",1); + imshow("Image", trame); + cvtColor(trame,gris,COLOR_BGR2GRAY); + GaussianBlur(gris,flou,Size(5,5),0,0); + Sobel(flou,contx,CV_64F,1,0); + Sobel(flou,conty,CV_64F,0,1); + cont=abs(contx)+abs(conty); + contbin=(cont couleurs; + vector indexcoul; + couleurs.reserve(nbcont); + indexcoul.reserve(nbcont); + for(index=0;index(x,y)-1; + if (index>=0) + { + indexcoul[index]++; + for (k=0;k<3;k++) + couleurs[index][k]= + couleurs[index][k]+trame.at(x,y)[k]; + } + } + for(index=0;index(x,y)-1; + if (index>=0) + for (k=0;k<3;k++) + trame.at(x,y)[k]=couleurs[index][k]; + else + trame.at(x,y)=couleur; + } + namedWindow("LPE",1); + imshow("LPE", trame); + if(waitKey(30) >= 0) + return true; + else + return false; +} + +int main(int, char**) +{ + VideoCapture cap(0); + int seuil=10; + Vec3b couleur(128,128,128); + while(Traitement(cap,seuil,couleur)==false); +} + + + diff --git a/opencv/test.cpp b/opencv/test.cpp new file mode 100644 index 0000000..83292c8 --- /dev/null +++ b/opencv/test.cpp @@ -0,0 +1,25 @@ +#include "opencv2/opencv.hpp" + +using namespace cv; + +int main(int, char**) +{ + VideoCapture cap(0); // open the default camera + if(!cap.isOpened()) // check if we succeeded + return -1; + + Mat edges; + namedWindow("edges",1); + for(;;) + { + Mat frame; + cap >> frame; // get a new frame from camera + cvtColor(frame, edges, CV_BGR2GRAY); + GaussianBlur(edges, edges, Size(7,7), 1.5, 1.5); + Canny(edges, edges, 0, 30, 3); + imshow("edges", edges); + if(waitKey(30) >= 0) break; + } + // the camera will be deinitialized automatically in VideoCapture destructor + return 0; +} diff --git a/opencv/testcam b/opencv/testcam new file mode 100755 index 0000000..7ad8177 Binary files /dev/null and b/opencv/testcam differ diff --git a/opencv/testcam.cpp b/opencv/testcam.cpp new file mode 100644 index 0000000..b80e7c8 --- /dev/null +++ b/opencv/testcam.cpp @@ -0,0 +1,36 @@ +#include "opencv2/opencv.hpp" + +using namespace cv; +using namespace std; + +int main(int argc, char* argv[]) +{ + VideoCapture cap(0); + + + if ( !cap.isOpened() ) + { + cout << "Cannot open webcam" << endl; + return -1; + } + namedWindow("MyVideo",CV_WINDOW_AUTOSIZE); + while(1) + { + Mat frame; + bool bSuccess = cap.read(frame); + if (!bSuccess) + { + cout << "Cannot read the frame from webcam" << endl; + break; + } + + imshow("MyVideo", frame); + + if(waitKey(30) == 27) + { + cout << "esc key is pressed by user" << endl; + break; + } + } + return 0; +} diff --git a/src/.traitement.cpp.swp b/src/.traitement.cpp.swp new file mode 100644 index 0000000..0998684 Binary files /dev/null and b/src/.traitement.cpp.swp differ diff --git a/src/traitement b/src/traitement new file mode 100755 index 0000000..63dd421 Binary files /dev/null and b/src/traitement differ diff --git a/src/traitement.cpp b/src/traitement.cpp new file mode 100644 index 0000000..6756258 --- /dev/null +++ b/src/traitement.cpp @@ -0,0 +1,24 @@ +#include "opencv2/opencv.hpp" + +int main(int, char**) +{ + cv::VideoCapture cap(0); // open the default camera + if(!cap.isOpened()) // check if we succeeded + return -1; + + cv::Mat edges; + cv::namedWindow("edges",1); + while(1){ + cv::Mat frame; + cap >> frame; // get a new frame from camera + //cv::cvtColor(frame, edges, CV_BGR2GRAY); + //cv::GaussianBlur(edges, edges, cv::Size(7,7), 1.5, 1.5); + //cv::Canny(edges, edges, 0, 30, 3); + cv::imshow("edges", frame); + if(cv::waitKey(30) == 27) { + break; + } + } + // the camera will be deinitialized automatically in VideoCapture destructor + return 0; +}