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
13fdcd78
Commit
13fdcd78
authored
4 years ago
by
Shahrul Kamil bin Hassan
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
cb884615
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Code/OpenMV Code/find_circles_1.py
+54
-0
54 additions, 0 deletions
Code/OpenMV Code/find_circles_1.py
with
54 additions
and
0 deletions
Code/OpenMV Code/find_circles_1.py
0 → 100644
+
54
−
0
View file @
13fdcd78
# Find Circles Example
#
# This example shows off how to find circles in the image using the Hough
# Transform. https://en.wikipedia.org/wiki/Circle_Hough_Transform
#
# Note that the find_circles() method will only find circles which are completely
# inside of the image. Circles which go outside of the image/roi are ignored...
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
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
,
10000
)
clock
=
time
.
clock
()
while
(
True
):
clock
.
tick
()
ir_led
.
on
()
#red_led.on()
#b_led.on()
#g_led.on()
img
=
sensor
.
snapshot
().
lens_corr
(
1.8
)
# Circle objects have four values: x, y, r (radius), and magnitude. The
# magnitude is the strength of the detection of the circle. Higher is
# better...
# `threshold` controls how many circles are found. Increase its value
# to decrease the number of circles detected...
# `x_margin`, `y_margin`, and `r_margin` control the merging of similar
# circles in the x, y, and r (radius) directions.
# r_min, r_max, and r_step control what radiuses of circles are tested.
# Shrinking the number of tested circle radiuses yields a big performance boost.
for
c
in
img
.
find_circles
(
threshold
=
2000
,
x_margin
=
10
,
y_margin
=
10
,
r_margin
=
10
,
r_min
=
2
,
r_max
=
100
,
r_step
=
2
):
img
.
draw_circle
(
c
.
x
(),
c
.
y
(),
c
.
r
(),
color
=
(
255
,
0
,
0
))
print
(
c
)
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