Changeset 33110 for other-projects/is-sheet-music-encore
- Timestamp:
- 2019-05-26T17:15:31+12:00 (5 years ago)
- 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 4 4 <list default="true" readonly="true" id="9bad4f92-4a7d-46a2-b6f0-94214c9f55cc" name="Default" comment=""> 5 5 <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" /> 6 7 <change beforePath="$PROJECT_DIR$/out/production/image-identification/Main.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/image-identification/Main.class" afterDir="false" /> 7 8 <change beforePath="$PROJECT_DIR$/src/Main.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/Main.java" afterDir="false" /> … … 20 21 <entry file="file://$PROJECT_DIR$/src/Main.java"> 21 22 <provider selected="true" editor-type-id="text-editor"> 22 <state relative-caret-position=" 2520">23 <caret line="1 68" 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" /> 24 25 <folding> 25 26 <element signature="imports" expanded="true" /> … … 39 40 </component> 40 41 <component name="ProjectFrameBounds" extendedState="6"> 41 <option name="x" value=" 451" />42 <option name="y" value=" 135" />43 <option name="width" value="13 70" />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" /> 45 46 </component> 46 47 <component name="ProjectView"> … … 57 58 <property name="GenerateAntBuildDialog.outputFileNameProperty" value="image-identification" /> 58 59 <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$" /> 60 61 <property name="project.structure.last.edited" value="Modules" /> 61 62 <property name="project.structure.proportion" value="0.15" /> … … 131 132 <window_info anchor="right" id="Palette" order="4" /> 132 133 <window_info anchor="bottom" id="TODO" order="10" /> 134 <window_info anchor="bottom" id="Messages" order="3" weight="0.32924336" /> 133 135 <window_info anchor="right" id="Palette	" order="1" /> 134 136 <window_info id="Image Layers" order="4" /> … … 136 138 <window_info anchor="bottom" id="Event Log" order="1" side_tool="true" /> 137 139 <window_info anchor="right" id="Maven Projects" order="3" /> 138 <window_info anchor="bottom" id="Run" order="6" weight="0.26 993865" />140 <window_info anchor="bottom" id="Run" order="6" weight="0.26789367" /> 139 141 <window_info anchor="bottom" id="Version Control" order="2" /> 140 142 <window_info anchor="bottom" id="Terminal" order="0" weight="0.42638037" /> … … 149 151 <window_info id="Favorites" order="3" side_tool="true" /> 150 152 <window_info anchor="right" content_ui="combo" id="Hierarchy" order="7" weight="0.25" /> 151 <window_info anchor="bottom" id="Messages" order="3" />152 153 <window_info anchor="bottom" id="Inspection" order="9" weight="0.4" /> 153 154 <window_info anchor="bottom" id="Inspection Results" order="11" weight="0.32924336" /> … … 161 162 <window_info anchor="right" content_ui="combo" id="Hierarchy" order="7" weight="0.25" /> 162 163 <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" /> 164 165 <window_info anchor="right" id="Theme Preview" order="2" /> 165 <window_info anchor="bottom" id="Cvs" order="8" weight="0.25" />166 166 <window_info content_ui="combo" id="Project" order="5" visible="true" weight="0.18382749" /> 167 167 <window_info id="Structure" order="6" side_tool="true" weight="0.25" /> … … 169 169 <window_info anchor="right" id="Ant Build" order="6" weight="0.25" /> 170 170 <window_info anchor="bottom" id="TODO" order="10" /> 171 <window_info anchor="bottom" id="Run" order="6" visible="true" weight="0.34662578" /> 171 172 <window_info id="Image Layers" order="4" /> 172 173 <window_info id="Designer" order="0" /> … … 178 179 <window_info anchor="bottom" id="Event Log" order="1" side_tool="true" /> 179 180 <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" /> 181 182 <window_info id="Capture Tool" order="2" /> 182 183 <window_info anchor="bottom" id="Message" order="4" /> … … 191 192 <component name="XDebuggerManager"> 192 193 <breakpoint-manager> 193 <option name="time" value=" 2" />194 <option name="time" value="3" /> 194 195 </breakpoint-manager> 195 196 </component> 196 197 <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> 197 218 <entry file="file://$PROJECT_DIR$/src/Main.java"> 198 219 <provider selected="true" editor-type-id="text-editor"> … … 324 345 <entry file="file://$PROJECT_DIR$/src/Main.java"> 325 346 <provider selected="true" editor-type-id="text-editor"> 326 <state relative-caret-position=" 2520">327 <caret line="1 68" 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" /> 328 349 <folding> 329 350 <element signature="imports" expanded="true" /> -
other-projects/is-sheet-music-encore/trunk/image-identification-development/src/Main.java
r33097 r33110 100 100 Mat edgesDetected = new Mat(); 101 101 Mat edgesDetectedRGB = new Mat(); 102 Mat forOTSU = new Mat(); 102 103 Mat edgesDetectedRGBProb; 103 104 Mat justEdges; //TESTING 104 String default_file = "Test 02.png";105 String default_file = "TestImages/houghlineTest.png"; 105 106 String filename = ((args.length > 0) ? args[0] : default_file); 106 107 … … 108 109 Mat original = Imgcodecs.imread(filename, Imgcodecs.IMREAD_GRAYSCALE); 109 110 // 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 112 125 Imgproc.cvtColor(edgesDetected, edgesDetectedRGB, Imgproc.COLOR_GRAY2BGR); 113 edgesDetectedRGBProb = edgesDetectedRGB.clone(); 114 115 justEdges = edgesDetectedRGBProb.clone();//TESTING 126 justEdges = edgesDetectedRGB.clone();//TESTING 116 127 117 128 // Standard Hough Line Transform 118 129 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 121 133 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 125 138 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 coord130 double a = Math.cos(theta), b = Math.sin(theta);131 double x0 = a * rho, y0 = b * rho;132 139 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); 136 156 } 137 157 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); 145 178 } 179 */ 146 180 147 //Convert MAT into a BufferedImage148 BufferedImage toBeClassifiedImg = toBufferedImage(edgesDetectedRGBProb);149 150 //Calculate if its sheet music or not151 Boolean isSheetMusic = Classifier(toBeClassifiedImg);152 System.out.println("Filename: " + filename + " Status: " + isSheetMusic);153 154 //Save Processed Image155 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);163 181 164 182 //Display Results -
other-projects/is-sheet-music-encore/trunk/image-identification-terminal/Makefile
r33097 r33110 14 14 15 15 16 16 image-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%1 Classifier:Probabilistic HoughLines 30.08%
Note:
See TracChangeset
for help on using the changeset viewer.