Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FLiTrak3D
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Cribellier, Antoine
FLiTrak3D
Commits
c4773800
Commit
c4773800
authored
2 years ago
by
Cribellier, Antoine
Browse files
Options
Downloads
Patches
Plain Diff
Added with_missing in Reconstructor3DSettings
parent
c3462cac
No related branches found
Branches containing commit
No related tags found
1 merge request
!10
Major development of the various modules + many bugs were solved
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
point_tracker/reconstructor3d.py
+9
-10
9 additions, 10 deletions
point_tracker/reconstructor3d.py
process/dlc_postprocessing.py
+4
-4
4 additions, 4 deletions
process/dlc_postprocessing.py
process/point_tracking.py
+2
-2
2 additions, 2 deletions
process/point_tracking.py
with
15 additions
and
16 deletions
point_tracker/reconstructor3d.py
+
9
−
10
View file @
c4773800
...
...
@@ -19,6 +19,8 @@ class Reconstructor3DSettings(BaseSettings):
Class for keeping track of the settings of Reconstructor3D.
"""
with_missing
:
bool
=
False
# Whether to try to reconstruct 3d obj with less than nb_cam number of 2d points
threshold_mean_repro_err
:
float
=
5.0
threshold_nb_camera_views
:
int
=
2
# Minimum number of camera views that will be used for the 3d reconstruction (when with_missing = True)
threshold_distance_tracks
:
float
=
0.02
# max distance (in meters) between two successive 3d points to set as a track
...
...
@@ -79,8 +81,7 @@ class Reconstructor3D:
return
Reconstructor3D
(
dlt_coefs
)
def
recon_objs
(
self
,
xs_pts
:
List
[
int
],
ys_pts
:
List
[
int
],
frames_coord
:
List
[
int
],
with_missing
:
bool
=
True
,
sort_by_rmse
:
bool
=
True
)
->
Tuple
[
any
]:
def
recon_objs
(
self
,
xs_pts
:
List
[
int
],
ys_pts
:
List
[
int
],
frames_coord
:
List
[
int
],
sort_by_rmse
:
bool
=
True
)
->
Tuple
[
any
]:
"""
Reconstruct 3d coordinates of objects from 2d coordinates of points for all frames
args are vectors of vectors (e.g. np.array([[451, 123], [78], [147, 65, 78, 79]])) of size nb_cam*nb_obj
...
...
@@ -91,7 +92,6 @@ class Reconstructor3D:
ys_pts: y coordinates in pixel of all pts for all frames for each camera
frames_coord: corresponding frames of all pts for each camera (can have duplicates (several pts per frames))
with_missing: Whether to try to reconstruct 3d obj with less than nb_cam number of 2d points
sort_by_rmse: Whether to sort the results by rmse (lower error first)
Returns:
...
...
@@ -142,7 +142,7 @@ class Reconstructor3D:
xs_pt
,
ys_pt
=
np
.
asarray
(
xs_pt
),
np
.
asarray
(
ys_pt
)
if
xs_pt
==
[]:
continue
xs_obj
,
ys_obj
,
zs_obj
,
index_match_pts
,
rmses_obj
=
self
.
match_pts_and_recon_obj
(
xs_pt
,
ys_pt
,
with_missing
)
xs_obj
,
ys_obj
,
zs_obj
,
index_match_pts
,
rmses_obj
=
self
.
match_pts_and_recon_obj
(
xs_pt
,
ys_pt
)
if
xs_obj
==
[]:
continue
index_pts
=
-
np
.
ones
(
np
.
array
(
index_match_pts
).
shape
)
...
...
@@ -177,14 +177,13 @@ class Reconstructor3D:
return
xs_objs
,
ys_objs
,
zs_objs
,
frames_objs
,
indexes_pts
,
rmses_objs
def
match_pts_and_recon_obj
(
self
,
xs_pts
,
ys_pts
,
with_missing
=
True
):
def
match_pts_and_recon_obj
(
self
,
xs_pts
,
ys_pts
):
"""
Match 2d pts together (by minimizing rmse) and reconstruct 3d coordinates of objects
Args:
xs_pts: x coordinates in pixel of all pts for all camera
ys_pts: y coordinates in pixel of all pts for all camera
with_missing: if True will also try to reconstruct 3d obj with less than nb_cam number of 2d points
Returns:
xs_obj: x coordinates for all objects (3d reconstructed and matched to minimized rmse)
...
...
@@ -194,7 +193,7 @@ class Reconstructor3D:
rmses_obj: minimized rmse for all objects
"""
if
with_missing
:
if
self
.
settings
.
with_missing
:
# Make matrix with indexes of cameras and with None when camera is missing (nan values in xs_px)
# (add a row of missing cam to look at combination involving less than the max number of cameras)
indexes_frames
=
[
np
.
append
(
np
.
arange
(
0
,
np
.
array
(
xs
).
size
),
None
)
for
xs
in
xs_pts
]
...
...
@@ -242,9 +241,9 @@ class Reconstructor3D:
repro_pts_cams_wo_missing
=
\
np
.
array
([
repro_pts_cams
[
j
]
for
j
,
_
in
enumerate
(
range
(
1
,
self
.
nb_cam
+
1
))
if
index_match
[
j
]
!=
None
])
# To correct the error reduction when we use
less
points than the max number of cams
correction_factor
=
count_missing
*
np
.
sqrt
(
2
)
if
count_missing
>
0
else
1
mean_repro_err
=
np
.
sqrt
(
np
.
mean
(
np
.
sum
((
repro_pts_cams_wo_missing
-
pts_cams
)
**
2
,
1
)))
*
correction_factor
# To correct the error reduction when we use
fewer
points than the max number of cams
correction_factor
=
np
.
sqrt
(
1
+
count_missing
)
if
count_missing
>
0
else
1
mean_repro_err
=
np
.
mean
(
np
.
sqrt
(
np
.
sum
((
repro_pts_cams_wo_missing
-
pts_cams
)
**
2
,
1
)))
*
correction_factor
if
mean_repro_err
<
self
.
settings
.
threshold_mean_repro_err
:
# Fill tracking results
...
...
This diff is collapsed.
Click to expand it.
process/dlc_postprocessing.py
+
4
−
4
View file @
c4773800
...
...
@@ -493,7 +493,7 @@ def save_stroboscopic_images(image_sequence: MultiImageSequence, frames: List[in
# frames_coord.append([frame, frame])
#
# xs_pose, ys_pose, zs_pose, frames_pose, indexes, rmses, = \
# reconstructor.recon_objs(xs_coord, ys_coord, frames_coord,
with_missing=False,
sort_by_rmse=False)
# reconstructor.recon_objs(xs_coord, ys_coord, frames_coord, sort_by_rmse=False)
#
# # if len(xs_pose) == 0:
# # xs_pose, ys_pose, zs_pose = [[np.nan, np.nan]], [[np.nan, np.nan]], [[np.nan, np.nan]]
...
...
@@ -626,7 +626,7 @@ def save_stroboscopic_images(image_sequence: MultiImageSequence, frames: List[in
# frames_coord.append([frame])
#
# xs_pose, ys_pose, zs_pose, frames_pose, indexes, rmses, = \
# reconstructor.recon_objs(xs_coord, ys_coord, frames_coord
, with_missing=False
)
# reconstructor.recon_objs(xs_coord, ys_coord, frames_coord)
#
# if len(xs_pose) == 0:
# skeleton3d[obj_name][label]['x'][i], skeleton3d[obj_name][label]['y'][i], \
...
...
@@ -786,7 +786,7 @@ def reverse_processes_2d_points(skeleton2d: Dict[str, any], settings: Settings,
# frames_coord.append([frame])
#
# xs_pose, ys_pose, zs_pose, frames_pose, indexes, rmses, = \
# reconstructor.recon_objs(xs_coord, ys_coord, frames_coord
, with_missing=False
)
# reconstructor.recon_objs(xs_coord, ys_coord, frames_coord)
#
# if len(xs_pose) == 0:
# skeleton3d[obj_name][label]['x'][i], skeleton3d[obj_name][label]['y'][i], \
...
...
@@ -871,7 +871,7 @@ def recon3d_dlc(skeleton2d: Dict[str, any], dlt_path: str,
frames_coord
.
append
([
frame
])
xs_pose
,
ys_pose
,
zs_pose
,
frames_pose
,
indexes
,
rmses
=
\
reconstructor
.
recon_objs
(
xs_coord
,
ys_coord
,
frames_coord
,
with_missing
=
True
)
reconstructor
.
recon_objs
(
xs_coord
,
ys_coord
,
frames_coord
)
if
len
(
xs_pose
)
==
0
:
skeleton3d
[
obj_name
][
label
][
'
x
'
][
i
],
skeleton3d
[
obj_name
][
label
][
'
y
'
][
i
],
\
...
...
This diff is collapsed.
Click to expand it.
process/point_tracking.py
+
2
−
2
View file @
c4773800
...
...
@@ -168,7 +168,7 @@ def reconstruct_3d_points(pts_dict: Dict[any, Dict[str, List[float]]], dlt_path:
frames_coord
=
np
.
array
([
pts_dict
[
camn
][
'
frame
'
]
for
camn
in
range
(
1
,
nb_cam
+
1
)])
xs_pose
,
ys_pose
,
zs_pose
,
frames_pose
,
indexes
,
rmses
,
=
\
reconstructor
.
recon_objs
(
xs_coord
,
ys_coord
,
frames_coord
,
with_missing
=
False
)
reconstructor
.
recon_objs
(
xs_coord
,
ys_coord
,
frames_coord
)
save_names_list
=
[
save_names
[
camn
]
for
camn
in
range
(
1
,
nb_cam
+
1
)]
save_paths_list
=
[
save_paths
[
camn
]
for
camn
in
range
(
1
,
nb_cam
+
1
)]
...
...
@@ -204,7 +204,7 @@ def reconstruct_3d_tracks(pts_dict: Dict[any, Dict[str, List[float]]], dlt_path:
frames_coord
=
np
.
array
([
pts_dict
[
camn
][
'
frame
'
]
for
camn
in
range
(
1
,
nb_cam
+
1
)])
xs_pose
,
ys_pose
,
zs_pose
,
frames_pose
,
indexes_pts
,
_
,
=
\
reconstructor
.
recon_objs
(
xs_coord
,
ys_coord
,
frames_coord
,
with_missing
=
False
)
reconstructor
.
recon_objs
(
xs_coord
,
ys_coord
,
frames_coord
)
tracks_dict
=
reconstructor
.
recon_tracks
(
xs_pose
,
ys_pose
,
zs_pose
,
frames_pose
,
indexes_pts
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment