Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion modules/cudaarithm/src/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,10 @@ void cv::cuda::flip(InputArray _src, OutputArray _dst, int flipCode, Stream& str

_dst.create(src.size(), src.type());
GpuMat dst = getOutputMat(_dst, src.size(), src.type(), stream);
if (src.data == dst.data && ((src.cols & 1) == 1 || (src.rows & 1) == 1))
CV_Error(Error::BadROISize, "In-place version of flip only accepts even width/height");

if (src.refcount != dst.refcount)
if (src.data != dst.data)
funcs[src.depth()][src.channels() - 1](src, dst, flipCode, StreamAccessor::getStream(stream));
else // in-place
ifuncs[src.depth()][src.channels() - 1](src, flipCode, StreamAccessor::getStream(stream));
Expand Down
2 changes: 2 additions & 0 deletions modules/cudaarithm/test/test_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,8 @@ CUDA_TEST_P(Flip, Accuracy)

CUDA_TEST_P(Flip, AccuracyInplace)
{
size.width = (size.width >> 1) << 1; // in-place version only accepts even number
size.height = (size.height >> 1) << 1; // in-place version only accepts even number
cv::Mat src = randomMat(size, type);

cv::cuda::GpuMat srcDst = loadMat(src, useRoi);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ and MPI-Sintel formats. Note that the resulting disparity map is scaled by 16.

@result returns zero if successfully read the ground truth
*/
CV_EXPORTS
CV_EXPORTS_W
int readGT(String src_path,OutputArray dst);

/** @brief Function for computing mean square error for disparity maps
Expand All @@ -173,7 +173,7 @@ int readGT(String src_path,OutputArray dst);

@result returns mean square error between GT and src
*/
CV_EXPORTS
CV_EXPORTS_W
double computeMSE(InputArray GT, InputArray src, Rect ROI);

/** @brief Function for computing the percent of "bad" pixels in the disparity map
Expand All @@ -189,7 +189,7 @@ double computeMSE(InputArray GT, InputArray src, Rect ROI);

@result returns mean square error between GT and src
*/
CV_EXPORTS
CV_EXPORTS_W
double computeBadPixelPercent(InputArray GT, InputArray src, Rect ROI, int thresh=24/*1.5 pixels*/);

/** @brief Function for creating a disparity map visualization (clamped CV_8U image)
Expand All @@ -200,7 +200,7 @@ double computeBadPixelPercent(InputArray GT, InputArray src, Rect ROI, int thres

@param scale disparity map will be multiplied by this value for visualization
*/
CV_EXPORTS
CV_EXPORTS_W
void getDisparityVis(InputArray src,OutputArray dst,double scale=1.0);

//! @}
Expand Down
24 changes: 24 additions & 0 deletions modules/ximgproc/misc/python/test/test_disparity.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env python
import cv2 as cv
import numpy as np

from tests_common import NewOpenCVTests

class disparity_test(NewOpenCVTests):
def test_disp(self):
# readGT
ret,GT = cv.ximgproc.readGT(self.find_file("cv/disparityfilter/GT.png"))
self.assertEqual(ret, 0) # returns 0 on success!
self.assertFalse(np.shape(GT) == ())

# computeMSE
left = cv.imread(self.find_file("cv/disparityfilter/disparity_left_raw.png"), cv.IMREAD_UNCHANGED)
self.assertFalse(np.shape(left) == ())
left = np.asarray(left, dtype=np.int16)
mse = cv.ximgproc.computeMSE(GT, left, (0, 0, GT.shape[1], GT.shape[0]))

# computeBadPixelPercent
bad = cv.ximgproc.computeBadPixelPercent(GT, left, (0, 0, GT.shape[1], GT.shape[0]), 24)

if __name__ == '__main__':
NewOpenCVTests.bootstrap()
3 changes: 0 additions & 3 deletions modules/ximgproc/src/disparity_filters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,6 @@ void DisparityWLSFilterImpl::ParallelMatOp_ParBody::operator() (const Range& ran
(wls->*ops[i])(*src[i],*dst[i]);
}

CV_EXPORTS_W
Ptr<DisparityWLSFilter> createDisparityWLSFilter(Ptr<StereoMatcher> matcher_left)
{
Ptr<DisparityWLSFilter> wls;
Expand Down Expand Up @@ -451,7 +450,6 @@ Ptr<DisparityWLSFilter> createDisparityWLSFilter(Ptr<StereoMatcher> matcher_left
return wls;
}

CV_EXPORTS_W
Ptr<StereoMatcher> createRightMatcher(Ptr<StereoMatcher> matcher_left)
{
int min_disp = matcher_left->getMinDisparity();
Expand Down Expand Up @@ -485,7 +483,6 @@ Ptr<StereoMatcher> createRightMatcher(Ptr<StereoMatcher> matcher_left)
}
}

CV_EXPORTS_W
Ptr<DisparityWLSFilter> createDisparityWLSFilterGeneric(bool use_confidence)
{
return Ptr<DisparityWLSFilter>(DisparityWLSFilterImpl::create(use_confidence));
Expand Down