added switch for counter or timestap sort, new imagefinder
This commit is contained in:
parent
6b4c3dbc5d
commit
0627b40f9b
|
@ -0,0 +1,28 @@
|
||||||
|
java -jar TLC_PostSW.jar -log -m createDB -r /home/hendrik/ftp/files/camera01/ -p /home/hendrik/TLC_PostSW/TLC01/ -n 83584
|
||||||
|
|
||||||
|
java -jar TLC_PostSW.jar -log -m createDB -r /home/hendrik/ftp/files/camera02/ -p /home/hendrik/TLC_PostSW/TLC02/ -n 83538
|
||||||
|
|
||||||
|
java -jar TLC_PostSW.jar -log -m createDB -r /home/hendrik/ftp/files/camera04/ -p /home/hendrik/TLC_PostSW/TLC04/ -n 11935
|
||||||
|
|
||||||
|
|
||||||
|
printf "TLC01: " && tail -n 1 ./TLC01/log01.txt && printf "TLC01: " && tail -n 1 ./TLC02/log02.txt && printf "TLC01: " && tail -n 1 ./TLC04/log04.txt
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
|
||||||
|
clear
|
||||||
|
|
||||||
|
printf "TLC01: " && tail -n 1 ./TLC01/log01.txt && printf "TLC01: " && tail -n 1 ./TLC02/log02.txt && printf "TLC01: " && tail -n 1 ./TLC04/log04.txt
|
||||||
|
|
||||||
|
printf "\n"
|
||||||
|
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
-log -m createDB -r /home/hendrik/Schreibtisch/Geiger_Timelaspe/Rohdaten/ -p /home/hendrik/Schreibtisch/Post_Sort/-i time -n 10
|
||||||
|
|
||||||
|
|
||||||
|
19711
|
|
@ -60,6 +60,9 @@ class DBController
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
System.out.println("Connect geklappt");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createTableImages()
|
public void createTableImages()
|
||||||
|
@ -73,6 +76,7 @@ class DBController
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
System.err.println("Couldn't handle DB-Query");
|
System.err.println("Couldn't handle DB-Query");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
System.exit(-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,28 +1,27 @@
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileFilter;
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.Arrays;
|
|
||||||
import org.apache.commons.io.filefilter.WildcardFileFilter;
|
|
||||||
|
|
||||||
|
public abstract class ImageFinder
|
||||||
public class ImageFinder
|
|
||||||
{
|
{
|
||||||
|
|
||||||
short maxYears = 5;
|
static short maxYears = 5;
|
||||||
|
|
||||||
int lengthRootFolder;
|
int lengthRootFolder;
|
||||||
String rootFolder;
|
|
||||||
|
|
||||||
int currentYear = 0;
|
static String rootFolder;
|
||||||
int currentMonth = 0;
|
|
||||||
|
|
||||||
String[] monthNames = { "01_January", "02_February", "03_March",
|
static int currentYear = 0;
|
||||||
"04_April", "05_May", "06_June", "07_July", "08_August",
|
|
||||||
"09_September", "10_October", "11_November", "12_December" };
|
|
||||||
|
|
||||||
Boolean[][] month = new Boolean[maxYears][12];
|
static int currentMonth = 0;
|
||||||
|
|
||||||
String[] years = new String[maxYears];
|
static String[] monthNames = { "01_January", "02_February", "03_March", "04_April",
|
||||||
|
"05_May", "06_June", "07_July", "08_August", "09_September",
|
||||||
|
"10_October", "11_November", "12_December" };
|
||||||
|
|
||||||
|
static Boolean[][] month = new Boolean[maxYears][12];
|
||||||
|
|
||||||
|
static String[] years = new String[maxYears];
|
||||||
|
|
||||||
public ImageFinder(String rootFolder)
|
public ImageFinder(String rootFolder)
|
||||||
{
|
{
|
||||||
|
@ -97,43 +96,7 @@ public class ImageFinder
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getImagePath(int imageCounter)
|
protected String convertImageCounter(int imageCounter)
|
||||||
{
|
|
||||||
String path = null;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (int i = currentYear; i < years.length; i++) {
|
|
||||||
if (years[i] != null) {
|
|
||||||
|
|
||||||
for (int j = currentMonth; j < month[i].length; j++) {
|
|
||||||
if(month[i][j]) {
|
|
||||||
//System.out.println("Patth: " + rootFolder + years[i] + "/" + monthNames[j] + "/" );
|
|
||||||
File dir = new File(rootFolder + years[i] + "/" + monthNames[j] + "/");
|
|
||||||
FileFilter fileFilter = new WildcardFileFilter(
|
|
||||||
"*" + convertImageCounter(imageCounter) + "*.jpg");
|
|
||||||
File[] files = dir.listFiles(fileFilter);
|
|
||||||
path = Arrays.toString(files);
|
|
||||||
path = path.replace("[", "");
|
|
||||||
path = path.replace("]", "");
|
|
||||||
if ((path == "null") || (files.length == 0)) {
|
|
||||||
//Nicht gefunden
|
|
||||||
//System.out.println("error404");
|
|
||||||
}else {
|
|
||||||
//Gefunden
|
|
||||||
currentMonth = j;
|
|
||||||
currentYear = i;
|
|
||||||
return path.substring(lengthRootFolder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
currentMonth = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return "404";
|
|
||||||
}
|
|
||||||
|
|
||||||
private String convertImageCounter(int imageCounter)
|
|
||||||
{
|
{
|
||||||
switch ((int) (Math.log10(imageCounter) + 1)) {
|
switch ((int) (Math.log10(imageCounter) + 1)) {
|
||||||
case 1:
|
case 1:
|
||||||
|
@ -153,4 +116,6 @@ public class ImageFinder
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract String getImagePath(int imageCounter);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileFilter;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import org.apache.commons.io.filefilter.WildcardFileFilter;
|
||||||
|
|
||||||
|
public class ImageFinderCounter extends ImageFinder
|
||||||
|
{
|
||||||
|
|
||||||
|
public ImageFinderCounter(String rootFolder)
|
||||||
|
{
|
||||||
|
super(rootFolder);
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getImagePath(int imageCounter)
|
||||||
|
{
|
||||||
|
String path = null;
|
||||||
|
|
||||||
|
for (int i = currentYear; i < years.length; i++) {
|
||||||
|
if (years[i] != null) {
|
||||||
|
|
||||||
|
for (int j = currentMonth; j < month[i].length; j++) {
|
||||||
|
if (month[i][j]) {
|
||||||
|
// System.out.println("Patth: " + rootFolder + years[i] + "/"
|
||||||
|
// + monthNames[j] + "/" );
|
||||||
|
File dir = new File(
|
||||||
|
rootFolder + years[i] + "/" + monthNames[j] + "/");
|
||||||
|
FileFilter fileFilter = new WildcardFileFilter(
|
||||||
|
"*" + convertImageCounter(imageCounter) + "*.jpg");
|
||||||
|
File[] files = dir.listFiles(fileFilter);
|
||||||
|
path = Arrays.toString(files);
|
||||||
|
path = path.replace("[", "");
|
||||||
|
path = path.replace("]", "");
|
||||||
|
if ((path == "null") || (files.length == 0)) {
|
||||||
|
// Nicht gefunden
|
||||||
|
// System.out.println("error404");
|
||||||
|
} else {
|
||||||
|
// Gefunden
|
||||||
|
currentMonth = j;
|
||||||
|
currentYear = i;
|
||||||
|
return path.substring(lengthRootFolder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
currentMonth = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "404";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,97 @@
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileFilter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.attribute.BasicFileAttributes;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
|
|
||||||
|
import org.apache.commons.io.filefilter.WildcardFileFilter;
|
||||||
|
|
||||||
|
public class ImageFinderTimestamp extends ImageFinder
|
||||||
|
{
|
||||||
|
|
||||||
|
public ImageFinderTimestamp(String rootFolder)
|
||||||
|
{
|
||||||
|
super(rootFolder);
|
||||||
|
// TODO Auto-generated constructor stub
|
||||||
|
}
|
||||||
|
|
||||||
|
static int sortedimagecounter = 0;
|
||||||
|
|
||||||
|
static int fileslenght = 0;
|
||||||
|
|
||||||
|
static File[] files = null;
|
||||||
|
|
||||||
|
private static void sortImages()
|
||||||
|
{
|
||||||
|
|
||||||
|
// System.out.println("Path: " + rootFolder + years[i] + "/"
|
||||||
|
// + monthNames[j] + "/" );
|
||||||
|
/*
|
||||||
|
* File dir = new File( rootFolder + years[i] + "/" + monthNames[j] +
|
||||||
|
* "/");
|
||||||
|
*/
|
||||||
|
File dir = new File(rootFolder + "/");
|
||||||
|
|
||||||
|
files = dir.listFiles();
|
||||||
|
|
||||||
|
fileslenght = files.length;
|
||||||
|
|
||||||
|
System.out.println("File lenght: " + fileslenght);
|
||||||
|
|
||||||
|
System.exit(0);
|
||||||
|
|
||||||
|
sortFilesByDateCreated(files);
|
||||||
|
|
||||||
|
sortedimagecounter = 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* for (int k = 0; k < files.length; k++) {
|
||||||
|
* System.out.println(files[k].getName()); }
|
||||||
|
*/
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getImagePath(int imageCounter)
|
||||||
|
{
|
||||||
|
String path = null;
|
||||||
|
|
||||||
|
if (sortedimagecounter != (fileslenght - 1)) {
|
||||||
|
System.out.println("sort new Images");
|
||||||
|
sortImages();
|
||||||
|
path = files[sortedimagecounter].getAbsolutePath();
|
||||||
|
sortedimagecounter++;
|
||||||
|
return path;
|
||||||
|
} else {
|
||||||
|
path = files[sortedimagecounter].getAbsolutePath();
|
||||||
|
sortedimagecounter++;
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void sortFilesByDateCreated(File[] files)
|
||||||
|
{
|
||||||
|
Arrays.sort(files, new Comparator<File>() {
|
||||||
|
public int compare(File f1, File f2)
|
||||||
|
{
|
||||||
|
long l1 = getFileCreationEpoch(f1);
|
||||||
|
long l2 = getFileCreationEpoch(f2);
|
||||||
|
return Long.valueOf(l1).compareTo(l2);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public static long getFileCreationEpoch(File file)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
BasicFileAttributes attr = Files.readAttributes(file.toPath(),
|
||||||
|
BasicFileAttributes.class);
|
||||||
|
return attr.creationTime().toInstant().toEpochMilli();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(file.getAbsolutePath(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -27,13 +27,15 @@ public class Main
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
ImageFinder imgF = null;
|
||||||
|
|
||||||
for (int i = 0; i < args.length; i++) {
|
for (int i = 0; i < args.length; i++) {
|
||||||
//System.out.println(i + ": " +args[i]);
|
//System.out.println(i + ": " +args[i]);
|
||||||
|
|
||||||
String value = args[i];
|
String value = args[i];
|
||||||
|
|
||||||
if (value.equals("-log")) {
|
if (value.equals("-log")) {
|
||||||
System.out.println("Logging will be used");
|
System.out.println("Logging will be used!");
|
||||||
log = true;
|
log = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,6 +44,7 @@ public class Main
|
||||||
if (args[i].equals("createDB")) {
|
if (args[i].equals("createDB")) {
|
||||||
modi = true;
|
modi = true;
|
||||||
System.out.println("[Modi] Index images and create DB");
|
System.out.println("[Modi] Index images and create DB");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
modi = false;
|
modi = false;
|
||||||
System.out.println("[Modi] Copy or Link images");
|
System.out.println("[Modi] Copy or Link images");
|
||||||
|
@ -66,12 +69,28 @@ public class Main
|
||||||
System.out.println("[outputPath] " + outputPath);
|
System.out.println("[outputPath] " + outputPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (value.equals("-i")) {
|
||||||
|
i++;
|
||||||
|
|
||||||
|
if (args[i].equals("counter")) {
|
||||||
|
System.out.println("[Identify] Find images with counter");
|
||||||
|
imgF = new ImageFinderCounter(rootFolderPath);
|
||||||
|
} else {
|
||||||
|
System.out.println("[Identify] Find images with date and time");
|
||||||
|
imgF = new ImageFinderTimestamp(rootFolderPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
if (value.equals("-n")) {
|
if (value.equals("-n")) {
|
||||||
i++;
|
i++;
|
||||||
maxImgageCounter = Integer.parseInt(args[i]);
|
maxImgageCounter = Integer.parseInt(args[i]);
|
||||||
System.out.println("[maxImgageCounter] " + maxImgageCounter);
|
System.out.println("[maxImgageCounter] " + maxImgageCounter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (value.equals("-help")) {
|
if (value.equals("-help")) {
|
||||||
System.out.println(
|
System.out.println(
|
||||||
"-log -m createDB -r /home/hendrik/FTP/camera01/ -p /home/hendrik/Schreibtisch/ -o /home/hendrik/Schreibtisch/testeritis/ -n 83584");
|
"-log -m createDB -r /home/hendrik/FTP/camera01/ -p /home/hendrik/Schreibtisch/ -o /home/hendrik/Schreibtisch/testeritis/ -n 83584");
|
||||||
|
@ -81,11 +100,12 @@ public class Main
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//System.exit(1);
|
|
||||||
|
|
||||||
|
|
||||||
if (modi) {
|
if (modi) {
|
||||||
long timeStart;
|
long timeStart;
|
||||||
ImageFinder imgF = new ImageFinder(rootFolderPath);
|
|
||||||
DBController db = new DBController(projectPath);
|
DBController db = new DBController(projectPath);
|
||||||
Exif exif = new Exif();
|
Exif exif = new Exif();
|
||||||
|
|
||||||
|
@ -102,10 +122,11 @@ public class Main
|
||||||
imgF.printFoundDirectories();
|
imgF.printFoundDirectories();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
timeStart = System.currentTimeMillis();
|
timeStart = System.currentTimeMillis();
|
||||||
System.out.println("Suche ...");
|
System.out.println("Suche ...");
|
||||||
|
|
||||||
|
//System.exit(1);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PrintWriter missingTxt = new PrintWriter(
|
PrintWriter missingTxt = new PrintWriter(
|
||||||
projectPath + "missingImages.txt");
|
projectPath + "missingImages.txt");
|
||||||
|
@ -120,7 +141,7 @@ public class Main
|
||||||
System.out.println("%");
|
System.out.println("%");
|
||||||
}
|
}
|
||||||
String path = imgF.getImagePath(i);
|
String path = imgF.getImagePath(i);
|
||||||
// System.out.println(i + " Path: " + path);
|
System.out.println(i + " Path: " + path);
|
||||||
if (path != "404") {
|
if (path != "404") {
|
||||||
// gefunden
|
// gefunden
|
||||||
File f = new File(rootFolderPath + path);
|
File f = new File(rootFolderPath + path);
|
||||||
|
@ -148,6 +169,7 @@ public class Main
|
||||||
* 0.001);
|
* 0.001);
|
||||||
System.out.println("Process time: " + processingTime + " seconds.");
|
System.out.println("Process time: " + processingTime + " seconds.");
|
||||||
} else {
|
} else {
|
||||||
|
System.out.println("Troll");
|
||||||
///////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////
|
||||||
DBController db = new DBController(projectPath);
|
DBController db = new DBController(projectPath);
|
||||||
db.connectDatabase();
|
db.connectDatabase();
|
||||||
|
|
Loading…
Reference in New Issue