Skip to content

Commit b2a39e8

Browse files
authored
Merge pull request #952 from JuliaRobotics/23Q1/enh/imagefeatures
add ImageFeatures utils for ORB
2 parents c210f11 + d3d8ab3 commit b2a39e8

18 files changed

Lines changed: 477 additions & 289 deletions

Project.toml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ version = "0.14.0"
88
ApproxManifoldProducts = "9bbbb610-88a1-53cd-9763-118ce10c1f89"
99
Base64 = "2a0f44e3-6c83-55bd-87e4-b1978d98bd5f"
1010
Colors = "5ae59095-9a9b-59fe-a467-6f913c188581"
11+
ColorVectorSpace = "c3611d14-8923-5661-9e6a-0046d554d3a4"
1112
Combinatorics = "861a8166-3701-5b0c-9a16-15d98fcdc6aa"
1213
CoordinateTransformations = "150eb455-5306-5404-9cee-2592286d6298"
1314
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
@@ -20,13 +21,17 @@ DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
2021
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
2122
FileIO = "5789e2e9-d7fb-5bc7-8068-2c6fae9b9549"
2223
GeometryBasics = "5c1252a2-5f33-56bf-86c9-59e7332b4326"
24+
GeometricalPredicates = "fd0ad045-b25c-564e-8f9c-8ef5c5f21267"
2325
ImageCore = "a09fc81d-aa75-5fe9-8630-4744c3626534"
2426
ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1"
2527
IncrementalInference = "904591bb-b899-562f-9e6f-b8df64c7d480"
28+
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
2629
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
2730
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
2831
JSON2 = "2535ab7d-5cd8-5a07-80ac-9b1792aadce3"
32+
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
2933
KernelDensityEstimate = "2472808a-b354-52ea-a80e-1658a3c6056d"
34+
LasIO = "570499db-eae3-5eb6-bdd5-a5326f375e68"
3035
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
3136
Manifolds = "1cead3c2-87b3-11e9-0ccd-23c62b72b94e"
3237
MultivariateStats = "6f286f6a-111f-5878-ab1e-185364afe411"
@@ -55,22 +60,27 @@ YAML = "ddb6d928-2868-570f-bddf-ab3f9cf99eb6"
5560
ApproxManifoldProducts = "0.6"
5661
AprilTags = "0.8, 0.9"
5762
Colors = "0.12"
63+
ColorVectorSpace = "0.9"
5864
Combinatorics = "1"
5965
CoordinateTransformations = "0.5, 0.6"
6066
DataStructures = "0.17, 0.18"
61-
DistributedFactorGraphs = "0.18, 0.19"
67+
DistributedFactorGraphs = "0.19, 0.20"
6268
Distributions = "0.25"
6369
DocStringExtensions = "0.8, 0.9"
6470
FFTW = "1"
6571
FileIO = "1"
6672
GeometryBasics = "0.4"
73+
GeometricalPredicates = "0.4"
6774
ImageCore = "0.8, 0.9"
6875
ImageMagick = "1"
69-
IncrementalInference = "0.31, 0.32"
76+
IncrementalInference = "0.31, 0.32, 0.33"
77+
Interpolations = "0.14"
7078
JLD2 = "0.3, 0.4"
7179
JSON = "0.20, 0.21"
7280
JSON2 = "0.3, 0.4"
81+
JSON3 = "1"
7382
KernelDensityEstimate = "0.5"
83+
LasIO = "0.3"
7484
Manifolds = "0.8"
7585
MultivariateStats = "0.10"
7686
NLsolve = "4"
@@ -79,7 +89,7 @@ Optim = "1"
7989
ProgressMeter = "1"
8090
Reexport = "1"
8191
Requires = "1"
82-
RoME = "0.21"
92+
RoME = "0.21, 0.22"
8393
Rotations = "1.1"
8494
StaticArrays = "1"
8595
StatsBase = "0.33"
@@ -98,7 +108,7 @@ Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6"
98108
FixedPointNumbers = "53c48c17-4a7d-5ca2-90c5-79b7896eea93"
99109
GraphPlot = "a2cc645c-3eea-5389-862e-a155d0052231"
100110
Images = "916415d5-f1e6-5110-898d-aaa5f9f070e0"
101-
LasIO = "570499db-eae3-5eb6-bdd5-a5326f375e68"
111+
ImageFeatures = "92ff4b2b-8094-53d3-b29d-97f740f06cef"
102112
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"
103113
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
104114
RoMEPlotting = "238d586b-a4bf-555c-9891-eda6fc5e55a2"
@@ -107,4 +117,4 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
107117
ZMQ = "c2297ded-f4af-51ae-bb23-16f91089e4e1"
108118

