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
9fd608e8
Commit
9fd608e8
authored
2 years ago
by
Guillaume Duret
Browse files
Options
Downloads
Patches
Plain Diff
new set up rearangement
parent
b15e8a39
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
compute_features.py
+30
-15
30 additions, 15 deletions
compute_features.py
main.py
+6
-6
6 additions, 6 deletions
main.py
with
36 additions
and
21 deletions
compute_features.py
+
30
−
15
View file @
9fd608e8
...
...
@@ -89,16 +89,16 @@ def process_compute(data_name, camera, Nb_camera, World_begin, Nb_world, list_ca
meta
[
'
Nb_instance_category
'
]
=
1
if
not
os
.
path
.
isfile
(
f
'
{
data_name
}
/Generated/
Meta_Gen/
{
categories
}
/
{
categories
}
.json
'
):
with
open
(
f
'
{
data_name
}
/Generated/
Meta_Gen/
{
categories
}
/
{
categories
}
.json
'
,
mode
=
'
w
'
)
as
f
:
if
not
os
.
path
.
isfile
(
f
'
{
data_name
}
/Generated/
{
categories
}
/
Meta_Gen/
{
categories
}
.json
'
):
with
open
(
f
'
{
data_name
}
/Generated/
{
categories
}
/
Meta_Gen/
{
categories
}
.json
'
,
mode
=
'
w
'
)
as
f
:
feeds
=
{}
feeds
[
meta
[
'
id_generated
'
]]
=
meta
f
.
write
(
json
.
dumps
(
feeds
,
indent
=
2
))
else
:
with
open
(
f
'
{
data_name
}
/Generated/
Meta_Gen/
{
categories
}
/
{
categories
}
.json
'
)
as
feedsjson
:
with
open
(
f
'
{
data_name
}
/Generated/
{
categories
}
/
Meta_Gen/
{
categories
}
.json
'
)
as
feedsjson
:
feeds
=
json
.
load
(
feedsjson
)
feeds
[
meta
[
'
id_generated
'
]]
=
meta
with
open
(
f
'
{
data_name
}
/Generated/
Meta_Gen/
{
categories
}
/
{
categories
}
.json
'
,
mode
=
'
w
'
)
as
f
:
with
open
(
f
'
{
data_name
}
/Generated/
{
categories
}
/
Meta_Gen/
{
categories
}
.json
'
,
mode
=
'
w
'
)
as
f
:
f
.
write
(
json
.
dumps
(
feeds
,
indent
=
4
))
# with open(f'{data_name}/Generated/Meta_Gen/{categories}/{categories}.json', "a") as meta_file:
...
...
@@ -116,13 +116,13 @@ def process_compute(data_name, camera, Nb_camera, World_begin, Nb_world, list_ca
T_exp
=
transformation
@
xyz
T_exp
=
np
.
array
(
T_exp
)
num_arr
=
np
.
c_
[
R_exp
,
T_exp
[
0
]]
np
.
save
(
f
'
{
data_name
}
/Generated/Pose_transformed/
{
categories
}
/
{
p
}
.npy
'
,
num_arr
)
# save
np
.
save
(
f
'
{
data_name
}
/Generated/
{
categories
}
/
Pose_transformed/
{
p
}
.npy
'
,
num_arr
)
# save
else
:
continue
if
data_Bbox_2d
[
k
][
'
id
'
]
==
catergories_occ_array
[
categories
][
0
]:
bbox
=
bbox_2d
(
data_Bbox_2d
[
k
])
np
.
savetxt
(
f
'
{
data_name
}
/Generated/
Bbox/
{
categories
}
/
{
p
}
.txt
'
,
np
.
array
(
bbox
).
reshape
((
1
,
4
)))
# save
np
.
savetxt
(
f
'
{
data_name
}
/Generated/
{
categories
}
/
Bbox/
{
p
}
.txt
'
,
np
.
array
(
bbox
).
reshape
((
1
,
4
)))
# save
else
:
continue
...
...
@@ -130,13 +130,14 @@ def process_compute(data_name, camera, Nb_camera, World_begin, Nb_world, list_ca
img
=
cv2
.
imread
(
f
"
{
data_name
}
/Instance_Segmentation/
{
p
}
.png
"
,
cv2
.
IMREAD_UNCHANGED
)
# plt.imread(path)
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/
{
categories
}
/
Instance_Mask/
{
p
}
.png
"
,
255
*
instance_img
)
img
=
image
.
imread
(
f
"
{
data_name
}
/RGB/
{
p
}
.png
"
)
img
=
cv2
.
imread
(
f
"
{
data_name
}
/RGB/
{
p
}
.png
"
)
cv2
.
imwrite
(
f
"
{
data_name
}
/Generated/
{
categories
}
/RGB_Gen/
{
p
}
.png
"
,
img
)
np
.
set_printoptions
(
precision
=
15
)
pose
=
np
.
load
(
f
'
{
data_name
}
/Generated/Pose_transformed/
{
categories
}
/
{
p
}
.npy
'
)
pose
=
np
.
load
(
f
'
{
data_name
}
/Generated/
{
categories
}
/
Pose_transformed/
{
p
}
.npy
'
)
#print(pose)
R_exp
=
pose
[
0
:
3
,
0
:
3
]
tVec
=
pose
[
0
:
3
,
3
]
...
...
@@ -147,18 +148,32 @@ def process_compute(data_name, camera, Nb_camera, World_begin, Nb_world, list_ca
# [0.0, 0.0, 1.0]])
fps_points
=
np
.
loadtxt
(
f
'
{
data_name
}
/Generated/
FPS
/
{
categories
}
_fps_3d.txt
'
)
fps_points
=
np
.
loadtxt
(
f
'
{
data_name
}
/Generated/
{
categories
}
/
{
categories
}
_fps_3d.txt
'
)
# process(pcd_bbox, pcd, R_exp, tVec, camera, img)
center
=
fps_points
.
mean
(
0
)
fps_points
=
np
.
append
(
fps_points
,
[
center
],
axis
=
0
)
points
=
process2
(
fps_points
,
R_exp
,
tVec
,
camera
,
img
,
vis
)
out
=
np
.
zeros
((
1
,
401
))
#out = np.zeros((1, ))
out
=
[
int
(
catergories_occ_array
[
categories
][
0
])]
# [catergories_occ_array[categories][0]] #obj_id #len have to be 1 !!
print
(
out
)
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
]
#out[0][ind] = point[0][0] / img.shape[1]
#[0][ind + 1] = point[0][1] / img.shape[0]
x
=
point
[
0
][
0
]
/
img
.
shape
[
1
]
y
=
point
[
0
][
1
]
/
img
.
shape
[
0
]
out
.
append
(
x
)
out
.
append
(
y
)
ind
+=
2
np
.
savetxt
(
f
'
{
data_name
}
/Generated/FPS/
{
categories
}
/
{
p
}
.txt
'
,
out
)
print
(
"
points
"
,
points
)
print
(
"
out
"
,
out
)
print
(
"
np.array(out).reshape(1, len(out))
"
,
np
.
array
(
out
).
reshape
(
1
,
len
(
out
)))
np
.
savetxt
(
f
'
{
data_name
}
/Generated/
{
categories
}
/FPS/
{
p
}
.txt
'
,
np
.
array
(
out
).
reshape
(
1
,
len
(
out
)))
#print("stop")
with
open
(
f
'
{
data_name
}
/Generated/Count_
{
p
}
.json
'
,
mode
=
'
w
'
)
as
f
:
...
...
This diff is collapsed.
Click to expand it.
main.py
+
6
−
6
View file @
9fd608e8
...
...
@@ -25,9 +25,9 @@ def generate_folders(name, list_categories):
os
.
mkdir
(
f
"
{
name
}
/
{
f
}
"
)
else
:
for
cat
in
list_categories
:
is_exist2
=
os
.
path
.
exists
(
f
"
{
name
}
/Generated/
{
f
}
/
{
cat
}
"
)
is_exist2
=
os
.
path
.
exists
(
f
"
{
name
}
/Generated/
{
cat
}
/
{
f
}
"
)
if
not
is_exist2
:
os
.
makedirs
(
f
"
{
name
}
/Generated/
{
f
}
/
{
cat
}
"
)
os
.
makedirs
(
f
"
{
name
}
/Generated/
{
cat
}
/
{
f
}
"
)
if
__name__
==
'
__main__
'
:
...
...
@@ -60,18 +60,18 @@ if __name__ == '__main__':
generate_folders
(
dataset_name
,
list_categories
)
for
cat
in
list_categories
:
src_bbox
=
f
"
Models/
{
cat
}
/
{
cat
.
lower
()
}
.ply
"
dst_bbox
=
f
"
{
dataset_name
}
/Generated/
Models/
{
cat
}
/
{
cat
.
lower
()
}
.ply
"
dst_bbox
=
f
"
{
dataset_name
}
/Generated/
{
cat
}
/
{
cat
.
lower
()
}
.ply
"
shutil
.
copy
(
src_bbox
,
dst_bbox
)
for
categories
in
list_categories
:
point_cloud
=
f
'
{
dataset_name
}
/Generated/
Models/
{
categories
}
/
{
categories
.
lower
()
}
.ply
'
point_cloud
=
f
'
{
dataset_name
}
/Generated/
{
categories
}
/
{
categories
.
lower
()
}
.ply
'
pcd
=
o3d
.
io
.
read_point_cloud
(
point_cloud
)
#print("pcd", pcd)
fps_points
=
apply_fps
(
pcd
,
200
)
fps_points
=
apply_fps
(
pcd
,
8
)
#print(fps_points)
np
.
savetxt
(
f
'
{
dataset_name
}
/Generated/
FPS
/
{
categories
}
_fps_3d.txt
'
,
fps_points
)
np
.
savetxt
(
f
'
{
dataset_name
}
/Generated/
{
categories
}
/
{
categories
}
_fps_3d.txt
'
,
fps_points
)
if
choice
==
'
high
'
:
...
...
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