Wrote some readme and added some feedback functionality. DepthMapNeedle now tells you, when exports are finished and so on.
This commit is contained in:
parent
77a2f0b6e7
commit
94993a907f
4 changed files with 35 additions and 12 deletions
Binary file not shown.
|
@ -1,2 +1,10 @@
|
|||
# DepthMapNeedle
|
||||
DepthMapNeedle is a java tool to inject or extract depth information in form of depthmaps from photos shot using Google Cameras Blur function.
|
||||
This is a command line tool. Simply extract depth information as a png file by typing 'java -jar DepthMapNeedle -e <Image>.jpg'. The depthmap will be stored in the same location as the image as '<Image>_d.png'.
|
||||
In the same way you can extract the unblurred source image by replacing the '-e' with '-s'.
|
||||
But the best part is, that you can modify the extracted depthmap in the image manipulation program of your choice and then replace the old depthmap in the image.
|
||||
This can be handy in case the original depthmap has some imperfections. Simply extract the depthmap, manipulate it and inject the fixed depthmap back into the image.
|
||||
Now all you have to do is rerender the image in the google camera.
|
||||
|
||||
Enjoy ;)
|
||||
Vanitas
|
||||
|
|
|
@ -10,7 +10,8 @@ public class DepthMapNeedle
|
|||
for(int i=1; i<args.length; i++)
|
||||
{
|
||||
JPEG image = new JPEG(args[i]);
|
||||
image.exportDepthMap();
|
||||
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"))
|
||||
|
@ -18,7 +19,8 @@ public class DepthMapNeedle
|
|||
for(int i=1; i<args.length; i++)
|
||||
{
|
||||
JPEG image = new JPEG(args[i]);
|
||||
image.exportSourceImage();
|
||||
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"))
|
||||
|
@ -27,7 +29,8 @@ public class DepthMapNeedle
|
|||
for(int i=2; i<args.length; i++)
|
||||
{
|
||||
JPEG image = new JPEG(args[i]);
|
||||
image.injectDepthMap(depthmap);
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -30,32 +30,42 @@ public class JPEG extends Const
|
|||
tail = this.getImageTail();
|
||||
}
|
||||
|
||||
public void exportDepthMap()
|
||||
public boolean exportDepthMap()
|
||||
{
|
||||
String out = filename;
|
||||
if(out.endsWith(".jpg") || out.endsWith(".JPG")) out = out.substring(0, out.length()-4);
|
||||
this.exportDepthMap(out+"_d.png");
|
||||
return this.exportDepthMap(out+"_d.png");
|
||||
}
|
||||
|
||||
public void exportDepthMap(String file)
|
||||
public boolean exportDepthMap(String file)
|
||||
{
|
||||
byte[] b64 = ArrayUtils.unsign(extractDepthMap());
|
||||
byte[] depth = Base64.getDecoder().decode(b64);
|
||||
IO.write(depth, file);
|
||||
if(depth != null)
|
||||
{
|
||||
IO.write(depth, file);
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
public void exportSourceImage()
|
||||
public boolean exportSourceImage()
|
||||
{
|
||||
String out = filename;
|
||||
if(out.endsWith(".jpg") || out.endsWith(".JPG")) out = out.substring(0, out.length()-4);
|
||||
this.exportSourceImage(out+"_s.jpg");
|
||||
return this.exportSourceImage(out+"_s.jpg");
|
||||
}
|
||||
|
||||
public void exportSourceImage(String file)
|
||||
public boolean exportSourceImage(String file)
|
||||
{
|
||||
byte[] b64 = ArrayUtils.unsign(extractSourceImage());
|
||||
byte[] src = Base64.getDecoder().decode(b64);
|
||||
IO.write(src, file);
|
||||
if(src != null)
|
||||
{
|
||||
IO.write(src, file);
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
public byte[] extractDepthMap()
|
||||
|
@ -139,10 +149,12 @@ public class JPEG extends Const
|
|||
this.disassemble();
|
||||
}
|
||||
|
||||
public void injectDepthMap(String filename)
|
||||
public boolean injectDepthMap(String filename)
|
||||
{
|
||||
byte[] depth = Base64.getEncoder().encode(IO.read(new File(filename)));
|
||||
xmpExt = JPEGUtils.replace(xmpExt, keyGDepthData, depth);
|
||||
if(xmpExt != null) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
public byte[] reassemble()
|
||||
|
|
Loading…
Reference in a new issue