Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
N
November 2021 Blimp Competition
Manage
Activity
Members
Labels
Plan
Issues
2
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Shahrul Kamil bin Hassan
November 2021 Blimp Competition
Commits
a87decc7
Commit
a87decc7
authored
4 years ago
by
Zhiying Li
Browse files
Options
Downloads
Patches
Plain Diff
Add A center dot
parent
64cf3f46
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Code/Ball_Detection/PyTorch_with_ESPCAM/imageTread_AT.py
+22
-15
22 additions, 15 deletions
Code/Ball_Detection/PyTorch_with_ESPCAM/imageTread_AT.py
with
22 additions
and
15 deletions
Code/Ball_Detection/PyTorch_with_ESPCAM/imageTread_AT.py
+
22
−
15
View file @
a87decc7
...
@@ -38,30 +38,33 @@ if __name__ == "__main__":
...
@@ -38,30 +38,33 @@ if __name__ == "__main__":
#print(len(gray_image.shape))
#print(len(gray_image.shape))
h
,
w
,
_
=
frame
.
shape
h
,
w
,
_
=
frame
.
shape
# put a dot in center of the frame
cv2
.
circle
(
frame
,
(
w
//
2
,
h
//
2
),
7
,
(
255
,
0
,
0
),
-
1
)
"""
"""
If you also want to extract the tag pose, estimate_tag_pose should be set to True
If you also want to extract the tag pose, estimate_tag_pose should be set to True
and camera_params ([fx, fy, cx, cy])
and camera_params ([fx, fy, cx, cy])
and tag_size (in meters) should be supplied.
and tag_size (in meters) should be supplied.
The detect method returns a list of Detection objects each having
The detect method returns a list of Detection objects each having
the following attributes
the following attributes
(note that the ones with an asterisks are computed only if estimate_tag_pose=True):
(note that the ones with an asterisks are computed only if estimate_tag_pose=True):
"""
"""
"""
"""
So fx and fy are the focal lengths expressed in pixels.
So fx and fy are the focal lengths expressed in pixels.
Cx and Cy describe the coordinates of the so called principal
Cx and Cy describe the coordinates of the so called principal
point that should be in the center of the image.
point that should be in the center of the image.
It is e.g. not in the center of the image if you cropped the image,
It is e.g. not in the center of the image if you cropped the image,
what you should never do when calibrating.
what you should never do when calibrating.
fx, fy, cx, cy are given in Pixels in Computer Vision ( and openCV)
fx, fy, cx, cy are given in Pixels in Computer Vision ( and openCV)
but e.g. in Photogrammetry you often use mm
but e.g. in Photogrammetry you often use mm
"""
"""
fx
=
800
fx
=
800
fy
=
600
fy
=
600
cx
=
0
cx
=
40
0
cy
=
0
cy
=
30
0
results
=
detector
.
detect
(
gray_image
,
estimate_tag_pose
=
True
,
camera_params
=
[
fx
,
fy
,
cx
,
cy
],
tag_size
=
0.16
)
results
=
detector
.
detect
(
gray_image
,
estimate_tag_pose
=
True
,
camera_params
=
[
fx
,
fy
,
cx
,
cy
],
tag_size
=
0.16
)
# loop over the AprilTag detection results
# loop over the AprilTag detection results
for
r
in
results
:
for
r
in
results
:
...
@@ -84,10 +87,14 @@ if __name__ == "__main__":
...
@@ -84,10 +87,14 @@ if __name__ == "__main__":
cv2
.
circle
(
frame
,
(
cX
,
cY
),
5
,
(
0
,
0
,
255
),
-
1
)
cv2
.
circle
(
frame
,
(
cX
,
cY
),
5
,
(
0
,
0
,
255
),
-
1
)
# draw the tag family on the image
# draw the tag family on the image
print
(
"
cX,cY:{},{}
"
.
format
(
cX
,
cY
))
print
(
"
cX,cY:{},{}
"
.
format
(
cX
,
cY
))
tagFamily
=
r
.
tag_family
.
decode
(
"
utf-8
"
)
tagFamily
=
r
.
tag_family
.
decode
(
"
utf-8
"
)
tid
=
r
.
tag_id
tid
=
r
.
tag_id
cv2
.
putText
(
frame
,
tagFamily
,
(
ptA
[
0
],
ptA
[
1
]
-
15
),
cv2
.
putText
(
frame
,
tagFamily
,
(
ptA
[
0
],
ptA
[
1
]
-
15
),
cv2
.
FONT_HERSHEY_SIMPLEX
,
0.5
,
(
0
,
255
,
0
),
2
)
cv2
.
FONT_HERSHEY_SIMPLEX
,
0.5
,
(
0
,
255
,
0
),
2
)
cv2
.
putText
(
frame
,
"
tx: {:.2f} ty: {:.2f} tz:{:.2f}
"
.
format
(
tx
[
0
],
ty
[
0
],
tz
[
0
]),
(
ptA
[
0
],
ptA
[
1
]
+
30
),
cv2
.
FONT_HERSHEY_SIMPLEX
,
0.5
,
(
0
,
255
,
0
),
2
)
print
(
"
[INFO] tag id: {}
"
.
format
(
tid
))
print
(
"
[INFO] tag id: {}
"
.
format
(
tid
))
# show the output image after AprilTag detection
# show the output image after AprilTag detection
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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