Changeset 33110


Ignore:
Timestamp:
2019-05-26T17:15:31+12:00 (5 years ago)
Author:
cpb16
Message:

Ground truth complete for SE and BK. Added file to keep track of all error images downdloaded. added file for notes for next meeting

Location:
other-projects/is-sheet-music-encore/trunk
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • other-projects/is-sheet-music-encore/trunk/image-identification-development/.idea/workspace.xml

    r33097 r33110  
    44    <list default="true" readonly="true" id="9bad4f92-4a7d-46a2-b6f0-94214c9f55cc" name="Default" comment="">
    55      <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
     6      <change beforePath="$PROJECT_DIR$/Test_HoughLineP.png" beforeDir="false" afterPath="$PROJECT_DIR$/Test_HoughLineP.png" afterDir="false" />
    67      <change beforePath="$PROJECT_DIR$/out/production/image-identification/Main.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/image-identification/Main.class" afterDir="false" />
    78      <change beforePath="$PROJECT_DIR$/src/Main.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Main.java" afterDir="false" />
     
    2021        <entry file="file://$PROJECT_DIR$/src/Main.java">
    2122          <provider selected="true" editor-type-id="text-editor">
    22             <state relative-caret-position="2520">
    23               <caret line="168" lean-forward="true" selection-start-line="168" selection-end-line="168" />
     23            <state relative-caret-position="694">
     24              <caret line="174" column="36" lean-forward="true" selection-start-line="174" selection-start-column="36" selection-end-line="174" selection-end-column="36" />
    2425              <folding>
    2526                <element signature="imports" expanded="true" />
     
    3940  </component>
    4041  <component name="ProjectFrameBounds" extendedState="6">
    41     <option name="x" value="451" />
    42     <option name="y" value="135" />
    43     <option name="width" value="1370" />
    44     <option name="height" value="910" />
     42    <option name="x" value="712" />
     43    <option name="y" value="69" />
     44    <option name="width" value="1350" />
     45    <option name="height" value="850" />
    4546  </component>
    4647  <component name="ProjectView">
     
    5758    <property name="GenerateAntBuildDialog.outputFileNameProperty" value="image-identification" />
    5859    <property name="full.screen.before.presentation.mode" value="false" />
    59     <property name="last_opened_file_path" value="$USER_HOME$/Desktop" />
     60    <property name="last_opened_file_path" value="$PROJECT_DIR$" />
    6061    <property name="project.structure.last.edited" value="Modules" />
    6162    <property name="project.structure.proportion" value="0.15" />
     
    131132      <window_info anchor="right" id="Palette" order="4" />
    132133      <window_info anchor="bottom" id="TODO" order="10" />
     134      <window_info anchor="bottom" id="Messages" order="3" weight="0.32924336" />
    133135      <window_info anchor="right" id="Palette&#9;" order="1" />
    134136      <window_info id="Image Layers" order="4" />
     
    136138      <window_info anchor="bottom" id="Event Log" order="1" side_tool="true" />
    137139      <window_info anchor="right" id="Maven Projects" order="3" />
    138       <window_info anchor="bottom" id="Run" order="6" weight="0.26993865" />
     140      <window_info anchor="bottom" id="Run" order="6" weight="0.26789367" />
    139141      <window_info anchor="bottom" id="Version Control" order="2" />
    140142      <window_info anchor="bottom" id="Terminal" order="0" weight="0.42638037" />
     
    149151      <window_info id="Favorites" order="3" side_tool="true" />
    150152      <window_info anchor="right" content_ui="combo" id="Hierarchy" order="7" weight="0.25" />
    151       <window_info anchor="bottom" id="Messages" order="3" />
    152153      <window_info anchor="bottom" id="Inspection" order="9" weight="0.4" />
    153154      <window_info anchor="bottom" id="Inspection Results" order="11" weight="0.32924336" />
     
    161162      <window_info anchor="right" content_ui="combo" id="Hierarchy" order="7" weight="0.25" />
    162163      <window_info anchor="right" id="Capture Analysis" order="0" />
    163       <window_info anchor="bottom" id="Run" order="6" visible="true" weight="0.34662578" />
     164      <window_info anchor="bottom" id="Version Control" order="2" />
    164165      <window_info anchor="right" id="Theme Preview" order="2" />
    165       <window_info anchor="bottom" id="Cvs" order="8" weight="0.25" />
    166166      <window_info content_ui="combo" id="Project" order="5" visible="true" weight="0.18382749" />
    167167      <window_info id="Structure" order="6" side_tool="true" weight="0.25" />
     
    169169      <window_info anchor="right" id="Ant Build" order="6" weight="0.25" />
    170170      <window_info anchor="bottom" id="TODO" order="10" />
     171      <window_info anchor="bottom" id="Run" order="6" visible="true" weight="0.34662578" />
    171172      <window_info id="Image Layers" order="4" />
    172173      <window_info id="Designer" order="0" />
     
    178179      <window_info anchor="bottom" id="Event Log" order="1" side_tool="true" />
    179180      <window_info anchor="bottom" id="Inspection" order="9" weight="0.4" />
    180       <window_info anchor="bottom" id="Version Control" order="2" />
     181      <window_info anchor="bottom" id="Cvs" order="8" weight="0.25" />
    181182      <window_info id="Capture Tool" order="2" />
    182183      <window_info anchor="bottom" id="Message" order="4" />
     
    191192  <component name="XDebuggerManager">
    192193    <breakpoint-manager>
    193       <option name="time" value="2" />
     194      <option name="time" value="3" />
    194195    </breakpoint-manager>
    195196  </component>
    196197  <component name="editorHistoryManager">
     198    <entry file="file://$PROJECT_DIR$/src/Main.java">
     199      <provider selected="true" editor-type-id="text-editor">
     200        <state relative-caret-position="1620">
     201          <caret line="108" column="29" lean-forward="true" selection-start-line="108" selection-start-column="29" selection-end-line="108" selection-end-column="29" />
     202          <folding>
     203            <element signature="imports" expanded="true" />
     204          </folding>
     205        </state>
     206      </provider>
     207    </entry>
     208    <entry file="file://$PROJECT_DIR$/src/Main.java">
     209      <provider selected="true" editor-type-id="text-editor">
     210        <state relative-caret-position="2520">
     211          <caret line="168" lean-forward="true" selection-start-line="168" selection-end-line="168" />
     212          <folding>
     213            <element signature="imports" expanded="true" />
     214          </folding>
     215        </state>
     216      </provider>
     217    </entry>
    197218    <entry file="file://$PROJECT_DIR$/src/Main.java">
    198219      <provider selected="true" editor-type-id="text-editor">
     
    324345    <entry file="file://$PROJECT_DIR$/src/Main.java">
    325346      <provider selected="true" editor-type-id="text-editor">
    326         <state relative-caret-position="2520">
    327           <caret line="168" lean-forward="true" selection-start-line="168" selection-end-line="168" />
     347        <state relative-caret-position="694">
     348          <caret line="174" column="36" lean-forward="true" selection-start-line="174" selection-start-column="36" selection-end-line="174" selection-end-column="36" />
    328349          <folding>
    329350            <element signature="imports" expanded="true" />
  • other-projects/is-sheet-music-encore/trunk/image-identification-development/src/Main.java

    r33097 r33110  
    100100            Mat edgesDetected = new Mat();
    101101            Mat edgesDetectedRGB = new Mat();
     102            Mat forOTSU = new Mat();
    102103            Mat edgesDetectedRGBProb;
    103104            Mat justEdges; //TESTING
    104             String default_file = "Test02.png";
     105            String default_file = "TestImages/houghlineTest.png";
    105106            String filename = ((args.length > 0) ? args[0] : default_file);
    106107
     
    108109            Mat original = Imgcodecs.imread(filename, Imgcodecs.IMREAD_GRAYSCALE);
    109110            // Edge detection
    110             Imgproc.Canny(original, edgesDetected, 50, 200, 3, false);
    111             //Copy edges to the images that will display the results in BGR
     111            //01 CANNY
     112            //Imgproc.Canny(original, edgesDetected, 50, 200, 3, false);
     113            //02 BINARYINV
     114            Imgproc.adaptiveThreshold(original, edgesDetected,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV,15, 2);
     115            //03 BINARY
     116            //Imgproc.adaptiveThreshold(original, edgesDetected,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY,15, 2);
     117            //04 NO PROC
     118            //edgesDetected = original.clone();
     119            //05 OTSU THRESHOLD
     120            //Imgproc.threshold(original, edgesDetected,0,255,Imgproc.THRESH_BINARY_INV+Imgproc.THRESH_OTSU);
     121
     122
     123
     124            //Convert to RGB
    112125            Imgproc.cvtColor(edgesDetected, edgesDetectedRGB, Imgproc.COLOR_GRAY2BGR);
    113             edgesDetectedRGBProb = edgesDetectedRGB.clone();
    114 
    115             justEdges = edgesDetectedRGBProb.clone();//TESTING
     126            justEdges = edgesDetectedRGB.clone();//TESTING
    116127
    117128            // Standard Hough Line Transform
    118129            Mat lines = new Mat(); // will hold the results of the detection
    119             //(edgeDetectedImage, outputOfDetection(r,Ξ), resolution of r, resolution of Ξ, threshold (minimum num of intersections)
    120             Imgproc.HoughLines(edgesDetected, lines, 1.4, Math.PI / 180, 500); // runs the actual detection
     130            //(edgeDetectedImage, outputOfDetection(r,Ξ), resolution of rho, resolution of theta, threshold (minimum num of intersections)
     131            Imgproc.HoughLines(edgesDetected, lines, 1, Math.PI / 180.0, 350); // runs the actual detection
     132            //Imgproc.HoughLines(edgesDetected, lines, 5.0, 4.0, 7); // runs the actual detection
    121133
    122             // Draw the lines
    123             //LOOK OVER THIS AGAIN THE 1000 might be image height?
    124             //THRESHOLD should be changed, based on img dimensions?
     134            //make some test images. black and white. row of white row of black. call hough transform. check if its displaying as expected
     135            //make sure res of 0 is appropriate, try 360
     136            //expect theta values of 0+-
     137            //try greyscale image
    125138
    126             for (int x = 0; x < lines.rows(); x++) {
    127                 double rho = lines.get(x, 0)[0],
    128                         theta = lines.get(x, 0)[1];
    129                 //CONVERT to Cartisean coord
    130                 double a = Math.cos(theta), b = Math.sin(theta);
    131                 double x0 = a * rho, y0 = b * rho;
    132139
    133                 Point pt1 = new Point(Math.round(x0 + 1000 * (-b)), Math.round(y0 + 1000 * (a)));
    134                 Point pt2 = new Point(Math.round(x0 - 1000 * (-b)), Math.round(y0 - 1000 * (a)));
    135                 Imgproc.line(edgesDetectedRGB, pt1, pt2, new Scalar(0, 0, 255), 3, Imgproc.LINE_AA, 0);
     140            for (int i = 0; i < lines.cols(); i++) {
     141                double rho = lines.get(0, i)[0];
     142                double theta = lines.get(0, i)[1];
     143                double cosTheta = Math.cos(theta);
     144                double sinTheta = Math.sin(theta);
     145                double x0 = cosTheta * rho;
     146                double y0 = sinTheta * rho;
     147                double xpt1 = x0 + 10000 * (-sinTheta);
     148                double ypt1 = y0 + 10000 * (cosTheta);
     149                double xpt2 = x0 - 10000 * (-sinTheta);
     150                double ypt2 = y0 - 10000 * (cosTheta);
     151                double angle = Core.fastAtan2((float)ypt2 - (float)ypt1, (float)xpt2 - (float)xpt1) * (Math.PI/180.0);
     152                Point pt1 = new Point(xpt1, ypt1);
     153                Point pt2 = new Point(xpt2, ypt2);
     154                Imgproc.line(edgesDetectedRGB, pt1, pt2, new Scalar(0, 0, 255), 3, Imgproc.LINE_AA,0);
     155                System.out.println("rho: " + rho + '\n' + "theta: " + theta + '\n' + "angle: " + angle);
    136156            }
    137157
    138             // Probabilistic Line Transform
    139             Mat linesP = new Mat(); // will hold the results of the detection
    140             Imgproc.HoughLinesP(edgesDetected, linesP, 1, Math.PI / 180, 50, 50, 10); // runs the actual detection
    141             // Draw the lines
    142             for (int x = 0; x < linesP.rows(); x++) {
    143                 double[] l = linesP.get(x, 0);
    144                 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);
     158            /*
     159            for (int x = 0; x < lines.rows(); x++) {
     160                double rho = lines.get(x, 0)[0];
     161                double theta = lines.get(x, 0)[1];
     162                double cosTheta = Math.cos(theta);
     163                double sinTheta = Math.sin(theta);                //CONVERT to Cartisean coord
     164                double x0 = cosTheta * rho;
     165                double y0 = sinTheta * rho;
     166
     167                double xpt1 = Math.round(x0 + 10000 * (-sinTheta));
     168                double ypt1 = Math.round(y0 + 10000 * (cosTheta));
     169                double xpt2 = Math.round(x0 - 10000 * (-sinTheta));
     170                double ypt2 = Math.round(y0 - 10000 * (cosTheta));
     171                double angle = Core.fastAtan2((float)ypt2 - (float)ypt1, (float)xpt2 - (float)xpt1) * (Math.PI/180.0);
     172
     173                Point pt1 = new Point(xpt1, ypt1);
     174                Point pt2 = new Point(xpt2, ypt2);
     175                Imgproc.line(edgesDetectedRGB, pt1, pt2, new Scalar(0, 0, 255), 3, Imgproc.LINE_AA, 0);
     176
     177                System.out.println("rho: " + rho + '\n' + "theta: " + theta + '\n' + "angle: " + angle);
    145178            }
     179            */
    146180
    147             //Convert MAT into a BufferedImage
    148             BufferedImage toBeClassifiedImg = toBufferedImage(edgesDetectedRGBProb);
    149 
    150             //Calculate if its sheet music or not
    151             Boolean isSheetMusic = Classifier(toBeClassifiedImg);
    152             System.out.println("Filename: " + filename + "  Status: " + isSheetMusic);
    153 
    154             //Save Processed Image
    155             String processedFile = null;
    156             if (isSheetMusic == true) {
    157                 //NEED FIGURE OUT HOW RUN IN SCRIPT. THEN USE ARGS as filename + "HoughLineP + "png"
    158                 processedFile = "SheetMusic/Test_HoughLineP.png";
    159             }else {
    160                 processedFile = "Test_HoughLineP.png";
    161             }
    162             imwrite(processedFile, edgesDetectedRGBProb);
    163181
    164182            //Display Results
  • other-projects/is-sheet-music-encore/trunk/image-identification-terminal/Makefile

    r33097 r33110  
    1414
    1515
    16 
     16image-run-classifier01:
     17    javac javaAccuracyCalculator.java
     18    javac -cp /Scratch/cpb16/opencv-3.4.2/build/bin/opencv-342.jar javaImageClassifier.java;
     19    ./testClassifer.sh ../download-images/BK 1
     20    echo "Displaying javaImageClassifier output"
     21    less log.txt
     22    java javaAccuracyCalculator log.txt 1 results.txt
     23    less results.txt
     24    rm log.txt
  • other-projects/is-sheet-music-encore/trunk/image-identification-terminal/results.txt

    r33097 r33110  
    1 Classifier:Probabilistic HoughLines 100.0%
     1Classifier:Probabilistic HoughLines 30.08%
Note: See TracChangeset for help on using the changeset viewer.