109119
[targets]
110-
test = ["AprilTags", "BSON", "DelimitedFiles", "Downloads", "FixedPointNumbers", "GraphPlot", "Images", "LasIO", "PyCall", "Random", "RobotOS", "Test", "ZMQ"]
120+
test = ["AprilTags", "BSON", "DelimitedFiles", "Downloads", "FixedPointNumbers", "GraphPlot", "Images", "PyCall", "Random", "RobotOS", "Test", "ZMQ"]

src/3rdParty/_PCL/_PCL.jl

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import ..Caesar: _FastTransform3D
88
import ..Caesar: homogeneous_coord_to_euler_coord, euler_coord_to_homogeneous_coord, euler_angles_to_linearized_rotation_matrix
99
import ..Caesar: _SE3_MANI # create_homogeneous_transformation_matrix
1010
import ..Caesar: getBelief, mean, calcPPE
11+
import ..Caesar: AbstractBoundingBox, OrientedBoundingBox, AxisAlignedBoundingBox, inside
1112

1213
using FileIO
1314
using Colors
@@ -22,11 +23,11 @@ using LinearAlgebra
2223
using NearestNeighbors
2324
using Manifolds
2425
import Rotations as _Rot
25-
import GeometryBasics as GeoB # name collisions on members: Point, etc.
2626
using DistributedFactorGraphs
2727
using TensorCast
2828
using UUIDs
2929
using MultivariateStats
30+
using LasIO
3031

3132
# FIXME REMOVE, only used for legacy getDataPointCloud
3233
using Serialization
@@ -48,17 +49,17 @@ import IncrementalInference: ArrayPartition
4849

4950
# bring in the types
5051
include("entities/PCLTypes.jl")
51-
include("entities/OtherTypes.jl")
5252
# bring in further source code
5353
include("services/GeomBasicsUtils.jl")
5454
include("services/PointCloud.jl")
55+
include("services/LasIOSupport.jl")
5556
include("services/PointCloudUtils.jl")
5657
include("services/ConsolidateRigidTransform.jl")
5758
include("services/ICP_Simple.jl")
5859

5960

6061
function __init__()
61-
@require LasIO="570499db-eae3-5eb6-bdd5-a5326f375e68" include("services/LasIOSupport.jl")
62+
# @require LasIO="570499db-eae3-5eb6-bdd5-a5326f375e68" include("services/LasIOSupport.jl")
6263
@require RobotOS="22415677-39a4-5241-a37a-00beabbbdae8" include("services/ROSConversions.jl")
6364
# moved plotting out of Caesar, use Arena.jl or RoMEPlotting.jl instead
6465
end

src/3rdParty/_PCL/services/GeomBasicsUtils.jl

Lines changed: 1 addition & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,7 @@
11
# Utils based on GeometryBasics
22

33

4-
"""
5-
$SIGNATURES
6-
7-
Get the eight corners of bounding box in it's local coordinates.
8-
9-
See also: [`plotBoundingBox`](@ref)
10-
"""
11-
function getCorners(
12-
BB::_PCL.AbstractBoundingBox
13-
)
14-
# https://math.stackexchange.com/questions/1472049/check-if-a-point-is-inside-a-rectangular-shaped-area-3d
15-
hr = BB.hr
16-
x_, y_, z_ = hr.origin[1], hr.origin[2], hr.origin[3]
17-
dx, dy, dz = hr.widths[1], hr.widths[2], hr.widths[3]
184

