Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
FruitBin
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Guillaume Duret
FruitBin
Commits
d3d18380
Commit
d3d18380
authored
2 years ago
by
Guillaume Duret
Browse files
Options
Downloads
Patches
Plain Diff
optimising FPS too
parent
bf8879c5
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
compute_features.py
+34
-2
34 additions, 2 deletions
compute_features.py
fps_alg.py
+4
-18
4 additions, 18 deletions
fps_alg.py
main.py
+4
-4
4 additions, 4 deletions
main.py
with
42 additions
and
24 deletions
compute_features.py
+
34
−
2
View file @
d3d18380
...
@@ -10,9 +10,11 @@ from bbox_2d import bbox_2d
...
@@ -10,9 +10,11 @@ from bbox_2d import bbox_2d
import
cv2
import
cv2
from
instance_mask
import
instance
from
instance_mask
import
instance
from
pose
import
convert2
from
pose
import
convert2
from
matplotlib
import
image
from
fps_alg
import
process2
def
process_compute
(
data_name
,
Nb_camera
,
Nb_world
,
list_categories
,
occ_target
):
def
process_compute
(
data_name
,
camera
,
Nb_camera
,
Nb_world
,
list_categories
,
occ_target
,
vis
):
transformation
=
np
.
matrix
([[
0.0000000
,
-
1.0000000
,
0.0000000
],
transformation
=
np
.
matrix
([[
0.0000000
,
-
1.0000000
,
0.0000000
],
[
0.0000000
,
0.0000000
,
-
1.0000000
],
[
0.0000000
,
0.0000000
,
-
1.0000000
],
[
1.0000000
,
0.0000000
,
0.0000000
]])
[
1.0000000
,
0.0000000
,
0.0000000
]])
...
@@ -31,7 +33,7 @@ def process_compute(data_name, Nb_camera, Nb_world, list_categories, occ_target)
...
@@ -31,7 +33,7 @@ def process_compute(data_name, Nb_camera, Nb_world, list_categories, occ_target)
with
open
(
f
'
{
data_name
}
/Pose/
{
p
}
.json
'
,
'
r
'
)
as
f
:
with
open
(
f
'
{
data_name
}
/Pose/
{
p
}
.json
'
,
'
r
'
)
as
f
:
data_3D_pose
=
json
.
load
(
f
)
data_3D_pose
=
json
.
load
(
f
)
#print(data)
#print(data)
print
(
"
len(data)
"
,
len
(
data_3D_pose
))
#
print("len(data)", len(data_3D_pose))
### 2D BBox ###
### 2D BBox ###
with
open
(
f
"
{
data_name
}
/Bbox_2d/
{
p
}
.json
"
,
'
r
'
)
as
f
:
with
open
(
f
"
{
data_name
}
/Bbox_2d/
{
p
}
.json
"
,
'
r
'
)
as
f
:
...
@@ -75,6 +77,36 @@ def process_compute(data_name, Nb_camera, Nb_world, list_categories, occ_target)
...
@@ -75,6 +77,36 @@ def process_compute(data_name, Nb_camera, Nb_world, list_categories, occ_target)
instance_img
=
instance
(
img
,
id
)
instance_img
=
instance
(
img
,
id
)
cv2
.
imwrite
(
f
"
{
data_name
}
/Generated/Instance_Mask/
{
categories
}
/
{
p
}
.png
"
,
255
*
instance_img
)
cv2
.
imwrite
(
f
"
{
data_name
}
/Generated/Instance_Mask/
{
categories
}
/
{
p
}
.png
"
,
255
*
instance_img
)
img
=
image
.
imread
(
f
"
{
data_name
}
/RGB/
{
p
}
.png
"
)
np
.
set_printoptions
(
precision
=
15
)
pose
=
np
.
load
(
f
'
{
data_name
}
/Generated/Pose_transformed/
{
categories
}
/
{
p
}
.npy
'
)
#print(pose)
R_exp
=
pose
[
0
:
3
,
0
:
3
]
tVec
=
pose
[
0
:
3
,
3
]
#print(tVec)
# camera = np.matrix([[1386.4138492513919, 0.0, 960.5],
# [0.0, 1386.4138492513919, 540.5],
# [0.0, 0.0, 1.0]])
fps_points
=
np
.
loadtxt
(
f
'
{
data_name
}
/Generated/FPS/
{
categories
}
_fps_3d.txt
'
)
# process(pcd_bbox, pcd, R_exp, tVec, camera, img)
points
=
process2
(
fps_points
,
R_exp
,
tVec
,
camera
,
img
,
vis
)
out
=
np
.
zeros
((
1
,
401
))
out
[
0
]
=
catergories_occ_array
[
categories
]
#obj_id #len have to be 1 !!
ind
=
1
for
point
in
points
:
out
[
0
][
ind
]
=
point
[
0
][
0
]
/
img
.
shape
[
1
]
out
[
0
][
ind
+
1
]
=
point
[
0
][
1
]
/
img
.
shape
[
0
]
ind
+=
2
np
.
savetxt
(
f
'
{
data_name
}
/Generated/FPS/
{
categories
}
/
{
p
}
.txt
'
,
out
)
#print("stop")
print
(
cont1
,
cont2
,
cont3
)
print
(
cont1
,
cont2
,
cont3
)
This diff is collapsed.
Click to expand it.
fps_alg.py
+
4
−
18
View file @
d3d18380
...
@@ -97,29 +97,15 @@ def apply_fps(pcd, fps_num):
...
@@ -97,29 +97,15 @@ def apply_fps(pcd, fps_num):
def
process2
(
pcd
,
R_exp
,
tVec
,
camera
,
img
,
vis
=
True
):
def
process2
(
pcd
,
R_exp
,
tVec
,
camera
,
img
,
vis
=
True
):
# point_cloud_in_numpy = np.asarray(pcd.points)
# center = point_cloud_in_numpy.mean(0)
#
# new_point = fps(point_cloud_in_numpy, center, fps_num)
# print(new_point)
# pcd_fps = o3d.geometry.PointCloud()
# pcd_fps.points = o3d.utility.Vector3dVector(pcd)
camera
=
np
.
array
(
camera
)
camera
=
np
.
array
(
camera
)
print
(
R_exp
)
R_exp
=
np
.
array
(
R_exp
,
dtype
=
"
float64
"
)
R_exp
=
np
.
array
(
R_exp
,
dtype
=
"
float64
"
)
print
(
R_exp
)
print
(
tVec
)
tVec
=
np
.
array
(
tVec
,
dtype
=
"
float64
"
)
tVec
=
np
.
array
(
tVec
,
dtype
=
"
float64
"
)
print
(
tVec
)
pcd_fps_numpy
=
np
.
asarray
(
pcd
)
pcd_fps_numpy
=
np
.
asarray
(
pcd
)
keypoint_2d
=
cv2
.
projectPoints
(
pcd_fps_numpy
,
R_exp
,
tVec
,
camera
,
np
.
zeros
(
shape
=
[
5
,
1
],
dtype
=
'
float64
'
))
keypoint_2d
=
cv2
.
projectPoints
(
pcd_fps_numpy
,
R_exp
,
tVec
,
camera
,
np
.
zeros
(
shape
=
[
5
,
1
],
dtype
=
'
float64
'
))
for
n
in
range
(
len
(
pcd_fps_numpy
)):
#
for n in range(len(pcd_fps_numpy)):
print
(
pcd_fps_numpy
[
n
],
'
==>
'
,
keypoint_2d
[
0
][
n
])
#
print(pcd_fps_numpy[n], '==>', keypoint_2d[0][n])
if
vis
:
if
vis
:
out
=
np
.
zeros
((
img
.
shape
[
0
],
img
.
shape
[
1
],
16
))
out
=
np
.
zeros
((
img
.
shape
[
0
],
img
.
shape
[
1
],
16
))
...
@@ -195,11 +181,11 @@ def generate_fps(data_name, camera, Nb_camera, Nb_world, list_categories, occ_ta
...
@@ -195,11 +181,11 @@ def generate_fps(data_name, camera, Nb_camera, Nb_world, list_categories, occ_ta
np
.
set_printoptions
(
precision
=
15
)
np
.
set_printoptions
(
precision
=
15
)
pose
=
np
.
load
(
f
'
{
data_name
}
/Generated/Pose_transformed/
{
categories
}
/
{
p
}
.npy
'
)
pose
=
np
.
load
(
f
'
{
data_name
}
/Generated/Pose_transformed/
{
categories
}
/
{
p
}
.npy
'
)
print
(
pose
)
#
print(pose)
R_exp
=
pose
[
0
:
3
,
0
:
3
]
R_exp
=
pose
[
0
:
3
,
0
:
3
]
tVec
=
pose
[
0
:
3
,
3
]
tVec
=
pose
[
0
:
3
,
3
]
print
(
tVec
)
#
print(tVec)
# camera = np.matrix([[1386.4138492513919, 0.0, 960.5],
# camera = np.matrix([[1386.4138492513919, 0.0, 960.5],
# [0.0, 1386.4138492513919, 540.5],
# [0.0, 1386.4138492513919, 540.5],
# [0.0, 0.0, 1.0]])
# [0.0, 0.0, 1.0]])
...
...
This diff is collapsed.
Click to expand it.
main.py
+
4
−
4
View file @
d3d18380
...
@@ -5,7 +5,7 @@ from prepare_data import reform_data
...
@@ -5,7 +5,7 @@ from prepare_data import reform_data
#from pose import transform_pose
#from pose import transform_pose
#from bbox_2d import generate_2d_bbox
#from bbox_2d import generate_2d_bbox
#from instance_mask import generate_instance_mask
#from instance_mask import generate_instance_mask
from
fps_alg
import
generate_fps
,
apply_fps
from
fps_alg
import
apply_fps
from
bbox_3d
import
generate_3d_bbox
from
bbox_3d
import
generate_3d_bbox
from
compute_features
import
process_compute
from
compute_features
import
process_compute
import
shutil
import
shutil
...
@@ -54,7 +54,7 @@ if __name__ == '__main__':
...
@@ -54,7 +54,7 @@ if __name__ == '__main__':
point_cloud
=
f
'
{
dataset_name
}
/Generated/Models/
{
categories
}
/
{
categories
.
lower
()
}
.ply
'
point_cloud
=
f
'
{
dataset_name
}
/Generated/Models/
{
categories
}
/
{
categories
.
lower
()
}
.ply
'
pcd
=
o3d
.
io
.
read_point_cloud
(
point_cloud
)
pcd
=
o3d
.
io
.
read_point_cloud
(
point_cloud
)
print
(
"
pcd
"
,
pcd
)
#
print("pcd", pcd)
fps_points
=
apply_fps
(
pcd
,
200
)
fps_points
=
apply_fps
(
pcd
,
200
)
#print(fps_points)
#print(fps_points)
...
@@ -74,9 +74,9 @@ if __name__ == '__main__':
...
@@ -74,9 +74,9 @@ if __name__ == '__main__':
reform_data
(
dataset_src
,
dataset_name
,
dataset_type
,
frame
,
Nb_camera
,
Nb_world
)
reform_data
(
dataset_src
,
dataset_name
,
dataset_type
,
frame
,
Nb_camera
,
Nb_world
)
process_compute
(
dataset_name
,
Nb_camera
,
Nb_world
,
list_categories
,
occ_target
)
process_compute
(
dataset_name
,
camera
,
Nb_camera
,
Nb_world
,
list_categories
,
occ_target
,
False
)
#transform_pose(dataset_name, Nb_camera, Nb_world, list_categories, occ_target)
#transform_pose(dataset_name, Nb_camera, Nb_world, list_categories, occ_target)
#generate_2d_bbox(dataset_name, Nb_camera, Nb_world, list_categories, occ_target)
#generate_2d_bbox(dataset_name, Nb_camera, Nb_world, list_categories, occ_target)
#generate_instance_mask(dataset_name, Nb_camera, Nb_world, list_categories, occ_target)
#generate_instance_mask(dataset_name, Nb_camera, Nb_world, list_categories, occ_target)
generate_fps
(
dataset_name
,
camera
,
Nb_camera
,
Nb_world
,
list_categories
,
occ_target
,
True
)
#
generate_fps(dataset_name, camera, Nb_camera, Nb_world, list_categories, occ_target, True)
#generate_3d_bbox(dataset_name)
#generate_3d_bbox(dataset_name)
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