@@ -44,6 +44,17 @@ canreproject(camera::AbstractCameraModel) = true
4444# # =========================================================================================
4545
4646
47+ # # From JuliaRobotics/SensorFeatureTracking.jl
48+ function project! (
49+ ret:: AbstractVector{<:Real} ,
50+ ci:: CameraCalibration , # CameraIntrinsic,
51+ ce:: ArrayPartition ,
52+ pt:: AbstractVector{<:Real}
53+ )
54+ res = ci. K* (ce. x[2 ]* pt + ce. x[1 ])
55+ ret[1 : 2 ] = res[1 : 2 ]. / res[3 ]
56+ PixelIndex (ret[1 ], ret[2 ])
57+ end
4758
4859"""
4960 $SIGNATURES
@@ -67,36 +78,19 @@ function project(
6778 c_P:: Union{<:AbstractVector{<:Real}, <:Point3}
6879 )
6980 #
70- column = pp_w (model) + f_w (model) * c_P[1 ] / c_P[3 ]
71- row = pp_h (model) - f_h (model) * c_P[2 ] / c_P[3 ]
72- return PixelIndex (column, row)
73- end
74-
75- # # From JuliaRobotics/SensorFeatureTracking.jl
76- function project! (
77- ret:: AbstractVector{<:Real} ,
78- ci:: CameraCalibration , # CameraIntrinsic,
79- ce:: ArrayPartition ,
80- pt:: Vector{Float64}
81- )
82- res = ci. K* (ce. R* pt + ce. t)
83- ret[1 : 2 ] = res[1 : 2 ]. / res[3 ]
84- nothing
81+ ret = MVector (0. ,0. )
82+ e0 = ArrayPartition ( SVector (0. ,0. ,0. ), SMatrix {3,3} (1. ,0. ,0. ,0. ,1. ,0. ,0. ,0. ,1. ) )
83+ project! (ret, model, e0, c_P)
84+ # column = pp_w(model) + f_w(model) * c_P[1] / c_P[3]
85+ # row = pp_h(model) - f_h(model) * c_P[2] / c_P[3]
86+ # return PixelIndex(column, row)
8587end
8688
8789project! (
8890 ret:: AbstractVector{<:Real} ,
8991 cm:: CameraModelFull ,
9092 pt:: AbstractVector{<:Real} ) = project! (ret, cm. ci, cm. ce, pt)
9193
92- function project (
93- cm:: CameraModelFull ,
94- pt:: AbstractVector{<:Real}
95- )
96- res = Vector {Float64} (2 )
97- project! (res, cm, pt)
98- return res
99- end
10094
10195# # homogeneous point coords xyzw (stereo cameras)
10296# xyzw are in the camera frame (c_), i.e. x-columns, y-rows, z-forward
0 commit comments