Changeset 33243

Show
Ignore:
Timestamp:
27.06.2019 15:19:39 (4 weeks ago)
Author:
cpb16
Message:

Had break through with the refined houghlinesP algorithm overall accurarcy rate of 93%

Location:
other-projects/is-sheet-music-encore/trunk
Files:
8 modified

Legend:

Unmodified
Added
Removed
  • other-projects/is-sheet-music-encore/trunk/Makefile

    r33221 r33243  
    9090#HoughLinesP_refined 
    9191run-classifier-houghlinesP-refined-test: 
     92    #cd image-identification-terminal; rm log-houghlinesP-refined-test.txt 
    9293        #Compile 
    9394    cd image-identification-terminal; javac javaAccuracyCalculator.java 
     
    100101    @date 
    101102        #Calculate the Accuracy of the classifier 
    102     cd image-identification-terminal; java javaAccuracyCalculator log-houghlinesP-refined-test.txt houghlinesP-refined results.txt 
     103    cd image-identification-terminal; java javaAccuracyCalculator log-houghlinesP-refined-test.txt houghlinesP-refined-test results.txt 
    103104        #Display output of javaImageClassifier 
    104105    cd image-identification-terminal; less log-houghlinesP-refined-test.txt 
     
    107108 
    108109run-classifier-houghlinesP-refined-all: 
     110    cd image-identification-terminal; rm log-houghlinesP-refined-MU.txt 
    109111        #Compile 
    110112    cd image-identification-terminal; javac javaAccuracyCalculator.java 
     
    113115    @echo starting classfier 
    114116    @date 
    115     cd image-identification-terminal; ./runClassifer.sh /Scratch/cpb16/is-sheet-music-encore/download-images/MU houghlinesP log-houghlinesP-refined-MU.txt -all 
     117    cd image-identification-terminal; ./runClassifer.sh /Scratch/cpb16/is-sheet-music-encore/download-images/MU houghlinesP-refined log-houghlinesP-refined-MU.txt -all 
    116118    @echo finished classifier 
    117119    @date 
    118120        #Calculate the Accuracy of the classifier 
    119     cd image-identification-terminal; java javaAccuracyCalculator log-houghlinesP-refined-MU.txt houghlinesP results.txt 
     121    cd image-identification-terminal; java javaAccuracyCalculator log-houghlinesP-refined-MU.txt houghlinesP-refined-all results.txt 
    120122        #Display output of javaImageClassifier 
    121123    cd image-identification-terminal; less log-houghlinesP-refined-MU.txt 
     
    145147    cd image-identification-terminal; less log-houghlinesP-refined-MU.txt 
    146148 
    147 run-classifier-houghlinesP-refined-test-remote: 
    148         #Compile 
    149     cd image-identification-terminal; javac javaAccuracyCalculator.java 
    150     cd image-identification-terminal; javac -cp /Scratch/cpb16/opencv-3.4.2/build/bin/opencv-342.jar javaImageClassifier.java; 
    151         #Run javaImageClassifier on all images in TestImages 
    152     @echo starting classfier 
    153     @date 
    154     cd image-identification-terminal; ./runClassifer.sh /Scratch/cpb16/is-sheet-music-encore/download-images/TestImages houghlinesP-refined log-TestImages.txt -all 
    155     @echo finished classifier 
    156     @date 
    157         #Calculate the Accuracy of the classifier 
    158     cd image-identification-terminal; java javaAccuracyCalculator log-TestImages.txt houghlinesP-refined-test results.txt 
    159         #Display output of javaImageClassifier 
    160     cd image-identification-terminal; less log-TestImages.txt 
    161         #Display output of javaAccuracyCalculator output 
    162     cd image-identification-terminal; less results.txt 
    163     cd image-identification-terminal; rm log-TestImages.txt 
    164  
  • other-projects/is-sheet-music-encore/trunk/image-identification-development/.idea/workspace.xml

    r33170 r33243  
    2020        <entry file="file://$PROJECT_DIR$/src/Main.java"> 
    2121          <provider selected="true" editor-type-id="text-editor"> 
    22             <state relative-caret-position="337"> 
    23               <caret line="187" column="68" lean-forward="true" selection-start-line="187" selection-start-column="68" selection-end-line="187" selection-end-column="68" /> 
     22            <state relative-caret-position="-810"> 
     23              <caret line="126" column="37" lean-forward="true" selection-start-line="126" selection-start-column="37" selection-end-line="126" selection-end-column="37" /> 
    2424              <folding> 
    2525                <element signature="imports" expanded="true" /> 
     
    3131    </leaf> 
    3232  </component> 
     33  <component name="FindInProjectRecents"> 
     34    <findStrings> 
     35      <find>aeu.ark+=13960=t93787r1w-10.png</find> 
     36    </findStrings> 
     37  </component> 
    3338  <component name="IdeDocumentHistory"> 
    3439    <option name="CHANGED_PATHS"> 
     
    3843    </option> 
    3944  </component> 
    40   <component name="ProjectFrameBounds" extendedState="4"> 
     45  <component name="ProjectFrameBounds" extendedState="6"> 
    4146    <option name="x" value="992" /> 
    42     <option name="y" value="52" /> 
     47    <option name="y" value="24" /> 
    4348    <option name="width" value="928" /> 
    44     <option name="height" value="1028" /> 
     49    <option name="height" value="1056" /> 
    4550  </component> 
    4651  <component name="ProjectView"> 
     
    127132  </component> 
    128133  <component name="ToolWindowManager"> 
    129     <frame x="992" y="52" width="928" height="1028" extended-state="4" /> 
     134    <frame x="65" y="24" width="1855" height="1056" extended-state="6" /> 
    130135    <editor active="true" /> 
    131136    <layout> 
    132137      <window_info anchor="right" id="Palette" order="4" /> 
    133138      <window_info anchor="bottom" id="TODO" order="10" /> 
    134       <window_info anchor="bottom" id="Messages" order="3" weight="0.32924336" /> 
     139      <window_info anchor="bottom" id="Messages" order="3" weight="0.32842106" /> 
    135140      <window_info anchor="right" id="Palette&#9;" order="1" /> 
    136141      <window_info id="Image Layers" order="4" /> 
     
    138143      <window_info anchor="bottom" id="Event Log" order="1" side_tool="true" /> 
    139144      <window_info anchor="right" id="Maven Projects" order="3" /> 
    140       <window_info active="true" anchor="bottom" id="Run" order="6" visible="true" weight="0.22526316" /> 
     145      <window_info active="true" anchor="bottom" id="Run" order="6" visible="true" weight="0.21881391" /> 
    141146      <window_info anchor="bottom" id="Version Control" order="2" /> 
    142147      <window_info anchor="bottom" id="Terminal" order="0" weight="0.42638037" /> 
     
    148153      <window_info id="UI Designer" order="1" /> 
    149154      <window_info anchor="right" id="Theme Preview" order="2" /> 
    150       <window_info anchor="bottom" id="Debug" order="7" weight="0.3997955" /> 
     155      <window_info anchor="bottom" id="Debug" order="7" weight="0.39894736" /> 
    151156      <window_info id="Favorites" order="3" side_tool="true" /> 
    152157      <window_info anchor="right" content_ui="combo" id="Hierarchy" order="7" weight="0.25" /> 
     
    162167      <window_info anchor="right" content_ui="combo" id="Hierarchy" order="7" weight="0.25" /> 
    163168      <window_info anchor="right" id="Capture Analysis" order="0" /> 
    164       <window_info anchor="bottom" id="Version Control" order="2" /> 
     169      <window_info anchor="bottom" id="Run" order="6" visible="true" weight="0.34662578" /> 
    165170      <window_info anchor="right" id="Theme Preview" order="2" /> 
     171      <window_info anchor="bottom" id="Cvs" order="8" weight="0.25" /> 
    166172      <window_info content_ui="combo" id="Project" order="5" visible="true" weight="0.18382749" /> 
    167173      <window_info id="Structure" order="6" side_tool="true" weight="0.25" /> 
     
    169175      <window_info anchor="right" id="Ant Build" order="6" weight="0.25" /> 
    170176      <window_info anchor="bottom" id="TODO" order="10" /> 
    171       <window_info anchor="bottom" id="Run" order="6" visible="true" weight="0.34662578" /> 
    172177      <window_info id="Image Layers" order="4" /> 
    173178      <window_info id="Designer" order="0" /> 
     
    179184      <window_info anchor="bottom" id="Event Log" order="1" side_tool="true" /> 
    180185      <window_info anchor="bottom" id="Inspection" order="9" weight="0.4" /> 
    181       <window_info anchor="bottom" id="Cvs" order="8" weight="0.25" /> 
     186      <window_info anchor="bottom" id="Version Control" order="2" /> 
    182187      <window_info id="Capture Tool" order="2" /> 
    183188      <window_info anchor="bottom" id="Message" order="4" /> 
     
    198203    <entry file="file://$PROJECT_DIR$/src/Main.java"> 
    199204      <provider selected="true" editor-type-id="text-editor"> 
     205        <state relative-caret-position="645"> 
     206          <caret line="43" selection-start-line="43" selection-end-line="43" selection-end-column="49" /> 
     207          <folding> 
     208            <element signature="imports" expanded="true" /> 
     209          </folding> 
     210        </state> 
     211      </provider> 
     212    </entry> 
     213    <entry file="file://$PROJECT_DIR$/src/Main.java"> 
     214      <provider selected="true" editor-type-id="text-editor"> 
     215        <state relative-caret-position="585"> 
     216          <caret line="39" column="47" selection-start-line="39" selection-start-column="47" selection-end-line="39" selection-end-column="47" /> 
     217          <folding> 
     218            <element signature="imports" expanded="true" /> 
     219          </folding> 
     220        </state> 
     221      </provider> 
     222    </entry> 
     223    <entry file="file://$PROJECT_DIR$/src/Main.java"> 
     224      <provider selected="true" editor-type-id="text-editor"> 
     225        <state relative-caret-position="1980"> 
     226          <caret line="132" selection-start-line="132" selection-end-line="132" /> 
     227          <folding> 
     228            <element signature="imports" expanded="true" /> 
     229          </folding> 
     230        </state> 
     231      </provider> 
     232    </entry> 
     233    <entry file="file://$PROJECT_DIR$/src/Main.java"> 
     234      <provider selected="true" editor-type-id="text-editor"> 
     235        <state relative-caret-position="2805"> 
     236          <caret line="187" column="68" lean-forward="true" selection-start-line="187" selection-start-column="68" selection-end-line="187" selection-end-column="68" /> 
     237          <folding> 
     238            <element signature="imports" expanded="true" /> 
     239          </folding> 
     240        </state> 
     241      </provider> 
     242    </entry> 
     243    <entry file="file://$PROJECT_DIR$/src/Main.java"> 
     244      <provider selected="true" editor-type-id="text-editor"> 
    200245        <state relative-caret-position="2430"> 
    201246          <caret line="162" lean-forward="true" selection-start-line="162" selection-end-line="162" /> 
     
    375420    <entry file="file://$PROJECT_DIR$/src/Main.java"> 
    376421      <provider selected="true" editor-type-id="text-editor"> 
    377         <state relative-caret-position="337"> 
    378           <caret line="187" column="68" lean-forward="true" selection-start-line="187" selection-start-column="68" selection-end-line="187" selection-end-column="68" /> 
     422        <state relative-caret-position="-810"> 
     423          <caret line="126" column="37" lean-forward="true" selection-start-line="126" selection-start-column="37" selection-end-line="126" selection-end-column="37" /> 
    379424          <folding> 
    380425            <element signature="imports" expanded="true" /> 
  • other-projects/is-sheet-music-encore/trunk/image-identification-development/src/Main.java

    r33170 r33243  
    44import org.opencv.imgcodecs.Imgcodecs; 
    55import org.opencv.imgproc.Imgproc; 
     6import org.opencv.photo.Photo; 
    67import static org.opencv.imgcodecs.Imgcodecs.imwrite; 
    78import java.awt.image.BufferedImage; 
    89import java.awt.image.DataBufferByte; 
    910import java.io.File; 
     11import java.util.ArrayList; 
    1012import javax.imageio.ImageIO; 
    1113 
     
    3739 
    3840    //GLOBAL_CONSTANTS 
     41    static int CLASSIFIER_HOUGHLINESP_MIN   = 10; 
     42    static int CLASSIFIER_HOUGHLINESP_MAX   = 65; 
     43    static int HOUGHLINEP_THRESHOLD         = 10; 
     44    static int MINLINECOUNT                 = 40; 
     45    static double MAXLINEGAP                = 4; 
     46    static double SLOPEGRADIENT             = 0.02; 
    3947    //SHOULD TURN INTO ARGS 
    4048 
     
    5967        return null; 
    6068    } 
    61  
    62     private static boolean Classifier(BufferedImage img){ 
     69    private static boolean ClassifierPixelCount(BufferedImage img){ 
    6370        try { 
    6471            //Read file 
     
    8592            percentage = ((float)redCount/(float)pixelCount)*(float)100; 
    8693            //If more than %10 and less than %50 then its sheet music! 
    87             if(percentage > 10 && percentage < 50){ //MAKE THESE CONSTANTS!! 
     94            if(percentage > CLASSIFIER_HOUGHLINESP_MIN && percentage < CLASSIFIER_HOUGHLINESP_MAX){ //MAKE THESE CONSTANTS!! 
    8895                return true;} 
    8996        } 
     
    93100        return false; 
    94101    } 
     102    private static boolean Classifier(int lineCount){ 
     103 
     104           if(lineCount>MINLINECOUNT){ 
     105                return true; 
     106            } 
     107            else{ 
     108                return false; 
     109            } 
     110    } 
     111 
    95112 
    96113    public static void main(String[] args) { 
    97114        System.loadLibrary(Core.NATIVE_LIBRARY_NAME); 
    98115        try { 
     116            //temp array for terminalversion 
     117 
     118            ArrayList returnArray = new ArrayList(); 
     119            returnArray.add(true); 
     120            returnArray.add(10); 
     121 
     122 
    99123            //Variables 
    100124            Mat edgesDetected = new Mat(); 
    101125            Mat edgesDetectedRGB = new Mat(); 
     126            Mat edgesExtra = new Mat(); 
    102127            Mat edgesDetectedRGBProb; 
    103128            Mat edgeDoesntMakeSense; 
    104129            Mat justEdges; //TESTING 
     130 
     131            String directory = "/Scratch/cpb16/is-sheet-music-encore/download-images/MU/"; 
     132            //!!!!!!!!!!!!!!!!!!!!!!!!!!!NOT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
     133            //mdp.39015097852365-2.png 176 lines    Contents page. 
     134            //mdp.39015097852555-3.png 76  lines 
     135            String default_file = directory+"SheetMusic/mdp.39015080972303-3.png"; 
     136            //String default_file ="TestImages/NotNot/mdp.39015080972303-3.png"; 
     137 
     138 
     139            //System.out.println(default_file); 
    105140            //String default_file = "TestImages/NotSheetMusic01.png"; 
    106             String default_file = "TestImages/NotSheetMusic02.png"; 
     141            //String default_file = "TestImages/NotSheetMusic02.png"; 
    107142            //String default_file = "TestImages/SheetMusic01.png"; 
    108143            //String default_file = "TestImages/SheetMusic02.png"; 
    109144            //String default_file = "TestImages/vLine.png"; 
    110145            String filename = ((args.length > 0) ? args[0] : default_file); 
     146            File file = new File(filename); 
     147            if(!file.exists()){System.err.println("Image not found: "+ filename);} 
     148 
     149            int horizontalLineCount =0; 
    111150 
    112151            // Load an image 
     
    114153            // Edge detection 
    115154            //01 CANNY 
    116             Imgproc.Canny(original, edgesDetected, 50, 200, 3, false); 
     155            //Imgproc.Canny(original, edgesDetected, 50, 200, 3, false); 
     156            //Imgproc.Canny(original, edgesDetected,0, 100, 3, false ); 
    117157            //Imgproc.Canny(original, edgesDetected,80, 120); 
    118158            //02 BINARYINV 
    119             //Imgproc.adaptiveThreshold(original, edgesDetected,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV,15, 2); 
     159            Imgproc.adaptiveThreshold(original, edgesDetected,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV,15, 2); 
     160 
     161            //Imgproc.adaptiveThreshold(original, edgesExtra,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV,15, 2); 
     162            //Imgproc.medianBlur(edgesExtra, edgesDetected, 3); 
    120163            //03 BINARY 
    121164            //Imgproc.adaptiveThreshold(original, edgesDetected,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY,15, 2); 
     
    127170 
    128171 
     172 
     173 
    129174            //Convert to RGB for future use 
    130175            Imgproc.cvtColor(edgesDetected, edgesDetectedRGB, Imgproc.COLOR_GRAY2BGR); 
     
    136181            //(edgeDetectedImage, outputOfDetection(r,Ξ), resolution of rho, resolution of theta, threshold (minimum num of intersections) 
    137182 
    138             double minLineLength = edgesDetectedRGB.size().width/4; 
    139             Imgproc.HoughLinesP(edgesDetected, linesP, 1, Math.PI / 180, 50, minLineLength, 10); // runs the actual detection 
    140  
    141  
     183            double minLineLength = edgesDetectedRGB.size().width/8; 
     184 
     185            Imgproc.HoughLinesP(edgesDetected, linesP, 1, Math.PI / 720, HOUGHLINEP_THRESHOLD, minLineLength,MAXLINEGAP); // runs the actual detection 
     186            //Imgproc.HoughLinesP(edgesDetected, linesP, 1, Math.PI / 180, HOUGHLINEP_THRESHOLD, minLineLength,MAXLINEGAP); // runs the actual detection 
     187            System.out.println("Before Graident Filtering num lines: " + linesP.rows()); 
    142188 
    143189            //Imgproc.HoughLinesP(edgesDetected,linesP,1,Math.PI/2, 50, 80, 5); 
     
    170216 
    171217 
    172  
    173  
    174  
    175  
    176                 if(m<=0.1) { 
     218                if(m<=SLOPEGRADIENT) { 
    177219                    //System.out.println("m: " + m); 
    178                     Imgproc.line(edgesDetectedRGB, new Point(l[0], l[1]), new Point(l[2], l[3]), new Scalar(0, 0, 255), 3, Imgproc.LINE_AA, 0); 
     220                    Imgproc.line(edgesDetectedRGB, new Point(l[0], l[1]), new Point(l[2], l[3]), new Scalar(0, 0, 255), 1, Imgproc.LINE_AA, 0); 
     221                    horizontalLineCount++; 
    179222                } 
    180223 
     
    189232 
    190233            BufferedImage toBeClassifiedImg = toBufferedImage(edgesDetectedRGB); 
    191             System.out.println("Result: " + Classifier(toBeClassifiedImg)); 
    192  
     234            System.out.println("Result: " + Classifier(horizontalLineCount)); 
     235 
     236 
     237            System.out.println(); 
    193238            //Display Results 
    194             //HighGui.imshow("Source", original); 
     239            HighGui.imshow("Source", original); 
    195240            //HighGui.imshow("Just Edges", justEdges); //TESTING 
    196241            HighGui.imshow("Detected Lines (in red) - positive", edgesDetectedRGB); 
  • other-projects/is-sheet-music-encore/trunk/image-identification-terminal/javaImageClassifier.java

    r33221 r33243  
    1212import javax.imageio.ImageIO; 
    1313import java.util.logging.Logger; 
     14import java.util.ArrayList; 
    1415 
    1516//REFERENCES: 
     
    2829public class javaImageClassifier{ 
    2930    //Constants 
    30     static int CLASSIFIER_HOUGHLINESP_MIN = 5; 
    31     static int CLASSIFIER_HOUGHLINESP_MAX = 40; 
     31 
     32    static int CLASSIFIER_HOUGHLINESP_MIN   = 10; 
     33    static int CLASSIFIER_HOUGHLINESP_MAX   = 65; 
     34    static int HOUGHLINEP_THRESHOLD         = 10; 
     35    static int MINLINECOUNT                 = 40; //50 
     36    static double MAXLINEGAP                = 4; 
     37    static double SLOPEGRADIENT             = 0.02; //0.01 
    3238 
    3339    public static void main(String[] args) {     
     
    3743            } 
    3844            else { 
     45                ArrayList result_refined = null; 
    3946                Boolean result = null; 
    4047                String imageFilename = args[0]; 
    4148                String classifierType = args[1]; 
    42                 String outputFilename = args[2];             
     49                String outputFilename = args[2]; 
     50                //Prep Writing output to disc 
     51                File log = new File(outputFilename); 
     52                FileWriter fileWriter = new FileWriter(log, true); 
     53                BufferedWriter bw = new BufferedWriter(fileWriter);          
    4354                //Execute classifierType defined from arguement 
     55                 
     56                //Split output by tab for processing in next java program 
     57                //imageFilename = 1, result = 3, classifierType = 4 
    4458                switch(classifierType){ 
    4559                case "houghlinesP": 
    4660                    result = setup_HoughLinesP(imageFilename); //true or false 
     61                    bw.write("Filename:" + '\t' + imageFilename + '\t' + "Classified as:" + '\t' + result + '\t' + classifierType + '\n'); 
    4762                    break; 
    4863                case "houghlinesP-refined": 
    49                     result = setup_HoughLinesP_refined(imageFilename); 
     64                    result_refined = setup_HoughLinesP_refined(imageFilename); 
     65                    bw.write("Filename:" + '\t' + imageFilename + '\t' + "Classified as:" + '\t' + result_refined.get(0) + '\t' + "Number of lines:" + '\t' + result_refined.get(1) + '\t' + classifierType + '\n'); 
    5066                    break; 
    5167                default: 
     
    5369                    break; 
    5470                }            
    55                 //Write output to disc 
    56                 File log = new File(outputFilename); 
    57                 FileWriter fileWriter = new FileWriter(log, true); 
    58                 BufferedWriter bw = new BufferedWriter(fileWriter); 
    59                 //Split output by tab for processing in next java program 
    60                 //imageFilename = 1, result = 3, classifierType = 4 
    61                 bw.write("Filename:" + '\t' + imageFilename + '\t' + "Classified as:" + '\t' + result + '\t' + classifierType + '\n'); 
     71 
    6272                bw.close();              
    6373            } 
     
    8191        Mat edgesDetected = new Mat(); 
    8292        Mat edgesDetectedRGB = new Mat(); 
     93        Mat edgesExtra = new Mat(); 
    8394        Mat edgesDetectedRGBProb; 
    8495        // Load an image 
     
    108119 } 
    109120  
    110      private static Boolean setup_HoughLinesP_refined(String filename){ 
     121     private static ArrayList setup_HoughLinesP_refined(String filename){ 
    111122    System.loadLibrary(Core.NATIVE_LIBRARY_NAME); 
    112123    Boolean isSheetMusic = null; 
     124    ArrayList returnArray = new ArrayList(); 
    113125    try{ 
     126         
    114127        //Variables 
     128        int horizontalLineCount =0; 
    115129        Mat edgesDetected = new Mat(); 
    116130        Mat edgesDetectedRGB = new Mat(); 
     131        Mat edgesExtra = new Mat(); 
    117132        Mat edgesDetectedRGBProb; 
    118133        // Load an image 
    119134        Mat original = Imgcodecs.imread(filename, Imgcodecs.IMREAD_GRAYSCALE); 
    120135        // Edge detection 
    121         Imgproc.Canny(original, edgesDetected, 50, 200, 3, false); 
     136        //Imgproc.Canny(original, edgesDetected, 50, 200, 3, false); 
     137        Imgproc.adaptiveThreshold(original, edgesDetected,255, Imgproc.ADAPTIVE_THRESH_GAUSSIAN_C,Imgproc.THRESH_BINARY_INV,15, 2); 
     138        //Imgproc.medianBlur(edgesExtra, edgesDetected, 3); 
     139         
     140         
    122141        //Copy edges to the images that will display the results in BGR 
    123142        Imgproc.cvtColor(edgesDetected, edgesDetectedRGB, Imgproc.COLOR_GRAY2BGR); 
    124143        // Probabilistic Line Transform 
    125144        Mat linesP = new Mat(); // will hold the results of the detection 
    126         double minLineLength = edgesDetectedRGB.size().width/4; 
    127         //Imgproc.HoughLinesP(edgesDetected, linesP, 1, Math.PI / 180, 50, minLineLength, 10);// runs the actual detection 
    128             Imgproc.HoughLinesP(edgesDetected, linesP, 1, Math.PI / 180, 10, minLineLength, 5);// remote testing 
     145        double minLineLength = edgesDetectedRGB.size().width/8; 
     146        //Imgproc.HoughLinesP(edgesDetected, linesP, 1, Math.PI / 180, 10, minLineLength, MAXLINEGAP);// runs the actual detection 
     147        Imgproc.HoughLinesP(edgesDetected, linesP, 1, Math.PI / 720, HOUGHLINEP_THRESHOLD, minLineLength, MAXLINEGAP); //TESTING 
    129148        // Draw the lines 
    130149         
     
    139158            //System.out.println(l[2]); 
    140159            //System.out.println(l[3]); 
    141             if(m<0.1) { 
     160            if(m<SLOPEGRADIENT) { 
    142161                //System.out.println("m: " + m); 
    143                 Imgproc.line(edgesDetectedRGB, new Point(l[0], l[1]), new Point(l[2], l[3]), new Scalar(0, 0, 255), 3, Imgproc.LINE_AA, 0); 
     162                Imgproc.line(edgesDetectedRGB, new Point(l[0], l[1]), new Point(l[2], l[3]), new Scalar(0, 0, 255), 1, Imgproc.LINE_AA, 0); 
     163                horizontalLineCount++; 
    144164            } 
    145165        } 
     
    148168        BufferedImage toBeClassifiedImg = toBufferedImage(edgesDetectedRGB); 
    149169        //Calculate if its sheet music or not 
    150         isSheetMusic = classifier_HoughLinesP(toBeClassifiedImg);   
    151  
     170        isSheetMusic = classifier_HoughLinesP_refined(horizontalLineCount);   
     171        returnArray.add(isSheetMusic); 
     172        returnArray.add(horizontalLineCount); 
    152173             
    153174    } 
     
    155176            System.err.println(e); 
    156177        } 
    157         return isSheetMusic; 
     178        return returnArray; 
    158179 } 
    159180  
     
    193214        return false; 
    194215    } 
     216     
     217    private static boolean classifier_HoughLinesP_refined(int lineCount){ 
     218        if(lineCount>MINLINECOUNT){ 
     219            return true; 
     220        } 
     221        else{ 
     222            return false; 
     223        } 
     224    } 
     225     
    195226        private static  BufferedImage toBufferedImage(Mat mat){ 
    196227        //MOSTLY COPY PASTE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
  • other-projects/is-sheet-music-encore/trunk/image-identification-terminal/results.txt

    r33221 r33243  
    2222 
    2323 
    24 Date: Sun Jun 23 17:48:16 NZST 2019 
     24BEST SO FAR 
     25Date: Tue Jun 25 16:02:11 NZST 2019 
     26Classifier: houghlinesP-refined 
     27truePositive: 80 
     28falseNegative: 20 
     29falsePositve: 11 
     30trueNegative: 89 
     31SheetMusicAccuracyRate: 80.0% 
     32NotSheetMusicAccuracyRate: 89.0% 
     33OverallAccuracyRate: 84.5% 
     34 
     35Date: Tue Jun 25 16:21:55 NZST 2019 
     36Classifier: houghlinesP 
     37truePositive: 3063 
     38falseNegative: 98 
     39falsePositve: 596 
     40trueNegative: 1244 
     41SheetMusicAccuracyRate: 96.89972% 
     42NotSheetMusicAccuracyRate: 67.608696% 
     43OverallAccuracyRate: 86.12277% 
     44 
     45Date: Tue Jun 25 20:06:21 NZST 2019 
     46Classifier: houghlinesP-refined-all 
     47truePositive: 1723 
     48falseNegative: 1438 
     49falsePositve: 86 
     50trueNegative: 1754 
     51SheetMusicAccuracyRate: 54.508064% 
     52NotSheetMusicAccuracyRate: 95.32609% 
     53OverallAccuracyRate: 69.52609% 
     54 
     55Date: Tue Jun 25 20:13:22 NZST 2019 
     56Classifier: houghlinesP-refined 
     57truePositive: 80 
     58falseNegative: 20 
     59falsePositve: 11 
     60trueNegative: 89 
     61SheetMusicAccuracyRate: 80.0% 
     62NotSheetMusicAccuracyRate: 89.0% 
     63OverallAccuracyRate: 84.5% 
     64 
     65Date: Tue Jun 25 22:40:22 NZST 2019 
     66Classifier: houghlinesP-refined-all-canny 
     67truePositive: 1124 
     68falseNegative: 2037 
     69falsePositve: 61 
     70trueNegative: 1779 
     71SheetMusicAccuracyRate: 35.558365% 
     72NotSheetMusicAccuracyRate: 96.684784% 
     73OverallAccuracyRate: 58.048393% 
     74 
     75MAX 65 
     76MIN 10 
     77ALL MU 
     78RESULT: 
     79 
     80 
     81Date: Wed Jun 26 20:08:09 NZST 2019 
     82Classifier: houghlinesP-refined-all-canny 
     83truePositive: 1124 
     84falseNegative: 2037 
     85falsePositve: 61 
     86trueNegative: 1779 
     87SheetMusicAccuracyRate: 35.558365% 
     88NotSheetMusicAccuracyRate: 96.684784% 
     89OverallAccuracyRate: 58.048393% 
     90 
     91Date: Wed Jun 26 20:44:04 NZST 2019 
     92Classifier: houghlinesP-refined-all 
     93truePositive: 1725 
     94falseNegative: 1436 
     95falsePositve: 87 
     96trueNegative: 1753 
     97SheetMusicAccuracyRate: 54.571335% 
     98NotSheetMusicAccuracyRate: 95.271736% 
     99OverallAccuracyRate: 69.54609% 
     100 
     101BOTH PRE THURSDAY MEETING 
     102Date: Wed Jun 26 21:40:37 NZST 2019 
     103Classifier: houghlinesP 
     104truePositive: 3103 
     105falseNegative: 58 
     106falsePositve: 660 
     107trueNegative: 1180 
     108SheetMusicAccuracyRate: 98.16514% 
     109NotSheetMusicAccuracyRate: 64.13044% 
     110OverallAccuracyRate: 85.642876% 
     111 
     112Date: Wed Jun 26 21:40:37 NZST 2019 
     113Classifier: houghlinesP-refined 
     114truePositive: 1725 
     115falseNegative: 1436 
     116falsePositve: 87 
     117trueNegative: 1753 
     118SheetMusicAccuracyRate: 54.571335% 
     119NotSheetMusicAccuracyRate: 95.271736% 
     120OverallAccuracyRate: 69.54609% 
     121 
     122 
     123POST MEETING  
     124 
     125 
     126Date: Thu Jun 27 11:56:02 NZST 2019 
     127Classifier: houghlinesP-refined 
     128truePositive: 0 
     129falseNegative: 0 
     130falsePositve: 0 
     131trueNegative: 0 
     132SheetMusicAccuracyRate: 0.0% 
     133NotSheetMusicAccuracyRate: 0.0% 
     134OverallAccuracyRate: 0.0% 
     135 
     136Date: Thu Jun 27 12:04:40 NZST 2019 
    25137Classifier: houghlinesP-refined-test 
    26 truePositive: 5 
    27 falseNegative: 5 
    28 falsePositve: 0 
    29 trueNegative: 10 
    30 SheetMusicAccuracyRate: 50.0% 
    31 NotSheetMusicAccuracyRate: 100.0% 
    32 OverallAccuracyRate: 75.0% 
     138truePositive: 7 
     139falseNegative: 3 
     140falsePositve: 5 
     141trueNegative: 5 
     142SheetMusicAccuracyRate: 70.0% 
     143NotSheetMusicAccuracyRate: 50.0% 
     144OverallAccuracyRate: 60.000004% 
    33145 
    34 Date: Sun Jun 23 17:50:39 NZST 2019 
    35 Classifier: houghlinesP-refined-test 
    36 truePositive: 5 
    37 falseNegative: 5 
    38 falsePositve: 0 
    39 trueNegative: 10 
    40 SheetMusicAccuracyRate: 50.0% 
    41 NotSheetMusicAccuracyRate: 100.0% 
    42 OverallAccuracyRate: 75.0% 
     146LINE GAP OF 10 
    43147 
     148Date: Thu Jun 27 12:24:59 NZST 2019 
     149Classifier: houghlinesP-refined-all 
     150truePositive: 2808 
     151falseNegative: 353 
     152falsePositve: 307 
     153trueNegative: 1533 
     154SheetMusicAccuracyRate: 88.83265% 
     155NotSheetMusicAccuracyRate: 83.315216% 
     156OverallAccuracyRate: 86.802635% 
     157 
     158 
     159LINE GAP OF 4 
     160 
     161 
     162Date: Thu Jun 27 14:35:24 NZST 2019 
     163Classifier: houghlinesP-refined-all 
     164truePositive: 2626 
     165falseNegative: 535 
     166falsePositve: 77 
     167trueNegative: 1763 
     168SheetMusicAccuracyRate: 83.074974% 
     169NotSheetMusicAccuracyRate: 95.815216% 
     170OverallAccuracyRate: 87.76244% 
     171 
     172MINLINECOUNT=40 
     173gradient = 0.02 
     174Date: Thu Jun 27 15:10:14 NZST 2019 
     175Classifier: houghlinesP-refined-all 
     176truePositive: 2961 
     177falseNegative: 200 
     178falsePositve: 136 
     179trueNegative: 1704 
     180SheetMusicAccuracyRate: 93.67289% 
     181NotSheetMusicAccuracyRate: 92.608696% 
     182OverallAccuracyRate: 93.28135% 
     183 
  • other-projects/is-sheet-music-encore/trunk/image-identification-terminal/runClassifer.sh

    r33221 r33243  
    22 
    33if [ $# != 4 ] ; then  
    4   echo "Usage: ./testClassifier.sh file_name classifier_type output_filename num_doc(-a = all -test = 100)" 1>&2 
     4  echo "Usage: ./testClassifier.sh file_name classifier_type output_filename type(-a:all -test:100)" 1>&2 
    55  exit 1 
    66fi 
     
    88folder_name=$1 
    99classifier_type=$2 
    10 output_filename=$3 
    11 num_doc=$4 
     10output=$3 
    1211i=0 
     12j=0 
    1313case "$4" in 
    1414    -all) 
     
    1616        for file_name in $folder_name/*/*.png; do 
    1717            echo $file_name 
    18             echo $output_filename 
     18            echo $output 
    1919            echo $i 
    2020            echo "" 
    21             java -cp /Scratch/cpb16/opencv-3.4.2/build/bin/opencv-342.jar:. -Djava.library.path=/Scratch/cpb16/opencv-3.4.2/build/lib/  javaImageClassifier $file_name $classifier_type $output_filename 
     21            java -cp /Scratch/cpb16/opencv-3.4.2/build/bin/opencv-342.jar:. -Djava.library.path=/Scratch/cpb16/opencv-3.4.2/build/lib/  javaImageClassifier $file_name $classifier_type $output 
    2222            i=$[$i+1] 
    2323        done 
    24         ;; 
     24    ;; 
     25         
    2526    -test) 
    26         #Runs javaImageClassifier on 100 images 
    27         for file_name in $folder_name/*/*.png; do 
    28         if [ $i -lt 200 ] ; then 
    29             echo $file_name 
    30             echo $output_filename 
    31             echo $i 
    32             echo "" 
    33             java -cp /Scratch/cpb16/opencv-3.4.2/build/bin/opencv-342.jar:. -Djava.library.path=/Scratch/cpb16/opencv-3.4.2/build/lib/  javaImageClassifier $file_name $classifier_type $output_filename 
    34             i=$[$i+1] 
    35         else 
    36             exit 0 
    37         fi       
     27        #Runs javaImageClassifier on 100 images of each 
     28        for file_name in $folder_name/SheetMusic/*.png; do 
     29            if [ $i -lt 10 ] ; then 
     30                echo $file_name 
     31                echo $output 
     32                echo $i 
     33                echo "" 
     34                java -cp /Scratch/cpb16/opencv-3.4.2/build/bin/opencv-342.jar:. -Djava.library.path=/Scratch/cpb16/opencv-3.4.2/build/lib/  javaImageClassifier $file_name $classifier_type $output 
     35                i=$[$i+1]        
     36            fi 
    3837        done 
    39         ;; 
    40     -small) 
    41         #Runs javaImageClassifier on 100 images 
    42         for file_name in $folder_name/*/*.png; do 
    43         if [ $i -lt 50 ] ; then 
    44             echo $file_name 
    45             echo $output_filename 
    46             echo $i 
    47             echo "" 
    48             java -cp /Scratch/cpb16/opencv-3.4.2/build/bin/opencv-342.jar:. -Djava.library.path=/Scratch/cpb16/opencv-3.4.2/build/lib/  javaImageClassifier $file_name $classifier_type $output_filename 
    49             i=$[$i+1] 
    50         else 
    51             exit 0 
    52         fi       
     38        for file_name in $folder_name/NotSheetMusic/*.png; do 
     39            if [ $j -lt 10 ] ; then 
     40                echo $file_name 
     41                echo $output 
     42                echo $j 
     43                echo "" 
     44                java -cp /Scratch/cpb16/opencv-3.4.2/build/bin/opencv-342.jar:. -Djava.library.path=/Scratch/cpb16/opencv-3.4.2/build/lib/  javaImageClassifier $file_name $classifier_type $output 
     45                j=$[$j+1]        
     46            fi 
    5347        done 
    54         ;; 
     48    ;; 
     49             
    5550esac