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
7c0e6efd
Commit
7c0e6efd
authored
Mar 22, 2020
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stereo: fix massive invalid range access and uninitialized values
parent
9c0e1525
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
107 additions
and
57 deletions
+107
-57
perf_bm.cpp
modules/stereo/perf/perf_bm.cpp
+6
-2
descriptor.cpp
modules/stereo/src/descriptor.cpp
+15
-15
descriptor.hpp
modules/stereo/src/descriptor.hpp
+43
-14
matching.hpp
modules/stereo/src/matching.hpp
+43
-26
No files found.
modules/stereo/perf/perf_bm.cpp
View file @
7c0e6efd
...
...
@@ -64,7 +64,9 @@ PERF_TEST_P( s_bm, sgm_perf,
Mat
out1
(
sz
,
sdepth
);
Ptr
<
StereoBinarySGBM
>
sgbm
=
StereoBinarySGBM
::
create
(
0
,
16
,
5
);
sgbm
->
setBinaryKernelType
(
CV_DENSE_CENSUS
);
declare
.
in
(
left
,
WARMUP_RNG
)
declare
.
in
(
left
,
WARMUP_RNG
)
.
in
(
right
,
WARMUP_RNG
)
.
out
(
out1
)
.
time
(
0.1
)
.
iterations
(
20
);
...
...
@@ -103,7 +105,9 @@ PERF_TEST_P( s_bm, bm_perf,
sbm
->
setSpekleRemovalTechnique
(
CV_SPECKLE_REMOVAL_AVG_ALGORITHM
);
sbm
->
setUsePrefilter
(
false
);
declare
.
in
(
left
,
WARMUP_RNG
)
declare
.
in
(
left
,
WARMUP_RNG
)
.
in
(
right
,
WARMUP_RNG
)
.
out
(
out1
)
.
time
(
0.1
)
.
iterations
(
20
);
...
...
modules/stereo/src/descriptor.cpp
View file @
7c0e6efd
...
...
@@ -64,12 +64,12 @@ namespace cv
int
stride
=
(
int
)
image1
.
step
;
if
(
type
==
CV_DENSE_CENSUS
)
{
parallel_for_
(
Range
(
n2
,
image1
.
rows
-
n2
),
parallel_for_
(
Range
(
0
,
image1
.
rows
),
CombinedDescriptor
<
1
,
1
,
1
,
2
,
CensusKernel
<
2
>
>
(
image1
.
cols
,
image1
.
rows
,
stride
,
n2
,
costs
,
CensusKernel
<
2
>
(
images
),
n2
));
}
else
if
(
type
==
CV_SPARSE_CENSUS
)
{
parallel_for_
(
Range
(
n2
,
image1
.
rows
-
n2
),
parallel_for_
(
Range
(
0
,
image1
.
rows
),
CombinedDescriptor
<
2
,
2
,
1
,
2
,
CensusKernel
<
2
>
>
(
image1
.
cols
,
image1
.
rows
,
stride
,
n2
,
costs
,
CensusKernel
<
2
>
(
images
),
n2
));
}
}
...
...
@@ -87,12 +87,12 @@ namespace cv
int
stride
=
(
int
)
image1
.
step
;
if
(
type
==
CV_DENSE_CENSUS
)
{
parallel_for_
(
Range
(
n2
,
image1
.
rows
-
n2
),
parallel_for_
(
Range
(
0
,
image1
.
rows
),
CombinedDescriptor
<
1
,
1
,
1
,
1
,
CensusKernel
<
1
>
>
(
image1
.
cols
,
image1
.
rows
,
stride
,
n2
,
costs
,
CensusKernel
<
1
>
(
images
),
n2
));
}
else
if
(
type
==
CV_SPARSE_CENSUS
)
{
parallel_for_
(
Range
(
n2
,
image1
.
rows
-
n2
),
parallel_for_
(
Range
(
0
,
image1
.
rows
),
CombinedDescriptor
<
2
,
2
,
1
,
1
,
CensusKernel
<
1
>
>
(
image1
.
cols
,
image1
.
rows
,
stride
,
n2
,
costs
,
CensusKernel
<
1
>
(
images
),
n2
));
}
}
...
...
@@ -106,7 +106,7 @@ namespace cv
int
n2
=
(
kernelSize
)
>>
1
;
Mat
images
[]
=
{
img1
,
img2
};
int
*
date
[]
=
{
(
int
*
)
dist1
.
data
,
(
int
*
)
dist2
.
data
};
parallel_for_
(
Range
(
n2
,
img1
.
rows
-
n2
),
StarKernelCensus
<
2
>
(
images
,
n2
,
date
));
parallel_for_
(
Range
(
0
,
img1
.
rows
),
StarKernelCensus
<
2
>
(
images
,
n2
,
date
));
}
//single version of star census
CV_EXPORTS
void
starCensusTransform
(
const
Mat
&
img1
,
int
kernelSize
,
Mat
&
dist
)
...
...
@@ -118,7 +118,7 @@ namespace cv
int
n2
=
(
kernelSize
)
>>
1
;
Mat
images
[]
=
{
img1
};
int
*
date
[]
=
{
(
int
*
)
dist
.
data
};
parallel_for_
(
Range
(
n2
,
img1
.
rows
-
n2
),
StarKernelCensus
<
1
>
(
images
,
n2
,
date
));
parallel_for_
(
Range
(
0
,
img1
.
rows
),
StarKernelCensus
<
1
>
(
images
,
n2
,
date
));
}
//Modified census transforms
//the first one deals with small illumination changes
...
...
@@ -139,7 +139,7 @@ namespace cv
if
(
type
==
CV_MODIFIED_CENSUS_TRANSFORM
)
{
//MCT
parallel_for_
(
Range
(
n2
,
img1
.
rows
-
n2
),
parallel_for_
(
Range
(
0
,
img1
.
rows
),
CombinedDescriptor
<
2
,
4
,
2
,
2
,
MCTKernel
<
2
>
>
(
img1
.
cols
,
img1
.
rows
,
stride
,
n2
,
date
,
MCTKernel
<
2
>
(
images
,
t
),
n2
));
}
else
if
(
type
==
CV_MEAN_VARIATION
)
...
...
@@ -159,7 +159,7 @@ namespace cv
(
int
*
)
integralImage1
.
data
,
(
int
*
)
integralImage2
.
data
};
parallel_for_
(
Range
(
n2
,
img1
.
rows
-
n2
),
parallel_for_
(
Range
(
0
,
img1
.
rows
),
CombinedDescriptor
<
2
,
3
,
2
,
2
,
MVKernel
<
2
>
>
(
img1
.
cols
,
img1
.
rows
,
stride
,
n2
,
date
,
MVKernel
<
2
>
(
images
,
integral
),
n2
));
}
}
...
...
@@ -177,7 +177,7 @@ namespace cv
if
(
type
==
CV_MODIFIED_CENSUS_TRANSFORM
)
{
//MCT
parallel_for_
(
Range
(
n2
,
img1
.
rows
-
n2
),
parallel_for_
(
Range
(
0
,
img1
.
rows
),
CombinedDescriptor
<
2
,
4
,
2
,
1
,
MCTKernel
<
1
>
>
(
img1
.
cols
,
img1
.
rows
,
stride
,
n2
,
date
,
MCTKernel
<
1
>
(
images
,
t
),
n2
));
}
else
if
(
type
==
CV_MEAN_VARIATION
)
...
...
@@ -189,7 +189,7 @@ namespace cv
CV_CheckGE
(
integralImage
.
cols
,
img1
.
cols
,
""
);
CV_CheckGE
(
integralImage
.
rows
,
img1
.
rows
,
""
);
int
*
integral
[]
=
{
(
int
*
)
integralImage
.
data
};
parallel_for_
(
Range
(
n2
,
img1
.
rows
-
n2
),
parallel_for_
(
Range
(
0
,
img1
.
rows
),
CombinedDescriptor
<
2
,
3
,
2
,
1
,
MVKernel
<
1
>
>
(
img1
.
cols
,
img1
.
rows
,
stride
,
n2
,
date
,
MVKernel
<
1
>
(
images
,
integral
),
n2
));
}
}
...
...
@@ -209,11 +209,11 @@ namespace cv
int
stride
=
(
int
)
img1
.
step
;
if
(
type
==
CV_CS_CENSUS
)
{
parallel_for_
(
Range
(
n2
,
img1
.
rows
-
n2
),
SymetricCensus
<
2
>
(
imag
,
n2
,
date
));
parallel_for_
(
Range
(
0
,
img1
.
rows
),
SymetricCensus
<
2
>
(
imag
,
n2
,
date
));
}
else
if
(
type
==
CV_MODIFIED_CS_CENSUS
)
{
parallel_for_
(
Range
(
n2
,
img1
.
rows
-
n2
),
parallel_for_
(
Range
(
0
,
img1
.
rows
),
CombinedDescriptor
<
1
,
1
,
1
,
2
,
ModifiedCsCensus
<
2
>
>
(
img1
.
cols
,
img1
.
rows
,
stride
,
n2
,
date
,
ModifiedCsCensus
<
2
>
(
images
,
n2
),
1
));
}
}
...
...
@@ -231,11 +231,11 @@ namespace cv
int
stride
=
(
int
)
img1
.
step
;
if
(
type
==
CV_CS_CENSUS
)
{
parallel_for_
(
Range
(
n2
,
img1
.
rows
-
n2
),
SymetricCensus
<
1
>
(
imag
,
n2
,
date
));
parallel_for_
(
Range
(
0
,
img1
.
rows
),
SymetricCensus
<
1
>
(
imag
,
n2
,
date
));
}
else
if
(
type
==
CV_MODIFIED_CS_CENSUS
)
{
parallel_for_
(
Range
(
n2
,
img1
.
rows
-
n2
),
parallel_for_
(
Range
(
0
,
img1
.
rows
),
CombinedDescriptor
<
1
,
1
,
1
,
1
,
ModifiedCsCensus
<
1
>
>
(
img1
.
cols
,
img1
.
rows
,
stride
,
n2
,
date
,
ModifiedCsCensus
<
1
>
(
images
,
n2
),
1
));
}
}
...
...
@@ -250,7 +250,7 @@ namespace cv
int
height
=
image
.
rows
;
cost
.
setTo
(
0
);
int
*
c
=
(
int
*
)
cost
.
data
;
parallel_for_
(
Range
(
win
+
1
,
height
-
win
-
1
),
MeanKernelIntegralImage
(
image
,
win
,
scalling
,
c
));
parallel_for_
(
Range
(
0
,
height
),
MeanKernelIntegralImage
(
image
,
win
,
scalling
,
c
));
}
}
}
modules/stereo/src/descriptor.hpp
View file @
7c0e6efd
...
...
@@ -210,11 +210,18 @@ namespace cv
n2_stop
=
k2Stop
;
}
void
operator
()(
const
cv
::
Range
&
r
)
const
CV_OVERRIDE
{
for
(
int
i
=
r
.
start
;
i
<
=
r
.
end
;
i
++
)
for
(
int
i
=
r
.
start
;
i
<
r
.
end
;
i
++
)
{
int
rWidth
=
i
*
stride_
;
for
(
int
j
=
n2
+
2
;
j
<=
width
-
n2
-
2
;
j
++
)
for
(
int
j
=
0
;
j
<
width
;
j
++
)
{
if
(
i
<
n2
||
i
>=
height
-
n2
||
j
<
n2
+
2
||
j
>=
width
-
n2
-
2
)
{
for
(
int
l
=
0
;
l
<
nr_img
;
l
++
)
dst
[
l
][
rWidth
+
j
]
=
0
;
// TODO out of range value?
continue
;
}
int
c
[
nr_img
];
memset
(
c
,
0
,
sizeof
(
c
[
0
])
*
nr_img
);
for
(
int
step
=
step_start
;
step
<=
step_end
;
step
+=
step_inc
)
...
...
@@ -243,21 +250,33 @@ namespace cv
class
MeanKernelIntegralImage
:
public
ParallelLoopBody
{
private
:
int
*
img
;
int
windowSize
,
width
;
const
Mat
&
img
;
int
windowSize
;
float
scalling
;
int
*
c
;
public
:
MeanKernelIntegralImage
(
const
cv
::
Mat
&
image
,
int
window
,
float
scale
,
int
*
cost
)
:
img
((
int
*
)
image
.
data
),
windowSize
(
window
)
,
width
(
image
.
cols
)
,
scalling
(
scale
)
,
c
(
cost
){};
void
operator
()(
const
cv
::
Range
&
r
)
const
CV_OVERRIDE
{
for
(
int
i
=
r
.
start
;
i
<=
r
.
end
;
i
++
)
img
(
image
),
windowSize
(
window
),
scalling
(
scale
),
c
(
cost
)
{}
void
operator
()(
const
cv
::
Range
&
r
)
const
CV_OVERRIDE
{
const
int
width
=
img
.
cols
;
const
int
height
=
img
.
rows
;
for
(
int
i
=
r
.
start
;
i
<
r
.
end
;
i
++
)
{
int
y0
=
std
::
max
(
0
,
i
-
windowSize
+
1
);
int
y1
=
std
::
min
(
height
-
1
,
i
+
windowSize
);
int
iw
=
i
*
width
;
for
(
int
j
=
windowSize
+
1
;
j
<=
width
-
windowSize
-
1
;
j
++
)
for
(
int
j
=
0
;
j
<
width
;
j
++
)
{
c
[
iw
+
j
]
=
(
int
)((
img
[(
i
+
windowSize
-
1
)
*
width
+
j
+
windowSize
-
1
]
+
img
[(
i
-
windowSize
-
1
)
*
width
+
j
-
windowSize
-
1
]
-
img
[(
i
+
windowSize
)
*
width
+
j
-
windowSize
]
-
img
[(
i
-
windowSize
)
*
width
+
j
+
windowSize
])
*
scalling
);
int
x0
=
std
::
max
(
0
,
j
-
windowSize
+
1
);
int
x1
=
std
::
min
(
height
-
1
,
j
+
windowSize
);
c
[
iw
+
j
]
=
(
int
)(
(
img
.
at
<
int
>
(
y0
,
x0
)
+
img
.
at
<
int
>
(
y0
,
x0
)
-
img
.
at
<
int
>
(
y1
,
x0
)
-
img
.
at
<
int
>
(
y0
,
x1
)
)
*
scalling
);
}
}
}
...
...
@@ -285,13 +304,18 @@ namespace cv
stride_
=
(
int
)
img
[
0
].
step
;
}
void
operator
()(
const
cv
::
Range
&
r
)
const
CV_OVERRIDE
{
for
(
int
i
=
r
.
start
;
i
<
=
r
.
end
;
i
++
)
for
(
int
i
=
r
.
start
;
i
<
r
.
end
;
i
++
)
{
int
rWidth
=
i
*
stride_
;
for
(
int
j
=
n2
;
j
<=
width
-
n2
;
j
++
)
for
(
int
j
=
0
;
j
<
width
;
j
++
)
{
for
(
int
d
=
0
;
d
<
im_num
;
d
++
)
{
if
(
i
<
n2
||
i
>=
height
-
n2
||
j
<
n2
||
j
>=
width
-
n2
)
{
dst
[
d
][
rWidth
+
j
]
=
0
;
// TODO out of range value?
continue
;
}
int
c
=
0
;
for
(
int
step
=
4
;
step
>
0
;
step
--
)
{
...
...
@@ -377,13 +401,18 @@ namespace cv
stride_
=
(
int
)
img
[
0
].
step
;
}
void
operator
()(
const
cv
::
Range
&
r
)
const
CV_OVERRIDE
{
for
(
int
i
=
r
.
start
;
i
<
=
r
.
end
;
i
++
)
for
(
int
i
=
r
.
start
;
i
<
r
.
end
;
i
++
)
{
int
distV
=
i
*
stride_
;
for
(
int
j
=
n2
;
j
<=
width
-
n2
;
j
++
)
for
(
int
j
=
0
;
j
<
width
;
j
++
)
{
for
(
int
d
=
0
;
d
<
im_num
;
d
++
)
{
if
(
i
<
n2
||
i
>=
height
-
n2
||
j
<
n2
||
j
>=
width
-
n2
)
{
dst
[
d
][
distV
+
j
]
=
0
;
// TODO out of range value?
continue
;
}
int
c
=
0
;
//the classic center symetric census which compares the curent pixel with its symetric not its center.
for
(
int
ii
=
-
n2
;
ii
<=
0
;
ii
++
)
...
...
modules/stereo/src/matching.hpp
View file @
7c0e6efd
...
...
@@ -64,7 +64,7 @@ namespace cv
//!the confidence to which a min disparity found is good or not
double
confidenceCheck
;
//!the LUT used in case SSE is not available
int
hamLut
[
6553
7
];
int
hamLut
[
6553
6
];
// FIXIT use preferined 8-bit lookup table for hamming
//!function used for getting the minimum disparity from the cost volume"
static
int
minim
(
short
*
c
,
int
iwpj
,
int
widthDisp
,
const
double
confidence
,
const
int
search_region
)
{
...
...
@@ -131,7 +131,7 @@ namespace cv
//!a pre processing function that generates the Hamming LUT in case the algorithm will ever be used on platform where SSE is not available
void
hammingLut
()
{
for
(
int
i
=
0
;
i
<
=
65536
;
i
++
)
for
(
int
i
=
0
;
i
<
65536
;
i
++
)
{
int
dist
=
0
;
int
j
=
i
;
...
...
@@ -157,19 +157,16 @@ namespace cv
hammingDistance
(
const
Mat
&
leftImage
,
const
Mat
&
rightImage
,
short
*
cost
,
int
maxDisp
,
int
kerSize
,
int
*
hammingLUT
)
:
left
((
int
*
)
leftImage
.
data
),
right
((
int
*
)
rightImage
.
data
),
c
(
cost
),
v
(
maxDisp
),
kernelSize
(
kerSize
),
width
(
leftImage
.
cols
),
MASK
(
65535
),
hammLut
(
hammingLUT
){}
void
operator
()(
const
cv
::
Range
&
r
)
const
CV_OVERRIDE
{
for
(
int
i
=
r
.
start
;
i
<
=
r
.
end
;
i
++
)
for
(
int
i
=
r
.
start
;
i
<
r
.
end
;
i
++
)
{
int
iw
=
i
*
width
;
for
(
int
j
=
kernelSize
;
j
<
width
-
kernelSize
;
j
++
)
{
int
j2
;
int
xorul
;
int
iwj
;
iwj
=
iw
+
j
;
int
iwj
=
iw
+
j
;
for
(
int
d
=
0
;
d
<=
v
;
d
++
)
{
j2
=
(
0
>
j
-
d
)
?
(
0
)
:
(
j
-
d
);
xorul
=
left
[(
iwj
)]
^
right
[(
iw
+
j2
)];
int
j2
=
std
::
max
(
0
,
j
-
d
);
int
xorul
=
left
[(
iwj
)]
^
right
[(
iw
+
j2
)];
#if CV_POPCNT
if
(
checkHardwareSupport
(
CV_CPU_POPCNT
))
{
...
...
@@ -203,16 +200,25 @@ namespace cv
parSum
=
(
short
*
)
partialSums
.
data
;
}
void
operator
()(
const
cv
::
Range
&
r
)
const
CV_OVERRIDE
{
for
(
int
i
=
r
.
start
;
i
<
=
r
.
end
;
i
++
)
for
(
int
i
=
r
.
start
;
i
<
r
.
end
;
i
++
)
{
int
iwi
=
(
i
-
1
)
*
width
;
for
(
int
j
=
win
+
1
;
j
<=
width
-
win
-
1
;
j
++
)
int
iwi
=
i
*
width
;
for
(
int
j
=
0
;
j
<=
width
;
j
++
)
{
int
w
=
(
iwi
+
j
)
*
(
maxDisp
+
1
);
if
(
i
<
win
+
1
||
i
>=
height
-
win
-
1
||
j
<
win
+
1
||
j
>=
width
-
win
-
1
)
{
for
(
int
d
=
0
;
d
<=
maxDisp
;
d
++
)
{
c
[
w
+
d
]
=
0
;
}
continue
;
}
int
w1
=
((
i
+
win
+
1
)
*
width
+
j
+
win
)
*
(
maxDisp
+
1
);
int
w2
=
((
i
-
win
)
*
width
+
j
-
win
-
1
)
*
(
maxDisp
+
1
);
int
w3
=
((
i
+
win
+
1
)
*
width
+
j
-
win
-
1
)
*
(
maxDisp
+
1
);
int
w4
=
((
i
-
win
)
*
width
+
j
+
win
)
*
(
maxDisp
+
1
);
int
w
=
(
iwi
+
j
-
1
)
*
(
maxDisp
+
1
);
for
(
int
d
=
0
;
d
<=
maxDisp
;
d
++
)
{
c
[
w
+
d
]
=
parSum
[
w1
+
d
]
+
parSum
[
w2
+
d
]
...
...
@@ -244,7 +250,7 @@ namespace cv
confCheck
=
confidence
;
}
void
operator
()(
const
cv
::
Range
&
r
)
const
CV_OVERRIDE
{
for
(
int
i
=
r
.
start
;
i
<
=
r
.
end
;
i
++
)
for
(
int
i
=
r
.
start
;
i
<
r
.
end
;
i
++
)
{
int
lr
;
int
v
=
-
1
;
...
...
@@ -301,10 +307,16 @@ namespace cv
width
=
originalImage
.
cols
;
}
void
operator
()(
const
cv
::
Range
&
r
)
const
CV_OVERRIDE
{
for
(
int
m
=
r
.
start
;
m
<
=
r
.
end
;
m
++
)
for
(
int
m
=
r
.
start
;
m
<
r
.
end
;
m
++
)
{
for
(
int
n
=
4
;
n
<
width
-
4
;
++
n
)
for
(
int
n
=
0
;
n
<
width
;
++
n
)
{
if
(
m
<
1
||
m
>=
height
-
1
||
n
<
4
||
n
>=
width
-
4
)
{
filtered
[
m
*
width
+
n
]
=
original
[
m
*
width
+
n
];
// FIXIT replace with OpenCV function
continue
;
}
int
k
=
0
;
T
window
[
9
];
for
(
int
i
=
n
-
4
;
i
<=
n
+
4
;
++
i
)
...
...
@@ -341,10 +353,16 @@ namespace cv
width
=
originalImage
.
cols
;
}
void
operator
()(
const
Range
&
r
)
const
CV_OVERRIDE
{
for
(
int
n
=
r
.
start
;
n
<
=
r
.
end
;
++
n
)
for
(
int
n
=
r
.
start
;
n
<
r
.
end
;
++
n
)
{
for
(
int
m
=
4
;
m
<
height
-
4
;
++
m
)
{
if
(
m
<
4
||
m
>=
height
-
4
||
n
<
1
||
n
>=
width
-
1
)
{
filtered
[
m
*
width
+
n
]
=
original
[
m
*
width
+
n
];
// FIXIT replace with OpenCV function
continue
;
}
int
k
=
0
;
T
window
[
9
];
for
(
int
i
=
m
-
4
;
i
<=
m
+
4
;
++
i
)
...
...
@@ -430,11 +448,11 @@ namespace cv
short
*
c
=
(
short
*
)
cost
.
data
;
short
*
ham
=
(
short
*
)
hammingDistanceCost
.
data
;
memset
(
c
,
0
,
sizeof
(
c
[
0
])
*
(
width
+
1
)
*
(
height
+
1
)
*
(
maxDisp
+
1
));
for
(
int
i
=
1
;
i
<
=
height
;
i
++
)
for
(
int
i
=
1
;
i
<
height
;
i
++
)
{
int
iw
=
i
*
width
;
int
iwi
=
(
i
-
1
)
*
width
;
for
(
int
j
=
1
;
j
<
=
width
;
j
++
)
for
(
int
j
=
1
;
j
<
width
;
j
++
)
{
int
iwj
=
(
iw
+
j
)
*
(
maxDisp
+
1
);
int
iwjmu
=
(
iw
+
j
-
1
)
*
(
maxDisp
+
1
);
...
...
@@ -445,9 +463,9 @@ namespace cv
}
}
}
for
(
int
i
=
1
;
i
<
=
height
;
i
++
)
for
(
int
i
=
1
;
i
<
height
;
i
++
)
{
for
(
int
j
=
1
;
j
<
=
width
;
j
++
)
for
(
int
j
=
1
;
j
<
width
;
j
++
)
{
int
iwj
=
(
i
*
width
+
j
)
*
(
maxDisp
+
1
);
int
iwjmu
=
((
i
-
1
)
*
width
+
j
)
*
(
maxDisp
+
1
);
...
...
@@ -464,13 +482,12 @@ namespace cv
CV_Assert
(
windowSize
%
2
!=
0
);
CV_Assert
(
partialSums
.
rows
==
cost
.
rows
);
CV_Assert
(
partialSums
.
cols
==
cost
.
cols
);
int
win
=
windowSize
/
2
;
short
*
c
=
(
short
*
)
cost
.
data
;
int
maxDisp
=
maxDisparity
;
int
width
=
cost
.
cols
/
(
maxDisp
+
1
)
-
1
;
int
height
=
cost
.
rows
-
1
;
memset
(
c
,
0
,
sizeof
(
c
[
0
])
*
width
*
height
*
(
maxDisp
+
1
));
parallel_for_
(
cv
::
Range
(
win
+
1
,
height
-
win
-
1
),
agregateCost
(
partialSums
,
windowSize
,
maxDisp
,
cost
));
parallel_for_
(
cv
::
Range
(
0
,
height
),
agregateCost
(
partialSums
,
windowSize
,
maxDisp
,
cost
));
}
//!remove small regions that have an area smaller than t, we fill the region with the average of the good pixels around it
template
<
typename
T
>
...
...
@@ -571,7 +588,7 @@ namespace cv
int
width
=
costVolume
.
cols
/
(
disparity
+
1
)
-
1
;
int
height
=
costVolume
.
rows
-
1
;
memset
(
map
,
0
,
sizeof
(
map
[
0
])
*
width
*
height
);
parallel_for_
(
Range
(
0
,
height
-
1
),
makeMap
(
costVolume
,
th
,
disparity
,
confidenceCheck
,
scallingFactor
,
mapFinal
));
parallel_for_
(
Range
(
0
,
height
),
makeMap
(
costVolume
,
th
,
disparity
,
confidenceCheck
,
scallingFactor
,
mapFinal
));
}
public
:
//!a median filter of 1x9 and 9x1
...
...
@@ -581,7 +598,7 @@ namespace cv
{
CV_Assert
(
originalImage
.
rows
==
filteredImage
.
rows
);
CV_Assert
(
originalImage
.
cols
==
filteredImage
.
cols
);
parallel_for_
(
Range
(
1
,
originalImage
.
rows
-
2
),
Median1x9
<
T
>
(
originalImage
,
filteredImage
));
parallel_for_
(
Range
(
0
,
originalImage
.
rows
),
Median1x9
<
T
>
(
originalImage
,
filteredImage
));
}
//!9x1 median filter
template
<
typename
T
>
...
...
@@ -589,7 +606,7 @@ namespace cv
{
CV_Assert
(
originalImage
.
cols
==
filteredImage
.
cols
);
CV_Assert
(
originalImage
.
cols
==
filteredImage
.
cols
);
parallel_for_
(
Range
(
1
,
originalImage
.
cols
-
2
),
Median9x1
<
T
>
(
originalImage
,
filteredImage
));
parallel_for_
(
Range
(
0
,
originalImage
.
cols
),
Median9x1
<
T
>
(
originalImage
,
filteredImage
));
}
//!constructor for the matching class
//!maxDisp - represents the maximum disparity
...
...
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