diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..1647e72 Binary files /dev/null and b/.DS_Store differ diff --git a/Activity/.DS_Store b/Activity/.DS_Store new file mode 100644 index 0000000..9758296 Binary files /dev/null and b/Activity/.DS_Store differ diff --git a/Activity/PriseEnMainActivite0/.DS_Store b/Activity/PriseEnMainActivite0/.DS_Store new file mode 100644 index 0000000..16a8302 Binary files /dev/null and b/Activity/PriseEnMainActivite0/.DS_Store differ diff --git a/Activity/PriseEnMainActivite0/.classpath b/Activity/PriseEnMainActivite0/.classpath new file mode 100644 index 0000000..07f5f9e --- /dev/null +++ b/Activity/PriseEnMainActivite0/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/Activity/PriseEnMainActivite0/.project b/Activity/PriseEnMainActivite0/.project new file mode 100644 index 0000000..6c16d55 --- /dev/null +++ b/Activity/PriseEnMainActivite0/.project @@ -0,0 +1,28 @@ + + + PriseEnMainActivite0 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + + + 1683024126025 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + + diff --git a/Activity/PriseEnMainActivite0/.settings/org.eclipse.jdt.core.prefs b/Activity/PriseEnMainActivite0/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..bb35fa0 --- /dev/null +++ b/Activity/PriseEnMainActivite0/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Activity/PriseEnMainActivite0/Mabiblio.jar b/Activity/PriseEnMainActivite0/Mabiblio.jar new file mode 100644 index 0000000..5b6929c Binary files /dev/null and b/Activity/PriseEnMainActivite0/Mabiblio.jar differ diff --git a/Activity/PriseEnMainActivite0/Thumbs.db b/Activity/PriseEnMainActivite0/Thumbs.db new file mode 100644 index 0000000..9aebfb4 Binary files /dev/null and b/Activity/PriseEnMainActivite0/Thumbs.db differ diff --git a/Activity/PriseEnMainActivite0/bin/Activite0.class b/Activity/PriseEnMainActivite0/bin/Activite0.class new file mode 100644 index 0000000..0d79c70 Binary files /dev/null and b/Activity/PriseEnMainActivite0/bin/Activite0.class differ diff --git a/Activity/PriseEnMainActivite0/bin/Thumbs.db b/Activity/PriseEnMainActivite0/bin/Thumbs.db new file mode 100644 index 0000000..16624dc Binary files /dev/null and b/Activity/PriseEnMainActivite0/bin/Thumbs.db differ diff --git a/Activity/PriseEnMainActivite0/ref110.jpg b/Activity/PriseEnMainActivite0/ref110.jpg new file mode 100644 index 0000000..2aad348 Binary files /dev/null and b/Activity/PriseEnMainActivite0/ref110.jpg differ diff --git a/Activity/PriseEnMainActivite0/ref30.jpg b/Activity/PriseEnMainActivite0/ref30.jpg new file mode 100644 index 0000000..32627e4 Binary files /dev/null and b/Activity/PriseEnMainActivite0/ref30.jpg differ diff --git a/Activity/PriseEnMainActivite0/ref50.jpg b/Activity/PriseEnMainActivite0/ref50.jpg new file mode 100644 index 0000000..0ddc9ac Binary files /dev/null and b/Activity/PriseEnMainActivite0/ref50.jpg differ diff --git a/Activity/PriseEnMainActivite0/ref70.jpg b/Activity/PriseEnMainActivite0/ref70.jpg new file mode 100644 index 0000000..3298076 Binary files /dev/null and b/Activity/PriseEnMainActivite0/ref70.jpg differ diff --git a/Activity/PriseEnMainActivite0/ref90.jpg b/Activity/PriseEnMainActivite0/ref90.jpg new file mode 100644 index 0000000..34aa798 Binary files /dev/null and b/Activity/PriseEnMainActivite0/ref90.jpg differ diff --git a/Activity/PriseEnMainActivite0/refdouble.jpg b/Activity/PriseEnMainActivite0/refdouble.jpg new file mode 100644 index 0000000..5c057d3 Binary files /dev/null and b/Activity/PriseEnMainActivite0/refdouble.jpg differ diff --git a/Activity/PriseEnMainActivite0/src/Activite0.java b/Activity/PriseEnMainActivite0/src/Activite0.java new file mode 100644 index 0000000..be0de48 --- /dev/null +++ b/Activity/PriseEnMainActivite0/src/Activite0.java @@ -0,0 +1,9 @@ +import utilitaireAgreg.*; + +public class Activite0 { + + + public static void main(String[] args) { + MaBibliothequeTraitementImage.ObjectifARealiser("video1.avi"); + } +} \ No newline at end of file diff --git a/Activity/PriseEnMainActivite0/src/Thumbs.db b/Activity/PriseEnMainActivite0/src/Thumbs.db new file mode 100644 index 0000000..16624dc Binary files /dev/null and b/Activity/PriseEnMainActivite0/src/Thumbs.db differ diff --git a/Activity/PriseEnMainActivite0/video1.avi b/Activity/PriseEnMainActivite0/video1.avi new file mode 100644 index 0000000..8fac3e1 Binary files /dev/null and b/Activity/PriseEnMainActivite0/video1.avi differ diff --git a/Activity/PriseEnMainActivite0/video1.mp4 b/Activity/PriseEnMainActivite0/video1.mp4 new file mode 100644 index 0000000..3826b37 Binary files /dev/null and b/Activity/PriseEnMainActivite0/video1.mp4 differ diff --git a/Activity/PriseEnMainActivite0/video2.avi b/Activity/PriseEnMainActivite0/video2.avi new file mode 100644 index 0000000..52209c9 Binary files /dev/null and b/Activity/PriseEnMainActivite0/video2.avi differ diff --git a/Activity/PriseEnMainActivite0/video2.mp4 b/Activity/PriseEnMainActivite0/video2.mp4 new file mode 100644 index 0000000..9ecf0e7 Binary files /dev/null and b/Activity/PriseEnMainActivite0/video2.mp4 differ diff --git a/Activity/PriseEnMainActivite1/.DS_Store b/Activity/PriseEnMainActivite1/.DS_Store new file mode 100644 index 0000000..4d188e1 Binary files /dev/null and b/Activity/PriseEnMainActivite1/.DS_Store differ diff --git a/Activity/PriseEnMainActivite1/.classpath b/Activity/PriseEnMainActivite1/.classpath new file mode 100644 index 0000000..a1a3b39 --- /dev/null +++ b/Activity/PriseEnMainActivite1/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/Activity/PriseEnMainActivite1/.project b/Activity/PriseEnMainActivite1/.project new file mode 100644 index 0000000..50fc30b --- /dev/null +++ b/Activity/PriseEnMainActivite1/.project @@ -0,0 +1,28 @@ + + + PriseEnMainActivite1 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + + + 1683024126038 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + + diff --git a/Activity/PriseEnMainActivite1/.settings/org.eclipse.jdt.core.prefs b/Activity/PriseEnMainActivite1/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..bb35fa0 --- /dev/null +++ b/Activity/PriseEnMainActivite1/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Activity/PriseEnMainActivite1/Thumbs.db b/Activity/PriseEnMainActivite1/Thumbs.db new file mode 100644 index 0000000..84584c1 Binary files /dev/null and b/Activity/PriseEnMainActivite1/Thumbs.db differ diff --git a/Activity/PriseEnMainActivite1/activite1.png b/Activity/PriseEnMainActivite1/activite1.png new file mode 100644 index 0000000..7ff3a7d Binary files /dev/null and b/Activity/PriseEnMainActivite1/activite1.png differ diff --git a/Activity/PriseEnMainActivite1/bin/Activite1.class b/Activity/PriseEnMainActivite1/bin/Activite1.class new file mode 100644 index 0000000..43ba821 Binary files /dev/null and b/Activity/PriseEnMainActivite1/bin/Activite1.class differ diff --git a/Activity/PriseEnMainActivite1/src/Activite1.java b/Activity/PriseEnMainActivite1/src/Activite1.java new file mode 100644 index 0000000..5f776cc --- /dev/null +++ b/Activity/PriseEnMainActivite1/src/Activite1.java @@ -0,0 +1,41 @@ +import java.io.File; + +import org.opencv.core.Mat; +import org.opencv.highgui.Highgui; + +public class Activite1 { + + public static void main(String[] args) { + //Chargement de la librairie + System.loadLibrary("opencv_java249"); + //Lecture du fichier image et transformation en matrice + Mat m=LectureImage("activite1.png"); + + //Début du traitement + for (int i=0; i + + + + + + + diff --git a/Activity/PriseEnMainActivite2/.project b/Activity/PriseEnMainActivite2/.project new file mode 100644 index 0000000..c66e5e6 --- /dev/null +++ b/Activity/PriseEnMainActivite2/.project @@ -0,0 +1,28 @@ + + + PriseEnMainActivite2 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + + + 1683024126053 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + + diff --git a/Activity/PriseEnMainActivite2/.settings/org.eclipse.jdt.core.prefs b/Activity/PriseEnMainActivite2/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..bb35fa0 --- /dev/null +++ b/Activity/PriseEnMainActivite2/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Activity/PriseEnMainActivite2/Thumbs.db b/Activity/PriseEnMainActivite2/Thumbs.db new file mode 100644 index 0000000..6816637 Binary files /dev/null and b/Activity/PriseEnMainActivite2/Thumbs.db differ diff --git a/Activity/PriseEnMainActivite2/bgr.png b/Activity/PriseEnMainActivite2/bgr.png new file mode 100644 index 0000000..322eab0 Binary files /dev/null and b/Activity/PriseEnMainActivite2/bgr.png differ diff --git a/Activity/PriseEnMainActivite2/bin/Activite2.class b/Activity/PriseEnMainActivite2/bin/Activite2.class new file mode 100644 index 0000000..d3dc7b2 Binary files /dev/null and b/Activity/PriseEnMainActivite2/bin/Activite2.class differ diff --git a/Activity/PriseEnMainActivite2/src/Activite2.java b/Activity/PriseEnMainActivite2/src/Activite2.java new file mode 100644 index 0000000..accb4ad --- /dev/null +++ b/Activity/PriseEnMainActivite2/src/Activite2.java @@ -0,0 +1,64 @@ +import java.awt.image.BufferedImage; +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.InputStream; +import java.util.Vector; + +import javax.imageio.ImageIO; +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JLabel; + +import org.opencv.core.Core; +import org.opencv.core.Mat; +import org.opencv.core.MatOfByte; +import org.opencv.highgui.Highgui; + +public class Activite2 { + + public static void main(String[] args) { + // TODO Auto-generated method stubCE + System.loadLibrary("opencv_java249"); + //Lecture du fichier image et transformation en matrice + Mat m=LectureImage("bgr.png"); + //Création d'un vecteur de matrices + Vector channels=new Vector(); + //découpage de la matrice en 3 canneaux séparés + Core.split(m,channels); + for (int i=0;i + + + + + + + diff --git a/Activity/PriseEnMainActivite3/.project b/Activity/PriseEnMainActivite3/.project new file mode 100644 index 0000000..59671ec --- /dev/null +++ b/Activity/PriseEnMainActivite3/.project @@ -0,0 +1,28 @@ + + + PriseEnMainActivite3 + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + + + 1683024126069 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + + diff --git a/Activity/PriseEnMainActivite3/.settings/org.eclipse.jdt.core.prefs b/Activity/PriseEnMainActivite3/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..bb35fa0 --- /dev/null +++ b/Activity/PriseEnMainActivite3/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/Activity/PriseEnMainActivite3/bin/Activite3.class b/Activity/PriseEnMainActivite3/bin/Activite3.class new file mode 100644 index 0000000..3397ff1 Binary files /dev/null and b/Activity/PriseEnMainActivite3/bin/Activite3.class differ diff --git a/Activity/PriseEnMainActivite3/bin/MaBibliothequeTraitementImage.class b/Activity/PriseEnMainActivite3/bin/MaBibliothequeTraitementImage.class new file mode 100644 index 0000000..ab45649 Binary files /dev/null and b/Activity/PriseEnMainActivite3/bin/MaBibliothequeTraitementImage.class differ diff --git a/Activity/PriseEnMainActivite3/p0.jpg b/Activity/PriseEnMainActivite3/p0.jpg new file mode 100644 index 0000000..a5257d6 Binary files /dev/null and b/Activity/PriseEnMainActivite3/p0.jpg differ diff --git a/Activity/PriseEnMainActivite3/src/Activite3.java b/Activity/PriseEnMainActivite3/src/Activite3.java new file mode 100644 index 0000000..323b4de --- /dev/null +++ b/Activity/PriseEnMainActivite3/src/Activite3.java @@ -0,0 +1,15 @@ + +import org.opencv.core.*; +import org.opencv.highgui.*; + +public class Activite3 { + + public static void main(String[] args) + { + System.loadLibrary("opencv_java249"); + Mat m=Highgui.imread("p0.jpg",Highgui.CV_LOAD_IMAGE_COLOR); + MaBibliothequeTraitementImage.afficheImage("Image originale", m); + + + } +} \ No newline at end of file diff --git a/Activity/PriseEnMainActivite3/src/MaBibliothequeTraitementImage.java b/Activity/PriseEnMainActivite3/src/MaBibliothequeTraitementImage.java new file mode 100644 index 0000000..e128188 --- /dev/null +++ b/Activity/PriseEnMainActivite3/src/MaBibliothequeTraitementImage.java @@ -0,0 +1,88 @@ +import java.awt.Dimension; +import java.awt.image.BufferedImage; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Random; +import java.util.Vector; + +import javax.imageio.ImageIO; +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; + +import org.opencv.core.Core; +import org.opencv.core.CvType; +import org.opencv.core.Mat; +import org.opencv.core.MatOfByte; +import org.opencv.core.MatOfDMatch; +import org.opencv.core.MatOfInt4; +import org.opencv.core.MatOfKeyPoint; +import org.opencv.core.MatOfPoint; +import org.opencv.core.MatOfPoint2f; +import org.opencv.core.Point; +import org.opencv.core.Rect; +import org.opencv.core.Scalar; +import org.opencv.core.Size; +import org.opencv.features2d.DMatch; +import org.opencv.features2d.DescriptorExtractor; +import org.opencv.features2d.DescriptorMatcher; +import org.opencv.features2d.FeatureDetector; +import org.opencv.features2d.Features2d; +import org.opencv.highgui.Highgui; +import org.opencv.imgproc.Imgproc; + +public class MaBibliothequeTraitementImage { + + + + //Methode qui permet de transformer une matrice intialement au format BGR au format HSV + public static Mat transformeBGRversHSV(Mat matriceBGR){ + Mat matriceHSV=new Mat(matriceBGR.height(),matriceBGR.cols(),matriceBGR.type()); + Imgproc.cvtColor(matriceBGR,matriceHSV,Imgproc.COLOR_BGR2HSV); + return matriceHSV; + + } + + //Methode qui convertit une matrice avec 3 cannaux en un vecteur de 3 matrices monocanal (un canal par couleur) + public static Vector splitHSVChannels(Mat input) { + Vector channels = new Vector(); + Core.split(input, channels); + return channels; + } + + //Methode qui permet d'afficher une image dans une fenetre java independante + public static void afficheImage(String title, Mat img){ + MatOfByte matOfByte=new MatOfByte(); + Highgui.imencode(".png",img,matOfByte); + byte[] byteArray=matOfByte.toArray(); + BufferedImage bufImage=null; + try{ + InputStream in=new ByteArrayInputStream(byteArray); + bufImage=ImageIO.read(in); + JFrame frame=new JFrame(); + frame.setTitle(title); + frame.getContentPane().add(new JLabel(new ImageIcon(bufImage))); + frame.pack(); + frame.setVisible(true); + + } + catch(Exception e){ + e.printStackTrace(); + } + + + } + + + + + + +} + diff --git "a/Deuxi\303\244meEtude/.DS_Store" "b/Deuxi\303\244meEtude/.DS_Store" new file mode 100644 index 0000000..0fac40f Binary files /dev/null and "b/Deuxi\303\244meEtude/.DS_Store" differ diff --git "a/Deuxi\303\244meEtude/.classpath" "b/Deuxi\303\244meEtude/.classpath" new file mode 100644 index 0000000..4759107 --- /dev/null +++ "b/Deuxi\303\244meEtude/.classpath" @@ -0,0 +1,8 @@ + + + + + + + + diff --git "a/Deuxi\303\244meEtude/.project" "b/Deuxi\303\244meEtude/.project" new file mode 100644 index 0000000..f1dd6bf --- /dev/null +++ "b/Deuxi\303\244meEtude/.project" @@ -0,0 +1,28 @@ + + + DeuxièmeEtude + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + + + 1683024125971 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + + diff --git "a/Deuxi\303\244meEtude/.settings/org.eclipse.jdt.core.prefs" "b/Deuxi\303\244meEtude/.settings/org.eclipse.jdt.core.prefs" new file mode 100644 index 0000000..bb35fa0 --- /dev/null +++ "b/Deuxi\303\244meEtude/.settings/org.eclipse.jdt.core.prefs" @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git "a/Deuxi\303\244meEtude/Mabiblio.jar" "b/Deuxi\303\244meEtude/Mabiblio.jar" new file mode 100644 index 0000000..5b6929c Binary files /dev/null and "b/Deuxi\303\244meEtude/Mabiblio.jar" differ diff --git "a/Deuxi\303\244meEtude/Thumbs.db" "b/Deuxi\303\244meEtude/Thumbs.db" new file mode 100644 index 0000000..90e6818 Binary files /dev/null and "b/Deuxi\303\244meEtude/Thumbs.db" differ diff --git "a/Deuxi\303\244meEtude/bin/.DS_Store" "b/Deuxi\303\244meEtude/bin/.DS_Store" new file mode 100644 index 0000000..f0a562a Binary files /dev/null and "b/Deuxi\303\244meEtude/bin/.DS_Store" differ diff --git "a/Deuxi\303\244meEtude/bin/MaBibliothequeTraitementImageEtendue_DEUX.class" "b/Deuxi\303\244meEtude/bin/MaBibliothequeTraitementImageEtendue_DEUX.class" new file mode 100644 index 0000000..0c6439d Binary files /dev/null and "b/Deuxi\303\244meEtude/bin/MaBibliothequeTraitementImageEtendue_DEUX.class" differ diff --git "a/Deuxi\303\244meEtude/bin/Principale_DEUX.class" "b/Deuxi\303\244meEtude/bin/Principale_DEUX.class" new file mode 100644 index 0000000..8cd6263 Binary files /dev/null and "b/Deuxi\303\244meEtude/bin/Principale_DEUX.class" differ diff --git "a/Deuxi\303\244meEtude/p1.jpg" "b/Deuxi\303\244meEtude/p1.jpg" new file mode 100644 index 0000000..222e3ae Binary files /dev/null and "b/Deuxi\303\244meEtude/p1.jpg" differ diff --git "a/Deuxi\303\244meEtude/p10.jpg" "b/Deuxi\303\244meEtude/p10.jpg" new file mode 100644 index 0000000..4a21be3 Binary files /dev/null and "b/Deuxi\303\244meEtude/p10.jpg" differ diff --git "a/Deuxi\303\244meEtude/p2.jpg" "b/Deuxi\303\244meEtude/p2.jpg" new file mode 100644 index 0000000..ca33c65 Binary files /dev/null and "b/Deuxi\303\244meEtude/p2.jpg" differ diff --git "a/Deuxi\303\244meEtude/p3.jpg" "b/Deuxi\303\244meEtude/p3.jpg" new file mode 100644 index 0000000..eb34287 Binary files /dev/null and "b/Deuxi\303\244meEtude/p3.jpg" differ diff --git "a/Deuxi\303\244meEtude/p4.jpg" "b/Deuxi\303\244meEtude/p4.jpg" new file mode 100644 index 0000000..e5c2fba Binary files /dev/null and "b/Deuxi\303\244meEtude/p4.jpg" differ diff --git "a/Deuxi\303\244meEtude/p5.jpg" "b/Deuxi\303\244meEtude/p5.jpg" new file mode 100644 index 0000000..e443c8f Binary files /dev/null and "b/Deuxi\303\244meEtude/p5.jpg" differ diff --git "a/Deuxi\303\244meEtude/p6.jpg" "b/Deuxi\303\244meEtude/p6.jpg" new file mode 100644 index 0000000..cd6b4e9 Binary files /dev/null and "b/Deuxi\303\244meEtude/p6.jpg" differ diff --git "a/Deuxi\303\244meEtude/p7.JPG" "b/Deuxi\303\244meEtude/p7.JPG" new file mode 100644 index 0000000..827c466 Binary files /dev/null and "b/Deuxi\303\244meEtude/p7.JPG" differ diff --git "a/Deuxi\303\244meEtude/p8.jpg" "b/Deuxi\303\244meEtude/p8.jpg" new file mode 100644 index 0000000..86f84a8 Binary files /dev/null and "b/Deuxi\303\244meEtude/p8.jpg" differ diff --git "a/Deuxi\303\244meEtude/p9.jpg" "b/Deuxi\303\244meEtude/p9.jpg" new file mode 100644 index 0000000..fb9b846 Binary files /dev/null and "b/Deuxi\303\244meEtude/p9.jpg" differ diff --git "a/Deuxi\303\244meEtude/ref110.jpg" "b/Deuxi\303\244meEtude/ref110.jpg" new file mode 100644 index 0000000..2aad348 Binary files /dev/null and "b/Deuxi\303\244meEtude/ref110.jpg" differ diff --git "a/Deuxi\303\244meEtude/ref30.jpg" "b/Deuxi\303\244meEtude/ref30.jpg" new file mode 100644 index 0000000..32627e4 Binary files /dev/null and "b/Deuxi\303\244meEtude/ref30.jpg" differ diff --git "a/Deuxi\303\244meEtude/ref50.jpg" "b/Deuxi\303\244meEtude/ref50.jpg" new file mode 100644 index 0000000..0ddc9ac Binary files /dev/null and "b/Deuxi\303\244meEtude/ref50.jpg" differ diff --git "a/Deuxi\303\244meEtude/ref70.jpg" "b/Deuxi\303\244meEtude/ref70.jpg" new file mode 100644 index 0000000..3298076 Binary files /dev/null and "b/Deuxi\303\244meEtude/ref70.jpg" differ diff --git "a/Deuxi\303\244meEtude/ref90.jpg" "b/Deuxi\303\244meEtude/ref90.jpg" new file mode 100644 index 0000000..34aa798 Binary files /dev/null and "b/Deuxi\303\244meEtude/ref90.jpg" differ diff --git "a/Deuxi\303\244meEtude/refdouble.jpg" "b/Deuxi\303\244meEtude/refdouble.jpg" new file mode 100644 index 0000000..5c057d3 Binary files /dev/null and "b/Deuxi\303\244meEtude/refdouble.jpg" differ diff --git "a/Deuxi\303\244meEtude/src/.DS_Store" "b/Deuxi\303\244meEtude/src/.DS_Store" new file mode 100644 index 0000000..c5f9c5f Binary files /dev/null and "b/Deuxi\303\244meEtude/src/.DS_Store" differ diff --git "a/Deuxi\303\244meEtude/src/MaBibliothequeTraitementImageEtendueDEUX.java" "b/Deuxi\303\244meEtude/src/MaBibliothequeTraitementImageEtendueDEUX.java" new file mode 100644 index 0000000..4169276 --- /dev/null +++ "b/Deuxi\303\244meEtude/src/MaBibliothequeTraitementImageEtendueDEUX.java" @@ -0,0 +1,225 @@ +import java.awt.Dimension; +import java.awt.image.BufferedImage; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.List; +import java.util.Random; +import java.util.Vector; + +import javax.imageio.ImageIO; +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; + +import org.opencv.core.Core; +import org.opencv.core.CvType; +import org.opencv.core.Mat; +import org.opencv.core.MatOfByte; +import org.opencv.core.MatOfDMatch; +import org.opencv.core.MatOfInt4; +import org.opencv.core.MatOfKeyPoint; +import org.opencv.core.MatOfPoint; +import org.opencv.core.MatOfPoint2f; +import org.opencv.core.Point; +import org.opencv.core.Rect; +import org.opencv.core.Scalar; +import org.opencv.core.Size; +import org.opencv.features2d.DMatch; +import org.opencv.features2d.DescriptorExtractor; +import org.opencv.features2d.DescriptorMatcher; +import org.opencv.features2d.FeatureDetector; +import org.opencv.features2d.Features2d; +import org.opencv.highgui.Highgui; +import org.opencv.imgproc.Imgproc; + +public class MaBibliothequeTraitementImageEtendue { + //Contient toutes les méthodes necessaires à la transformation des images + + + //Methode qui permet de transformer une matrice intialement au format BGR au format HSV + public static Mat transformeBGRversHSV(Mat matriceBGR){ + Mat matriceHSV=new Mat(matriceBGR.height(),matriceBGR.cols(),matriceBGR.type()); + Imgproc.cvtColor(matriceBGR,matriceHSV,Imgproc.COLOR_BGR2HSV); + return matriceHSV; + + } + + //Methode qui convertit une matrice avec 3 canaux en un vecteur de 3 matrices monocanal (un canal par couleur) + public static Vector splitHSVChannels(Mat input) { + Vector channels = new Vector(); + Core.split(input, channels); + return channels; + } + + //Methode qui permet d'afficher une image sur un panel + public static void afficheImage(String title, Mat img){ + MatOfByte matOfByte=new MatOfByte(); + Highgui.imencode(".png",img,matOfByte); + byte[] byteArray=matOfByte.toArray(); + BufferedImage bufImage=null; + try{ + InputStream in=new ByteArrayInputStream(byteArray); + bufImage=ImageIO.read(in); + JFrame frame=new JFrame(); + frame.setTitle(title); + frame.getContentPane().add(new JLabel(new ImageIcon(bufImage))); + frame.pack(); + frame.setVisible(true); + + } + catch(Exception e){ + e.printStackTrace(); + } + + + } + + + + //Methode qui permet d'extraire les contours d'une image donnee + public static List ExtractContours(Mat input) { + // Detecter les contours des formes trouvées + int thresh = 100; + Mat canny_output = new Mat(); + List contours = new ArrayList(); + MatOfInt4 hierarchy = new MatOfInt4(); + Imgproc.Canny( input, canny_output, thresh, thresh*2); + + + /// Find extreme outer contours + Imgproc.findContours( canny_output, contours, hierarchy,Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE); + + Mat drawing = Mat.zeros( canny_output.size(), CvType.CV_8UC3 ); + Random rand = new Random(); + for( int i = 0; i< contours.size(); i++ ) + { + Scalar color = new Scalar( rand.nextInt(255 - 0 + 1) , rand.nextInt(255 - 0 + 1),rand.nextInt(255 - 0 + 1) ); + Imgproc.drawContours( drawing, contours, i, color, 1, 8, hierarchy, 0, new Point() ); + } + //afficheImage("Contours",drawing); + + return contours; + } + + //Methode qui permet de decouper et identifier les contours carrés, triangulaires ou rectangulaires. + //Renvoie null si aucun contour rond n'a été trouvé. + //Renvoie une matrice carrée englobant un contour rond si un contour rond a été trouvé + public static Mat DetectForm(Mat img,MatOfPoint contour) { + MatOfPoint2f matOfPoint2f = new MatOfPoint2f(); + MatOfPoint2f approxCurve = new MatOfPoint2f(); + float[] radius = new float[1]; + Point center = new Point(); + Rect rect = Imgproc.boundingRect(contour); + double contourArea = Imgproc.contourArea(contour); + + + matOfPoint2f.fromList(contour.toList()); + // Cherche le plus petit cercle entourant le contour + Imgproc.minEnclosingCircle(matOfPoint2f, center, radius); + //System.out.println(contourArea+" "+Math.PI*radius[0]*radius[0]); + //on dit que c'est un cercle si l'aire occupé par le contour est à supérieure à 80% de l'aire occupée par un cercle parfait + if ((contourArea / (Math.PI*radius[0]*radius[0])) >=0.8) { + //System.out.println("Cercle"); + Core.circle(img, center, (int)radius[0], new Scalar(255, 0, 0), 2); + Core.rectangle(img, new Point(rect.x,rect.y), new Point(rect.x+rect.width,rect.y+rect.height), new Scalar (0, 255, 0), 2); + Mat tmp = img.submat(rect.y,rect.y+rect.height,rect.x,rect.x+rect.width); + Mat sign = Mat.zeros(tmp.size(),tmp.type()); + tmp.copyTo(sign); + return sign; + }else { + + Imgproc.approxPolyDP(matOfPoint2f, approxCurve, Imgproc.arcLength(matOfPoint2f, true) * 0.02, true); + long total = approxCurve.total(); + if (total == 3 ) { // is triangle + //System.out.println("Triangle"); + Point [] pt = approxCurve.toArray(); + Core.line(img, pt[0], pt[1], new Scalar(255,0,0),2); + Core.line(img, pt[1], pt[2], new Scalar(255,0,0),2); + Core.line(img, pt[2], pt[0], new Scalar(255,0,0),2); + Core.rectangle(img, new Point(rect.x,rect.y), new Point(rect.x+rect.width,rect.y+rect.height), new Scalar (0, 255, 0), 2); + Mat tmp = img.submat(rect.y,rect.y+rect.height,rect.x,rect.x+rect.width); + Mat sign = Mat.zeros(tmp.size(),tmp.type()); + tmp.copyTo(sign); + return null; + } + if (total >= 4 && total <= 6) { + List cos = new ArrayList<>(); + Point[] points = approxCurve.toArray(); + for (int j = 2; j < total + 1; j++) { + cos.add(angle(points[(int) (j % total)], points[j - 2], points[j - 1])); + } + Collections.sort(cos); + Double minCos = cos.get(0); + Double maxCos = cos.get(cos.size() - 1); + boolean isRect = total == 4 && minCos >= -0.1 && maxCos <= 0.3; + boolean isPolygon = (total == 5 && minCos >= -0.34 && maxCos <= -0.27) || (total == 6 && minCos >= -0.55 && maxCos <= -0.45); + if (isRect) { + double ratio = Math.abs(1 - (double) rect.width / rect.height); + //drawText(rect.tl(), ratio <= 0.02 ? "SQU" : "RECT"); + //System.out.println("Rectangle"); + Core.rectangle(img, new Point(rect.x,rect.y), new Point(rect.x+rect.width,rect.y+rect.height), new Scalar (0, 255, 0), 2); + Mat tmp = img.submat(rect.y,rect.y+rect.height,rect.x,rect.x+rect.width); + Mat sign = Mat.zeros(tmp.size(),tmp.type()); + tmp.copyTo(sign); + return null; + } + if (isPolygon) { + //System.out.println("Polygon"); + //drawText(rect.tl(), "Polygon"); + } + } + } + return null; + + } + + + + public static double angle(Point a, Point b, Point c) { + Point ab = new Point( b.x - a.x, b.y - a.y ); + Point cb = new Point( b.x - c.x, b.y - c.y ); + double dot = (ab.x * cb.x + ab.y * cb.y); // dot product + double cross = (ab.x * cb.y - ab.y * cb.x); // cross product + double alpha = Math.atan2(cross, dot); + return Math.floor(alpha * 180. / Math.PI + 0.5); + } + + + //methode à completer + public static double Similitude(Mat object,String signfile) { + + // Conversion du signe de reference en niveaux de gris et normalisation + Mat panneauref = Highgui.imread(signfile); + Mat graySign = new Mat(panneauref.rows(), panneauref.cols(), panneauref.type()); + Imgproc.cvtColor(panneauref, graySign, Imgproc.COLOR_BGRA2GRAY); + Core.normalize(graySign, graySign, 0, 255, Core.NORM_MINMAX); + Mat signeNoirEtBlanc=new Mat(); + + + + //Conversion du panneau extrait de l'image en gris et normalisation et redimensionnement à la taille du panneau de réference + Mat grayObject = new Mat(panneauref.rows(), panneauref.cols(), panneauref.type()); + Imgproc.resize(object, object, graySign.size()); + //afficheImage("Panneau extrait de l'image",object); + Imgproc.cvtColor(object, grayObject, Imgproc.COLOR_BGRA2GRAY); + Core.normalize(grayObject, grayObject, 0, 255, Core.NORM_MINMAX); + //Imgproc.resize(grayObject, grayObject, graySign.size()); + + + + //à compléter... + + return -1; + + + + + } + +} + diff --git "a/Deuxi\303\244meEtude/src/PrincipaleDEUX.java" "b/Deuxi\303\244meEtude/src/PrincipaleDEUX.java" new file mode 100644 index 0000000..acbd3c3 --- /dev/null +++ "b/Deuxi\303\244meEtude/src/PrincipaleDEUX.java" @@ -0,0 +1,61 @@ + +import java.util.Arrays; +import java.util.List; + +import org.opencv.core.*; +import org.opencv.highgui.*; +import utilitaireAgreg.MaBibliothequeTraitementImage; +public class Principale { + + public static void main(String[] args) + { + //Ouverture le l'image et saturation des rouges + System.loadLibrary("opencv_java249"); + Mat m=Highgui.imread("p10.jpg",Highgui.CV_LOAD_IMAGE_COLOR); + MaBibliothequeTraitementImageEtendue.afficheImage("Image test�e", m); + Mat transformee=MaBibliothequeTraitementImageEtendue.transformeBGRversHSV(m); + //la methode seuillage est ici extraite de l'archivage jar du meme nom + Mat saturee=MaBibliothequeTraitementImage.seuillage(transformee, 6, 170, 110); + Mat objetrond = null; + + //Cr�ation d'une liste des contours � partir de l'image satur�e + List ListeContours= MaBibliothequeTraitementImageEtendue .ExtractContours(saturee); + int i=0; + double [] scores=new double [6]; + //Pour tous les contours de la liste + for (MatOfPoint contour: ListeContours ){ + i++; + objetrond=MaBibliothequeTraitementImage.DetectForm(m,contour); + + if (objetrond!=null){ + MaBibliothequeTraitementImage.afficheImage("Objet rond det�ct�", objetrond); + scores[0]=MaBibliothequeTraitementImage.Similitude(objetrond,"ref30.jpg"); + scores[1]=MaBibliothequeTraitementImage.Similitude(objetrond,"ref50.jpg"); + scores[2]=MaBibliothequeTraitementImage.Similitude(objetrond,"ref70.jpg"); + scores[3]=MaBibliothequeTraitementImage.Similitude(objetrond,"ref90.jpg"); + scores[4]=MaBibliothequeTraitementImage.Similitude(objetrond,"ref110.jpg"); + scores[5]=MaBibliothequeTraitementImage.Similitude(objetrond,"refdouble.jpg"); + + + //recherche de l'index du maximum et affichage du panneau detect� + double scoremax=-1; + int indexmax=0; + for(int j=0;jscoremax){scoremax=scores[j];indexmax=j;}} + if(scoremax<0){System.out.println("Aucun Panneau d�t�ct�");} + else{switch(indexmax){ + case -1:;break; + case 0:System.out.println("Panneau 30 d�t�ct�");break; + case 1:System.out.println("Panneau 50 d�t�ct�");break; + case 2:System.out.println("Panneau 70 d�t�ct�");break; + case 3:System.out.println("Panneau 90 d�t�ct�");break; + case 4:System.out.println("Panneau 110 d�t�ct�");break; + case 5:System.out.println("Panneau interdiction de d�passer d�t�ct�");break; + }} + + } + } + + + } +} \ No newline at end of file diff --git a/ISN2022-DIAH b/ISN2022-DIAH new file mode 160000 index 0000000..78d3f4b --- /dev/null +++ b/ISN2022-DIAH @@ -0,0 +1 @@ +Subproject commit 78d3f4b79925ca6ca50c53f3ee53795b6b71ecdf diff --git a/TroisiemeEtude/.classpath b/TroisiemeEtude/.classpath new file mode 100644 index 0000000..6798a3d --- /dev/null +++ b/TroisiemeEtude/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/TroisiemeEtude/.project b/TroisiemeEtude/.project new file mode 100644 index 0000000..067da89 --- /dev/null +++ b/TroisiemeEtude/.project @@ -0,0 +1,28 @@ + + + TroisiemeEtude + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + + + 1683024126086 + + 30 + + org.eclipse.core.resources.regexFilterMatcher + node_modules|\.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__ + + + + diff --git a/TroisiemeEtude/.settings/org.eclipse.jdt.core.prefs b/TroisiemeEtude/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..bb35fa0 --- /dev/null +++ b/TroisiemeEtude/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,11 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.debug.lineNumber=generate +org.eclipse.jdt.core.compiler.debug.localVariable=generate +org.eclipse.jdt.core.compiler.debug.sourceFile=generate +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/TroisiemeEtude/Thumbs.db b/TroisiemeEtude/Thumbs.db new file mode 100644 index 0000000..9aebfb4 Binary files /dev/null and b/TroisiemeEtude/Thumbs.db differ diff --git a/TroisiemeEtude/bin/AnalyseVideo.class b/TroisiemeEtude/bin/AnalyseVideo.class new file mode 100644 index 0000000..c80d0de Binary files /dev/null and b/TroisiemeEtude/bin/AnalyseVideo.class differ diff --git a/TroisiemeEtude/bin/Thumbs.db b/TroisiemeEtude/bin/Thumbs.db new file mode 100644 index 0000000..16624dc Binary files /dev/null and b/TroisiemeEtude/bin/Thumbs.db differ diff --git a/TroisiemeEtude/ref110.jpg b/TroisiemeEtude/ref110.jpg new file mode 100644 index 0000000..2aad348 Binary files /dev/null and b/TroisiemeEtude/ref110.jpg differ diff --git a/TroisiemeEtude/ref30.jpg b/TroisiemeEtude/ref30.jpg new file mode 100644 index 0000000..32627e4 Binary files /dev/null and b/TroisiemeEtude/ref30.jpg differ diff --git a/TroisiemeEtude/ref50.jpg b/TroisiemeEtude/ref50.jpg new file mode 100644 index 0000000..0ddc9ac Binary files /dev/null and b/TroisiemeEtude/ref50.jpg differ diff --git a/TroisiemeEtude/ref70.jpg b/TroisiemeEtude/ref70.jpg new file mode 100644 index 0000000..3298076 Binary files /dev/null and b/TroisiemeEtude/ref70.jpg differ diff --git a/TroisiemeEtude/ref90.jpg b/TroisiemeEtude/ref90.jpg new file mode 100644 index 0000000..34aa798 Binary files /dev/null and b/TroisiemeEtude/ref90.jpg differ diff --git a/TroisiemeEtude/refdouble.jpg b/TroisiemeEtude/refdouble.jpg new file mode 100644 index 0000000..5c057d3 Binary files /dev/null and b/TroisiemeEtude/refdouble.jpg differ diff --git a/TroisiemeEtude/src/AnalyseVideo.java b/TroisiemeEtude/src/AnalyseVideo.java new file mode 100644 index 0000000..94d903e --- /dev/null +++ b/TroisiemeEtude/src/AnalyseVideo.java @@ -0,0 +1,99 @@ +import java.awt.image.BufferedImage; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import javax.imageio.ImageIO; +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JLabel; + +import org.opencv.core.Core; +import org.opencv.core.CvType; +import org.opencv.core.Mat; +import org.opencv.core.MatOfByte; +import org.opencv.core.MatOfPoint; +import org.opencv.core.Rect; +import org.opencv.core.Scalar; +import org.opencv.core.Size; +import org.opencv.highgui.Highgui; +import org.opencv.highgui.VideoCapture; +import org.opencv.imgproc.Imgproc; +import utilitaireAgreg.*; +public class AnalyseVideo { + static { + System.loadLibrary(Core.NATIVE_LIBRARY_NAME); + } + + static Mat imag = null; + + public static void main(String[] args) { + JFrame jframe = new JFrame("Detection de panneaux sur un flux vidéo"); + jframe.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + JLabel vidpanel = new JLabel(); + jframe.setContentPane(vidpanel); + jframe.setSize(720, 480); + jframe.setVisible(true); + + Mat frame = new Mat(); + VideoCapture camera = new VideoCapture("video1.avi"); + Mat PanneauAAnalyser = null; + + while (camera.read(frame)) { + //A completer + + + ImageIcon image = new ImageIcon(Mat2bufferedImage(frame)); + vidpanel.setIcon(image); + vidpanel.repaint(); + } + } + + + + + + + public static BufferedImage Mat2bufferedImage(Mat image) { + MatOfByte bytemat = new MatOfByte(); + Highgui.imencode(".jpg", image, bytemat); + byte[] bytes = bytemat.toArray(); + InputStream in = new ByteArrayInputStream(bytes); + BufferedImage img = null; + try { + img = ImageIO.read(in); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + return img; + } + + + + public static int identifiepanneau(Mat objetrond){ + double [] scores=new double [6]; + int indexmax=-1; + if (objetrond!=null){ + scores[0]=MaBibliothequeTraitementImage.tauxDeSimilitude(objetrond,"ref30.jpg"); + scores[1]=MaBibliothequeTraitementImage.tauxDeSimilitude(objetrond,"ref50.jpg"); + scores[2]=MaBibliothequeTraitementImage.tauxDeSimilitude(objetrond,"ref70.jpg"); + scores[3]=MaBibliothequeTraitementImage.tauxDeSimilitude(objetrond,"ref90.jpg"); + scores[4]=MaBibliothequeTraitementImage.tauxDeSimilitude(objetrond,"ref110.jpg"); + scores[5]=MaBibliothequeTraitementImage.tauxDeSimilitude(objetrond,"refdouble.jpg"); + + double scoremax=scores[0]; + + for(int j=1;jscoremax){scoremax=scores[j];indexmax=j;}} + + + } + return indexmax; + } + + +} \ No newline at end of file diff --git a/TroisiemeEtude/src/Thumbs.db b/TroisiemeEtude/src/Thumbs.db new file mode 100644 index 0000000..16624dc Binary files /dev/null and b/TroisiemeEtude/src/Thumbs.db differ diff --git a/TroisiemeEtude/video1.avi b/TroisiemeEtude/video1.avi new file mode 100644 index 0000000..8fac3e1 Binary files /dev/null and b/TroisiemeEtude/video1.avi differ diff --git a/TroisiemeEtude/video1.mp4 b/TroisiemeEtude/video1.mp4 new file mode 100644 index 0000000..3826b37 Binary files /dev/null and b/TroisiemeEtude/video1.mp4 differ diff --git a/TroisiemeEtude/video2.avi b/TroisiemeEtude/video2.avi new file mode 100644 index 0000000..52209c9 Binary files /dev/null and b/TroisiemeEtude/video2.avi differ diff --git a/TroisiemeEtude/video2.mp4 b/TroisiemeEtude/video2.mp4 new file mode 100644 index 0000000..9ecf0e7 Binary files /dev/null and b/TroisiemeEtude/video2.mp4 differ diff --git a/TutoOpenCv/.DS_Store b/TutoOpenCv/.DS_Store new file mode 100644 index 0000000..3fcccba Binary files /dev/null and b/TutoOpenCv/.DS_Store differ diff --git a/TutoOpenCv/.vscode/launch.json b/TutoOpenCv/.vscode/launch.json new file mode 100644 index 0000000..26ef7ab --- /dev/null +++ b/TutoOpenCv/.vscode/launch.json @@ -0,0 +1,70 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "type": "java", + "name": "BGRtoHSV", + "request": "launch", + "mainClass": "BGRtoHSV", + "projectName": "TutoOpenCv_56708bcb", + "vmArgs": "-Djava.library.path=/Users/Ibrahim/Tools/opencv-2.4.13.6/build/lib" + }, + { + "type": "java", + "name": "Principale", + "request": "launch", + "mainClass": "Principale", + "projectName": "TutoOpenCv_56708bcb", + "vmArgs": "-Djava.library.path=/Users/Ibrahim/Tools/opencv-2.4.13.6/build/lib" + }, + { + "type": "java", + "name": "CanauxCouleurs", + "request": "launch", + "mainClass": "CanauxCouleurs", + "projectName": "TutoOpenCv_56708bcb", + "vmArgs": "-Djava.library.path=/Users/Ibrahim/Tools/opencv-2.4.13.6/build/lib" + }, + { + "type": "java", + "name": "ReadImage", + "request": "launch", + "mainClass": "ReadImage", + "projectName": "TutoOpenCv_56708bcb", + "vmArgs": "-Djava.library.path=/Users/Ibrahim/Tools/opencv-2.4.13.6/build/lib" + }, + { + "type": "java", + "name": "App", + "request": "launch", + "mainClass": "App", + "projectName": "TutoOpenCv_56708bcb", + "vmArgs": "-Djava.library.path=/Users/Ibrahim/Tools/opencv-2.4.13.6/build/lib" + }, + { + "type": "java", + "name": "Exercice1", + "request": "launch", + "mainClass": "Exercice1", + "projectName": "TutoOpenCv_56708bcb", + "vmArgs": "-Djava.library.path=/Users/Ibrahim/Tools/opencv-2.4.13.6/build/lib" + }, + { + "type": "java", + "name": "Current File", + "request": "launch", + "mainClass": "${file}" + }, + { + "type": "java", + "name": "FirstApp", + "request": "launch", + "mainClass": "FirstApp", + "projectName": "TutoOpenCv_56708bcb", + "vmArgs": "-Djava.library.path=/Users/Ibrahim/Tools/opencv-2.4.13.6/build/lib" + } + ] +} \ No newline at end of file diff --git a/TutoOpenCv/.vscode/settings.json b/TutoOpenCv/.vscode/settings.json new file mode 100644 index 0000000..cf58418 --- /dev/null +++ b/TutoOpenCv/.vscode/settings.json @@ -0,0 +1,10 @@ +{ + "java.project.sourcePaths": ["src"], + "java.project.outputPath": "bin", + "java.project.referencedLibraries": [ + "lib/**/*.jar", + "/Users/ibrahim/Tools/opencv-2.4.13.6/build/bin/opencv-2413.jar", + "/Users/ibrahim/Tools/Mabiblio.jar" + ], + "git.ignoreLimitWarning": true +} diff --git a/TutoOpenCv/README.md b/TutoOpenCv/README.md new file mode 100644 index 0000000..7c03a53 --- /dev/null +++ b/TutoOpenCv/README.md @@ -0,0 +1,18 @@ +## Getting Started + +Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code. + +## Folder Structure + +The workspace contains two folders by default, where: + +- `src`: the folder to maintain sources +- `lib`: the folder to maintain dependencies + +Meanwhile, the compiled output files will be generated in the `bin` folder by default. + +> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there. + +## Dependency Management + +The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies). diff --git a/TutoOpenCv/assets/.DS_Store b/TutoOpenCv/assets/.DS_Store new file mode 100644 index 0000000..b313814 Binary files /dev/null and b/TutoOpenCv/assets/.DS_Store differ diff --git a/TutoOpenCv/assets/Ball_13.png b/TutoOpenCv/assets/Ball_13.png new file mode 100644 index 0000000..0bc858c Binary files /dev/null and b/TutoOpenCv/assets/Ball_13.png differ diff --git a/TutoOpenCv/assets/Ball_three.png b/TutoOpenCv/assets/Ball_three.png new file mode 100644 index 0000000..de39e9d Binary files /dev/null and b/TutoOpenCv/assets/Ball_three.png differ diff --git a/TutoOpenCv/assets/Billard_Balls.jpg b/TutoOpenCv/assets/Billard_Balls.jpg new file mode 100644 index 0000000..3c640ec Binary files /dev/null and b/TutoOpenCv/assets/Billard_Balls.jpg differ diff --git a/TutoOpenCv/assets/Temoin.png b/TutoOpenCv/assets/Temoin.png new file mode 100644 index 0000000..784b747 Binary files /dev/null and b/TutoOpenCv/assets/Temoin.png differ diff --git a/TutoOpenCv/assets/bgr.png b/TutoOpenCv/assets/bgr.png new file mode 100644 index 0000000..322eab0 Binary files /dev/null and b/TutoOpenCv/assets/bgr.png differ diff --git a/TutoOpenCv/assets/circles.jpg b/TutoOpenCv/assets/circles.jpg new file mode 100644 index 0000000..f1e3522 Binary files /dev/null and b/TutoOpenCv/assets/circles.jpg differ diff --git a/TutoOpenCv/assets/circles_rectangles.jpg b/TutoOpenCv/assets/circles_rectangles.jpg new file mode 100644 index 0000000..af284c6 Binary files /dev/null and b/TutoOpenCv/assets/circles_rectangles.jpg differ diff --git a/TutoOpenCv/assets/hsv.png b/TutoOpenCv/assets/hsv.png new file mode 100755 index 0000000..b5d9725 Binary files /dev/null and b/TutoOpenCv/assets/hsv.png differ diff --git a/TutoOpenCv/assets/opencv.png b/TutoOpenCv/assets/opencv.png new file mode 100644 index 0000000..86350a7 Binary files /dev/null and b/TutoOpenCv/assets/opencv.png differ diff --git a/TutoOpenCv/assets/p1.jpg b/TutoOpenCv/assets/p1.jpg new file mode 100644 index 0000000..4a21be3 Binary files /dev/null and b/TutoOpenCv/assets/p1.jpg differ diff --git a/TutoOpenCv/assets/p10.jpg b/TutoOpenCv/assets/p10.jpg new file mode 100644 index 0000000..4a21be3 Binary files /dev/null and b/TutoOpenCv/assets/p10.jpg differ diff --git a/TutoOpenCv/assets/p1_bis.jpg b/TutoOpenCv/assets/p1_bis.jpg new file mode 100644 index 0000000..222e3ae Binary files /dev/null and b/TutoOpenCv/assets/p1_bis.jpg differ diff --git a/TutoOpenCv/assets/p2.jpg b/TutoOpenCv/assets/p2.jpg new file mode 100644 index 0000000..ca33c65 Binary files /dev/null and b/TutoOpenCv/assets/p2.jpg differ diff --git a/TutoOpenCv/assets/p3.jpg b/TutoOpenCv/assets/p3.jpg new file mode 100644 index 0000000..eb34287 Binary files /dev/null and b/TutoOpenCv/assets/p3.jpg differ diff --git a/TutoOpenCv/assets/p4.jpg b/TutoOpenCv/assets/p4.jpg new file mode 100644 index 0000000..e5c2fba Binary files /dev/null and b/TutoOpenCv/assets/p4.jpg differ diff --git a/TutoOpenCv/assets/p5.jpg b/TutoOpenCv/assets/p5.jpg new file mode 100644 index 0000000..e443c8f Binary files /dev/null and b/TutoOpenCv/assets/p5.jpg differ diff --git a/TutoOpenCv/assets/p6.jpg b/TutoOpenCv/assets/p6.jpg new file mode 100644 index 0000000..cd6b4e9 Binary files /dev/null and b/TutoOpenCv/assets/p6.jpg differ diff --git a/TutoOpenCv/assets/p7.JPG b/TutoOpenCv/assets/p7.JPG new file mode 100644 index 0000000..827c466 Binary files /dev/null and b/TutoOpenCv/assets/p7.JPG differ diff --git a/TutoOpenCv/assets/p8.jpg b/TutoOpenCv/assets/p8.jpg new file mode 100644 index 0000000..86f84a8 Binary files /dev/null and b/TutoOpenCv/assets/p8.jpg differ diff --git a/TutoOpenCv/assets/p9.jpg b/TutoOpenCv/assets/p9.jpg new file mode 100644 index 0000000..fb9b846 Binary files /dev/null and b/TutoOpenCv/assets/p9.jpg differ diff --git a/TutoOpenCv/assets/ref110.jpg b/TutoOpenCv/assets/ref110.jpg new file mode 100644 index 0000000..2aad348 Binary files /dev/null and b/TutoOpenCv/assets/ref110.jpg differ diff --git a/TutoOpenCv/assets/ref30.jpg b/TutoOpenCv/assets/ref30.jpg new file mode 100644 index 0000000..32627e4 Binary files /dev/null and b/TutoOpenCv/assets/ref30.jpg differ diff --git a/TutoOpenCv/assets/ref50.jpg b/TutoOpenCv/assets/ref50.jpg new file mode 100644 index 0000000..0ddc9ac Binary files /dev/null and b/TutoOpenCv/assets/ref50.jpg differ diff --git a/TutoOpenCv/assets/ref70.jpg b/TutoOpenCv/assets/ref70.jpg new file mode 100644 index 0000000..3298076 Binary files /dev/null and b/TutoOpenCv/assets/ref70.jpg differ diff --git a/TutoOpenCv/assets/ref90.jpg b/TutoOpenCv/assets/ref90.jpg new file mode 100644 index 0000000..34aa798 Binary files /dev/null and b/TutoOpenCv/assets/ref90.jpg differ diff --git a/TutoOpenCv/assets/refdouble.jpg b/TutoOpenCv/assets/refdouble.jpg new file mode 100644 index 0000000..5c057d3 Binary files /dev/null and b/TutoOpenCv/assets/refdouble.jpg differ diff --git a/TutoOpenCv/bin/.DS_Store b/TutoOpenCv/bin/.DS_Store new file mode 100644 index 0000000..3f34e81 Binary files /dev/null and b/TutoOpenCv/bin/.DS_Store differ diff --git a/TutoOpenCv/bin/BGRtoHSV.class b/TutoOpenCv/bin/BGRtoHSV.class new file mode 100644 index 0000000..92bde6e Binary files /dev/null and b/TutoOpenCv/bin/BGRtoHSV.class differ diff --git a/TutoOpenCv/bin/CanauxCouleurs.class b/TutoOpenCv/bin/CanauxCouleurs.class new file mode 100644 index 0000000..00a75ca Binary files /dev/null and b/TutoOpenCv/bin/CanauxCouleurs.class differ diff --git a/TutoOpenCv/bin/DetectContour.class b/TutoOpenCv/bin/DetectContour.class new file mode 100644 index 0000000..8005c3e Binary files /dev/null and b/TutoOpenCv/bin/DetectContour.class differ diff --git a/TutoOpenCv/bin/Exercice1.class b/TutoOpenCv/bin/Exercice1.class new file mode 100644 index 0000000..6c282f4 Binary files /dev/null and b/TutoOpenCv/bin/Exercice1.class differ diff --git a/TutoOpenCv/bin/MaBibliothequeTraitementImage.class b/TutoOpenCv/bin/MaBibliothequeTraitementImage.class new file mode 100644 index 0000000..bfbb9aa Binary files /dev/null and b/TutoOpenCv/bin/MaBibliothequeTraitementImage.class differ diff --git a/TutoOpenCv/bin/MaBibliothequeTraitementImageEtendue_DEUX.class b/TutoOpenCv/bin/MaBibliothequeTraitementImageEtendue_DEUX.class new file mode 100644 index 0000000..0c6439d Binary files /dev/null and b/TutoOpenCv/bin/MaBibliothequeTraitementImageEtendue_DEUX.class differ diff --git a/TutoOpenCv/bin/Principale.class b/TutoOpenCv/bin/Principale.class new file mode 100644 index 0000000..05be207 Binary files /dev/null and b/TutoOpenCv/bin/Principale.class differ diff --git a/TutoOpenCv/bin/Principale_DEUX.class b/TutoOpenCv/bin/Principale_DEUX.class new file mode 100644 index 0000000..8cd6263 Binary files /dev/null and b/TutoOpenCv/bin/Principale_DEUX.class differ diff --git a/TutoOpenCv/bin/ReadImage.class b/TutoOpenCv/bin/ReadImage.class new file mode 100644 index 0000000..c0e743c Binary files /dev/null and b/TutoOpenCv/bin/ReadImage.class differ diff --git a/TutoOpenCv/src/.DS_Store b/TutoOpenCv/src/.DS_Store new file mode 100644 index 0000000..3f34e81 Binary files /dev/null and b/TutoOpenCv/src/.DS_Store differ diff --git a/TutoOpenCv/src/BGRtoHSV.java b/TutoOpenCv/src/BGRtoHSV.java new file mode 100644 index 0000000..b1ad0d6 --- /dev/null +++ b/TutoOpenCv/src/BGRtoHSV.java @@ -0,0 +1,50 @@ + +import org.opencv.core.Scalar; +import org.opencv.highgui.Highgui; +import org.opencv.imgproc.Imgproc; + + +import java.util.Arrays; +import java.util.Vector; + +import org.opencv.core.Core; +import org.opencv.core.CvType; +import org.opencv.core.Mat; + + + +public class BGRtoHSV{ + +public static void main(String[] args){ + System.loadLibrary(Core.NATIVE_LIBRARY_NAME); + Mat m = Highgui.imread("/Users/ibrahim/Java_Project/TutoOpenCv/assets/hsv.png"); + Mat output = Mat.zeros(m.size(),m.type()); + Imgproc.cvtColor(m,output,Imgproc.COLOR_BGR2HSV); + CanauxCouleurs.Imshow("HSV",output); + Vector channels = new Vector(); + Core.split(output,channels); + double hsv_values[][]={{1,255,255},{179,1,255},{179,0,1}}; + for(int i=0;i<3;i++){ + CanauxCouleurs.Imshow(Integer.toString(i)+"HSV",channels.get(i)); + Mat chans[]=new Mat[3]; + for (int j=0;j<3;j++){ + + Mat empty = new Mat(m.size(), CvType.CV_8UC1); + Mat comp = new Mat(m.size(), CvType.CV_8UC1); + Scalar v = new Scalar(hsv_values[i][j]); + Core.multiply(empty, v, comp); + chans[j]=comp; + } + chans[i]=channels.get(i); + Mat dst = Mat.zeros(output.size(),output.type()); + Mat res = Mat.ones(dst.size(),dst.type()); + Core.merge(Arrays.asList(chans),dst); + Imgproc.cvtColor(dst, res, Imgproc.COLOR_HSV2BGR); + CanauxCouleurs.Imshow(Integer.toString(i), res); + + + + + } + } +} \ No newline at end of file diff --git a/TutoOpenCv/src/CanauxCouleurs.java b/TutoOpenCv/src/CanauxCouleurs.java new file mode 100644 index 0000000..a5e22e8 --- /dev/null +++ b/TutoOpenCv/src/CanauxCouleurs.java @@ -0,0 +1,48 @@ +import org.opencv.core.MatOfByte; +import org.opencv.highgui.Highgui; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.Vector; +import javax.imageio.ImageIO; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.ImageIcon; + +import org.opencv.core.Core; +//import org.opencv.core.CvType; +import org.opencv.core.Mat; + + +public class CanauxCouleurs { + public static void Imshow(String title,Mat img){ + MatOfByte matOfByte = new MatOfByte(); + Highgui.imencode(".png", img, matOfByte); + byte[] byteArray = matOfByte.toArray(); + java.awt.image.BufferedImage bufImage = null; + try { + InputStream in = new ByteArrayInputStream(byteArray); + bufImage = ImageIO.read(in); + JFrame frame = new JFrame(); + frame.setTitle(title); + frame.getContentPane().add(new JLabel(new ImageIcon(bufImage))); + frame.pack(); + frame.setVisible(true); + } + catch (Exception e){ + e.printStackTrace(); + } + } + + public static void main(String[] args){ + System.loadLibrary(Core.NATIVE_LIBRARY_NAME); + Mat m = Highgui.imread("./assets/bgr.png"); + Vector channels = new Vector(); + Core.split(m,channels); + // BGR order + for (int i=0;i splitHSVChannels(Mat input) { + Vector channels = new Vector(); + Core.split(input, channels); + return channels; + } + + //Methode qui permet d'afficher une image sur un panel + public static void afficheImage(String title, Mat img){ + MatOfByte matOfByte = new MatOfByte(); + Highgui.imencode(".png", img, matOfByte); + byte[] byteArray = matOfByte.toArray(); + java.awt.image.BufferedImage bufImage = null; + try { + InputStream in = new ByteArrayInputStream(byteArray); + bufImage = ImageIO.read(in); + JFrame frame = new JFrame(); + frame.setTitle(title); + frame.getContentPane().add(new JLabel(new ImageIcon(bufImage))); + frame.pack(); + frame.setVisible(true); + } + catch (Exception e){ + e.printStackTrace(); + } + } + + //Methode qui permet de saturer les couleurs rouges � partir de 3 seuils + public static Mat seuillage(Mat input, int seuilRougeOrange, int seuilRougeViolet,int seuilSaturation){ + //� completer + Mat threshold_img = new Mat(); + Mat threshold_img1 = new Mat(); + Mat threshold_img2 = new Mat(); + //threshold_img1 = seuillage_exemple(input, seuilRougeViolet); + //threshold_img1 = seuillage_exemple(input, seuilRougeOrange); + Core.inRange(input,new Scalar(0,seuilSaturation,100),new Scalar(seuilRougeOrange,255,255),threshold_img1); + Core.inRange(input,new Scalar(160,seuilSaturation,100),new Scalar(seuilRougeViolet,255,255),threshold_img2); + Core.bitwise_or(threshold_img1,threshold_img2, threshold_img); + Imgproc.GaussianBlur(threshold_img,threshold_img,new Size(9,9),2,2); + + //image satur�e � retourner + return threshold_img; + + + + } + + + //Methode d'exemple qui permet de saturer les couleurs rouges � partir d'un seul seuil + public static Mat seuillage_exemple(Mat input, int seuilRougeViolet){ + // Decomposition en 3 cannaux HSV + Vector channels = splitHSVChannels(input); + //cr�ation d'un seuil + Scalar rougeviolet = new Scalar(seuilRougeViolet); + //Cr�ation d'une matrice + Mat rouges=new Mat(); + //Comparaison et saturation des pixels dont la composante rouge est plus grande que le seuil rougeViolet + Core.compare(channels.get(0), rougeviolet, rouges, Core.CMP_GT); + //image satur�e � retourner + return rouges; + } + + //Methode qui permet d'extraire les contours d'une image donnee + public static List ExtractContours(Mat input) { + // Detecter les contours des formes trouv�es + int thresh = 100; + Mat canny_output = new Mat(); + List contours = new ArrayList(); + MatOfInt4 hierarchy = new MatOfInt4(); + Imgproc.Canny( input, canny_output, thresh, thresh*2); + + + /// Find extreme outer contours + Imgproc.findContours( canny_output, contours, hierarchy,Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_SIMPLE); + + Mat drawing = Mat.zeros( canny_output.size(), CvType.CV_8UC3 ); + Random rand = new Random(); + for( int i = 0; i< contours.size(); i++ ) + { + Scalar color = new Scalar( rand.nextInt(255 - 0 + 1) , rand.nextInt(255 - 0 + 1),rand.nextInt(255 - 0 + 1) ); + Imgproc.drawContours( drawing, contours, i, color, 1, 8, hierarchy, 0, new Point() ); + } + //afficheImage("Contours",drawing); + + return contours; + } + + //Methode qui permet de decouper et identifier les contours carr�s, triangulaires ou rectangulaires. + //Renvoie null si aucun contour rond n'a �t� trouv�. + //Renvoie une matrice carr�e englobant un contour rond si un contour rond a �t� trouv� + public static Mat DetectForm(Mat img,MatOfPoint contour) { + MatOfPoint2f matOfPoint2f = new MatOfPoint2f(); + MatOfPoint2f approxCurve = new MatOfPoint2f(); + float[] radius = new float[1]; + Point center = new Point(); + Rect rect = Imgproc.boundingRect(contour); + double contourArea = Imgproc.contourArea(contour); + + + matOfPoint2f.fromList(contour.toList()); + // Cherche le plus petit cercle entourant le contour + Imgproc.minEnclosingCircle(matOfPoint2f, center, radius); + //System.out.println(contourArea+" "+Math.PI*radius[0]*radius[0]); + //on dit que c'est un cercle si l'aire occup� par le contour est � sup�rieure � 80% de l'aire occup�e par un cercle parfait + if ((contourArea / (Math.PI*radius[0]*radius[0])) >=0.8) { + //System.out.println("Cercle"); + Core.circle(img, center, (int)radius[0], new Scalar(255, 0, 0), 2); + Core.rectangle(img, new Point(rect.x,rect.y), new Point(rect.x+rect.width,rect.y+rect.height), new Scalar (0, 255, 0), 2); + Mat tmp = img.submat(rect.y,rect.y+rect.height,rect.x,rect.x+rect.width); + Mat sign = Mat.zeros(tmp.size(),tmp.type()); + tmp.copyTo(sign); + return sign; + }else { + + Imgproc.approxPolyDP(matOfPoint2f, approxCurve, Imgproc.arcLength(matOfPoint2f, true) * 0.02, true); + long total = approxCurve.total(); + if (total == 3 ) { // is triangle + //System.out.println("Triangle"); + Point [] pt = approxCurve.toArray(); + Core.line(img, pt[0], pt[1], new Scalar(255,0,0),2); + Core.line(img, pt[1], pt[2], new Scalar(255,0,0),2); + Core.line(img, pt[2], pt[0], new Scalar(255,0,0),2); + Core.rectangle(img, new Point(rect.x,rect.y), new Point(rect.x+rect.width,rect.y+rect.height), new Scalar (0, 255, 0), 2); + Mat tmp = img.submat(rect.y,rect.y+rect.height,rect.x,rect.x+rect.width); + Mat sign = Mat.zeros(tmp.size(),tmp.type()); + tmp.copyTo(sign); + return null; + } + if (total >= 4 && total <= 6) { + List cos = new ArrayList<>(); + Point[] points = approxCurve.toArray(); + for (int j = 2; j < total + 1; j++) { + cos.add(angle(points[(int) (j % total)], points[j - 2], points[j - 1])); + } + Collections.sort(cos); + Double minCos = cos.get(0); + Double maxCos = cos.get(cos.size() - 1); + boolean isRect = total == 4 && minCos >= -0.1 && maxCos <= 0.3; + boolean isPolygon = (total == 5 && minCos >= -0.34 && maxCos <= -0.27) || (total == 6 && minCos >= -0.55 && maxCos <= -0.45); + if (isRect) { + double ratio = Math.abs(1 - (double) rect.width / rect.height); + //drawText(rect.tl(), ratio <= 0.02 ? "SQU" : "RECT"); + //System.out.println("Rectangle"); + Core.rectangle(img, new Point(rect.x,rect.y), new Point(rect.x+rect.width,rect.y+rect.height), new Scalar (0, 255, 0), 2); + Mat tmp = img.submat(rect.y,rect.y+rect.height,rect.x,rect.x+rect.width); + Mat sign = Mat.zeros(tmp.size(),tmp.type()); + tmp.copyTo(sign); + return null; + } + if (isPolygon) { + //System.out.println("Polygon"); + //drawText(rect.tl(), "Polygon"); + } + } + } + return null; + + } + + + + public static double angle(Point a, Point b, Point c) { + Point ab = new Point( b.x - a.x, b.y - a.y ); + Point cb = new Point( b.x - c.x, b.y - c.y ); + double dot = (ab.x * cb.x + ab.y * cb.y); // dot product + double cross = (ab.x * cb.y - ab.y * cb.x); // cross product + double alpha = Math.atan2(cross, dot); + return Math.floor(alpha * 180. / Math.PI + 0.5); + } + + + //methode � completer + public static double tauxDeSimilitude(Mat object,String signfile) { + + // Conversion du signe de reference en niveaux de gris et normalisation + Mat panneauref = Highgui.imread(signfile); + Mat graySign = new Mat(panneauref.rows(), panneauref.cols(), panneauref.type()); + Imgproc.cvtColor(panneauref, graySign, Imgproc.COLOR_BGRA2GRAY); + Core.normalize(graySign, graySign, 0, 255, Core.NORM_MINMAX); + Mat signeNoirEtBlanc=new Mat(); + + + + //Conversion du panneau extrait de l'image en gris et normalisation et redimensionnement � la taille du panneau de r�ference + Mat grayObject = new Mat(panneauref.rows(), panneauref.cols(), panneauref.type()); + Imgproc.resize(object, object, graySign.size()); + afficheImage("Panneau extrait de l'image",object); + Imgproc.cvtColor(object, grayObject, Imgproc.COLOR_BGRA2GRAY); + Core.normalize(grayObject, grayObject, 0, 255, Core.NORM_MINMAX); + Imgproc.resize(grayObject, grayObject, graySign.size()); + + + + //� compl�ter... + int totalpixel = panneauref.rows()*panneauref.cols(); + double cpt = 0; + for (int i=0;i ListeContours= MaBibliothequeTraitementImage.ExtractContours(saturee); + int i=0; + double [] scores=new double [6]; + //Pour tous les contours de la liste + for (MatOfPoint contour: ListeContours ){ + i++; + objetrond=MaBibliothequeTraitementImage.DetectForm(m,contour); + + if (objetrond!=null){ + MaBibliothequeTraitementImage.afficheImage("Objet rond det�ct�", objetrond); + scores[0]=MaBibliothequeTraitementImage.tauxDeSimilitude(objetrond,"/Users/ibrahim/Java_Project/TutoOpenCv/assets/ref30.jpg"); + scores[1]=MaBibliothequeTraitementImage.tauxDeSimilitude(objetrond,"/Users/ibrahim/Java_Project/TutoOpenCv/assets/ref50.jpg"); + scores[2]=MaBibliothequeTraitementImage.tauxDeSimilitude(objetrond,"/Users/ibrahim/Java_Project/TutoOpenCv/assets/ref70.jpg"); + scores[3]=MaBibliothequeTraitementImage.tauxDeSimilitude(objetrond,"/Users/ibrahim/Java_Project/TutoOpenCv/assets/ref90.jpg"); + scores[4]=MaBibliothequeTraitementImage.tauxDeSimilitude(objetrond,"/Users/ibrahim/Java_Project/TutoOpenCv/assets/ref110.jpg"); + scores[5]=MaBibliothequeTraitementImage.tauxDeSimilitude(objetrond,"/Users/ibrahim/Java_Project/TutoOpenCv/assets/refdouble.jpg"); + + + //recherche de l'index du maximum et affichage du panneau detect� + double scoremax=-1; + int indexmax=0; + for(int j=0;jscoremax){scoremax=scores[j];indexmax=j;}} + if(scoremax<0){System.out.println("Aucun Panneau d�t�ct�");} + else{switch(indexmax){ + case -1:;break; + case 0:System.out.println("Panneau 30 d�t�ct�");break; + case 1:System.out.println("Panneau 50 d�t�ct�");break; + case 2:System.out.println("Panneau 70 d�t�ct�");break; + case 3:System.out.println("Panneau 90 d�t�ct�");break; + case 4:System.out.println("Panneau 110 d�t�ct�");break; + case 5:System.out.println("Panneau interdiction de d�passer d�t�ct�");break; + }} + + } + } + + + } +} \ No newline at end of file diff --git a/TutoOpenCv/src/ReadImage.java b/TutoOpenCv/src/ReadImage.java new file mode 100644 index 0000000..72f49c3 --- /dev/null +++ b/TutoOpenCv/src/ReadImage.java @@ -0,0 +1,15 @@ +import org.opencv.core.Core; +import org.opencv.core.CvType; +import org.opencv.core.Mat; + +public class ReadImage { + public static void main(String[] args) { + System.loadLibrary(Core.NATIVE_LIBRARY_NAME); + Mat mat = Mat.eye( 3, 3, CvType.CV_8UC1 ); + System.out.println( "mat = " + mat.dump() ); + } +} + + + + diff --git a/Twizy2023-1 b/Twizy2023-1 new file mode 160000 index 0000000..bb9679d --- /dev/null +++ b/Twizy2023-1 @@ -0,0 +1 @@ +Subproject commit bb9679dd6d77c37d270140b0aa7f060ff97cd9d7