Compare commits

...

No commits in common. 'master' and 'old' have entirely different histories.
master ... old

  1. 1
      apikey
  2. BIN
      cache/-1976272648
  3. BIN
      cache/-952931915
  4. 27
      d4dj/.classpath
  5. 23
      d4dj/.project
  6. 4
      d4dj/.settings/org.eclipse.core.resources.prefs
  7. 8
      d4dj/.settings/org.eclipse.jdt.core.prefs
  8. 4
      d4dj/.settings/org.eclipse.m2e.core.prefs
  9. 0
      d4dj/imgtest1.png
  10. 0
      d4dj/imgtest2.png
  11. 0
      d4dj/imgtest3.png
  12. 0
      d4dj/imgtest4.png
  13. 0
      d4dj/imgtest5.png
  14. 12
      d4dj/pom.xml
  15. 0
      d4dj/src/main/java/com/recognition/software/jdeskew/ImageDeskew.java
  16. 0
      d4dj/src/main/java/com/recognition/software/jdeskew/ImageUtil.java
  17. 177
      d4dj/src/main/java/d4dj/d4dj/App.java
  18. 0
      d4dj/src/main/java/org/json/CDL.java
  19. 0
      d4dj/src/main/java/org/json/Cookie.java
  20. 0
      d4dj/src/main/java/org/json/CookieList.java
  21. 0
      d4dj/src/main/java/org/json/HTTP.java
  22. 0
      d4dj/src/main/java/org/json/HTTPTokener.java
  23. 0
      d4dj/src/main/java/org/json/JSONArray.java
  24. 0
      d4dj/src/main/java/org/json/JSONException.java
  25. 0
      d4dj/src/main/java/org/json/JSONML.java
  26. 0
      d4dj/src/main/java/org/json/JSONObject.java
  27. 0
      d4dj/src/main/java/org/json/JSONPointer.java
  28. 0
      d4dj/src/main/java/org/json/JSONPointerException.java
  29. 0
      d4dj/src/main/java/org/json/JSONString.java
  30. 0
      d4dj/src/main/java/org/json/JSONStringer.java
  31. 0
      d4dj/src/main/java/org/json/JSONTokener.java
  32. 0
      d4dj/src/main/java/org/json/JSONWriter.java
  33. 0
      d4dj/src/main/java/org/json/Property.java
  34. 0
      d4dj/src/main/java/org/json/XML.java
  35. 0
      d4dj/src/main/java/org/json/XMLTokener.java
  36. 0
      d4dj/src/main/java/sig/utils/Audio.java
  37. 0
      d4dj/src/main/java/sig/utils/DebugUtils.java
  38. 0
      d4dj/src/main/java/sig/utils/DrawUtils.java
  39. 0
      d4dj/src/main/java/sig/utils/FileUtils.java
  40. 0
      d4dj/src/main/java/sig/utils/GithubUtils.java
  41. 42
      d4dj/src/main/java/sig/utils/ImageUtils.java
  42. 0
      d4dj/src/main/java/sig/utils/JavaUtils.java
  43. 0
      d4dj/src/main/java/sig/utils/ReflectUtils.java
  44. 0
      d4dj/src/main/java/sig/utils/SoundUtils.java
  45. 0
      d4dj/src/main/java/sig/utils/TextUtils.java
  46. 0
      d4dj/src/main/java/sig/utils/TimeUtils.java
  47. 0
      d4dj/src/main/resources/readme.html
  48. 0
      d4dj/src/main/resources/tessdata/configs/alto
  49. 0
      d4dj/src/main/resources/tessdata/configs/api_config
  50. 0
      d4dj/src/main/resources/tessdata/configs/bazaar
  51. 0
      d4dj/src/main/resources/tessdata/configs/digits
  52. 0
      d4dj/src/main/resources/tessdata/configs/hocr
  53. 0
      d4dj/src/main/resources/tessdata/configs/lstmbox
  54. 0
      d4dj/src/main/resources/tessdata/configs/pdf
  55. 0
      d4dj/src/main/resources/tessdata/configs/quiet
  56. 0
      d4dj/src/main/resources/tessdata/configs/tsv
  57. 0
      d4dj/src/main/resources/tessdata/configs/txt
  58. 0
      d4dj/src/main/resources/tessdata/configs/unlv
  59. 0
      d4dj/src/main/resources/tessdata/configs/wordstrbox
  60. 0
      d4dj/src/main/resources/tessdata/eng.traineddata
  61. 0
      d4dj/src/main/resources/tessdata/osd.traineddata
  62. 0
      d4dj/src/main/resources/tessdata/pdf.ttf
  63. 0
      d4dj/src/main/resources/versionchanges.txt
  64. 0
      d4dj/src/main/resources/win32-x86-64/libtesseract500.dll
  65. 0
      d4dj/src/main/resources/win32-x86/libtesseract500.dll
  66. 0
      d4dj/src/test/java/d4dj/d4dj/AppTest.java
  67. 0
      d4dj/src/test/java/net/sourceforge/tess4j/ProgressMonitor.java
  68. 0
      d4dj/src/test/java/net/sourceforge/tess4j/TessAPI1Test.java
  69. 0
      d4dj/src/test/java/net/sourceforge/tess4j/TessAPIImpl.java
  70. 0
      d4dj/src/test/java/net/sourceforge/tess4j/TessAPITest.java
  71. 0
      d4dj/src/test/java/net/sourceforge/tess4j/Tesseract1Test.java
  72. 0
      d4dj/src/test/java/net/sourceforge/tess4j/TesseractTest.java
  73. 0
      d4dj/src/test/java/net/sourceforge/tess4j/TestFolderExtraction.java
  74. 0
      d4dj/src/test/java/net/sourceforge/tess4j/util/ImageIOHelperTest.java
  75. 0
      d4dj/src/test/java/net/sourceforge/tess4j/util/PdfUtilitiesTest.java
  76. 0
      d4dj/src/test/resources/log4j.properties
  77. 0
      d4dj/src/test/resources/logback-test.xml
  78. 0
      d4dj/src/test/resources/test-data/eurotext.bmp
  79. 0
      d4dj/src/test/resources/test-data/eurotext.pdf
  80. 0
      d4dj/src/test/resources/test-data/eurotext.png
  81. 0
      d4dj/src/test/resources/test-data/eurotext.tif
  82. 0
      d4dj/src/test/resources/test-data/eurotext90.png
  83. 0
      d4dj/src/test/resources/test-data/eurotext_deskew.png
  84. 0
      d4dj/src/test/resources/test-data/eurotext_unlv.png
  85. 0
      d4dj/src/test/resources/test-data/eurotext_unlv.uzn
  86. 0
      d4dj/src/test/resources/test-data/multipage-pdf.pdf
  87. 0
      d4dj/src/test/resources/test-results/.gitignore
  88. BIN
      d4dj/target/classes/com/recognition/software/jdeskew/ImageDeskew$HoughLine.class
  89. BIN
      d4dj/target/classes/com/recognition/software/jdeskew/ImageDeskew.class
  90. BIN
      d4dj/target/classes/com/recognition/software/jdeskew/ImageUtil.class
  91. BIN
      d4dj/target/classes/d4dj/d4dj/App.class
  92. BIN
      d4dj/target/classes/d4dj/d4dj/SubmitThread.class
  93. 0
      d4dj/target/classes/org/json/CDL.class
  94. 0
      d4dj/target/classes/org/json/Cookie.class
  95. 0
      d4dj/target/classes/org/json/CookieList.class
  96. 0
      d4dj/target/classes/org/json/HTTP.class
  97. 0
      d4dj/target/classes/org/json/HTTPTokener.class
  98. 0
      d4dj/target/classes/org/json/JSONArray.class
  99. 0
      d4dj/target/classes/org/json/JSONException.class
  100. 0
      d4dj/target/classes/org/json/JSONML.class
  101. Some files were not shown because too many files have changed in this diff Show More

