Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv_contrib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv_contrib
Commits
5032b58e
Commit
5032b58e
authored
Mar 21, 2018
by
berak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
aruco: add a user supplied random seed for creating custom dictionaries
parent
2888fea1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
14 deletions
+19
-14
dictionary.hpp
modules/aruco/include/opencv2/aruco/dictionary.hpp
+7
-4
dictionary.cpp
modules/aruco/src/dictionary.cpp
+12
-10
No files found.
modules/aruco/include/opencv2/aruco/dictionary.hpp
View file @
5032b58e
...
...
@@ -84,14 +84,14 @@ class CV_EXPORTS_W Dictionary {
/**
* @see generateCustomDictionary
*/
CV_WRAP_AS
(
create
)
static
Ptr
<
Dictionary
>
create
(
int
nMarkers
,
int
markerSize
);
CV_WRAP_AS
(
create
)
static
Ptr
<
Dictionary
>
create
(
int
nMarkers
,
int
markerSize
,
int
randomSeed
=
0
);
/**
* @see generateCustomDictionary
*/
CV_WRAP_AS
(
create_from
)
static
Ptr
<
Dictionary
>
create
(
int
nMarkers
,
int
markerSize
,
const
Ptr
<
Dictionary
>
&
baseDictionary
);
const
Ptr
<
Dictionary
>
&
baseDictionary
,
int
randomSeed
=
0
);
/**
* @see getPredefinedDictionary
...
...
@@ -176,7 +176,8 @@ CV_EXPORTS_W Ptr<Dictionary> getPredefinedDictionary(int dict);
*/
CV_EXPORTS_AS
(
custom_dictionary
)
Ptr
<
Dictionary
>
generateCustomDictionary
(
int
nMarkers
,
int
markerSize
);
int
markerSize
,
int
randomSeed
=
0
);
/**
...
...
@@ -185,6 +186,7 @@ CV_EXPORTS_AS(custom_dictionary) Ptr<Dictionary> generateCustomDictionary(
* @param nMarkers number of markers in the dictionary
* @param markerSize number of bits per dimension of each markers
* @param baseDictionary Include the markers in this dictionary at the beginning (optional)
* @param randomSeed a user supplied seed for theRNG()
*
* This function creates a new dictionary composed by nMarkers markers and each markers composed
* by markerSize x markerSize bits. If baseDictionary is provided, its markers are directly
...
...
@@ -194,7 +196,8 @@ CV_EXPORTS_AS(custom_dictionary) Ptr<Dictionary> generateCustomDictionary(
CV_EXPORTS_AS
(
custom_dictionary_from
)
Ptr
<
Dictionary
>
generateCustomDictionary
(
int
nMarkers
,
int
markerSize
,
const
Ptr
<
Dictionary
>
&
baseDictionary
);
const
Ptr
<
Dictionary
>
&
baseDictionary
,
int
randomSeed
=
0
);
...
...
modules/aruco/src/dictionary.cpp
View file @
5032b58e
...
...
@@ -69,17 +69,18 @@ Dictionary::Dictionary(const Mat &_bytesList, int _markerSize, int _maxcorr) {
/**
*/
Ptr
<
Dictionary
>
Dictionary
::
create
(
int
nMarkers
,
int
markerSize
)
{
Ptr
<
Dictionary
>
Dictionary
::
create
(
int
nMarkers
,
int
markerSize
,
int
randomSeed
)
{
const
Ptr
<
Dictionary
>
baseDictionary
=
makePtr
<
Dictionary
>
();
return
create
(
nMarkers
,
markerSize
,
baseDictionary
);
return
create
(
nMarkers
,
markerSize
,
baseDictionary
,
randomSeed
);
}
/**
*/
Ptr
<
Dictionary
>
Dictionary
::
create
(
int
nMarkers
,
int
markerSize
,
const
Ptr
<
Dictionary
>
&
baseDictionary
)
{
return
generateCustomDictionary
(
nMarkers
,
markerSize
,
baseDictionary
);
const
Ptr
<
Dictionary
>
&
baseDictionary
,
int
randomSeed
)
{
return
generateCustomDictionary
(
nMarkers
,
markerSize
,
baseDictionary
,
randomSeed
);
}
...
...
@@ -346,11 +347,11 @@ Ptr<Dictionary> getPredefinedDictionary(int dict) {
/**
* @brief Generates a random marker Mat of size markerSize x markerSize
*/
static
Mat
_generateRandomMarker
(
int
markerSize
)
{
static
Mat
_generateRandomMarker
(
int
markerSize
,
RNG
&
rng
)
{
Mat
marker
(
markerSize
,
markerSize
,
CV_8UC1
,
Scalar
::
all
(
0
));
for
(
int
i
=
0
;
i
<
markerSize
;
i
++
)
{
for
(
int
j
=
0
;
j
<
markerSize
;
j
++
)
{
unsigned
char
bit
=
(
unsigned
char
)
(
r
and
()
%
2
);
unsigned
char
bit
=
(
unsigned
char
)
(
r
ng
.
uniform
(
0
,
2
)
);
marker
.
at
<
unsigned
char
>
(
i
,
j
)
=
bit
;
}
}
...
...
@@ -377,7 +378,8 @@ static int _getSelfDistance(const Mat &marker) {
/**
*/
Ptr
<
Dictionary
>
generateCustomDictionary
(
int
nMarkers
,
int
markerSize
,
const
Ptr
<
Dictionary
>
&
baseDictionary
)
{
const
Ptr
<
Dictionary
>
&
baseDictionary
,
int
randomSeed
)
{
RNG
rng
((
uint64
)(
randomSeed
));
Ptr
<
Dictionary
>
out
=
makePtr
<
Dictionary
>
();
out
->
markerSize
=
markerSize
;
...
...
@@ -415,7 +417,7 @@ Ptr<Dictionary> generateCustomDictionary(int nMarkers, int markerSize,
int
unproductiveIterations
=
0
;
while
(
out
->
bytesList
.
rows
<
nMarkers
)
{
Mat
currentMarker
=
_generateRandomMarker
(
markerSize
);
Mat
currentMarker
=
_generateRandomMarker
(
markerSize
,
rng
);
int
selfDistance
=
_getSelfDistance
(
currentMarker
);
int
minDistance
=
selfDistance
;
...
...
@@ -467,9 +469,9 @@ Ptr<Dictionary> generateCustomDictionary(int nMarkers, int markerSize,
/**
*/
Ptr
<
Dictionary
>
generateCustomDictionary
(
int
nMarkers
,
int
markerSize
)
{
Ptr
<
Dictionary
>
generateCustomDictionary
(
int
nMarkers
,
int
markerSize
,
int
randomSeed
)
{
Ptr
<
Dictionary
>
baseDictionary
=
makePtr
<
Dictionary
>
();
return
generateCustomDictionary
(
nMarkers
,
markerSize
,
baseDictionary
);
return
generateCustomDictionary
(
nMarkers
,
markerSize
,
baseDictionary
,
randomSeed
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment