From 2756ae205190afd8ced32750111e9219de44c9ba Mon Sep 17 00:00:00 2001 From: Alexander Mordvintsev Date: Tue, 29 Apr 2014 16:57:19 +0400 Subject: [PATCH 1/2] exposed OpenCL-control functions to python --- modules/core/include/opencv2/core/ocl.hpp | 12 ++++++------ modules/python/CMakeLists.txt | 1 + modules/python/src2/gen2.py | 3 ++- modules/python/src2/hdr_parser.py | 1 + 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/modules/core/include/opencv2/core/ocl.hpp b/modules/core/include/opencv2/core/ocl.hpp index b751c51201..99fa83a98d 100644 --- a/modules/core/include/opencv2/core/ocl.hpp +++ b/modules/core/include/opencv2/core/ocl.hpp @@ -46,12 +46,12 @@ namespace cv { namespace ocl { -CV_EXPORTS bool haveOpenCL(); -CV_EXPORTS bool useOpenCL(); -CV_EXPORTS bool haveAmdBlas(); -CV_EXPORTS bool haveAmdFft(); -CV_EXPORTS void setUseOpenCL(bool flag); -CV_EXPORTS void finish(); +CV_EXPORTS_W bool haveOpenCL(); +CV_EXPORTS_W bool useOpenCL(); +CV_EXPORTS_W bool haveAmdBlas(); +CV_EXPORTS_W bool haveAmdFft(); +CV_EXPORTS_W void setUseOpenCL(bool flag); +CV_EXPORTS_W void finish(); class CV_EXPORTS Context; class CV_EXPORTS Device; diff --git a/modules/python/CMakeLists.txt b/modules/python/CMakeLists.txt index 894c605f40..f796a97634 100644 --- a/modules/python/CMakeLists.txt +++ b/modules/python/CMakeLists.txt @@ -25,6 +25,7 @@ set(opencv_hdrs "${OPENCV_MODULE_opencv_core_LOCATION}/include/opencv2/core/types.hpp" "${OPENCV_MODULE_opencv_core_LOCATION}/include/opencv2/core/persistence.hpp" "${OPENCV_MODULE_opencv_core_LOCATION}/include/opencv2/core/utility.hpp" + "${OPENCV_MODULE_opencv_core_LOCATION}/include/opencv2/core/ocl.hpp" "${OPENCV_MODULE_opencv_flann_LOCATION}/include/opencv2/flann/miniflann.hpp" "${OPENCV_MODULE_opencv_imgproc_LOCATION}/include/opencv2/imgproc.hpp" "${OPENCV_MODULE_opencv_video_LOCATION}/include/opencv2/video/background_segm.hpp" diff --git a/modules/python/src2/gen2.py b/modules/python/src2/gen2.py index 3d1300847f..b613ccd4ac 100755 --- a/modules/python/src2/gen2.py +++ b/modules/python/src2/gen2.py @@ -776,7 +776,7 @@ class PythonWrapperGenerator(object): classname = bareclassname = "" name = decl[0] dpos = name.rfind(".") - if dpos >= 0 and name[:dpos] != "cv": + if dpos >= 0 and name[:dpos] not in ["cv", "cv.ocl"]: classname = bareclassname = re.sub(r"^cv\.", "", name[:dpos]) name = name[dpos+1:] dpos = classname.rfind(".") @@ -785,6 +785,7 @@ class PythonWrapperGenerator(object): classname = classname.replace(".", "_") cname = name name = re.sub(r"^cv\.", "", name) + name = name.replace(".", "_") isconstructor = cname == bareclassname cname = cname.replace(".", "::") isclassmethod = False diff --git a/modules/python/src2/hdr_parser.py b/modules/python/src2/hdr_parser.py index b6f21c31eb..78981ed1c3 100755 --- a/modules/python/src2/hdr_parser.py +++ b/modules/python/src2/hdr_parser.py @@ -6,6 +6,7 @@ import os, sys, re, string # the list only for debugging. The real list, used in the real OpenCV build, is specified in CMakeLists.txt opencv_hdr_list = [ "../../core/include/opencv2/core.hpp", +"../../core/include/opencv2/core/ocl.hpp", "../../flann/include/opencv2/flann/miniflann.hpp", "../../ml/include/opencv2/ml.hpp", "../../imgproc/include/opencv2/imgproc.hpp", From a52979c37fab17249aa389cefc7778e93d2e1487 Mon Sep 17 00:00:00 2001 From: Alexander Mordvintsev Date: Wed, 14 May 2014 17:44:40 +0400 Subject: [PATCH 2/2] exposed TVL1 optical flow to python --- modules/video/include/opencv2/video/tracking.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/video/include/opencv2/video/tracking.hpp b/modules/video/include/opencv2/video/tracking.hpp index 2045b19d98..1cc27fb3ef 100644 --- a/modules/video/include/opencv2/video/tracking.hpp +++ b/modules/video/include/opencv2/video/tracking.hpp @@ -177,11 +177,11 @@ public: -class CV_EXPORTS DenseOpticalFlow : public Algorithm +class CV_EXPORTS_W DenseOpticalFlow : public Algorithm { public: - virtual void calc( InputArray I0, InputArray I1, InputOutputArray flow ) = 0; - virtual void collectGarbage() = 0; + CV_WRAP virtual void calc( InputArray I0, InputArray I1, InputOutputArray flow ) = 0; + CV_WRAP virtual void collectGarbage() = 0; }; // Implementation of the Zach, Pock and Bischof Dual TV-L1 Optical Flow method @@ -189,7 +189,7 @@ public: // see reference: // [1] C. Zach, T. Pock and H. Bischof, "A Duality Based Approach for Realtime TV-L1 Optical Flow". // [2] Javier Sanchez, Enric Meinhardt-Llopis and Gabriele Facciolo. "TV-L1 Optical Flow Estimation". -CV_EXPORTS Ptr createOptFlow_DualTVL1(); +CV_EXPORTS_W Ptr createOptFlow_DualTVL1(); } // cv