use of georegression.struct.se.Se3_F64 in project BoofCV by lessthanoptimal.
the class GenericFiducialDetectorChecks method checkImageLocation.
@Test
public void checkImageLocation() {
for (ImageType type : types) {
ImageBase image = loadImage(type);
FiducialDetector detector = createDetector(type);
// It's not specified if the center should be undistorted or distorted. Just make it easier by
// using undistorted
LensDistortionNarrowFOV distortion = loadDistortion(false);
detector.setLensDistortion(distortion, image.width, image.height);
detector.detect(image);
assertTrue(detector.totalFound() >= 1);
assertTrue(detector.is3D());
for (int i = 0; i < detector.totalFound(); i++) {
Se3_F64 fidToCam = new Se3_F64();
Point2D_F64 found = new Point2D_F64();
detector.getFiducialToCamera(i, fidToCam);
detector.getCenter(i, found);
Point2D_F64 rendered = new Point2D_F64();
WorldToCameraToPixel worldToPixel = PerspectiveOps.createWorldToPixel(distortion, fidToCam);
worldToPixel.transform(new Point3D_F64(0, 0, 0), rendered);
// see if the reprojected is near the pixel location
assertTrue(rendered.distance(found) <= pixelAndProjectedTol);
}
}
}
use of georegression.struct.se.Se3_F64 in project BoofCV by lessthanoptimal.
the class GenericFiducialDetectorChecks method checkMultipleRuns.
@Test
public void checkMultipleRuns() {
for (ImageType type : types) {
ImageBase image = loadImage(type);
FiducialDetector detector = createDetector(type);
detector.setLensDistortion(loadDistortion(true), image.width, image.height);
detector.detect(image);
assertTrue(detector.totalFound() >= 1);
Results results = extractResults(detector);
// run it again
detector.detect(image);
// see if it produced exactly the same results
assertEquals(results.id.length, detector.totalFound());
for (int i = 0; i < detector.totalFound(); i++) {
assertEquals(results.id[i], detector.getId(i));
Se3_F64 pose = new Se3_F64();
detector.getFiducialToCamera(i, pose);
assertEquals(0, pose.getT().distance(results.pose.get(i).T), 1e-8);
assertTrue(MatrixFeatures_DDRM.isIdentical(pose.getR(), results.pose.get(i).R, 1e-8));
}
}
}
use of georegression.struct.se.Se3_F64 in project BoofCV by lessthanoptimal.
the class GenericFiducialDetectorChecks method checkHandleNewIntrinsic.
/**
* Tests several items:
*
* 1) Does it properly handle setIntrinsic() being called multiple times
* 2) Can it handle no distortion
*/
@Test
public void checkHandleNewIntrinsic() {
for (ImageType type : types) {
ImageBase image = loadImage(type);
FiducialDetector detector = createDetector(type);
detector.setLensDistortion(loadDistortion(true), image.width, image.height);
detector.detect(image);
assertTrue(detector.totalFound() >= 1);
checkBounds(detector);
Results results = extractResults(detector);
// run it again with a changed intrinsic that's incorrect
detector.setLensDistortion(loadDistortion(false), image.width, image.height);
detector.detect(image);
checkBounds(detector);
// results should have changed
if (results.id.length == detector.totalFound()) {
assertEquals(results.id.length, detector.totalFound());
for (int i = 0; i < detector.totalFound(); i++) {
assertEquals(results.id[i], detector.getId(i));
Se3_F64 pose = new Se3_F64();
Point2D_F64 pixel = new Point2D_F64();
detector.getFiducialToCamera(i, pose);
detector.getCenter(i, pixel);
assertTrue(pose.getT().distance(results.pose.get(i).T) > 1e-4);
assertFalse(MatrixFeatures_DDRM.isIdentical(pose.getR(), results.pose.get(i).R, 1e-4));
// pixel location is based on the observed location, thus changing the intrinsics should not
// affect it
assertTrue(results.pixel.get(i).distance(pixel) <= 2.0);
}
} else {
// clearly changed
}
// then reproduce original
detector.setLensDistortion(loadDistortion(true), image.width, image.height);
detector.detect(image);
// see if it produced exactly the same results
assertEquals(results.id.length, detector.totalFound());
for (int i = 0; i < detector.totalFound(); i++) {
assertEquals(results.id[i], detector.getId(i));
Se3_F64 pose = new Se3_F64();
detector.getFiducialToCamera(i, pose);
assertEquals(0, pose.getT().distance(results.pose.get(i).T), 1e-8);
assertTrue(MatrixFeatures_DDRM.isIdentical(pose.getR(), results.pose.get(i).R, 1e-8));
}
}
}
use of georegression.struct.se.Se3_F64 in project BoofCV by lessthanoptimal.
the class GenericFiducialDetectorChecks method checkSubImage.
@Test
public void checkSubImage() {
for (ImageType type : types) {
ImageBase image = loadImage(type);
FiducialDetector detector = createDetector(type);
detector.setLensDistortion(loadDistortion(true), image.width, image.height);
detector.detect(image);
assertTrue(detector.totalFound() >= 1);
long[] foundID = new long[detector.totalFound()];
List<Se3_F64> foundPose = new ArrayList<>();
for (int i = 0; i < detector.totalFound(); i++) {
foundID[i] = detector.getId(i);
Se3_F64 pose = new Se3_F64();
detector.getFiducialToCamera(i, pose);
foundPose.add(pose);
}
// run it again with a sub-image
detector.detect(BoofTesting.createSubImageOf(image));
// see if it produced exactly the same results
assertEquals(foundID.length, detector.totalFound());
for (int i = 0; i < detector.totalFound(); i++) {
assertEquals(foundID[i], detector.getId(i));
Se3_F64 pose = new Se3_F64();
detector.getFiducialToCamera(i, pose);
assertEquals(0, pose.getT().distance(foundPose.get(i).T), 1e-8);
assertTrue(MatrixFeatures_DDRM.isIdentical(pose.getR(), foundPose.get(i).R, 1e-8));
}
}
}
use of georegression.struct.se.Se3_F64 in project BoofCV by lessthanoptimal.
the class GenericQrCodeDetectorChecks method rotation.
/**
* See if a clear well defined qr code can be detected while rating
*/
@Test
public void rotation() {
QrCodeDetector<GrayF32> detector = createDetector();
CameraPinholeRadial model = CalibrationIO.load(getClass().getResource("calib/pinhole_radial.yaml"));
SimulatePlanarWorld simulator = new SimulatePlanarWorld();
simulator.setCamera(model);
simulator.resetScene();
Se3_F64 markerToWorld = new Se3_F64();
simulator.addTarget(markerToWorld, simulatedTargetWidth, generateMarker());
markerToWorld.T.set(0, 0, 0.5);
for (int i = 0; i < 30; i++) {
double roll = 2 * Math.PI * i / 30.0;
ConvertRotation3D_F64.eulerToMatrix(EulerType.XYZ, 0, 0, roll, markerToWorld.R);
renderAndCheck(detector, simulator);
}
}
Aggregations