Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drawing-app
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
sweng-group-15
drawing-app
Commits
05429a34
Commit
05429a34
authored
5 years ago
by
Yuriy Maksymets
Browse files
Options
Downloads
Patches
Plain Diff
Configurable rho step
parent
40f0f158
No related branches found
No related tags found
1 merge request
!65
Simple shape recognition
Pipeline
#104987
failed
5 years ago
Stage: fetch
Stage: deps
Stage: check
Stage: build
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/shapes.js
+6
-4
6 additions, 4 deletions
src/shapes.js
with
6 additions
and
4 deletions
src/shapes.js
+
6
−
4
View file @
05429a34
...
@@ -8,7 +8,6 @@ function sin(a) {
...
@@ -8,7 +8,6 @@ function sin(a) {
return
Math
.
sin
(
dtor
(
a
))
return
Math
.
sin
(
dtor
(
a
))
}
}
const
rhoStep
=
5
const
angleStep
=
10
const
angleStep
=
10
const
numAngleCells
=
180
/
angleStep
const
numAngleCells
=
180
/
angleStep
const
rhoMax
=
1000
const
rhoMax
=
1000
...
@@ -38,14 +37,14 @@ function findMaxInHough(accum, threshold) {
...
@@ -38,14 +37,14 @@ function findMaxInHough(accum, threshold) {
return
undefined
return
undefined
}
}
function
constructHoughAccumulator
(
accumulator
,
x
,
y
)
{
function
constructHoughAccumulator
(
config
,
accumulator
,
x
,
y
)
{
for
(
let
thetaIndex
=
0
;
thetaIndex
<
numAngleCells
;
thetaIndex
++
)
{
for
(
let
thetaIndex
=
0
;
thetaIndex
<
numAngleCells
;
thetaIndex
++
)
{
const
theta
=
thetaIndex
*
angleStep
const
theta
=
thetaIndex
*
angleStep
let
rho
=
x
*
cos
(
theta
)
+
y
*
sin
(
theta
)
let
rho
=
x
*
cos
(
theta
)
+
y
*
sin
(
theta
)
rho
=
Math
.
floor
(
rho
)
rho
=
Math
.
floor
(
rho
)
rho
+=
rhoMax
rho
+=
rhoMax
rho
>>=
1
rho
>>=
1
rho
/=
rhoStep
rho
/=
config
.
rhoStep
rho
=
Math
.
floor
(
rho
)
rho
=
Math
.
floor
(
rho
)
if
(
accumulator
[
thetaIndex
]
==
undefined
)
accumulator
[
thetaIndex
]
=
[]
if
(
accumulator
[
thetaIndex
]
==
undefined
)
accumulator
[
thetaIndex
]
=
[]
if
(
accumulator
[
thetaIndex
][
rho
]
==
undefined
)
{
if
(
accumulator
[
thetaIndex
][
rho
]
==
undefined
)
{
...
@@ -150,7 +149,10 @@ function recognizeRect(points) {
...
@@ -150,7 +149,10 @@ function recognizeRect(points) {
function
recognizeLine
(
points
)
{
function
recognizeLine
(
points
)
{
if
(
!
(
points
&&
points
.
length
))
return
{}
if
(
!
(
points
&&
points
.
length
))
return
{}
const
accum
=
Array
(
numAngleCells
)
const
accum
=
Array
(
numAngleCells
)
points
.
forEach
((
x
)
=>
constructHoughAccumulator
(
accum
,
...
x
))
const
houghConfig
=
{
rhoStep
:
points
.
length
>
100
?
50
:
5
,
}
points
.
forEach
((
x
)
=>
constructHoughAccumulator
(
houghConfig
,
accum
,
...
x
))
const
angle
=
findMaxInHough
(
accum
,
points
.
length
-
1
)
const
angle
=
findMaxInHough
(
accum
,
points
.
length
-
1
)
if
(
angle
!==
undefined
)
{
if
(
angle
!==
undefined
)
{
...
...
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