Skip to content

Commit dff1422

Browse files
committed
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
2 parents 53b9880 + b3ad2c3 commit dff1422

File tree

7 files changed

+92
-7
lines changed

7 files changed

+92
-7
lines changed

modules/line_descriptor/misc/python/pyopencv_LSDDetector.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
template<> struct pyopencvVecConverter<line_descriptor::KeyLine>
44
{
5-
static bool to(PyObject* obj, std::vector<line_descriptor::KeyLine>& value, const ArgInfo info)
5+
static bool to(PyObject* obj, std::vector<line_descriptor::KeyLine>& value, const ArgInfo& info)
66
{
77
return pyopencv_to_generic_vec(obj, value, info);
88
}

modules/rgbd/include/opencv2/rgbd.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,3 @@
2121
#endif
2222

2323
/* End of file. */
24-

modules/rgbd/include/opencv2/rgbd/depth.hpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,25 @@ namespace rgbd
345345
{
346346
}
347347

348+
/** Constructor
349+
* @param block_size The size of the blocks to look at for a stable MSE
350+
* @param min_size The minimum size of a cluster to be considered a plane
351+
* @param threshold The maximum distance of a point from a plane to belong to it (in meters)
352+
* @param sensor_error_a coefficient of the sensor error. 0 by default, 0.0075 for a Kinect
353+
* @param sensor_error_b coefficient of the sensor error. 0 by default
354+
* @param sensor_error_c coefficient of the sensor error. 0 by default
355+
* @param method The method to use to compute the planes.
356+
*/
357+
RgbdPlane(int method, int block_size,
358+
int min_size, double threshold, double sensor_error_a = 0,
359+
double sensor_error_b = 0, double sensor_error_c = 0);
360+
361+
~RgbdPlane();
362+
363+
CV_WRAP static Ptr<RgbdPlane> create(int method, int block_size, int min_size, double threshold,
364+
double sensor_error_a = 0, double sensor_error_b = 0,
365+
double sensor_error_c = 0);
366+
348367
/** Find The planes in a depth image
349368
* @param points3d the 3d points organized like the depth image: rows x cols with 3 channels
350369
* @param normals the normals for every point in the depth image

modules/rgbd/misc/python/pyopencv_linemod.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
template<> struct pyopencvVecConverter<linemod::Match>
55
{
6-
static bool to(PyObject* obj, std::vector<linemod::Match>& value, const ArgInfo info)
6+
static bool to(PyObject* obj, std::vector<linemod::Match>& value, const ArgInfo& info)
77
{
88
return pyopencv_to_generic_vec(obj, value, info);
99
}
@@ -16,7 +16,7 @@ template<> struct pyopencvVecConverter<linemod::Match>
1616

1717
template<> struct pyopencvVecConverter<linemod::Template>
1818
{
19-
static bool to(PyObject* obj, std::vector<linemod::Template>& value, const ArgInfo info)
19+
static bool to(PyObject* obj, std::vector<linemod::Template>& value, const ArgInfo& info)
2020
{
2121
return pyopencv_to_generic_vec(obj, value, info);
2222
}
@@ -29,7 +29,7 @@ template<> struct pyopencvVecConverter<linemod::Template>
2929

3030
template<> struct pyopencvVecConverter<linemod::Feature>
3131
{
32-
static bool to(PyObject* obj, std::vector<linemod::Feature>& value, const ArgInfo info)
32+
static bool to(PyObject* obj, std::vector<linemod::Feature>& value, const ArgInfo& info)
3333
{
3434
return pyopencv_to_generic_vec(obj, value, info);
3535
}
@@ -42,7 +42,7 @@ template<> struct pyopencvVecConverter<linemod::Feature>
4242

4343
template<> struct pyopencvVecConverter<Ptr<linemod::Modality> >
4444
{
45-
static bool to(PyObject* obj, std::vector<Ptr<linemod::Modality> >& value, const ArgInfo info)
45+
static bool to(PyObject* obj, std::vector<Ptr<linemod::Modality> >& value, const ArgInfo& info)
4646
{
4747
return pyopencv_to_generic_vec(obj, value, info);
4848
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env python
2+
3+
# Python 2/3 compatibility
4+
from __future__ import print_function
5+
6+
import os, numpy
7+
8+
import cv2 as cv
9+
10+
from tests_common import NewOpenCVTests
11+
12+
class rgbd_test(NewOpenCVTests):
13+
14+
def test_computeRgbdPlane(self):
15+
16+
depth_image = self.get_sample('/cv/rgbd/depth.png', cv.IMREAD_ANYDEPTH)
17+
if depth_image is None:
18+
raise unittest.SkipTest("Missing files with test data")
19+
20+
K = numpy.array([[525, 0, 320.5], [0, 525, 240.5], [0, 0, 1]])
21+
points3d = cv.rgbd.depthTo3d(depth_image, K)
22+
normals_computer = normals_computer = cv.rgbd.RgbdNormals_create(480, 640, 5, K)
23+
normals = normals_computer.apply(points3d)
24+
rgbd_plane = cv.rgbd.RgbdPlane_create(cv.rgbd.RgbdPlane_RGBD_PLANE_METHOD_DEFAULT, 40, 1600, 0.01, 0, 0, 0)
25+
_, planes_coeff = rgbd_plane.apply(points3d, normals)
26+
27+
planes_coeff_expected = \
28+
numpy.asarray([[[-0.02447728, -0.8678335 , -0.49625182, 4.02800846]],
29+
[[-0.05055107, -0.86144137, -0.50533485, 3.95456314]],
30+
[[-0.03294908, -0.86964548, -0.49257591, 3.97052431]],
31+
[[-0.02886586, -0.87153459, -0.48948362, 7.77550507]],
32+
[[-0.04455929, -0.87659335, -0.47916424, 3.93200684]],
33+
[[-0.21514639, 0.18835169, -0.95824611, 7.59479475]],
34+
[[-0.01006953, -0.86679155, -0.49856904, 4.01355648]],
35+
[[-0.00876531, -0.87571168, -0.48275498, 3.96768975]],
36+
[[-0.06395926, -0.86951321, -0.48975089, 4.08618736]],
37+
[[-0.01403128, -0.87593341, -0.48222789, 7.74559402]],
38+
[[-0.01143177, -0.87495202, -0.4840748 , 7.75355816]]],
39+
dtype=numpy.float32)
40+
41+
eps = 0.05
42+
self.assertLessEqual(cv.norm(planes_coeff, planes_coeff_expected, cv.NORM_L2), eps)
43+
44+
if __name__ == '__main__':
45+
NewOpenCVTests.bootstrap()

modules/rgbd/src/odometry.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,28 @@ Ptr<DepthCleaner> DepthCleaner::create(int depth_in, int window_size_in, int met
983983
return makePtr<DepthCleaner>(depth_in, window_size_in, method_in);
984984
}
985985

986+
RgbdPlane::RgbdPlane(int method, int block_size,
987+
int min_size, double threshold, double sensor_error_a,
988+
double sensor_error_b, double sensor_error_c) :
989+
method_(method),
990+
block_size_(block_size),
991+
min_size_(min_size),
992+
threshold_(threshold),
993+
sensor_error_a_(sensor_error_a),
994+
sensor_error_b_(sensor_error_b),
995+
sensor_error_c_(sensor_error_c)
996+
{}
997+
998+
Ptr<RgbdPlane> RgbdPlane::create(int method, int block_size, int min_size, double threshold,
999+
double sensor_error_a, double sensor_error_b,
1000+
double sensor_error_c ) {
1001+
return makePtr<RgbdPlane>(method, block_size, min_size, threshold,
1002+
sensor_error_a, sensor_error_b, sensor_error_c);
1003+
}
1004+
1005+
RgbdPlane::~RgbdPlane()
1006+
{}
1007+
9861008
RgbdFrame::RgbdFrame() : ID(-1)
9871009
{}
9881010

modules/surface_matching/misc/python/pyopencv_ppf_match_3d.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
template<> struct pyopencvVecConverter<ppf_match_3d::Pose3DPtr >
44
{
5-
static bool to(PyObject* obj, std::vector<ppf_match_3d::Pose3DPtr >& value, const ArgInfo info)
5+
static bool to(PyObject* obj, std::vector<ppf_match_3d::Pose3DPtr >& value, const ArgInfo& info)
66
{
77
return pyopencv_to_generic_vec(obj, value, info);
88
}

0 commit comments

Comments
 (0)