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
ecc9cd2f
Commit
ecc9cd2f
authored
2 years ago
by
Guillaume Duret
Browse files
Options
Downloads
Patches
Plain Diff
isolate generated data for learning from raw data
parent
bcb6847d
No related branches found
No related tags found
No related merge requests found
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
bbox_2d.py
+3
-3
3 additions, 3 deletions
bbox_2d.py
bbox_3d.py
+1
-1
1 addition, 1 deletion
bbox_3d.py
fps_alg.py
+5
-5
5 additions, 5 deletions
fps_alg.py
instance_mask.py
+2
-1
2 additions, 1 deletion
instance_mask.py
main.py
+7
-17
7 additions, 17 deletions
main.py
pose.py
+3
-3
3 additions, 3 deletions
pose.py
with
21 additions
and
30 deletions
bbox_2d.py
+
3
−
3
View file @
ecc9cd2f
...
@@ -31,17 +31,17 @@ def generate_2d_bbox(data_name, Nb_camera, Nb_world):
...
@@ -31,17 +31,17 @@ def generate_2d_bbox(data_name, Nb_camera, Nb_world):
if
data
[
i
][
'
id
'
]
==
4
:
if
data
[
i
][
'
id
'
]
==
4
:
cont1
+=
1
cont1
+=
1
bbox
=
bbox_2d
(
data
[
i
])
bbox
=
bbox_2d
(
data
[
i
])
np
.
savetxt
(
f
'
{
data_name
}
/Bbox/banana1/
{
p
}
.txt
'
,
np
.
array
(
bbox
).
reshape
((
1
,
4
)))
# save
np
.
savetxt
(
f
'
{
data_name
}
/
Generated/
Bbox/banana1/
{
p
}
.txt
'
,
np
.
array
(
bbox
).
reshape
((
1
,
4
)))
# save
elif
data
[
i
][
'
id
'
]
==
5
:
elif
data
[
i
][
'
id
'
]
==
5
:
cont2
+=
1
cont2
+=
1
bbox
=
bbox_2d
(
data
[
i
])
bbox
=
bbox_2d
(
data
[
i
])
np
.
savetxt
(
f
'
{
data_name
}
/Bbox/orange2/
{
p
}
.txt
'
,
np
.
array
(
bbox
).
reshape
((
1
,
4
)))
# save
np
.
savetxt
(
f
'
{
data_name
}
/
Generated/
Bbox/orange2/
{
p
}
.txt
'
,
np
.
array
(
bbox
).
reshape
((
1
,
4
)))
# save
elif
data
[
i
][
'
id
'
]
==
6
:
elif
data
[
i
][
'
id
'
]
==
6
:
cont3
+=
1
cont3
+=
1
bbox
=
bbox_2d
(
data
[
i
])
bbox
=
bbox_2d
(
data
[
i
])
np
.
savetxt
(
f
'
{
data_name
}
/Bbox/pear2/
{
p
}
.txt
'
,
np
.
array
(
bbox
).
reshape
((
1
,
4
)))
# save
np
.
savetxt
(
f
'
{
data_name
}
/
Generated/
Bbox/pear2/
{
p
}
.txt
'
,
np
.
array
(
bbox
).
reshape
((
1
,
4
)))
# save
else
:
else
:
continue
continue
...
...
This diff is collapsed.
Click to expand it.
bbox_3d.py
+
1
−
1
View file @
ecc9cd2f
...
@@ -23,6 +23,6 @@ def generate_3d_bbox(data_name):
...
@@ -23,6 +23,6 @@ def generate_3d_bbox(data_name):
for
key
,
val
in
objs
.
items
():
for
key
,
val
in
objs
.
items
():
ext
=
[
x
/
2
for
x
in
val
]
ext
=
[
x
/
2
for
x
in
val
]
bbox
=
get_bbox
(
ext
)
bbox
=
get_bbox
(
ext
)
np
.
savetxt
(
f
'
{
data_name
}
/Bbox/
{
key
}
_bbox_3d.txt
'
,
bbox
)
np
.
savetxt
(
f
'
{
data_name
}
/
Generated/
Bbox/
{
key
}
_bbox_3d.txt
'
,
bbox
)
# print(ext)
# print(ext)
This diff is collapsed.
Click to expand it.
fps_alg.py
+
5
−
5
View file @
ecc9cd2f
...
@@ -167,21 +167,21 @@ def generate_fps(data_name, camera, Nb_camera, Nb_world, list_objects, vis=False
...
@@ -167,21 +167,21 @@ def generate_fps(data_name, camera, Nb_camera, Nb_world, list_objects, vis=False
# Read the point cloud
# Read the point cloud
for
obj
in
list_objects
:
for
obj
in
list_objects
:
obj_id
=
1
obj_id
=
1
point_cloud
=
f
'
{
data_name
}
/Models/
{
obj
}
/
{
obj
.
lower
()
}
.ply
'
point_cloud
=
f
'
{
data_name
}
/
Generated/
Models/
{
obj
}
/
{
obj
.
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
)
np
.
savetxt
(
f
'
{
data_name
}
/FPS/
{
obj
}
_fps_3d.txt
'
,
fps_points
)
np
.
savetxt
(
f
'
{
data_name
}
/
Generated/
FPS/
{
obj
}
_fps_3d.txt
'
,
fps_points
)
for
i
in
range
(
1
,
Nb_camera
*
Nb_world
+
1
):
for
i
in
range
(
1
,
Nb_camera
*
Nb_world
+
1
):
path
=
Path
(
f
'
{
data_name
}
/Pose_transformed/
{
obj
}
/
{
i
}
.npy
'
)
path
=
Path
(
f
'
{
data_name
}
/
Generated/
Pose_transformed/
{
obj
}
/
{
i
}
.npy
'
)
if
path
.
is_file
():
if
path
.
is_file
():
img
=
image
.
imread
(
f
"
{
data_name
}
/RGB/
{
i
}
.png
"
)
img
=
image
.
imread
(
f
"
{
data_name
}
/RGB/
{
i
}
.png
"
)
pose
=
np
.
load
(
f
'
{
data_name
}
/Pose_transformed/
{
obj
}
/
{
i
}
.npy
'
)
pose
=
np
.
load
(
f
'
{
data_name
}
/
Generated/
Pose_transformed/
{
obj
}
/
{
i
}
.npy
'
)
R_exp
=
pose
[
0
:
3
,
0
:
3
]
R_exp
=
pose
[
0
:
3
,
0
:
3
]
tVec
=
pose
[
0
:
3
,
3
]
tVec
=
pose
[
0
:
3
,
3
]
...
@@ -199,6 +199,6 @@ def generate_fps(data_name, camera, Nb_camera, Nb_world, list_objects, vis=False
...
@@ -199,6 +199,6 @@ def generate_fps(data_name, camera, Nb_camera, Nb_world, list_objects, vis=False
out
[
0
][
ind
]
=
point
[
0
][
0
]
/
img
.
shape
[
1
]
out
[
0
][
ind
]
=
point
[
0
][
0
]
/
img
.
shape
[
1
]
out
[
0
][
ind
+
1
]
=
point
[
0
][
1
]
/
img
.
shape
[
0
]
out
[
0
][
ind
+
1
]
=
point
[
0
][
1
]
/
img
.
shape
[
0
]
ind
+=
2
ind
+=
2
np
.
savetxt
(
f
'
{
data_name
}
/FPS/
{
obj
}
/
{
i
}
.txt
'
,
out
)
np
.
savetxt
(
f
'
{
data_name
}
/
Generated/
FPS/
{
obj
}
/
{
i
}
.txt
'
,
out
)
print
(
"
stop
"
)
print
(
"
stop
"
)
obj_id
+=
1
obj_id
+=
1
This diff is collapsed.
Click to expand it.
instance_mask.py
+
2
−
1
View file @
ecc9cd2f
...
@@ -131,5 +131,6 @@ def generate_instance_mask(data_name, Nb_camera, Nb_world):
...
@@ -131,5 +131,6 @@ def generate_instance_mask(data_name, Nb_camera, Nb_world):
instance_img
=
instance
(
img
,
id
)
instance_img
=
instance
(
img
,
id
)
print
(
"
instance_img[308][817] :
"
,
instance_img
[
308
][
817
])
print
(
"
instance_img[308][817] :
"
,
instance_img
[
308
][
817
])
cv2
.
imwrite
(
f
"
{
data_name
}
/Instance_Mask/
{
key
}
/
{
k
}
.png
"
,
255
*
instance_img
)
cv2
.
imwrite
(
f
"
{
data_name
}
/Generated/Instance_Mask/
{
key
}
/
{
k
}
.png
"
,
255
*
instance_img
)
This diff is collapsed.
Click to expand it.
main.py
+
7
−
17
View file @
ecc9cd2f
...
@@ -19,12 +19,12 @@ def generate_folders(name):
...
@@ -19,12 +19,12 @@ def generate_folders(name):
for
f
in
folders
:
for
f
in
folders
:
is_exist
=
os
.
path
.
exists
(
f
"
{
name
}
/
{
f
}
"
)
is_exist
=
os
.
path
.
exists
(
f
"
{
name
}
/
{
f
}
"
)
if
not
is_exist
:
if
not
is_exist
:
if
f
not
in
[
"
Instance_Mask
"
,
"
Models
"
,
"
Pose_transformed
"
,
"
Bbox
"
,
"
FPS
"
]:
if
f
not
in
[
"
RGB_Gen
"
,
"
Instance_Mask
"
,
"
Models
"
,
"
Pose_transformed
"
,
"
Bbox
"
,
"
FPS
"
]:
os
.
mkdir
(
f
"
{
name
}
/
{
f
}
"
)
os
.
mkdir
(
f
"
{
name
}
/
{
f
}
"
)
else
:
else
:
os
.
makedirs
(
f
"
{
name
}
/
{
f
}
/banana1
"
)
os
.
makedirs
(
f
"
{
name
}
/
Generated/
{
f
}
/banana1
"
)
os
.
makedirs
(
f
"
{
name
}
/
{
f
}
/orange2
"
)
os
.
makedirs
(
f
"
{
name
}
/
Generated/
{
f
}
/orange2
"
)
os
.
makedirs
(
f
"
{
name
}
/
{
f
}
/pear2
"
)
os
.
makedirs
(
f
"
{
name
}
/
Generated/
{
f
}
/pear2
"
)
...
@@ -189,8 +189,6 @@ if __name__ == '__main__':
...
@@ -189,8 +189,6 @@ if __name__ == '__main__':
# futur parameters :
# futur parameters :
Categories
=
[]
# to read
Categories
=
[]
# to read
Nb_instance
=
1
Nb_instance
=
1
Occ_target
=
0.5
Occ_target
=
0.5
...
@@ -202,18 +200,12 @@ if __name__ == '__main__':
...
@@ -202,18 +200,12 @@ if __name__ == '__main__':
dataset_src
=
"
/media/gduret/DATA/dataset/s2rg/Fruits_all_medium/data
"
dataset_src
=
"
/media/gduret/DATA/dataset/s2rg/Fruits_all_medium/data
"
catergories_instance_array_id_to_cat
,
catergories_instance_array_cat_to_id
=
compute_categories_id
(
dataset_src
,
1
)
catergories_instance_array_id_to_cat
,
catergories_instance_array_cat_to_id
=
compute_categories_id
(
dataset_src
,
1
)
choice
=
"
low
"
choice
=
"
low
"
data_options
=
{
"
high
"
:
"
ground_truth_rgb
"
,
data_options
=
{
"
high
"
:
"
ground_truth_rgb
"
,
"
low
"
:
"
ground_truth_depth
"
}
"
low
"
:
"
ground_truth_depth
"
}
dataset_type
=
data_options
[
choice
]
dataset_type
=
data_options
[
choice
]
compute_id_good_occ
(
dataset_src
,
1
,
1
,
dataset_type
,
"
1_926000000
"
,
catergories_instance_array_id_to_cat
,
catergories_instance_array_cat_to_id
,
Occ_target
)
compute_id_good_occ
(
dataset_src
,
1
,
1
,
dataset_type
,
"
1_926000000
"
,
catergories_instance_array_id_to_cat
,
catergories_instance_array_cat_to_id
,
Occ_target
)
...
@@ -224,7 +216,7 @@ if __name__ == '__main__':
...
@@ -224,7 +216,7 @@ if __name__ == '__main__':
list_obj
=
[
"
banana1
"
,
"
orange2
"
,
"
pear2
"
]
list_obj
=
[
"
banana1
"
,
"
orange2
"
,
"
pear2
"
]
for
obj
in
list_obj
:
for
obj
in
list_obj
:
src_bbox
=
f
"
Models/
{
obj
}
/
{
obj
.
lower
()
}
.ply
"
src_bbox
=
f
"
Models/
{
obj
}
/
{
obj
.
lower
()
}
.ply
"
dst_bbox
=
f
"
{
dataset_name
}
/Models/
{
obj
}
/
{
obj
.
lower
()
}
.ply
"
dst_bbox
=
f
"
{
dataset_name
}
/
Generated/
Models/
{
obj
}
/
{
obj
.
lower
()
}
.ply
"
shutil
.
copy
(
src_bbox
,
dst_bbox
)
shutil
.
copy
(
src_bbox
,
dst_bbox
)
if
choice
==
'
high
'
:
if
choice
==
'
high
'
:
...
@@ -236,7 +228,7 @@ if __name__ == '__main__':
...
@@ -236,7 +228,7 @@ if __name__ == '__main__':
[
0.0
,
1086.5054444841007
,
360.5
],
[
0.0
,
1086.5054444841007
,
360.5
],
[
0.0
,
0.0
,
1.0
]])
[
0.0
,
0.0
,
1.0
]])
np
.
savetxt
(
f
'
{
dataset_name
}
/camera_
{
choice
}
.txt
'
,
camera
)
np
.
savetxt
(
f
'
{
dataset_name
}
/
Generated/
camera_
{
choice
}
.txt
'
,
camera
)
# frame = "1_600000000"
# frame = "1_600000000"
frame
=
"
1_926000000
"
frame
=
"
1_926000000
"
...
@@ -244,10 +236,8 @@ if __name__ == '__main__':
...
@@ -244,10 +236,8 @@ if __name__ == '__main__':
Nb_world
=
2
Nb_world
=
2
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
)
transform_pose
(
dataset_name
,
Nb_camera
,
Nb_world
,
Occ_target
)
transform_pose
(
dataset_name
,
Nb_camera
,
Nb_world
,
Occ_target
)
generate_2d_bbox
(
dataset_name
,
Nb_camera
,
Nb_world
)
generate_2d_bbox
(
dataset_name
,
Nb_camera
,
Nb_world
)
generate_instance_mask
(
dataset_name
,
Nb_camera
,
Nb_world
)
generate_instance_mask
(
dataset_name
,
Nb_camera
,
Nb_world
)
generate_fps
(
dataset_name
,
camera
,
Nb_camera
,
Nb_world
,
list_obj
,
Tru
e
)
generate_fps
(
dataset_name
,
camera
,
Nb_camera
,
Nb_world
,
list_obj
,
Fals
e
)
#generate_3d_bbox(dataset_name)
#generate_3d_bbox(dataset_name)
This diff is collapsed.
Click to expand it.
pose.py
+
3
−
3
View file @
ecc9cd2f
...
@@ -113,7 +113,7 @@ def transform_pose(data_name, Nb_camera, Nb_world, occ_target):
...
@@ -113,7 +113,7 @@ def transform_pose(data_name, Nb_camera, Nb_world, occ_target):
T_exp
=
transformation
@
xyz
T_exp
=
transformation
@
xyz
T_exp
=
np
.
array
(
T_exp
)
T_exp
=
np
.
array
(
T_exp
)
num_arr
=
np
.
c_
[
R_exp
,
T_exp
[
0
]]
num_arr
=
np
.
c_
[
R_exp
,
T_exp
[
0
]]
np
.
save
(
f
'
{
data_name
}
/Pose_transformed/banana1/
{
p
}
.npy
'
,
num_arr
)
# save
np
.
save
(
f
'
{
data_name
}
/
Generated/
Pose_transformed/banana1/
{
p
}
.npy
'
,
num_arr
)
# save
elif
len
(
catergories_occ_array
[
'
orange2
'
])
==
1
and
data
[
k
][
'
id
'
]
==
catergories_occ_array
[
'
orange2
'
][
0
]:
elif
len
(
catergories_occ_array
[
'
orange2
'
])
==
1
and
data
[
k
][
'
id
'
]
==
catergories_occ_array
[
'
orange2
'
][
0
]:
cont2
+=
1
cont2
+=
1
...
@@ -126,7 +126,7 @@ def transform_pose(data_name, Nb_camera, Nb_world, occ_target):
...
@@ -126,7 +126,7 @@ def transform_pose(data_name, Nb_camera, Nb_world, occ_target):
T_exp
=
transformation
@
xyz
T_exp
=
transformation
@
xyz
T_exp
=
np
.
array
(
T_exp
)
T_exp
=
np
.
array
(
T_exp
)
num_arr
=
np
.
c_
[
R_exp
,
T_exp
[
0
]]
num_arr
=
np
.
c_
[
R_exp
,
T_exp
[
0
]]
np
.
save
(
f
'
{
data_name
}
/Pose_transformed/orange2/
{
p
}
.npy
'
,
num_arr
)
# save
np
.
save
(
f
'
{
data_name
}
/
Generated/
Pose_transformed/orange2/
{
p
}
.npy
'
,
num_arr
)
# save
elif
len
(
catergories_occ_array
[
'
pear2
'
])
==
1
and
data
[
k
][
'
id
'
]
==
catergories_occ_array
[
'
pear2
'
][
0
]:
elif
len
(
catergories_occ_array
[
'
pear2
'
])
==
1
and
data
[
k
][
'
id
'
]
==
catergories_occ_array
[
'
pear2
'
][
0
]:
cont3
+=
1
cont3
+=
1
...
@@ -139,7 +139,7 @@ def transform_pose(data_name, Nb_camera, Nb_world, occ_target):
...
@@ -139,7 +139,7 @@ def transform_pose(data_name, Nb_camera, Nb_world, occ_target):
T_exp
=
transformation
@
xyz
T_exp
=
transformation
@
xyz
T_exp
=
np
.
array
(
T_exp
)
T_exp
=
np
.
array
(
T_exp
)
num_arr
=
np
.
c_
[
R_exp
,
T_exp
[
0
]]
num_arr
=
np
.
c_
[
R_exp
,
T_exp
[
0
]]
np
.
save
(
f
'
{
data_name
}
/Pose_transformed/pear2/
{
p
}
.npy
'
,
num_arr
)
# save
np
.
save
(
f
'
{
data_name
}
/
Generated/
Pose_transformed/pear2/
{
p
}
.npy
'
,
num_arr
)
# save
else
:
else
:
continue
continue
print
(
cont1
,
cont2
,
cont3
)
print
(
cont1
,
cont2
,
cont3
)
...
...
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