@@ -48,11 +48,11 @@ canreproject(camera::AbstractCameraModel) = true
4848function project! (
4949 ret:: AbstractVector{<:Real} ,
5050 ci:: CameraCalibration , # CameraIntrinsic,
51- ce :: ArrayPartition ,
52- pt :: AbstractVector{<:Real}
51+ c_T_r :: ArrayPartition ,
52+ r_P :: AbstractVector{<:Real}
5353)
54- res = ci. K* (ce . x[2 ]* pt + ce . x[1 ])
55- ret[1 : 2 ] = res[ 1 : 2 ] . / res[3 ]
54+ res = ci. K* (c_T_r . x[2 ]* r_P + c_T_r . x[1 ])
55+ ret[1 : 2 ] ./= res[3 ]
5656 PixelIndex (ret[1 ], ret[2 ])
5757end
5858
@@ -66,7 +66,8 @@ to camera coordinates. This currently ignores any tangential
6666distortion between the lens and the image plane.
6767
6868Notes
69- - `c_P` is a point in the camera's reference frame.
69+ - `r_P` is a point in reference frame tranformed the camera's reference frame:
70+ - `c_P = c_T_r * r_P`
7071
7172Deprecates:
7273- yakir12: `point2pixel`: @deprecate point2pixel(model, pt) project(model, pt[[1;3;2]])
@@ -75,12 +76,12 @@ Also see: [`backproject`](@ref)
7576"""
7677function project (
7778 model:: AbstractCameraModel ,
78- c_P:: Union{<:AbstractVector{<:Real}, <:Point3}
79+ r_P:: Union{<:AbstractVector{<:Real}, <:Point3} ;
80+ c_T_r = ArrayPartition ( SVector (0. ,0. ,0. ), SMatrix {3,3} (1. ,0. ,0. ,0. ,1. ,0. ,0. ,0. ,1. ) )
7981 )
8082 #
8183 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+ project! (ret, model, c_T_r, r_P)
8485 # column = pp_w(model) + f_w(model) * c_P[1] / c_P[3]
8586 # row = pp_h(model) - f_h(model) * c_P[2] / c_P[3]
8687 # return PixelIndex(column, row)
@@ -96,17 +97,17 @@ project!(
9697# xyzw are in the camera frame (c_), i.e. x-columns, y-rows, z-forward
9798function projectHomogeneous (
9899 cam:: AbstractCameraModel ,
99- c_Ph:: SVector{4,Float64}
100+ c_Ph:: AbstractVector ,
100101)
101102 # left cam
102103 x,y,z,w = (c_Ph... ,)
103- fxz = f_w (cam) / z
104- fyz = f_h (cam) / z
105- col = x * fxz + pp_w (cam) # add center to get PixelIndex
106- row = y * fyz + pp_h (cam)
104+ fx_z = f_w (cam) / z
105+ fy_z = f_h (cam) / z
106+ col = x * fx_z + pp_w (cam) # add center to get PixelIndex
107+ row = y * fy_z + pp_h (cam)
107108 # infront or behind
108109 if (w== 0 && 0 < z) || 0 < (z/ w)
109- PixelIndex (col, row)
110+ PixelIndex (row,col )
110111 else
111112 PixelIndex (0. ,0. ; valid= false )
112113 end
0 commit comments