Index: other-projects/is-sheet-music-encore/trunk/image-identification/.idea/description.html
===================================================================
--- other-projects/is-sheet-music-encore/trunk/image-identification/.idea/description.html (revision 33069)
+++ other-projects/is-sheet-music-encore/trunk/image-identification/.idea/description.html (revision 33069)
@@ -0,0 +1,1 @@
+Simple Java application that includes a class with main()
method
Index: other-projects/is-sheet-music-encore/trunk/image-identification/.idea/misc.xml
===================================================================
--- other-projects/is-sheet-music-encore/trunk/image-identification/.idea/misc.xml (revision 33069)
+++ other-projects/is-sheet-music-encore/trunk/image-identification/.idea/misc.xml (revision 33069)
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
+
+
+
+
+
Index: other-projects/is-sheet-music-encore/trunk/image-identification/.idea/modules.xml
===================================================================
--- other-projects/is-sheet-music-encore/trunk/image-identification/.idea/modules.xml (revision 33069)
+++ other-projects/is-sheet-music-encore/trunk/image-identification/.idea/modules.xml (revision 33069)
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
Index: other-projects/is-sheet-music-encore/trunk/image-identification/.idea/project-template.xml
===================================================================
--- other-projects/is-sheet-music-encore/trunk/image-identification/.idea/project-template.xml (revision 33069)
+++ other-projects/is-sheet-music-encore/trunk/image-identification/.idea/project-template.xml (revision 33069)
@@ -0,0 +1,3 @@
+
+ IJ_BASE_PACKAGE
+
Index: other-projects/is-sheet-music-encore/trunk/image-identification/.idea/vcs.xml
===================================================================
--- other-projects/is-sheet-music-encore/trunk/image-identification/.idea/vcs.xml (revision 33069)
+++ other-projects/is-sheet-music-encore/trunk/image-identification/.idea/vcs.xml (revision 33069)
@@ -0,0 +1,6 @@
+
+
+
+
+
+
Index: other-projects/is-sheet-music-encore/trunk/image-identification/.idea/workspace.xml
===================================================================
--- other-projects/is-sheet-music-encore/trunk/image-identification/.idea/workspace.xml (revision 33069)
+++ other-projects/is-sheet-music-encore/trunk/image-identification/.idea/workspace.xml (revision 33069)
@@ -0,0 +1,288 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ $USER_HOME$/.subversion
+ 125
+
+
+
+
+ 1557697736662
+
+
+ 1557697736662
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ No facets are configured
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1.8
+
+
+
+
+
+
+
+
+
+
+
+ image-identification
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: other-projects/is-sheet-music-encore/trunk/image-identification/image-identification.iml
===================================================================
--- other-projects/is-sheet-music-encore/trunk/image-identification/image-identification.iml (revision 33069)
+++ other-projects/is-sheet-music-encore/trunk/image-identification/image-identification.iml (revision 33069)
@@ -0,0 +1,22 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Index: other-projects/is-sheet-music-encore/trunk/image-identification/src/Main.java
===================================================================
--- other-projects/is-sheet-music-encore/trunk/image-identification/src/Main.java (revision 33069)
+++ other-projects/is-sheet-music-encore/trunk/image-identification/src/Main.java (revision 33069)
@@ -0,0 +1,112 @@
+import org.opencv.core.*;
+import org.opencv.core.Point;
+import org.opencv.highgui.HighGui;
+import org.opencv.imgcodecs.Imgcodecs;
+import org.opencv.imgproc.Imgproc;
+import static org.opencv.imgcodecs.Imgcodecs.imwrite;
+
+
+//REFERENCES:
+//https://docs.opencv.org/3.4.3/d9/db0/tutorial_hough_lines.html
+
+
+public class Main {
+
+ private Scalar meanOfProcessed;
+
+ public static void main(String[] args) {
+ System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
+/*
+ // write your code here
+ System.out.println("Welcome to OpenCV " + Core.VERSION);
+ Mat m = new Mat(5, 10, CvType.CV_8UC1, new Scalar(0));
+ System.out.println("OpenCV Mat: " + m);
+ Mat mr1 = m.row(1);
+ mr1.setTo(new Scalar(1));
+ Mat mc5 = m.col(0);
+ mc5.setTo(new Scalar(8));
+ System.out.println("OpenCV Mat data:\n" + m.dump());
+ */
+ try {
+ //Variables
+ Mat edgesDetected = new Mat();
+ Mat edgesDetectedRGB = new Mat();
+ Mat edgesDetectedRGBProb;
+ Mat justEdges;
+
+
+
+ String default_file = "Test.png";
+ String filename = ((args.length > 0) ? args[0] : default_file);
+
+ // Load an image
+ Mat original = Imgcodecs.imread(filename, Imgcodecs.IMREAD_GRAYSCALE);
+ // Edge detection
+ Imgproc.Canny(original, edgesDetected, 50, 200, 3, false);
+ //Copy edges to the images that will display the results in BGR
+ Imgproc.cvtColor(edgesDetected, edgesDetectedRGB, Imgproc.COLOR_GRAY2BGR);
+ edgesDetectedRGBProb = edgesDetectedRGB.clone();
+
+ justEdges = edgesDetectedRGBProb.clone();
+
+
+
+ // Standard Hough Line Transform
+ Mat lines = new Mat(); // will hold the results of the detection
+ Imgproc.HoughLines(edgesDetected, lines, 1, Math.PI / 180, 150); // runs the actual detection
+ // Draw the lines
+ for (int x = 0; x < lines.rows(); x++) {
+ double rho = lines.get(x, 0)[0],
+ theta = lines.get(x, 0)[1];
+ double a = Math.cos(theta), b = Math.sin(theta);
+ double x0 = a * rho, y0 = b * rho;
+ Point pt1 = new Point(Math.round(x0 + 1000 * (-b)), Math.round(y0 + 1000 * (a)));
+ Point pt2 = new Point(Math.round(x0 - 1000 * (-b)), Math.round(y0 - 1000 * (a)));
+ Imgproc.line(edgesDetectedRGB, pt1, pt2, new Scalar(0, 0, 255), 3, Imgproc.LINE_AA, 0);
+ }
+
+
+
+ // Probabilistic Line Transform
+ Mat linesP = new Mat(); // will hold the results of the detection
+ Imgproc.HoughLinesP(edgesDetected, linesP, 1, Math.PI / 180, 50, 50, 10); // runs the actual detection
+ // Draw the lines
+ for (int x = 0; x < linesP.rows(); x++) {
+ double[] l = linesP.get(x, 0);
+ Imgproc.line(edgesDetectedRGBProb, new Point(l[0], l[1]), new Point(l[2], l[3]), new Scalar(0, 0, 255), 3, Imgproc.LINE_AA, 0);
+ }
+
+ //save output
+ imwrite(filename+"_HoughLineP", edgesDetectedRGBProb);
+ String processedFile = filename+"_HoughLineP";
+ //Load an image
+ Mat processed = Imgcodecs.imread(processedFile, Imgcodecs.IMREAD_COLOR);
+ System.out.println(Core.mean(processed));
+ String meanOfProcessed = (Core.mean(processed).toString());
+ //OUTPUTS [ BLUE , GREEN , RED, ALPHA?
+ //Core.mean GETS scalar of image (array of BGR) and calculates the average for each
+ //https://docs.opencv.org/java/2.4.2/org/opencv/core/Core.html#mean(org.opencv.core.Mat)
+
+ //With this logic, then if can say if the RED in the array is between 'x' and 'y' then its sheet music
+ System.out.println(meanOfProcessed); //PRINTS AS EXPECTED
+
+ //CONVERT STRING TO ARRAY OR FIND ANOTHER WAY OF GETTING TO RED VALUE
+ //SAVE AS VARIABLE : RedValue.
+ //IF redValue > 'x' and redValue < 'y' THEN it is sheet music
+
+
+
+ // Show results
+ //HighGui.imshow("Source", original);
+ //HighGui.imshow("Detected Lines (in red) - Standard Hough Line Transform", edgesDetectedRGB);
+ HighGui.imshow("Detected Lines (in red) - Probabilistic Line Transform", edgesDetectedRGBProb);
+ //HighGui.imshow("Just Edges", justEdges);
+ // Wait and Exit
+ HighGui.waitKey();
+ System.exit(0);
+ }
+ catch(Exception e){
+ System.err.println(e);
+ }
+ }
+}