DepthMapNeedle/src/DepthMapNeedle.java

55 lines
2.1 KiB
Java
Raw Normal View History

public class DepthMapNeedle
{
public static void main(String[] args)
{
if(args.length==0 || args[0].equals("-h")) help();
if(args.length >= 2 && args[0].equals("-e"))
{
for(int i=1; i<args.length; i++)
{
JPEG image = new JPEG(args[i]);
if(image.exportDepthMap()) System.out.println("Depthmap extracted for file " + args[i]+".");
else System.err.println("There is no Depthmap in file "+args[i]);
}
}
else if(args.length >=2 && args[0].equals("-s"))
{
for(int i=1; i<args.length; i++)
{
JPEG image = new JPEG(args[i]);
if(image.exportSourceImage()) System.out.println("Unblurred source image extracted for file "+args[i]+".");
else System.err.println("There is no unblurred source image in file "+args[i]+". Maybe this photo has not been taken with the blur function?");
}
}
else if(args.length >= 3 && args[0].equals("-i"))
{
String depthmap = args[1];
for(int i=2; i<args.length; i++)
{
JPEG image = new JPEG(args[i]);
if(image.injectDepthMap(depthmap)) System.out.println("Depthmap injected into file "+args[i]+".");
else System.err.println("Something went wrong while injecting "+depthmap+" into "+args[i]+".\nRemember: The first argument has to be a png and the following arguments must be jpgs shot with the blur function.");
image.save();
}
}
}
public static void help()
{
System.out.println("Welcome to DepthMapNeedle!"
+ "\nDepthMapNeedle is a tool to inject or extract depth information in form of depthmaps from photos shot using Google Cameras Blur function."
+ "\n"
+ "\nAvailable Options:"
+ "\n'-e <file1>.jpg ... <fileN>.jpg':"
+ "\n Extract the depthmap from the specified photo(s). The depthmaps will be stored with the suffix \"_d.png\"."
+ "\n'-s <file1>.jpg ... <fileN>.jpg':"
+ "\n Extract the unblurred source image from the photo(s). These files will be stored with the suffix \"_s.jpg\"."
+ "\n'-i <depthmap>.png <file1>.jpg <fileN>.jpg':"
+ "\n Inject a png file as Depthmap into the following specified jpg files."
+ "\n'-h':"
+ "\n Show this help text.");
}
}