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
01268aa3
Commit
01268aa3
authored
Nov 04, 2015
by
Oded Green
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Using std::vector instead of allocating memory myself
parent
801f118f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
12 deletions
+14
-12
estimated_covariance.cpp
modules/ximgproc/src/estimated_covariance.cpp
+14
-12
No files found.
modules/ximgproc/src/estimated_covariance.cpp
View file @
01268aa3
...
...
@@ -87,7 +87,7 @@ private:
void
iterateCombinations
(
Mat
inputData
,
Mat
outputData
);
void
computeOneCombination
(
int
comb_id
,
Mat
inputData
,
Mat
outputData
,
Mat
outputVector
,
int
*
finalMatPosR
,
int
*
finalMatPosC
);
Mat
outputVector
,
std
::
vector
<
int
>
finalMatPosR
,
std
::
vector
<
int
>
finalMatPosC
);
inline
void
complexSubtract
(
std
::
complex
<
float
>&
src
,
std
::
complex
<
float
>&
dst
){
dst
-=
src
;}
inline
void
complexAdd
(
std
::
complex
<
float
>&
src
,
std
::
complex
<
float
>&
dst
){
dst
+=
src
;}
...
...
@@ -103,7 +103,8 @@ private:
int
pc
;
int
threads
;
Combination
*
combinationsTable
;
// Combination* combinationsTable;
std
::
vector
<
Combination
>
combinationsTable
;
};
...
...
@@ -120,12 +121,12 @@ EstimateCovariance::EstimateCovariance(int pr_, int pc_){
}
EstimateCovariance
::~
EstimateCovariance
(){
delete
[]
combinationsTable
;
}
void
EstimateCovariance
::
initInternalDataStructures
(){
int
combCount
=
combinationCount
();
combinationsTable
=
new
Combination
[
combCount
]
;
combinationsTable
.
resize
(
combCount
)
;
buildCombinationsTable
();
}
...
...
@@ -203,26 +204,27 @@ void EstimateCovariance::iterateCombinations(Mat inputData,Mat outputData)
combs
=
combsPerCPU
-
1
;
startComb
=
remainder
*
combsPerCPU
+
(
thread_id
-
remainder
)
*
(
combsPerCPU
-
1
);
}
// stopComb=startComb+combs;
Mat
outputVector
(
pr
*
pc
,
1
,
DataType
<
std
::
complex
<
float
>
>::
type
);
int
*
finalMatPosR
=
new
int
[
pr
*
pc
]
;
int
*
finalMatPosC
=
new
int
[
pr
*
pc
]
;
std
::
vector
<
int
>
finalMatPosR
(
pr
*
pc
,
0
)
;
std
::
vector
<
int
>
finalMatPosC
(
pr
*
pc
,
0
)
;
for
(
idx
=
0
;
idx
<
combs
;
idx
++
){
outputVector
.
setTo
(
Scalar
(
0
,
0
));
memset
(
finalMatPosR
,
0
,
pr
*
pc
*
sizeof
(
int
));
memset
(
finalMatPosC
,
0
,
pr
*
pc
*
sizeof
(
int
));
for
(
unsigned
x
=
0
;
x
<
finalMatPosR
.
size
();
x
++
)
finalMatPosR
[
x
]
=
0
;
for
(
unsigned
x
=
0
;
x
<
finalMatPosC
.
size
();
x
++
)
finalMatPosC
[
x
]
=
0
;
computeOneCombination
(
startComb
++
,
inputData
,
outputData
,
outputVector
,
finalMatPosR
,
finalMatPosC
);
}
delete
[]
finalMatPosR
;
delete
[]
finalMatPosC
;
}
}
void
EstimateCovariance
::
computeOneCombination
(
int
comb_id
,
Mat
inputData
,
Mat
outputData
,
Mat
outputVector
,
int
*
finalMatPosR
,
int
*
finalMatPosC
)
Mat
outputVector
,
std
::
vector
<
int
>
finalMatPosR
,
std
::
vector
<
int
>
finalMatPosC
)
{
Combination
*
comb
=
&
combinationsTable
[
comb_id
];
int
type2
=
comb
->
type2
;
...
...
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