1
0
mirror of https://github.com/opencv/opencv_contrib.git synced 2025-10-20 04:25:42 +08:00

Merge pull request #3898 from CodeHotel:4.x

Fix: Restore MATLAB Module Compilation for OpenCV 4.x
This commit is contained in:
Alexander Smorkalov
2025-03-21 10:13:22 +03:00
committed by GitHub
3 changed files with 42 additions and 4 deletions

View File

@@ -113,6 +113,8 @@ ocv_add_module(matlab BINDINGS
opencv_calib opencv_calib3d opencv_calib opencv_calib3d
opencv_stitching opencv_superres opencv_stitching opencv_superres
opencv_xfeatures2d opencv_xfeatures2d
opencv_optflow
opencv_xphoto
) )
# get the commit information # get the commit information
@@ -156,6 +158,8 @@ endforeach()
# add extra headers by hand # add extra headers by hand
list(APPEND opencv_extra_hdrs "core=${OPENCV_MODULE_opencv_core_LOCATION}/include/opencv2/core/base.hpp") list(APPEND opencv_extra_hdrs "core=${OPENCV_MODULE_opencv_core_LOCATION}/include/opencv2/core/base.hpp")
list(APPEND opencv_extra_hdrs "video=${OPENCV_MODULE_opencv_video_LOCATION}/include/opencv2/video/tracking.hpp") list(APPEND opencv_extra_hdrs "video=${OPENCV_MODULE_opencv_video_LOCATION}/include/opencv2/video/tracking.hpp")
list(APPEND opencv_extra_hdrs "optflow=${OPENCV_MODULE_opencv_optflow_LOCATION}/include/opencv2/optflow.hpp")
# pass the OPENCV_CXX_EXTRA_FLAGS through to the mex compiler # pass the OPENCV_CXX_EXTRA_FLAGS through to the mex compiler
# remove the visibility modifiers, so the mex gateway is visible # remove the visibility modifiers, so the mex gateway is visible

View File

@@ -1,4 +1,10 @@
import collections import sys
if sys.version_info >= (3, 10):
import collections.abc
IterableType = collections.abc.Iterable
else:
import collections
IterableType = collections.Iterable
from textwrap import fill from textwrap import fill
from filters import * from filters import *
try: try:
@@ -371,7 +377,7 @@ def todict(obj):
return obj return obj
elif isinstance(obj, dict): elif isinstance(obj, dict):
return dict((key, todict(val)) for key, val in obj.items()) return dict((key, todict(val)) for key, val in obj.items())
elif isinstance(obj, collections.Iterable): elif isinstance(obj, IterableType):
return [todict(val) for val in obj] return [todict(val) for val in obj]
elif hasattr(obj, '__dict__'): elif hasattr(obj, '__dict__'):
return todict(vars(obj)) return todict(vars(obj))

View File

@@ -55,6 +55,21 @@
#include <opencv2/photo.hpp> #include <opencv2/photo.hpp>
#include <opencv2/stitching.hpp> #include <opencv2/stitching.hpp>
#include <opencv2/video.hpp> #include <opencv2/video.hpp>
#include <opencv2/optflow.hpp>
#include <opencv2/xphoto.hpp>
/* This 'using' line was added in order to fix the following Error.
* Failed to compile currentUIFramework:
* modules/matlab/src/currentUIFramework.cpp:
* In function void mexFunction(int, mxArray**, int, const mxArray**)
* error: string was not declared in this scope
* string retval; in line 41
*
* This error happens at the last stage of opencv build, when compiling the mex bindings
* TODO: This is NOT the optimal fix, and needs to be addressed
*/
using std::string;
namespace cv { namespace cv {
namespace bridge { namespace bridge {
@@ -85,17 +100,21 @@ typedef cv::Ptr<AlignMTB> Ptr_AlignMTB;
typedef cv::Ptr<CalibrateDebevec> Ptr_CalibrateDebevec; typedef cv::Ptr<CalibrateDebevec> Ptr_CalibrateDebevec;
typedef cv::Ptr<CalibrateRobertson> Ptr_CalibrateRobertson; typedef cv::Ptr<CalibrateRobertson> Ptr_CalibrateRobertson;
typedef cv::Ptr<DenseOpticalFlow> Ptr_DenseOpticalFlow; typedef cv::Ptr<DenseOpticalFlow> Ptr_DenseOpticalFlow;
typedef cv::Ptr<DualTVL1OpticalFlow> Ptr_DualTVL1OpticalFlow; typedef cv::Ptr<cv::optflow::DualTVL1OpticalFlow> Ptr_DualTVL1OpticalFlow;
typedef cv::Ptr<MergeDebevec> Ptr_MergeDebevec; typedef cv::Ptr<MergeDebevec> Ptr_MergeDebevec;
typedef cv::Ptr<MergeMertens> Ptr_MergeMertens; typedef cv::Ptr<MergeMertens> Ptr_MergeMertens;
typedef cv::Ptr<MergeRobertson> Ptr_MergeRobertson; typedef cv::Ptr<MergeRobertson> Ptr_MergeRobertson;
typedef cv::Ptr<Stitcher> Ptr_Stitcher; typedef cv::Ptr<Stitcher> Ptr_Stitcher;
typedef cv::Ptr<Tonemap> Ptr_Tonemap; typedef cv::Ptr<Tonemap> Ptr_Tonemap;
typedef cv::Ptr<TonemapDrago> Ptr_TonemapDrago; typedef cv::Ptr<TonemapDrago> Ptr_TonemapDrago;
typedef cv::Ptr<TonemapDurand> Ptr_TonemapDurand; typedef cv::Ptr<cv::xphoto::TonemapDurand> Ptr_TonemapDurand;
typedef cv::Ptr<TonemapMantiuk> Ptr_TonemapMantiuk; typedef cv::Ptr<TonemapMantiuk> Ptr_TonemapMantiuk;
typedef cv::Ptr<TonemapReinhard> Ptr_TonemapReinhard; typedef cv::Ptr<TonemapReinhard> Ptr_TonemapReinhard;
typedef cv::Ptr<float> Ptr_float; typedef cv::Ptr<float> Ptr_float;
typedef cv::Ptr<cv::GeneralizedHoughBallard> Ptr_GeneralizedHoughBallard;
typedef cv::Ptr<cv::GeneralizedHoughGuil> Ptr_GeneralizedHoughGuil;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// PREDECLARATIONS // PREDECLARATIONS
@@ -527,6 +546,15 @@ public:
Bridge& operator=(const Ptr_float& ) { return *this; } Bridge& operator=(const Ptr_float& ) { return *this; }
Ptr_float toPtrFloat() { return Ptr_float(); } Ptr_float toPtrFloat() { return Ptr_float(); }
operator Ptr_float() { return toPtrFloat(); } operator Ptr_float() { return toPtrFloat(); }
// --------------------------- Ptr_GeneralizedHoughBallard --------------
Bridge& operator=(const Ptr_GeneralizedHoughBallard& obj) { return *this; }
operator Ptr_GeneralizedHoughBallard() { return Ptr_GeneralizedHoughBallard(); }
// --------------------------- Ptr_GeneralizedHoughGuil ----------------------
Bridge& operator=(const Ptr_GeneralizedHoughGuil& obj) { return *this; }
operator Ptr_GeneralizedHoughGuil() { return Ptr_GeneralizedHoughGuil(); }
}; // class Bridge }; // class Bridge