Skip to content

Commit 8cc47c2

Browse files
authored
Merge pull request #3898 from CodeHotel:4.x
Fix: Restore MATLAB Module Compilation for OpenCV 4.x
2 parents 385bd6f + 5cdfca7 commit 8cc47c2

File tree

3 files changed

+42
-4
lines changed

3 files changed

+42
-4
lines changed

Diff for: modules/matlab/CMakeLists.txt

+4
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ ocv_add_module(matlab BINDINGS
113113
opencv_calib opencv_calib3d
114114
opencv_stitching opencv_superres
115115
opencv_xfeatures2d
116+
opencv_optflow
117+
opencv_xphoto
116118
)
117119

118120
# get the commit information
@@ -156,6 +158,8 @@ endforeach()
156158
# add extra headers by hand
157159
list(APPEND opencv_extra_hdrs "core=${OPENCV_MODULE_opencv_core_LOCATION}/include/opencv2/core/base.hpp")
158160
list(APPEND opencv_extra_hdrs "video=${OPENCV_MODULE_opencv_video_LOCATION}/include/opencv2/video/tracking.hpp")
161+
list(APPEND opencv_extra_hdrs "optflow=${OPENCV_MODULE_opencv_optflow_LOCATION}/include/opencv2/optflow.hpp")
162+
159163

160164
# pass the OPENCV_CXX_EXTRA_FLAGS through to the mex compiler
161165
# remove the visibility modifiers, so the mex gateway is visible

Diff for: modules/matlab/generator/parse_tree.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import collections
1+
import sys
2+
if sys.version_info >= (3, 10):
3+
import collections.abc
4+
IterableType = collections.abc.Iterable
5+
else:
6+
import collections
7+
IterableType = collections.Iterable
28
from textwrap import fill
39
from filters import *
410
try:
@@ -371,7 +377,7 @@ def todict(obj):
371377
return obj
372378
elif isinstance(obj, dict):
373379
return dict((key, todict(val)) for key, val in obj.items())
374-
elif isinstance(obj, collections.Iterable):
380+
elif isinstance(obj, IterableType):
375381
return [todict(val) for val in obj]
376382
elif hasattr(obj, '__dict__'):
377383
return todict(vars(obj))

Diff for: modules/matlab/include/opencv2/matlab/bridge.hpp

+30-2
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,21 @@
5555
#include <opencv2/photo.hpp>
5656
#include <opencv2/stitching.hpp>
5757
#include <opencv2/video.hpp>
58+
#include <opencv2/optflow.hpp>
59+
#include <opencv2/xphoto.hpp>
60+
61+
/* This 'using' line was added in order to fix the following Error.
62+
* Failed to compile currentUIFramework:
63+
* modules/matlab/src/currentUIFramework.cpp:
64+
* In function void mexFunction(int, mxArray**, int, const mxArray**)
65+
* error: string was not declared in this scope
66+
* string retval; in line 41
67+
*
68+
* This error happens at the last stage of opencv build, when compiling the mex bindings
69+
* TODO: This is NOT the optimal fix, and needs to be addressed
70+
*/
71+
using std::string;
72+
5873

5974
namespace cv {
6075
namespace bridge {
@@ -85,17 +100,21 @@ typedef cv::Ptr<AlignMTB> Ptr_AlignMTB;
85100
typedef cv::Ptr<CalibrateDebevec> Ptr_CalibrateDebevec;
86101
typedef cv::Ptr<CalibrateRobertson> Ptr_CalibrateRobertson;
87102
typedef cv::Ptr<DenseOpticalFlow> Ptr_DenseOpticalFlow;
88-
typedef cv::Ptr<DualTVL1OpticalFlow> Ptr_DualTVL1OpticalFlow;
103+
typedef cv::Ptr<cv::optflow::DualTVL1OpticalFlow> Ptr_DualTVL1OpticalFlow;
89104
typedef cv::Ptr<MergeDebevec> Ptr_MergeDebevec;
90105
typedef cv::Ptr<MergeMertens> Ptr_MergeMertens;
91106
typedef cv::Ptr<MergeRobertson> Ptr_MergeRobertson;
92107
typedef cv::Ptr<Stitcher> Ptr_Stitcher;
93108
typedef cv::Ptr<Tonemap> Ptr_Tonemap;
94109
typedef cv::Ptr<TonemapDrago> Ptr_TonemapDrago;
95-
typedef cv::Ptr<TonemapDurand> Ptr_TonemapDurand;
110+
typedef cv::Ptr<cv::xphoto::TonemapDurand> Ptr_TonemapDurand;
96111
typedef cv::Ptr<TonemapMantiuk> Ptr_TonemapMantiuk;
97112
typedef cv::Ptr<TonemapReinhard> Ptr_TonemapReinhard;
98113
typedef cv::Ptr<float> Ptr_float;
114+
typedef cv::Ptr<cv::GeneralizedHoughBallard> Ptr_GeneralizedHoughBallard;
115+
typedef cv::Ptr<cv::GeneralizedHoughGuil> Ptr_GeneralizedHoughGuil;
116+
117+
99118

100119
// ----------------------------------------------------------------------------
101120
// PREDECLARATIONS
@@ -527,6 +546,15 @@ class Bridge {
527546
Bridge& operator=(const Ptr_float& ) { return *this; }
528547
Ptr_float toPtrFloat() { return Ptr_float(); }
529548
operator Ptr_float() { return toPtrFloat(); }
549+
550+
// --------------------------- Ptr_GeneralizedHoughBallard --------------
551+
Bridge& operator=(const Ptr_GeneralizedHoughBallard& obj) { return *this; }
552+
operator Ptr_GeneralizedHoughBallard() { return Ptr_GeneralizedHoughBallard(); }
553+
554+
// --------------------------- Ptr_GeneralizedHoughGuil ----------------------
555+
Bridge& operator=(const Ptr_GeneralizedHoughGuil& obj) { return *this; }
556+
operator Ptr_GeneralizedHoughGuil() { return Ptr_GeneralizedHoughGuil(); }
557+
530558
}; // class Bridge
531559

532560

0 commit comments

Comments
 (0)