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
d40397b6
Commit
d40397b6
authored
2 years ago
by
Mahmoud Ahmed Ali
Browse files
Options
Downloads
Patches
Plain Diff
Add data label file
parent
816ba080
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
data_label.py
+29
-0
29 additions, 0 deletions
data_label.py
with
29 additions
and
0 deletions
data_label.py
0 → 100644
+
29
−
0
View file @
d40397b6
import
cv2
import
numpy
as
np
for
im
in
range
(
4995
):
id_obj
=
0.0
res_all
=
[]
for
obj
in
[
'
banana_mask
'
,
'
orange_mask
'
,
'
pear_mask
'
]:
res
=
[
id_obj
]
image
=
cv2
.
imread
(
f
"
{
obj
}
/
{
im
}
.png
"
,
0
)
image
=
image
/
255.0
_
,
contours
,
_
=
cv2
.
findContours
(
image
.
astype
(
np
.
uint8
),
cv2
.
RETR_TREE
,
cv2
.
CHAIN_APPROX_NONE
)
print
(
len
(
contours
[
0
]))
for
i
in
range
(
len
(
contours
[
0
])):
x
=
contours
[
0
][
i
][
0
][
0
]
/
640.0
res
.
append
(
x
)
y
=
contours
[
0
][
i
][
0
][
1
]
/
480.0
res
.
append
(
y
)
id_obj
+=
1.0
res_all
.
append
(
res
)
# res_ln = len(res_all)
# matrix = np.array([res_all[0], res_all[1], res_all[2]]).reshape(3, 1)
# np.savetxt(f'labels_all/{im}.txt', np.array(res_all).reshape((1,3)))
a_file
=
open
(
f
'
labels_all/
{
im
}
.txt
'
,
"
w
"
)
for
row
in
res_all
:
np
.
savetxt
(
a_file
,
np
.
array
(
row
).
reshape
(
1
,
len
(
row
)))
a_file
.
close
()
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