mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 09:25:45 +08:00
fixed python test failures (modified stereo correspondence test to use cv2.* stuff), fixed docs
This commit is contained in:
parent
7b5923e98b
commit
44157c421f
@ -1083,7 +1083,7 @@ Reprojects a disparity image to 3D space.
|
||||
|
||||
:param Q: :math:`4 \times 4` perspective transformation matrix that can be obtained with :ocv:func:`stereoRectify`.
|
||||
|
||||
:param handleMissingValues: Indicates, whether the function should handle missing values (i.e. points where the disparity was not computed). If ``handleMissingValues=true``, then pixels with the minimal disparity that corresponds to the outliers (see :ocv:funcx:`StereoBM::operator()` ) are transformed to 3D points with a very large Z value (currently set to 10000).
|
||||
:param handleMissingValues: Indicates, whether the function should handle missing values (i.e. points where the disparity was not computed). If ``handleMissingValues=true``, then pixels with the minimal disparity that corresponds to the outliers (see :ocv:funcx:`StereoMatcher::compute` ) are transformed to 3D points with a very large Z value (currently set to 10000).
|
||||
|
||||
:param ddepth: The optional output array depth. If it is ``-1``, the output image will have ``CV_32F`` depth. ``ddepth`` can also be set to ``CV_16S``, ``CV_32S`` or ``CV_32F``.
|
||||
|
||||
@ -1170,7 +1170,7 @@ StereoMatcher
|
||||
-------------
|
||||
.. ocv:class:: StereoMatcher : public Algorithm
|
||||
|
||||
The base class for stereo correspondence algorithms. ::
|
||||
The base class for stereo correspondence algorithms.
|
||||
|
||||
StereoMatcher::compute
|
||||
-----------------------
|
||||
|
@ -731,7 +731,7 @@ public:
|
||||
CV_WRAP virtual void setROI2(Rect roi2) = 0;
|
||||
};
|
||||
|
||||
CV_EXPORTS Ptr<StereoBM> createStereoBM(int numDisparities=0, int blockSize=21);
|
||||
CV_EXPORTS_W Ptr<StereoBM> createStereoBM(int numDisparities=0, int blockSize=21);
|
||||
|
||||
|
||||
class CV_EXPORTS_W StereoSGBM : public StereoMatcher
|
||||
@ -756,7 +756,7 @@ public:
|
||||
};
|
||||
|
||||
|
||||
CV_EXPORTS Ptr<StereoSGBM> createStereoSGBM(int minDisparity, int numDisparities, int blockSize,
|
||||
CV_EXPORTS_W Ptr<StereoSGBM> createStereoSGBM(int minDisparity, int numDisparities, int blockSize,
|
||||
int P1=0, int P2=0, int disp12MaxDiff=0,
|
||||
int preFilterCap=0, int uniquenessRatio=0,
|
||||
int speckleWindowSize=0, int speckleRange=0,
|
||||
|
@ -129,6 +129,10 @@ typedef Ptr<DescriptorExtractor> Ptr_DescriptorExtractor;
|
||||
typedef Ptr<Feature2D> Ptr_Feature2D;
|
||||
typedef Ptr<DescriptorMatcher> Ptr_DescriptorMatcher;
|
||||
|
||||
typedef Ptr<StereoMatcher> Ptr_StereoMatcher;
|
||||
typedef Ptr<StereoBM> Ptr_StereoBM;
|
||||
typedef Ptr<StereoSGBM> Ptr_StereoSGBM;
|
||||
|
||||
typedef Ptr<cv::softcascade::ChannelFeatureBuilder> Ptr_ChannelFeatureBuilder;
|
||||
|
||||
typedef SimpleBlobDetector::Params SimpleBlobDetector_Params;
|
||||
|
@ -14,6 +14,8 @@ import getopt
|
||||
import operator
|
||||
import functools
|
||||
|
||||
import numpy as np
|
||||
import cv2
|
||||
import cv2.cv as cv
|
||||
|
||||
from test2 import *
|
||||
@ -78,6 +80,12 @@ class OpenCVTests(unittest.TestCase):
|
||||
cv.SetData(imagefiledata, filedata, len(filedata))
|
||||
self.image_cache[filename] = cv.DecodeImageM(imagefiledata, iscolor)
|
||||
return self.image_cache[filename]
|
||||
|
||||
def get_sample2(self, filename, iscolor = cv.CV_LOAD_IMAGE_COLOR):
|
||||
if not filename in self.image_cache:
|
||||
filedata = urllib.urlopen("https://raw.github.com/Itseez/opencv/master/" + filename).read()
|
||||
self.image_cache[filename] = cv2.imdecode(np.fromstring(filedata, dtype=np.uint8), iscolor)
|
||||
return self.image_cache[filename]
|
||||
|
||||
def setUp(self):
|
||||
self.image_cache = {}
|
||||
@ -987,47 +995,14 @@ class AreaTests(OpenCVTests):
|
||||
self.assertRaises(cv.error, lambda: l[tup2])
|
||||
|
||||
def test_stereo(self):
|
||||
bm = cv.CreateStereoBMState()
|
||||
def illegal_delete():
|
||||
bm = cv.CreateStereoBMState()
|
||||
del bm.preFilterType
|
||||
def illegal_assign():
|
||||
bm = cv.CreateStereoBMState()
|
||||
bm.preFilterType = "foo"
|
||||
|
||||
self.assertRaises(TypeError, illegal_delete)
|
||||
self.assertRaises(TypeError, illegal_assign)
|
||||
|
||||
left = self.get_sample("samples/c/lena.jpg", 0)
|
||||
right = self.get_sample("samples/c/lena.jpg", 0)
|
||||
disparity = cv.CreateMat(512, 512, cv.CV_16SC1)
|
||||
cv.FindStereoCorrespondenceBM(left, right, disparity, bm)
|
||||
|
||||
gc = cv.CreateStereoGCState(16, 2)
|
||||
left_disparity = cv.CreateMat(512, 512, cv.CV_16SC1)
|
||||
right_disparity = cv.CreateMat(512, 512, cv.CV_16SC1)
|
||||
|
||||
def test_stereo(self):
|
||||
bm = cv.CreateStereoBMState()
|
||||
def illegal_delete():
|
||||
bm = cv.CreateStereoBMState()
|
||||
del bm.preFilterType
|
||||
def illegal_assign():
|
||||
bm = cv.CreateStereoBMState()
|
||||
bm.preFilterType = "foo"
|
||||
|
||||
self.assertRaises(TypeError, illegal_delete)
|
||||
self.assertRaises(TypeError, illegal_assign)
|
||||
|
||||
left = self.get_sample("samples/c/lena.jpg", 0)
|
||||
right = self.get_sample("samples/c/lena.jpg", 0)
|
||||
disparity = cv.CreateMat(512, 512, cv.CV_16SC1)
|
||||
cv.FindStereoCorrespondenceBM(left, right, disparity, bm)
|
||||
|
||||
gc = cv.CreateStereoGCState(16, 2)
|
||||
left_disparity = cv.CreateMat(512, 512, cv.CV_16SC1)
|
||||
right_disparity = cv.CreateMat(512, 512, cv.CV_16SC1)
|
||||
cv.FindStereoCorrespondenceGC(left, right, left_disparity, right_disparity, gc)
|
||||
left = self.get_sample2("samples/cpp/tsukuba_l.png", 0)
|
||||
right = self.get_sample2("samples/cpp/tsukuba_r.png", 0)
|
||||
bm = cv2.createStereoBM(32, 11)
|
||||
disparity = bm.compute(left, right)
|
||||
self.assertEqual(left.shape, disparity.shape)
|
||||
sgbm = cv2.createStereoSGBM(0, 32, 5)
|
||||
disparity2 = sgbm.compute(left, right)
|
||||
self.assertEqual(left.shape, disparity2.shape)
|
||||
|
||||
def test_kalman(self):
|
||||
k = cv.CreateKalman(2, 1, 0)
|
||||
|
Loading…
Reference in New Issue
Block a user