use of boofcv.struct.calib.CameraPinholeBrown in project BoofCV by lessthanoptimal.
the class TestVisOdomBundleAdjustment method createAlgSingleCamera.
private VisOdomBundleAdjustment<BTrack> createAlgSingleCamera() {
var alg = new VisOdomBundleAdjustment<>(BTrack::new);
alg.addCamera(new CameraPinholeBrown(0, 0, 0, 0, 0, 100, 200));
return alg;
}
use of boofcv.struct.calib.CameraPinholeBrown in project BoofCV by lessthanoptimal.
the class TestMonocularPlaneVisualOdometryScaleInput method process.
@Test
void process() {
image = null;
CameraPinholeBrown intrinsic = createIntrinsic();
Dummy dummy = new Dummy();
MonocularPlaneVisualOdometry<GrayF32> alg = new MonocularPlaneVisualOdometryScaleInput<>(dummy, 0.5);
alg.setCalibration(new MonoPlaneParameters(intrinsic, new Se3_F64()));
GrayF32 inputImage = new GrayF32(width, height);
alg.process(inputImage);
assertTrue(inputImage != image);
assertEquals(320, image.width);
assertEquals(160, image.height);
}
use of boofcv.struct.calib.CameraPinholeBrown in project BoofCV by lessthanoptimal.
the class SceneMergingOperations method getCommonFeaturePixelsViews.
/**
* Retrieves the pixel coordinates for all the other views in InlierInfo, excludes the first/target.
*
* @param db Used to look up image feature pixel coordinates
* @param inliers List of image features that were part of the inlier set in all the views
* @return List of observations in each view (expet the target) that are part of the inler and common set
*/
@SuppressWarnings("IntegerDivisionInFloatingPointContext")
List<DogArray<Point2D_F64>> getCommonFeaturePixelsViews(LookUpSimilarImages db, SceneWorkingGraph workingGraph, SceneWorkingGraph.InlierInfo inliers) {
List<DogArray<Point2D_F64>> listViewPixels = new ArrayList<>();
// Which features are inliers in view[0] / common view
DogArray_I32 viewZeroInlierIdx = inliers.observations.get(0);
// View 0 = common view and is skipped here
int numViews = inliers.observations.size;
for (int viewIdx = 1; viewIdx < numViews; viewIdx++) {
// Retrieve the feature pixel coordinates for this view
db.lookupPixelFeats(inliers.views.get(viewIdx).id, dbPixels);
// Which features are part of the inlier set
DogArray_I32 inlierIdx = inliers.observations.get(viewIdx);
BoofMiscOps.checkEq(viewZeroInlierIdx.size, inlierIdx.size, "Inliers count should be the same");
// Create storage for all the pixels in each view
DogArray<Point2D_F64> viewPixels = new DogArray<>(Point2D_F64::new);
listViewPixels.add(viewPixels);
viewPixels.resize(zeroViewPixels.size);
// camera model assumes pixels have been recentered
SceneWorkingGraph.View wview = Objects.requireNonNull(workingGraph.views.get(inliers.views.get(viewIdx).id));
SceneWorkingGraph.Camera camera = workingGraph.getViewCamera(wview);
CameraPinholeBrown cameraPrior = camera.prior;
// Add the inlier pixels from this view to the array in the correct order
for (int idx = 0; idx < inlierIdx.size; idx++) {
// feature ID in view[0]
int viewZeroIdx = viewZeroInlierIdx.get(idx);
// feature ID in the common list
int commonFeatureIdx = zeroFeatureToCommonIndex.get(viewZeroIdx);
if (commonFeatureIdx < 0)
continue;
// Copy the pixel from this view into the appropriate location
Point2D_F64 p = viewPixels.get(commonFeatureIdx);
p.setTo(dbPixels.get(inlierIdx.get(idx)));
p.x -= cameraPrior.cx;
p.y -= cameraPrior.cy;
}
}
return listViewPixels;
}
use of boofcv.struct.calib.CameraPinholeBrown in project BoofCV by lessthanoptimal.
the class TestLookUpCameraInfo method addCameraCanonical.
@Test
void addCameraCanonical() {
var alg = new LookUpCameraInfo();
alg.addCameraCanonical(1000, 200, 45);
CameraPinholeBrown found = alg.listCalibration.get(0);
assertEquals(1000, found.width);
assertEquals(200, found.height);
assertEquals(500, found.cx);
assertEquals(100, found.cy);
double f = 500 / Math.tan(UtilAngle.degreeToRadian(45) / 2.0);
assertEquals(1.0, f / found.fx, 1e-7);
assertEquals(1.0, f / found.fy, 1e-7);
}
use of boofcv.struct.calib.CameraPinholeBrown in project BoofCV by lessthanoptimal.
the class GenericDetectSingleFiducialCalibrationChecks method renderEasy.
protected GrayF32 renderEasy(ConfigGridDimen layout, List<Point2D_F64> locations2D) {
CameraPinholeBrown model = CalibrationIO.load(getClass().getResource("pinhole_radial.yaml"));
if (locations2D == null)
locations2D = new ArrayList<>();
GrayF32 pattern = new GrayF32(1, 1);
renderTarget(layout, simulatedTargetWidth, pattern, locations2D);
SimulatePlanarWorld simulator = new SimulatePlanarWorld();
simulator.setCamera(model);
Se3_F64 markerToWorld = SpecialEuclideanOps_F64.eulerXyz(0, 0, 0.5, 0, Math.PI, 0, null);
simulator.addSurface(markerToWorld, simulatedTargetWidth, pattern);
simulator.render();
return simulator.getOutput();
}
Aggregations