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.InputStreamReader;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.awt.image.BufferedImage;
|
||||
@ -56,8 +57,8 @@ public class ArcadeReader {
|
||||
* - Not going to support right now.
|
||||
*
|
||||
*/
|
||||
public static void retrieveData(BufferedImage img) {
|
||||
new LoveLiveReader().interpretBoxes();
|
||||
public static void retrieveData(Path img) {
|
||||
new LoveLiveReader().interpretBoxes(img);
|
||||
}
|
||||
}
|
||||
class Box{
|
||||
@ -80,8 +81,8 @@ class LoveLiveReader extends Reader{
|
||||
readRegions.add(new Box(10,40,24,24));
|
||||
readRegions.add(new Box(10,70,24,24));
|
||||
}
|
||||
void interpretBoxes(){
|
||||
String dataString = readAllBoxes();
|
||||
void interpretBoxes(Path img){
|
||||
String dataString = readAllBoxes(img);
|
||||
System.out.println(dataString);
|
||||
}
|
||||
}
|
||||
@ -95,9 +96,9 @@ abstract class Reader{
|
||||
int maxcombo;
|
||||
String other;
|
||||
List<Box> readRegions = new ArrayList<>();
|
||||
String readAllBoxes() {
|
||||
String readAllBoxes(Path img) {
|
||||
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());
|
||||
InputStreamReader result = new InputStreamReader(p.getInputStream());
|
||||
StringBuilder sb = new StringBuilder();
|
||||
@ -105,6 +106,13 @@ abstract class Reader{
|
||||
sb.append((char)result.read());
|
||||
}
|
||||
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();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
12
runocr.py
12
runocr.py
@ -1,13 +1,17 @@
|
||||
import easyocr
|
||||
import sys
|
||||
if len(sys.argv)==2:
|
||||
if len(sys.argv)==3:
|
||||
if sys.argv[1]=="ja":
|
||||
print("Loading JP data...")
|
||||
#print("Loading JP data...")
|
||||
#print("Reading image "+sys.argv[2])
|
||||
reader = easyocr.Reader(['ja','en'])
|
||||
print(reader.readtext(sys.argv[2]))
|
||||
else:
|
||||
print("Loading EN data...")
|
||||
#print("Loading EN data...")
|
||||
#print("Reading image "+sys.argv[2])
|
||||
reader2 = easyocr.Reader(['en'])
|
||||
print(reader2.readtext(sys.argv[2]))
|
||||
else:
|
||||
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"))
|
||||
));
|
||||
public static void main(String[] args) {
|
||||
ArcadeReader.retrieveData(null);
|
||||
ArcadeReader.retrieveData(Paths.get("sdvx.jpg"));
|
||||
/* Path secretFile = Paths.get(".clientsecret");
|
||||
List<String> data;
|
||||
try {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user