Camera and multi-view geometry foundations for MoonBit: small fixed-size math, projection, distortion, homography, epipolar constraints, and RANSAC.
moon add python123-ops/moon-cv-geometry///|
test "project a 3D camera point" {
let k = @camera.CameraIntrinsics::new(fx=500.0, fy=500.0, cx=320.0, cy=240.0)
let p = @core.Point3::new(x=1.0, y=2.0, z=4.0)
let pixel = @camera.project_point(p, k)
assert_true(@core.almost_equal(pixel.x, 445.0))
assert_true(@core.almost_equal(pixel.y, 490.0))
}moon run examples/project_point
moon run examples/undistort
moon run examples/homography
moon run examples/fundamental_ransacmoon fmt --check
moon check --target all --deny-warn
moon test --target all --deny-warn
moon info
moon packagefn adaptive_iteration_bound(inlier_ratio~ : Double, sample_size~ : Int, confidence? : Double) -> Int raise GeometryErrorfn calibration_report(observations : ArrayView[CalibrationObservation], intrinsics : CameraIntrinsics, pose : CameraPose, distortion? : Distortion) -> CalibrationReport raise GeometryErrorfn depth_from_disparity(focal~ : Double, baseline~ : Double, disparity~ : Double) -> Double raise GeometryErrorfn disparity_from_depth(focal~ : Double, baseline~ : Double, depth~ : Double) -> Double raise GeometryErrorfn estimate_essential_from_fundamental(f : FundamentalMatrix, k_left : Mat3, k_right : Mat3) -> EssentialMatrixfn estimate_fundamental(left : ArrayView[Point2], right : ArrayView[Point2]) -> FundamentalMatrix raise GeometryErrorfn estimate_fundamental_ransac(left : ArrayView[Point2], right : ArrayView[Point2], config? : RansacConfig) -> RansacResult[FundamentalMatrix] raise GeometryErrorfn estimate_homography(src : ArrayView[Point2], dst : ArrayView[Point2]) -> Homography raise GeometryErrorfn estimate_homography_from_four(src : ArrayView[Point2], dst : ArrayView[Point2]) -> Homography raise GeometryErrorfn estimate_homography_ransac(src : ArrayView[Point2], dst : ArrayView[Point2], config? : RansacConfig) -> RansacResult[Homography] raise GeometryErrorfn homography_reprojection_error(h : Homography, src : Point2, dst : Point2) -> Double raise GeometryErrorfn mat34_from_rows(r0 : (Double, Double, Double, Double), r1 : (Double, Double, Double, Double), r2 : (Double, Double, Double, Double)) -> Mat34fn mat3_from_rows(r0 : (Double, Double, Double), r1 : (Double, Double, Double), r2 : (Double, Double, Double)) -> Mat3fn mutual_matches(left : ArrayView[Point2], right : ArrayView[Point2], maximum_distance~ : Double) -> Array[PointMatch] raise GeometryErrorfn nearest_matches(left : ArrayView[Point2], right : ArrayView[Point2], maximum_distance~ : Double) -> Array[PointMatch] raise GeometryErrorfn project_point(camera_point : Point3, intrinsics : CameraIntrinsics, distortion? : Distortion) -> Point2 raise GeometryErrorfn project_point_with_pose(world_point : Point3, intrinsics : CameraIntrinsics, pose : CameraPose, distortion? : Distortion) -> Point2 raise GeometryErrorfn projection_jacobian(point : Point3, intrinsics : CameraIntrinsics) -> ProjectionJacobian raise GeometryErrorfn reconstruction_report(points : ArrayView[Point3], left : ArrayView[Ray3], right : ArrayView[Ray3]) -> ReconstructionReport raise GeometryErrorfn report_from_residuals(residuals : ArrayView[Double], threshold~ : Double) -> ConsensusReport raise GeometryErrorfn required_iterations(success_probability~ : Double, confidence? : Double) -> Int raise GeometryErrorfn solve_2x2(a00~ : Double, a01~ : Double, a10~ : Double, a11~ : Double, b0~ : Double, b1~ : Double) -> Vec2 raise GeometryErrorfn undistort_point_iterative(distorted : Point2, distortion : Distortion, iterations? : Int) -> Point2Camera and multi-view geometry foundations for MoonBit: small fixed-size math, projection, distortion, homography, epipolar constraints, and RANSAC.