Update torun both english and japanese reading and produce output
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
30b8a69c94
commit
af48607bd9
@ -1,5 +1,6 @@
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
@ -56,8 +57,8 @@ public class ArcadeReader {
|
|||||||
* - Not going to support right now.
|
* - Not going to support right now.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static void retrieveData(BufferedImage img) {
|
public static void retrieveData(Path img) {
|
||||||
new LoveLiveReader().interpretBoxes();
|
new LoveLiveReader().interpretBoxes(img);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
class Box{
|
class Box{
|
||||||
@ -80,8 +81,8 @@ class LoveLiveReader extends Reader{
|
|||||||
readRegions.add(new Box(10,40,24,24));
|
readRegions.add(new Box(10,40,24,24));
|
||||||
readRegions.add(new Box(10,70,24,24));
|
readRegions.add(new Box(10,70,24,24));
|
||||||
}
|
}
|
||||||
void interpretBoxes(){
|
void interpretBoxes(Path img){
|
||||||
String dataString = readAllBoxes();
|
String dataString = readAllBoxes(img);
|
||||||
System.out.println(dataString);
|
System.out.println(dataString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -95,9 +96,9 @@ abstract class Reader{
|
|||||||
int maxcombo;
|
int maxcombo;
|
||||||
String other;
|
String other;
|
||||||
List<Box> readRegions = new ArrayList<>();
|
List<Box> readRegions = new ArrayList<>();
|
||||||
String readAllBoxes() {
|
String readAllBoxes(Path img) {
|
||||||
try {
|
try {
|
||||||
Process p = Runtime.getRuntime().exec(new String[]{"python3","runocr.py","ja"});
|
Process p = Runtime.getRuntime().exec(new String[]{"python3","runocr.py","ja",img.toAbsolutePath().toString()});
|
||||||
while (p.isAlive());
|
while (p.isAlive());
|
||||||
InputStreamReader result = new InputStreamReader(p.getInputStream());
|
InputStreamReader result = new InputStreamReader(p.getInputStream());
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
@ -105,6 +106,13 @@ abstract class Reader{
|
|||||||
sb.append((char)result.read());
|
sb.append((char)result.read());
|
||||||
}
|
}
|
||||||
result.close();
|
result.close();
|
||||||
|
sb.append("\n");
|
||||||
|
p = Runtime.getRuntime().exec(new String[]{"python3","runocr.py","en",img.toAbsolutePath().toString()});
|
||||||
|
while (p.isAlive());
|
||||||
|
result = new InputStreamReader(p.getInputStream());
|
||||||
|
while (result.ready()) {
|
||||||
|
sb.append((char)result.read());
|
||||||
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
12
runocr.py
12
runocr.py
@ -1,13 +1,17 @@
|
|||||||
import easyocr
|
import easyocr
|
||||||
import sys
|
import sys
|
||||||
if len(sys.argv)==2:
|
if len(sys.argv)==3:
|
||||||
if sys.argv[1]=="ja":
|
if sys.argv[1]=="ja":
|
||||||
print("Loading JP data...")
|
#print("Loading JP data...")
|
||||||
|
#print("Reading image "+sys.argv[2])
|
||||||
reader = easyocr.Reader(['ja','en'])
|
reader = easyocr.Reader(['ja','en'])
|
||||||
|
print(reader.readtext(sys.argv[2]))
|
||||||
else:
|
else:
|
||||||
print("Loading EN data...")
|
#print("Loading EN data...")
|
||||||
|
#print("Reading image "+sys.argv[2])
|
||||||
reader2 = easyocr.Reader(['en'])
|
reader2 = easyocr.Reader(['en'])
|
||||||
|
print(reader2.readtext(sys.argv[2]))
|
||||||
else:
|
else:
|
||||||
print("Unspecified language. Format:")
|
print("Unspecified language. Format:")
|
||||||
print(" runocr.py <ja|en>")
|
print(" runocr.py <ja|en> filename")
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ public class sigPlace {
|
|||||||
"%FOOTER", Paths.get(REFDIR,"FOOTER.html"))
|
"%FOOTER", Paths.get(REFDIR,"FOOTER.html"))
|
||||||
));
|
));
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
ArcadeReader.retrieveData(null);
|
ArcadeReader.retrieveData(Paths.get("sdvx.jpg"));
|
||||||
/* Path secretFile = Paths.get(".clientsecret");
|
/* Path secretFile = Paths.get(".clientsecret");
|
||||||
List<String> data;
|
List<String> data;
|
||||||
try {
|
try {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user