Skip to content

Commit 6c3b94f

Browse files
committed
restore tests
1 parent 42c1f5c commit 6c3b94f

File tree

5 files changed

+17
-6
lines changed

5 files changed

+17
-6
lines changed

src/CameraModels.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ using Manifolds
55
using DocStringExtensions
66
using StaticArrays
77
import Rotations as Rot_
8-
8+
import Base: getindex, getproperty
99

1010

1111
# exports

src/entities/GeneralTypes.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ struct PixelIndex{T <: Real}
55
col::T
66
end
77

8+
function Base.getindex(p::PixelIndex,i::Int)
9+
if i === 1
10+
p.row
11+
elseif i === 2
12+
p.col
13+
else
14+
DomainError("Camera only has rows and columns, cannot index to $i")
15+
end
16+
end
817

918
const Vector2 = SVector{2, Float64}
1019
const Point3 = SVector{3, Float64}

src/services/CameraServices.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ Also see: [`project`](@ref)
9696
"""
9797
function backproject(
9898
model::CameraCalibrationT,
99-
px_coord::Union{<:AbstractVector{<:Real}, <:PixelCoordinate}
99+
px_coord::Union{<:AbstractVector{<:Real}, <:PixelIndex}
100100
)
101101
#
102102
x = (px_coord[1] - c_w(model)) / f_w(model)
@@ -124,7 +124,7 @@ end
124124
function project!(
125125
ret::AbstractVector{<:Real},
126126
ci::CameraCalibration, #CameraIntrinsic,
127-
ce::CameraExtrinsic,
127+
ce::ArrayPartition,
128128
pt::Vector{Float64}
129129
)
130130
res = ci.K*(ce.R*pt + ce.t)
@@ -152,7 +152,7 @@ function cameraResidual!(
152152
res::AbstractVector{<:Real},
153153
z::AbstractVector{<:Real},
154154
ci::CameraCalibration, #CameraIntrinsic,
155-
ce::CameraExtrinsic,
155+
ce::ArrayPartition,
156156
pt::AbstractVector{<:Real}
157157
)
158158
# in place memory operations

test/CameraTestBench.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ function run_test_bench(model::C, pixel_accuracy::Float64 = 1e-5, ray_accuracy::
3131
# Some models might not implement point2pixel.
3232
if canreproject(model)
3333
reprojection = point2pixel(model, point)
34-
@test some_pixel_location reprojection atol = pixel_accuracy
34+
@test some_pixel_location[1] reprojection[1] atol = pixel_accuracy
35+
@test some_pixel_location[2] reprojection[2] atol = pixel_accuracy
3536
else
3637
@info "point2pixel not implemented for $(C)."
3738
end

test/Pinhole.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ run_test_bench(model)
2121
@testset "Check Legacy Pinhole model." begin
2222
some_point = CameraModels.Point3(0, 1, 0)
2323
should_be_principal_point = point2pixel(model, some_point)
24-
@test principal_point should_be_principal_point
24+
@test principal_point[1] should_be_principal_point[1]
25+
@test principal_point[2] should_be_principal_point[2]
2526

2627
ray = pixel2ray(model, principal_point)
2728
@test CameraModels.direction(ray) CameraModels.Vector3(0,1,0)

0 commit comments

Comments
 (0)