@ -1 +0,0 @@
PR8LRMV1V0FX

BIN
cache/-1976272648 vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

BIN
cache/-952931915 vendored

Binary file not shown.

Before

Width:  |  Height:  |  Size: 38 KiB

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>d4dj</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>

@ -0,0 +1,4 @@
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/test/java=UTF-8
encoding/<project>=UTF-8

@ -0,0 +1,8 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.7

@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1

Before

Width:  |  Height:  |  Size: 5.9 KiB

After

Width:  |  Height:  |  Size: 5.9 KiB

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 6.7 KiB

Before

Width:  |  Height:  |  Size: 4.8 KiB

After

Width:  |  Height:  |  Size: 4.8 KiB

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Before

Width:  |  Height:  |  Size: 5.0 KiB

After

Width:  |  Height:  |  Size: 5.0 KiB

@ -9,6 +9,8 @@
<version>0.0.1-SNAPSHOT</version>
<name>d4dj</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@ -23,16 +25,16 @@
<version>4.11</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.sourceforge.tess4j</groupId>
<artifactId>tess4j</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpmime</artifactId>
<version>4.5.12</version>
</dependency>
</dependencies>

@ -0,0 +1,177 @@
package d4dj.d4dj;
import java.awt.Image;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import javax.imageio.ImageIO;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicNameValuePair;
import org.json.JSONObject;
import net.sourceforge.tess4j.Tesseract;
import net.sourceforge.tess4j.TesseractException;
import sig.utils.ImageUtils;
class SubmitThread implements Runnable{
String name,description,points;
int event,rank;
SubmitThread(String name,String description,String points,int event,int rank) {
this.name=name;
this.description=description;
this.points=points;
this.event=event;
this.rank=rank;
}
@Override
public void run() {
HttpClient httpclient = HttpClients.createDefault();
HttpPost httppost = new HttpPost("http://projectdivar.com/eventsubmit");
List<NameValuePair> params = new ArrayList<NameValuePair>();
params.add(new BasicNameValuePair("eventid", Integer.toString(7)));
params.add(new BasicNameValuePair("rank", Integer.toString(rank)));
params.add(new BasicNameValuePair("name", name));
params.add(new BasicNameValuePair("description", description));
params.add(new BasicNameValuePair("points", points));
try {
httppost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
//Execute and get the response.
HttpResponse response = null;
try {
response = httpclient.execute(httppost);
} catch (IOException e) {
e.printStackTrace();
}
HttpEntity entity = response.getEntity();
if (entity != null) {
try (InputStream instream = entity.getContent()) {
Scanner s = new Scanner(instream).useDelimiter("\\A");
String result = s.hasNext() ? s.next() : "";
System.out.println(result);
instream.close();
} catch (UnsupportedOperationException | IOException e) {
e.printStackTrace();
}
}
}
}
public class App
{
public static void main( String[] args )
{
/*
Tesseract tesseract = new Tesseract();
tesseract.setDatapath("C:\\Users\\sigon\\eclipse-workspace\\d4djRankReaderBot\\d4dj\\tessdata");
try {
tesseract.setLanguage("jpn");
//tesseract.setLanguage("eng");
String finaldata = tesseract.doOCR(new File("imgtest5.png"));
Thread.sleep(500);
System.out.println(finaldata);
} catch (TesseractException | InterruptedException e) {
e.printStackTrace();
}*/
Tesseract tesseract = new Tesseract();
tesseract.setTessVariable("tessedit_write_images", "true");
tesseract.setDatapath("C:\\Users\\sigon\\eclipse-workspace\\d4djRankReaderBot\\d4dj\\tessdata");
Rectangle[] namepositions = new Rectangle[] {new Rectangle(475,263,316,36),new Rectangle(475,384,316,36),new Rectangle(475,510,316,36),new Rectangle(475,636,316,36)};
Rectangle[] descriptions = new Rectangle[] {new Rectangle(475,328,544,36),new Rectangle(475,452,544,36),new Rectangle(475,576,544,36),new Rectangle(475,700,544,36)};
Rectangle[] pointpositions = new Rectangle[] {new Rectangle(1042,317,200,34),new Rectangle(1042,442,200,34),new Rectangle(1042,566,200,34),new Rectangle(1042,688,200,34)};
Point[] offsets = new Point[] {new Point(0,0),new Point(0,-2),new Point(0,-1),new Point(0,5),new Point(0,20)};
String[][] namedata = new String[5][4];
String[][] descriptiondata = new String[5][4];
String[][] pointdata = new String[5][4];
while (true) {
File f = new File("C:\\Users\\sigon\\Pictures\\MEmu Photo\\Screenshots");
//System.out.println(Arrays.deepToString(f.listFiles()));
if (f.listFiles().length==5) {
//New files found!
//Grab the first 5 files and try to parse them.
File[] list = f.listFiles();
for (int i=0;i<5;i++) {
try {
BufferedImage img = ImageUtils.toBufferedImage(ImageIO.read(list[i]));
//ImageIO.write(img,"png",new File("debug/img"+))
for (int j=0;j<4;j++) {
tesseract.setLanguage("jpn");
//ImageIO.write(img.getSubimage(namepositions[j].x+offsets[j].x,namepositions[j].y+offsets[j].y,namepositions[j].width,namepositions[j].height),"png",new File("debug/img"+i+"_"+j+"_0.png"));
//ImageIO.write(img.getSubimage(descriptions[j].x+offsets[j].x,descriptions[j].y+offsets[j].y,descriptions[j].width,descriptions[j].height),"png",new File("debug/img"+i+"_"+j+"_1.png"));
//ImageIO.write(img.getSubimage(pointpositions[j].x+offsets[j].x,pointpositions[j].y+offsets[j].y,pointpositions[j].width,pointpositions[j].height),"png",new File("debug/img"+i+"_"+j+"_2.png"));
String name = tesseract.doOCR(img,new Rectangle(namepositions[j].x+offsets[i].x,namepositions[j].y+offsets[i].y,namepositions[j].width,namepositions[j].height));
String description = tesseract.doOCR(img,new Rectangle(descriptions[j].x+offsets[i].x,descriptions[j].y+offsets[i].y,descriptions[j].width,descriptions[j].height));
tesseract.setLanguage("eng");
String points = tesseract.doOCR(img,new Rectangle(pointpositions[j].x+offsets[i].x,pointpositions[j].y+offsets[i].y,pointpositions[j].width,pointpositions[j].height));
namedata[i][j]=name;
descriptiondata[i][j]=description;
pointdata[i][j]=points;
}
} catch (IOException | TesseractException e) {
e.printStackTrace();
}
}
for (File ff : list) {
ff.delete();
}
// Request parameters and other properties.
for (int i=0;i<20;i++) {
new Thread(
new SubmitThread(namedata[i/4][i%4],descriptiondata[i/4][i%4],pointdata[i/4][i%4].replaceAll(" ","").replaceAll("\\.",""),7,i+1))
.start();
}
} else {
if (f.listFiles().length>5) {
File[] list = f.listFiles();
for (File ff : list) {
ff.delete();
}
}
}
/*System.out.println(Arrays.deepToString(namedata));
System.out.println(Arrays.deepToString(descriptiondata));
System.out.println(Arrays.deepToString(pointdata));*/
try {
Thread.sleep(10000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
}

@ -1,17 +1,12 @@
package sig.utils;
import java.awt.Color;
import javax.imageio.ImageIO;
import java.awt.Graphics2D;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsEnvironment;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.awt.image.ColorModel;
import java.awt.image.WritableRaster;
import java.io.File;
import java.io.IOException;
public class ImageUtils {
/**
@ -96,41 +91,4 @@ public class ImageUtils {
public static double distanceToColor(Color p2, Color p1) {
return Math.sqrt(Math.pow(p2.getRed()-p1.getRed(), 2)+Math.pow(p2.getGreen()-p1.getGreen(), 2)+Math.pow(p2.getBlue()-p1.getBlue(), 2));
}
public static BufferedImage invertImage(BufferedImage inputFile) {
for (int x = 0; x < inputFile.getWidth(); x++) {
for (int y = 0; y < inputFile.getHeight(); y++) {
int rgba = inputFile.getRGB(x, y);
Color col = new Color(rgba, true);
col = new Color(255 - col.getRed(),
255 - col.getGreen(),
255 - col.getBlue());
inputFile.setRGB(x, y, col.getRGB());
}
}
return inputFile;
}
public static BufferedImage
removeBrightPixels(BufferedImage inputFile,int threshold) {
for (int x = 0; x < inputFile.getWidth(); x++) {
for (int y = 0; y < inputFile.getHeight(); y++) {
int rgba = inputFile.getRGB(x, y);
Color col = new Color(rgba, true);
if (col.getRed()+col.getGreen()+col.getBlue()>threshold) {
col = new Color(255,
255,
255,0);
inputFile.setRGB(x, y, col.getRGB());
} else {
inputFile.setRGB(x, y, Color.BLACK.getRGB());
}
}
}
return inputFile;
}
public static BufferedImage deepCopy(BufferedImage bi) {
ColorModel cm = bi.getColorModel();
boolean isAlphaPremultiplied = cm.isAlphaPremultiplied();
WritableRaster raster = bi.copyData(null);
return new BufferedImage(cm, raster, isAlphaPremultiplied, null);
}
}

Before

Width:  |  Height:  |  Size: 100 KiB

After

Width:  |  Height:  |  Size: 100 KiB

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 42 KiB

Before

Width:  |  Height:  |  Size: 200 KiB

After

Width:  |  Height:  |  Size: 200 KiB

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 14 KiB

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save