Skip to content

Commit

Permalink
- increased size of border in square fiducials to improve performance…
Browse files Browse the repository at this point in the history
… at small acute angles
  • Loading branch information
lessthanoptimal committed Sep 8, 2014
1 parent 4e19011 commit 4bc62e3
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
*/
public class CreateFiducialSquareBinaryEPS {

public static String fileName = "pattern.eps";
public static int number = 284;
public static double width = 10;

Expand Down Expand Up @@ -62,6 +61,7 @@ public static void main(String[] args) throws FileNotFoundException {
number &= 0x0FFF;

System.out.println("Target width "+width+" (cm) number = "+number);
String fileName = String.format("square%04d.eps",number);

// print out the selected number in binary for debugging purposes
for (int i = 0; i < 12; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,9 @@ public static void main(String[] args) {

String directory = "../data/applet/fiducial/image/";

String imageName = "view01.jpg";
// String imageName = "view02.jpg";
String imageName = "image0000.jpg";
// String imageName = "image0001.jpg";
// String imageName = "image0002.jpg";

// load the lens distortion parameters and the input image
IntrinsicParameters param = UtilIO.loadXML(directory + "intrinsic.xml");
Expand All @@ -62,8 +63,8 @@ public static void main(String[] args) {
ImageFloat32 dog = UtilImageIO.loadImage(directory + "dog.png",ImageFloat32.class);
detector.addTarget(dog, 125);
// uncomment to detect the text target
// ImageFloat32 text = UtilImageIO.loadImage(directory + "text.png",ImageFloat32.class);
// detector.addTarget(text, 125);
ImageFloat32 text = UtilImageIO.loadImage(directory + "text.png",ImageFloat32.class);
detector.addTarget(text, 125);

detector.setIntrinsic(param);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ public static void main(String[] args) {

// load the lens distortion parameters and the input image
IntrinsicParameters param = UtilIO.loadXML(directory + "intrinsic.xml");
BufferedImage input = UtilImageIO.loadImage(directory + "angled00_643_284.jpg");
BufferedImage input = UtilImageIO.loadImage(directory + "image0000.jpg");
// BufferedImage input = UtilImageIO.loadImage(directory + "image0001.jpg");
// BufferedImage input = UtilImageIO.loadImage(directory + "image0002.jpg");
ImageFloat32 original = ConvertBufferedImage.convertFrom(input,true, ImageType.single(ImageFloat32.class));

// Detect the fiducial
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class ExampleCollectImages {
public static void main(String[] args) {

// Open a webcam at a resolution close to 640x480
Webcam webcam = Webcam.getWebcams().get(1);
Webcam webcam = Webcam.getWebcams().get(0);
UtilWebcamCapture.adjustResolution(webcam,640,480);
webcam.open();

Expand Down
1 change: 1 addition & 0 deletions main/recognition/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dependencies {
compile project(':main:sfm')

testCompile project(':main:io')
testCompile project(':main:visualize')
}

idea {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class DetectFiducialSquareBinary<T extends ImageSingleBand>
public DetectFiducialSquareBinary(InputToBinary<T> thresholder,
SplitMergeLineFitLoop fitPolygon,
double minContourFraction, Class<T> inputType) {
super(thresholder,fitPolygon, w*6, minContourFraction, inputType);
super(thresholder,fitPolygon, w*8, minContourFraction, inputType);

int widthNoBorder = w*4;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public class DetectFiducialSquareImage<T extends ImageSingleBand>
public DetectFiducialSquareImage(InputToBinary<T> thresholder,
SplitMergeLineFitLoop fitPolygon,
double minContourFraction, double matchThreshold, Class<T> inputType) {
super(thresholder,fitPolygon, squareLength+2*w, minContourFraction, inputType);
super(thresholder,fitPolygon, squareLength+squareLength, minContourFraction, inputType);

hammingThreshold = (int)(squareLength*squareLength*matchThreshold);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,9 @@ public void processSquare_negative() {

public static ImageFloat32 create( int square , int value ) {

ImageFloat32 ret = new ImageFloat32(square*6,square*6);
ImageFloat32 ret = new ImageFloat32(square*8,square*8);

int s2 = 2*square;

for (int i = 0; i < 12; i++) {
if( (value& (1<<i)) != 0 )
Expand All @@ -83,15 +85,14 @@ public static ImageFloat32 create( int square , int value ) {
int x = where%4;
int y = 3-(where/4);

x = square + square*x;
y = square + square*y;

x = s2 + square*x;
y = s2 + square*y;

ImageMiscOps.fillRectangle(ret,0xFF,x,y,square,square);
}
ImageMiscOps.fillRectangle(ret,0xFF,square,square,square,square);
ImageMiscOps.fillRectangle(ret,0xFF,square*4,square*4,square,square);
ImageMiscOps.fillRectangle(ret,0xFF,square*4,square,square,square);
ImageMiscOps.fillRectangle(ret,0xFF,s2,s2,square,square);
ImageMiscOps.fillRectangle(ret,0xFF,square*5,square*5,square,square);
ImageMiscOps.fillRectangle(ret,0xFF,square*5,s2,square,square);

return ret;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,16 @@ public void processSquare() {
PixelMath.multiply(pattern,255,pattern);

// add a border around it
ImageUInt8 border = new ImageUInt8(16*6,16*6);
border.subimage(16,16,16*5,16*5,null).setTo(pattern);
ImageUInt8 border = new ImageUInt8(16*8,16*8);
border.subimage(16*2,16*2,16*6,16*6,null).setTo(pattern);
ImageFloat32 input = new ImageFloat32(border.width,border.height);
ConvertImage.convert(border,input);

// BufferedImage foo = ConvertBufferedImage.convertTo(input,null);
// ShowImages.showWindow(foo,"target");
//
// BoofMiscOps.pause(10000);

// process it in different orientations
DetectFiducialSquareImage<ImageUInt8> alg =
new DetectFiducialSquareImage<ImageUInt8>(null,null,0.2,0.1,ImageUInt8.class);
Expand All @@ -72,7 +77,7 @@ public void processSquare() {
// give it a random input that shouldn't match
ImageMiscOps.fillUniform(pattern, rand, 0, 2);
PixelMath.multiply(pattern, 255, pattern);
border.subimage(16,16,16*5,16*5,null).setTo(pattern);
border.subimage(16*2,16*2,16*6,16*6,null).setTo(pattern);
ConvertImage.convert(border,input);
assertFalse(alg.processSquare(input, result));
}
Expand Down

0 comments on commit 4bc62e3

Please sign in to comment.