Skip to content

Commit

Permalink
Merge branch 'master' of github.com:lessthanoptimal/BoofCV
Browse files Browse the repository at this point in the history
  • Loading branch information
lessthanoptimal committed May 23, 2015
2 parents 5de5306 + c3d5c58 commit 407a090
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
2 changes: 1 addition & 1 deletion applications/build.gradle
Expand Up @@ -30,7 +30,7 @@ task fiducialBinary(dependsOn: classes ) << {
}
}

// gradle fiducialBinary -Pwidth=10.0 -Pnumber="../data/applet/fiducial/image/dog.png"
// gradle fiducialBinary -Pwidth=10.0 -Pimage="../data/applet/fiducial/image/dog.png"
task fiducialImage(dependsOn: classes ) << {

if (project.hasProperty('width') && project.hasProperty('image')) {
Expand Down
22 changes: 17 additions & 5 deletions applications/src/boofcv/app/CreateFiducialSquareImageEPS.java
Expand Up @@ -37,9 +37,12 @@ public class CreateFiducialSquareImageEPS {

public static String outputName = "fiducial_image.eps";
public static String inputPath = UtilIO.getPathToBase()+"data/applet/fiducial/image/dog.png";
public static double width = 10; // in centimeters
public static double width = 10; // in centimeters of fiducial

public static int threshold = 255/2; // threshold for converting to a binary image
public static double CM_TO_POINTS = 72.0/2.54;
// should it add the file name and size to the document?
public static boolean displayInfo = true;

public static String binaryToHex( ImageUInt8 binary ) {

Expand Down Expand Up @@ -76,9 +79,15 @@ public static void main(String[] args) throws FileNotFoundException {
String inputName = new File(inputPath).getName();

System.out.println("Target width "+width+" (cm) image = "+inputName);
System.out.println(" input path = "+inputPath);

ImageUInt8 image = UtilImageIO.loadImage(inputPath,ImageUInt8.class);

if( image == null ) {
System.err.println("Can't find image. Path = "+inputPath);
System.exit(0);
}

// make sure the image is square and divisible by 8
int s = image.width - (image.width%8);
if( image.width != s || image.height != s ) {
Expand All @@ -91,13 +100,13 @@ public static void main(String[] args) throws FileNotFoundException {
PrintStream out = new PrintStream(outputName);

double targetLength = width*CM_TO_POINTS;
double whiteBorder = targetLength/4.0;
double whiteBorder = Math.max(2*CM_TO_POINTS,targetLength/4.0);
double blackBorder = targetLength/4.0;
double innerWidth = targetLength/2.0;
double pageLength = targetLength+whiteBorder*2;
double scale = image.width/innerWidth;

ImageUInt8 binary = ThresholdImageOps.threshold(image,null,3*256/4,false);
ImageUInt8 binary = ThresholdImageOps.threshold(image,null,threshold,false);
// ShowImages.showWindow(VisualizeBinaryData.renderBinary(binary, false, null), "Binary Image");

out.println("%!PS-Adobe-3.0 EPSF-3.0\n" +
Expand All @@ -122,8 +131,10 @@ public static void main(String[] args) throws FileNotFoundException {
" newpath b2 b0 moveto b2 b3 lineto b3 b3 lineto b3 b0 lineto closepath fill\n");

// print out encoding information for convenience
out.print(" /Times-Roman findfont\n" +
"7 scalefont setfont b1 " + (pageLength - 10) + " moveto (" + inputName + " " + width + " cm) show\n");
if( displayInfo ) {
out.print(" /Times-Roman findfont\n" +
"7 scalefont setfont b1 " + (pageLength - 10) + " moveto (" + inputName + " " + width + " cm) show\n");
}

out.println("% Drawing the image");
out.println("b1 b1 translate");
Expand All @@ -132,5 +143,6 @@ public static void main(String[] args) throws FileNotFoundException {
out.print(" showpage\n" +
"%%EOF\n");

System.out.println("Saved to "+new File(outputName).getAbsolutePath());
}
}

0 comments on commit 407a090

Please sign in to comment.