Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
3
360monodepth
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
Releases
Package 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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
GDP Project 4
360monodepth
Commits
43347063
Commit
43347063
authored
3 years ago
by
Manuel
Browse files
Options
Downloads
Patches
Plain Diff
Remove unused files
parent
96247840
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
code/python/src/perspective_sampling/main.py
+0
-42
0 additions, 42 deletions
code/python/src/perspective_sampling/main.py
code/python/src/perspective_sampling/test_metrics.py
+0
-69
0 additions, 69 deletions
code/python/src/perspective_sampling/test_metrics.py
with
0 additions
and
111 deletions
code/python/src/perspective_sampling/main.py
deleted
100644 → 0
+
0
−
42
View file @
96247840
import
configuration
as
config
from
utility.cam_models
import
*
import
cv2
import
numpy
as
np
import
json
import
os
import
sys
# Add project library to Python path
python_src_dir
=
os
.
path
.
dirname
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)))
print
(
f
"
Adding
'
{
python_src_dir
}
'
to sys.path
"
)
sys
.
path
.
append
(
python_src_dir
)
# /code/python/src/
sys
.
path
.
append
(
os
.
path
.
dirname
(
python_src_dir
))
# /code/python/
# sys.path.append(os.path.join(python_src_dir, "../..")) # CR: unused?
# Data directory /data/
# TODO: remove the trailing slash once all usages of TEST_DATA_DIR are updated
TEST_DATA_DIR
=
os
.
path
.
abspath
(
"
../../../../data/
"
)
+
"
/
"
# Set the PyTorch hub folder as an environment variable
# TODO: use os.path.join instead of string
os
.
environ
[
'
TORCH_HOME
'
]
=
TEST_DATA_DIR
+
'
models/
'
if
__name__
==
"
__main__
"
:
data_root
=
config
.
TEST_DATA_DIR
json_file
=
json
.
load
(
open
(
data_root
+
'
brown_00/calibration.json
'
,
'
r
'
))
# Calibration file from Elliot
# There are 6 cameras. I dont know to which one belongs the image under test. I use all of them.
camera_params
=
json_file
[
'
cameras
'
]
img
=
cv2
.
cvtColor
(
cv2
.
imread
(
data_root
+
"
brown_00/video-frame-3840x2880.png
"
),
cv2
.
COLOR_BGR2RGB
)
img
=
np
.
moveaxis
(
img
,
0
,
1
)[::
-
1
,
...]
# Rotate image 90º counter clockwise
for
cam
in
camera_params
:
# Uncomment to undistort the whole input image
# mapx, mapy = create_perspective_undistortion_LUT(img.shape[:-1], ind_camera, sf=-7)
# undistorted = cv2.remap(img, mapx.astype(np.float32), mapy.astype(np.float32), cv2.INTER_LINEAR,
# borderMode=cv2.BORDER_CONSTANT)
RGB_subimages
,
depth_subimages
,
camera_array_size
=
sample_img
(
img
,
cam
,
run_midas
=
False
)
plot_img_array
(
camera_array_size
,
RGB_subimages
)
plot_img_array
(
camera_array_size
,
depth_subimages
)
This diff is collapsed.
Click to expand it.
code/python/src/perspective_sampling/test_metrics.py
deleted
100644 → 0
+
0
−
69
View file @
96247840
import
configuration
as
config
from
utility
import
depthmap_utils
from
utility
import
metrics
from
utility
import
image_io
from
utility
import
depthmap_utils
from
utility.logger
import
Logger
from
MiDaS
import
MiDaS_utils
import
numpy
as
np
log
=
Logger
(
__name__
)
log
.
logger
.
propagate
=
False
def
test_delta_inlier_ratio_map
(
dispmap_predict_filepath
,
depthmap_gt_filepath
,
output_filepath
):
"""
Test the error and error map.
"""
# 0) load data
gt_depthmap
=
depthmap_utils
.
read_dpt
(
depthmap_gt_filepath
)
gt_dispmap
=
depthmap_utils
.
depth2disparity
(
gt_depthmap
)
dispmap_predict
,
_
=
MiDaS_utils
.
read_pfm
(
dispmap_predict_filepath
)
mask
=
np
.
ones_like
(
gt_dispmap
)
# 1) compute the metric
for
index
in
range
(
1
,
4
):
delta_data
=
metrics
.
delta_inlier_ratio
(
dispmap_predict
,
gt_dispmap
,
mask
,
index
)
print
(
"
dalta_{} error is {}
"
.
format
(
index
,
delta_data
))
delta_data_map
=
metrics
.
delta_inlier_ratio_map
(
dispmap_predict
,
gt_dispmap
,
mask
,
index
)
depthmap_utils
.
depth_visual_save
(
delta_data_map
,
output_filepath
+
"
error_delta_{}.jpg
"
.
format
(
index
))
abs_rel_error
=
metrics
.
abs_rel_error
(
dispmap_predict
,
gt_dispmap
,
mask
)
abs_rel_error_map
=
metrics
.
abs_rel_error_map
(
dispmap_predict
,
gt_dispmap
,
mask
)
print
(
"
Absolute Relative Difference error is {}
"
.
format
(
abs_rel_error
))
depthmap_utils
.
depth_visual_save
(
abs_rel_error_map
,
output_filepath
+
"
error_abs_rel_error.jpg
"
)
sq_rel_error
=
metrics
.
sq_rel_error
(
dispmap_predict
,
gt_dispmap
,
mask
)
sq_rel_error_map
=
metrics
.
sq_rel_error_map
(
dispmap_predict
,
gt_dispmap
,
mask
)
print
(
"
Square Relative Difference error is {}
"
.
format
(
sq_rel_error
))
depthmap_utils
.
depth_visual_save
(
sq_rel_error_map
,
output_filepath
+
"
error_sq_rel_error.jpg
"
)
lin_rms_sq_error
=
metrics
.
lin_rms_sq_error
(
dispmap_predict
,
gt_dispmap
,
mask
)
lin_rms_sq_error_map
=
metrics
.
lin_rms_sq_error_map
(
dispmap_predict
,
gt_dispmap
,
mask
)
print
(
"
RMSE (linear) is {}
"
.
format
(
lin_rms_sq_error
))
depthmap_utils
.
depth_visual_save
(
lin_rms_sq_error_map
,
output_filepath
+
"
error_lin_rms_sq_error.jpg
"
)
log_rms_sq_error
=
metrics
.
log_rms_sq_error
(
dispmap_predict
,
gt_dispmap
,
mask
)
log_rms_sq_error_map
=
metrics
.
log_rms_sq_error_map
(
dispmap_predict
,
gt_dispmap
,
mask
)
print
(
"
RMSE (log) is {}
"
.
format
(
log_rms_sq_error
))
depthmap_utils
.
depth_visual_save
(
log_rms_sq_error_map
,
output_filepath
+
"
error_log_rms_sq_error.jpg
"
)
log_rms_scale_invariant
=
metrics
.
log_rms_scale_invariant
(
dispmap_predict
,
gt_dispmap
,
mask
)
log_rms_scale_invariant_map
=
metrics
.
log_rms_scale_invariant_map
(
dispmap_predict
,
gt_dispmap
,
mask
)
print
(
"
RMSE (log scale invariant) is {}
"
.
format
(
log_rms_scale_invariant
))
depthmap_utils
.
depth_visual_save
(
log_rms_scale_invariant_map
,
output_filepath
+
"
error_log_rms_scale_invariant_map.jpg
"
)
if
__name__
==
"
__main__
"
:
data_root
=
config
.
TEST_DATA_DIR
+
"
erp_00/
"
depth_gt_filepath
=
data_root
+
"
0001_depth.dpt
"
dispmap_filepath
=
data_root
+
"
0001_dispmap_aligned.pfm
"
output_filepath
=
data_root
+
"
debug/
"
test_delta_inlier_ratio_map
(
dispmap_filepath
,
depth_gt_filepath
,
output_filepath
)
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