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
c28417c8
Commit
c28417c8
authored
Aug 26, 2014
by
biagio montesano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Array32 class removal.
parent
9a52f462
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
198 deletions
+62
-198
descriptor.hpp
...descriptor/include/opencv2/line_descriptor/descriptor.hpp
+6
-46
binary_descriptor_matcher.cpp
modules/line_descriptor/src/binary_descriptor_matcher.cpp
+56
-152
No files found.
modules/line_descriptor/include/opencv2/line_descriptor/descriptor.hpp
View file @
c28417c8
...
...
@@ -888,51 +888,6 @@ protected:
AlgorithmInfo
*
info
()
const
;
private
:
class
Array32
{
public
:
/* set ARRAY_RESIZE_FACTOR */
static
void
setArrayResizeFactor
(
double
arf
);
/* constructor */
Array32
();
/* destructor */
~
Array32
();
/* cleaning function used in destructor */
void
cleanup
();
/* push data */
void
push
(
UINT32
data
);
/* insert data at given index */
void
insert
(
UINT32
index
,
UINT32
data
);
/* return data */
UINT32
*
data
();
/* return data size */
UINT32
size
();
/* return capacity */
UINT32
capacity
();
/* definition of operator = */
void
operator
=
(
const
Array32
&
);
/* print data */
void
print
();
/* initializer */
void
init
(
int
size
);
/* data */
UINT32
*
arr
;
};
class
BucketGroup
{
...
...
@@ -949,9 +904,14 @@ void insert( int subindex, UINT32 data );
/* perform a query to the bucket */
UINT32
*
query
(
int
subindex
,
int
*
size
);
/* utility functions */
void
insert_value
(
std
::
vector
<
uint32_t
>&
vec
,
int
index
,
UINT32
data
);
void
push_value
(
std
::
vector
<
uint32_t
>&
vec
,
UINT32
Data
);
/* data fields */
UINT32
empty
;
Array32
*
group
;
std
::
vector
<
uint32_t
>
group
;
};
...
...
modules/line_descriptor/src/binary_descriptor_matcher.cpp
View file @
c28417c8
...
...
@@ -844,7 +844,7 @@ int BinaryDescriptorMatcher::SparseHashtable::init( int _b )
/* destructor */
BinaryDescriptorMatcher
::
SparseHashtable
::~
SparseHashtable
()
{
free
(
table
);
free
(
table
);
}
/* insert data */
...
...
@@ -863,205 +863,109 @@ UINT32* BinaryDescriptorMatcher::SparseHashtable::query( UINT64 index, int *Size
BinaryDescriptorMatcher
::
BucketGroup
::
BucketGroup
()
{
empty
=
0
;
group
=
NULL
;
group
=
std
::
vector
<
uint32_t
>
(
2
,
0
)
;
}
/* destructor */
BinaryDescriptorMatcher
::
BucketGroup
::~
BucketGroup
()
{
if
(
group
!=
NULL
)
delete
group
;
}
/* insert data into the bucket */
void
BinaryDescriptorMatcher
::
BucketGroup
::
insert
(
int
subindex
,
UINT32
data
)
void
BinaryDescriptorMatcher
::
BucketGroup
::
insert_value
(
std
::
vector
<
uint32_t
>&
vec
,
int
index
,
UINT32
data
)
{
if
(
group
==
NULL
)
{
group
=
new
Array32
();
group
->
push
(
0
);
}
UINT32
lowerbits
=
(
(
UINT32
)
1
<<
subindex
)
-
1
;
int
end
=
popcnt
(
empty
&
lowerbits
);
if
(
!
(
empty
&
(
(
UINT32
)
1
<<
subindex
)
)
)
if
(
vec
.
size
()
>
1
)
{
group
->
insert
(
end
,
group
->
arr
[
end
+
2
]
);
empty
|=
(
UINT32
)
1
<<
subindex
;
}
if
(
vec
[
0
]
==
vec
[
1
]
)
{
vec
[
1
]
=
(
UINT32
)
ceil
(
vec
[
0
]
*
1.1
);
for
(
int
i
=
0
;
i
<
(
int
)
(
2
+
vec
[
1
]
-
vec
.
size
()
);
i
++
)
vec
.
push_back
(
0
);
int
totones
=
popcnt
(
empty
);
group
->
insert
(
totones
+
1
+
group
->
arr
[
2
+
end
+
1
],
data
);
for
(
int
i
=
end
+
1
;
i
<
totones
+
1
;
i
++
)
group
->
arr
[
2
+
i
]
++
;
}
}
/* perform a query to the bucket */
UINT32
*
BinaryDescriptorMatcher
::
BucketGroup
::
query
(
int
subindex
,
int
*
size
)
{
if
(
empty
&
(
(
UINT32
)
1
<<
subindex
)
)
{
UINT32
lowerbits
=
(
(
UINT32
)
1
<<
subindex
)
-
1
;
int
end
=
popcnt
(
empty
&
lowerbits
);
int
totones
=
popcnt
(
empty
);
*
size
=
group
->
arr
[
2
+
end
+
1
]
-
group
->
arr
[
2
+
end
];
return
group
->
arr
+
2
+
totones
+
1
+
group
->
arr
[
2
+
end
];
vec
.
insert
(
vec
.
begin
()
+
2
+
index
,
data
);
vec
[
2
+
index
]
=
data
;
vec
[
0
]
++
;
}
else
{
*
size
=
0
;
return
NULL
;
vec
=
std
::
vector
<
uint32_t
>
(
3
,
0
);
vec
[
0
]
=
1
;
vec
[
1
]
=
1
;
vec
[
2
]
=
data
;
}
}
/* set ARRAY_RESIZE_FACTOR */
void
BinaryDescriptorMatcher
::
Array32
::
setArrayResizeFactor
(
double
arf
)
{
ARRAY_RESIZE_FACTOR
=
arf
;
}
/* constructor */
BinaryDescriptorMatcher
::
Array32
::
Array32
()
{
arr
=
NULL
;
ARRAY_RESIZE_FACTOR
=
1.1
;
// minimum is 1.0
ARRAY_RESIZE_ADD_FACTOR
=
4
;
// minimum is 1
}
/* definition of operator =
Array32& Array32::operator = (const Array32 &rhs) */
void
BinaryDescriptorMatcher
::
Array32
::
operator
=
(
const
Array32
&
rhs
)
void
BinaryDescriptorMatcher
::
BucketGroup
::
push_value
(
std
::
vector
<
uint32_t
>&
vec
,
UINT32
Data
)
{
if
(
&
rhs
!=
this
)
this
->
arr
=
rhs
.
arr
;
}
/* destructor */
BinaryDescriptorMatcher
::
Array32
::~
Array32
()
{
cleanup
();
}
/* cleaning function used in destructor */
void
BinaryDescriptorMatcher
::
Array32
::
cleanup
()
{
free
(
arr
);
}
/* push data */
void
BinaryDescriptorMatcher
::
Array32
::
push
(
UINT32
Data
)
{
if
(
arr
)
if
(
vec
.
size
()
>
0
)
{
if
(
arr
[
0
]
==
arr
[
1
]
)
if
(
vec
[
0
]
==
vec
[
1
]
)
{
arr
[
1
]
=
(
UINT32
)
std
::
max
(
ceil
(
arr
[
1
]
*
ARRAY_RESIZE_FACTOR
),
arr
[
1
]
+
ARRAY_RESIZE_ADD_FACTOR
);
UINT32
*
new_Data
=
static_cast
<
UINT32
*>
(
realloc
(
arr
,
sizeof
(
UINT32
)
*
(
2
+
arr
[
1
]
)
)
);
if
(
new_Data
==
NULL
)
{
/* could not realloc, but orig still valid */
std
::
cout
<<
"ALERT!!!! Not enough memory, operation aborted!"
<<
std
::
endl
;
exit
(
0
);
}
else
{
arr
=
new_Data
;
}
vec
[
1
]
=
(
UINT32
)
std
::
max
(
ceil
(
vec
[
1
]
*
ARRAY_RESIZE_FACTOR
),
vec
[
1
]
+
ARRAY_RESIZE_ADD_FACTOR
);
for
(
int
i
=
0
;
i
<
(
int
)
(
2
+
vec
[
1
]
-
vec
.
size
()
);
i
++
)
vec
.
push_back
(
0
);
}
arr
[
2
+
arr
[
0
]]
=
Data
;
arr
[
0
]
++
;
vec
[
2
+
vec
[
0
]]
=
Data
;
vec
[
0
]
++
;
}
else
{
arr
=
(
UINT32
*
)
malloc
(
(
size_t
)(
2
+
ARRAY_RESIZE_ADD_FACTOR
)
*
sizeof
(
UINT32
)
);
arr
[
0
]
=
1
;
arr
[
1
]
=
1
;
arr
[
2
]
=
Data
;
vec
=
std
::
vector
<
uint32_t
>
(
2
+
ARRAY_RESIZE_ADD_FACTOR
,
0
);
vec
[
0
]
=
1
;
vec
[
1
]
=
1
;
vec
[
2
]
=
Data
;
}
}
/* insert data
at given index
*/
void
BinaryDescriptorMatcher
::
Array32
::
insert
(
UINT32
index
,
UINT32
D
ata
)
/* insert data
into the bucket
*/
void
BinaryDescriptorMatcher
::
BucketGroup
::
insert
(
int
subindex
,
UINT32
d
ata
)
{
if
(
arr
)
if
(
group
.
size
()
==
0
)
{
if
(
arr
[
0
]
==
arr
[
1
]
)
{
arr
[
1
]
=
(
UINT32
)
ceil
(
arr
[
0
]
*
1.1
);
UINT32
*
new_data
=
static_cast
<
UINT32
*>
(
realloc
(
arr
,
sizeof
(
UINT32
)
*
(
2
+
arr
[
1
]
)
)
);
if
(
new_data
==
NULL
)
{
// could not realloc, but orig still valid
std
::
cout
<<
"ALERT!!!! Not enough memory, operation aborted!"
<<
std
::
endl
;
exit
(
0
);
}
else
{
arr
=
new_data
;
}
}
memmove
(
arr
+
(
2
+
index
)
+
1
,
arr
+
(
2
+
index
),
(
arr
[
0
]
-
index
)
*
sizeof
(
*
arr
)
);
arr
[
2
+
index
]
=
Data
;
arr
[
0
]
++
;
push_value
(
group
,
0
);
}
else
UINT32
lowerbits
=
(
(
UINT32
)
1
<<
subindex
)
-
1
;
int
end
=
popcnt
(
empty
&
lowerbits
);
if
(
!
(
empty
&
(
(
UINT32
)
1
<<
subindex
)
)
)
{
arr
=
(
UINT32
*
)
malloc
(
3
*
sizeof
(
UINT32
)
);
arr
[
0
]
=
1
;
arr
[
1
]
=
1
;
arr
[
2
]
=
Data
;
insert_value
(
group
,
end
,
group
[
end
+
2
]
);
empty
|=
(
UINT32
)
1
<<
subindex
;
}
}
/* return data */
UINT32
*
BinaryDescriptorMatcher
::
Array32
::
data
()
{
return
arr
?
arr
+
2
:
NULL
;
}
/* return data size */
UINT32
BinaryDescriptorMatcher
::
Array32
::
size
()
{
return
arr
?
arr
[
0
]
:
0
;
}
int
totones
=
popcnt
(
empty
);
insert_value
(
group
,
totones
+
1
+
group
[
2
+
end
+
1
],
data
);
/* return capacity */
UINT32
BinaryDescriptorMatcher
::
Array32
::
capacity
()
{
return
arr
?
arr
[
1
]
:
0
;
for
(
int
i
=
end
+
1
;
i
<
totones
+
1
;
i
++
)
group
[
2
+
i
]
++
;
}
/* p
rint data
*/
void
BinaryDescriptorMatcher
::
Array32
::
print
(
)
/* p
erform a query to the bucket
*/
UINT32
*
BinaryDescriptorMatcher
::
BucketGroup
::
query
(
int
subindex
,
int
*
size
)
{
for
(
int
i
=
0
;
i
<
(
int
)
size
();
i
++
)
printf
(
"%d, "
,
arr
[
i
+
2
]
);
if
(
empty
&
(
(
UINT32
)
1
<<
subindex
)
)
{
UINT32
lowerbits
=
(
(
UINT32
)
1
<<
subindex
)
-
1
;
int
end
=
popcnt
(
empty
&
lowerbits
);
int
totones
=
popcnt
(
empty
);
printf
(
"
\n
"
);
}
*
size
=
group
[
2
+
end
+
1
]
-
group
[
2
+
end
];
return
&
(
*
(
group
.
begin
()
+
2
+
totones
+
1
+
(
int
)
group
[
2
+
end
]
)
);
}
/* initializer */
void
BinaryDescriptorMatcher
::
Array32
::
init
(
int
Size
)
{
if
(
arr
==
NULL
)
else
{
arr
=
(
UINT32
*
)
malloc
(
(
2
+
Size
)
*
sizeof
(
UINT32
)
);
arr
[
0
]
=
0
;
arr
[
1
]
=
Size
;
*
size
=
0
;
return
NULL
;
}
}
}
}
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