19-
p1 = [x_;y_;z_]
20-
p2 = [x_;y_+dy;z_]
21-
p4 = [x_+dx;y_;z_]
22-
p3 = [x_+dx;y_+dy;z_]
23-
24-
p5 = [x_;y_;z_+dz]
25-
p6 = [x_;y_+dy;z_+dz]
26-
p8 = [x_+dx;y_;z_+dz]
27-
p7 = [x_+dx;y_+dy;z_+dz]
28-
29-
corners_ = [p1,p2,p3,p4,p5,p6,p7,p8]
30-
31-
_r_H_bb(::_PCL.AxisAlignedBoundingBox) = SMatrix{4,4}(diagm(ones(4)))
32-
_r_H_bb(obb::_PCL.OrientedBoundingBox) = inv(obb.bb_H_r)
33-
r_H_bb = _r_H_bb(BB)
34-
(s->(r_H_bb*[s...;1.])[1:3]).(corners_)
35-
end
36-
37-
"""
38-
$SIGNATURES
39-
40-
Is point p inside the HyperRectangle.
41-
"""
42-
function inside(
43-
hr::GeoB.HyperRectangle,
44-
p #::GeoB.Point
45-
)
46-
#
47-
_p0,_p1 = GeoB.minmax(GeoB.Point(p...), hr.origin, hr.origin + hr.widths)
48-
_p0 == hr.origin && hr.widths == (_p1-_p0)
49-
end
50-
51-
# inside(
52-
# aabb::AxisAlignedBoundingBox,
53-
# p
54-
# ) = inside(aabb.hr, p)
55-
56-
57-
function inside(
58-
obb::AbstractBoundingBox,
59-
pt
60-
)
61-
# https://math.stackexchange.com/questions/1472049/check-if-a-point-is-inside-a-rectangular-shaped-area-3d
62-
p = getCorners(obb)
63-
64-
_i = p[2] - p[1]
65-
_j = p[4] - p[1]
66-
_k = p[5] - p[1]
67-
_v = pt - p[1]
68-
69-
# check if inside cuboid
70-
(0 < _v'*_i < _i'*_i) && (0 < _v'*_j < _j'_j) && (0 < _v'*_k < _k'*_k)
71-
end
725

736

747
"""
@@ -82,7 +15,7 @@ function getSubcloud(
8215
minrange::Real=0,
8316
maxrange::Real=999
8417
)
85-
objmask = map(s->_PCL.inside(mask, s.data[1:3]), pc_full.points)
18+
objmask = map(s->inside(mask, s.data[1:3]), pc_full.points)
8619
spt = (s->s.data[1:3]).(pc_full.points[objmask])
8720
if 0 == length(spt)
8821
return _PCL.PointCloud()

src/3rdParty/_PCL/services/LasIOSupport.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
# support saving and loading PointClouds as las files
22

3-
@info "Caesar._PCL is loading features using LasIO.jl"
3+
# @info "Caesar._PCL is loading features using LasIO.jl"
44

5-
using .LasIO
6-
using .FileIO
7-
using .Dates
8-
using .TensorCast
5+
# using .LasIO
6+
# using .FileIO
7+
# using .Dates
8+
# using .TensorCast
99

1010

1111
function loadLAS(

src/3rdParty/_PCL/services/PointCloudUtils.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ function getDataPointCloud(
88
nfg::AbstractDFG,
99
varlbl,
1010
pattern::Union{Symbol,UUID,<:AbstractString, Regex};
11+
format::Symbol = :las,
1112
getDatakws...
1213
)
1314
# get point cloud blob
@@ -17,8 +18,14 @@ function getDataPointCloud(
1718
@error "could find in variable $varlbl, blob $pattern"
1819
return nothing
1920
end
20-
# FIXME, change serialization to more standard pcd or laz formats, see Caesar.jl #921
21-
return dbl |> IOBuffer |> Serialization.deserialize
21+
if format == :las
22+
dbl |> IOBuffer |> loadLAS
23+
elseif format == :Serialization
24+
# FIXME, change serialization to more standard pcd or laz formats, see Caesar.jl #921
25+
return dbl |> IOBuffer |> Serialization.deserialize
26+
else
27+
error("Unknown point cloud blob format $format")
28+
end
2229
catch err
2330
if err isa KeyError
2431
@error err

src/Caesar.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import DistributedFactorGraphs: getManifold
88

99
# handy project consts (not for export)
1010
import IncrementalInference: NothingUnion, InstanceType
11+
import GeometricalPredicates as GeoPr
1112

1213
using Requires
1314
using Dates
@@ -19,6 +20,7 @@ using StaticArrays
1920
import Rotations as _Rot
2021
import GeometryBasics as GeoB
2122

23+
2224
# TODO remove
2325
const _Rotations = _Rot
2426

@@ -33,6 +35,7 @@ using
3335
CoordinateTransformations,
3436
JSON,
3537
JSON2,
38+
JSON3,
3639
UUIDs,
3740
Base64,
3841
FileIO,
@@ -65,6 +68,8 @@ include("transforms/entities/TransformTypes.jl")
6568
include("transforms/services/HomographyTransforms.jl")
6669
include("transforms/services/_FastTransform3D.jl")
6770

71+
include("entities/OtherTypes.jl")
72+
include("services/PointUtils.jl")
6873
include("services/DataUtils.jl")
6974
include("services/UserFunctions.jl")
7075

@@ -101,6 +106,7 @@ function __init__()
101106
@require ImageMagick="6218d12a-5da1-5696-b52f-db25d2ecc6d1" include("images/imagedata.jl")
102107
@require Images="916415d5-f1e6-5110-898d-aaa5f9f070e0" begin
103108
include("images/images.jl")
109+
include("images/ImageToVideoUtils.jl")
104110
include("images/ScanMatcherUtils.jl")
105111
include("images/ScanMatcherPose2.jl")
106112
include("images/ScatterAlignPose2.jl")
@@ -109,6 +115,7 @@ function __init__()
109115
# @require Gadfly="c91e804a-d5a3-530f-b6f0-dfbca275c004" include("plotting/ScatterAlignPlotting.jl")
110116
@require RobotOS="22415677-39a4-5241-a37a-00beabbbdae8" include("images/ROSConversions.jl")
111117
end
118+
@require ImageFeatures="92ff4b2b-8094-53d3-b29d-97f740f06cef" include("images/imagefeatures.jl")
112119
@require Distributed="8ba89e20-285c-5b6f-9357-94700520ee1b" include("images/DistributedUtils.jl")
113120
end
114121

src/ExportAPI.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,6 @@ export
4747
phaseShiftSingle!,
4848
liebf!,
4949
SASDebug
50+
51+
export calcPointsInPoly
52+
export inside, AxisAlignedBoundingBox, OrientedBoundingBox

src/beamforming/SASBearing2D.jl

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,45 @@ mutable struct PackedSASBearing2D <: DFG.AbstractPackedFactor
227227
waveformsInReal::Vector{Float64}
228228
waveformsInIm::Vector{Float64}
229229
PackedSASBearing2D() = new()
230-
PackedSASBearing2D(rangemodel::String, tp::Int, wavedataRawV::Vector{Float64}, wavedataRawV_dim::Int, cfgJson::String, cfgTotal::String, cfgLIE::String, waveformsInReal::Vector{Float64}, waveformsInIm::Vector{Float64}) = new(rangemodel, tp, wavedataRawV, wavedataRawV_dim, cfgJson, cfgTotal, cfgLIE, waveformsInReal, waveformsInIm)
231-
PackedSASBearing2D(rangemodel::String, tp::Int, wd::Array{Float64,2}, cf::Dict, cfgTotal::String, cfgLIE::String, waveformsInReal::Vector{Float64}, waveformsInIm::Vector{Float64}) = new(rangemodel, tp, wd[:], size(wd,1), JSON2.write(cf), cfgTotal, cfgLIE, waveformsInReal, waveformsInIm)
230+
PackedSASBearing2D(
231+
rangemodel::String,
232+
tp::Int,
233+
wavedataRawV::Vector{Float64},
234+
wavedataRawV_dim::Int,
235+
cfgJson::String,
236+
cfgTotal::String,
237+
cfgLIE::String,
238+
waveformsInReal::Vector{Float64},
239+
waveformsInIm::Vector{Float64}) = new(
240+
rangemodel,
241+
tp,
242+
wavedataRawV,
243+
wavedataRawV_dim,
244+
cfgJson,
245+
cfgTotal,
246+
cfgLIE,
247+
waveformsInReal,
248+
waveformsInIm
249+
)
250+
PackedSASBearing2D(
251+
rangemodel::String,
252+
tp::Int,
253+
wd::Array{Float64,2},
254+
cf::Dict,
255+
cfgTotal::String,
256+
cfgLIE::String,
257+
waveformsInReal::Vector{Float64},
258+
waveformsInIm::Vector{Float64}) = new(
259+
rangemodel,
260+
tp,
261+
wd[:],
262+
size(wd,1),
263+
JSON2.write(cf),
264+
cfgTotal,
265+
cfgLIE,
266+
waveformsInReal,
267+
waveformsInIm
268+
)
232269
end
233270

234271
# Note: Need this otherwise it uses a default converter and causes type conversion issues.

0 commit comments

Comments
 (0)