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
2400fa1a
Commit
2400fa1a
authored
3 years ago
by
Shahrul Kamil bin Hassan
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
13fdcd78
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Code/OpenMV Code/square_tracking.py
+45
-0
45 additions, 0 deletions
Code/OpenMV Code/square_tracking.py
with
45 additions
and
0 deletions
Code/OpenMV Code/square_tracking.py
0 → 100644
+
45
−
0
View file @
2400fa1a
# Find Rects Example
#
# This example shows off how to find rectangles in the image using the quad threshold
# detection code from our April Tags code. The quad threshold detection algorithm
# detects rectangles in an extremely robust way and is much better than Hough
# Transform based methods. For example, it can still detect rectangles even when lens
# distortion causes those rectangles to look bent. Rounded rectangles are no problem!
# (But, given this the code will also detect small radius circles too)...
import
sensor
,
image
,
time
,
pyb
ir_led
=
pyb
.
LED
(
4
)
red_led
=
pyb
.
LED
(
1
)
b_led
=
pyb
.
LED
(
2
)
g_led
=
pyb
.
LED
(
3
)
ir_led
.
off
()
ir_led
.
on
()
red_led
.
off
()
#red_led.on()
sensor
.
reset
()
sensor
.
set_pixformat
(
sensor
.
RGB565
)
# grayscale is faster (160x120 max on OpenMV-M7)
sensor
.
set_framesize
(
sensor
.
QVGA
)
sensor
.
skip_frames
(
time
=
2000
)
sensor
.
set_auto_gain
(
False
)
# must turn this off to prevent image washout...
sensor
.
set_auto_whitebal
(
False
)
# must turn this off to prevent image washout...
sensor
.
set_auto_exposure
(
False
,
25000
)
clock
=
time
.
clock
()
while
(
True
):
ir_led
.
on
()
#red_led.on()
#b_led.on()
#g_led.on()
img
=
sensor
.
snapshot
()
# `threshold` below should be set to a high enough value to filter out noise
# rectangles detected in the image which have low edge magnitudes. Rectangles
# have larger edge magnitudes the larger and more contrasty they are...
for
r
in
img
.
find_rects
(
threshold
=
5000
):
#img.draw_rectangle(r.rect(), color = (255, 0, 0))
#for p in r.corners(): img.draw_circle(p[0], p[1], 5, color = (0, 255, 0))
print
(
r
)
print
(
"
FPS %f
"
%
clock
.
fps
())
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