added contrib module support in Python wrappers (thanks to Eric Christiansen)
authorVadim Pisarevsky <no@email>
Wed, 4 Jul 2012 17:59:14 +0000 (17:59 +0000)
committerVadim Pisarevsky <no@email>
Wed, 4 Jul 2012 17:59:14 +0000 (17:59 +0000)
modules/contrib/include/opencv2/contrib/contrib.hpp
modules/python/CMakeLists.txt
modules/python/src2/cv2.cpp
modules/python/src2/hdr_parser.py

index 75b4065..2f7a119 100644 (file)
@@ -557,15 +557,15 @@ namespace cv
         void* user_data;
     };
 
-    CV_EXPORTS int chamerMatching( Mat& img, Mat& templ,
-                                  vector<vector<Point> >& results, vector<float>& cost,
+    CV_EXPORTS_W int chamerMatching( Mat& img, Mat& templ,
+                                  CV_OUT vector<vector<Point> >& results, CV_OUT vector<float>& cost,
                                   double templScale=1, int maxMatches = 20,
                                   double minMatchDistance = 1.0, int padX = 3,
                                   int padY = 3, int scales = 5, double minScale = 0.6, double maxScale = 1.6,
                                   double orientationWeight = 0.5, double truncate = 20);
 
 
-    class CV_EXPORTS StereoVar
+    class CV_EXPORTS_W StereoVar
     {
     public:
         // Flags
@@ -918,26 +918,26 @@ namespace cv
         void lda(InputArray src, InputArray labels);
     };
 
-    class CV_EXPORTS FaceRecognizer : public Algorithm
+    class CV_EXPORTS_W FaceRecognizer : public Algorithm
     {
     public:
         //! virtual destructor
         virtual ~FaceRecognizer() {}
 
         // Trains a FaceRecognizer.
-        virtual void train(InputArray src, InputArray labels) = 0;
+        CV_WRAP virtual void train(InputArray src, InputArray labels) = 0;
 
         // Gets a prediction from a FaceRecognizer.
         virtual int predict(InputArray src) const = 0;
 
         // Predicts the label and confidence for a given sample.
-        virtual void predict(InputArray src, int &label, double &dist) const = 0;
+        CV_WRAP virtual void predict(InputArray src, CV_OUT int &label, CV_OUT double &dist) const = 0;
 
         // Serializes this object to a given filename.
-        virtual void save(const string& filename) const;
+        CV_WRAP virtual void save(const string& filename) const;
 
         // Deserializes this object from a given filename.
-        virtual void load(const string& filename);
+        CV_WRAP virtual void load(const string& filename);
 
         // Serializes this object to a given cv::FileStorage.
         virtual void save(FileStorage& fs) const = 0;
@@ -947,9 +947,9 @@ namespace cv
 
     };
 
-    CV_EXPORTS Ptr<FaceRecognizer> createEigenFaceRecognizer(int num_components = 0, double threshold = DBL_MAX);
-    CV_EXPORTS Ptr<FaceRecognizer> createFisherFaceRecognizer(int num_components = 0, double threshold = DBL_MAX);
-    CV_EXPORTS Ptr<FaceRecognizer> createLBPHFaceRecognizer(int radius=1, int neighbors=8,
+    CV_EXPORTS_W Ptr<FaceRecognizer> createEigenFaceRecognizer(int num_components = 0, double threshold = DBL_MAX);
+    CV_EXPORTS_W Ptr<FaceRecognizer> createFisherFaceRecognizer(int num_components = 0, double threshold = DBL_MAX);
+    CV_EXPORTS_W Ptr<FaceRecognizer> createLBPHFaceRecognizer(int radius=1, int neighbors=8,
                                                             int grid_x=8, int grid_y=8, double threshold = DBL_MAX);
 
     enum
@@ -968,12 +968,11 @@ namespace cv
         COLORMAP_HOT = 11
     };
 
-    CV_EXPORTS void applyColorMap(InputArray src, OutputArray dst, int colormap);
+    CV_EXPORTS_W void applyColorMap(InputArray src, OutputArray dst, int colormap);
 
-    CV_EXPORTS bool initModule_contrib();
+    CV_EXPORTS_W bool initModule_contrib();
 }
 
-
 #include "opencv2/contrib/retina.hpp"
 
 #endif
index 81cf81d..4636dfa 100644 (file)
@@ -10,7 +10,7 @@ if(ANDROID OR IOS OR NOT PYTHONLIBS_FOUND OR NOT PYTHON_USE_NUMPY)
 endif()
 
 set(the_description "The python bindings")
-ocv_add_module(python BINDINGS opencv_core opencv_flann opencv_imgproc opencv_video opencv_ml opencv_features2d opencv_highgui opencv_calib3d opencv_photo opencv_objdetect opencv_legacy OPTIONAL opencv_nonfree)
+ocv_add_module(python BINDINGS opencv_core opencv_flann opencv_imgproc opencv_video opencv_ml opencv_features2d opencv_highgui opencv_calib3d opencv_photo opencv_objdetect opencv_contrib opencv_legacy OPTIONAL opencv_nonfree)
 
 add_definitions(-DPYTHON_USE_NUMPY=1)
 
@@ -20,6 +20,8 @@ ocv_module_include_directories(
     "${CMAKE_CURRENT_SOURCE_DIR}/src2"
     )
 
+    
+
 set(opencv_hdrs
     "${OPENCV_MODULE_opencv_core_LOCATION}/include/opencv2/core/core.hpp"
     "${OPENCV_MODULE_opencv_flann_LOCATION}/include/opencv2/flann/miniflann.hpp"
@@ -31,7 +33,8 @@ set(opencv_hdrs
     "${OPENCV_MODULE_opencv_ml_LOCATION}/include/opencv2/ml/ml.hpp"
     "${OPENCV_MODULE_opencv_features2d_LOCATION}/include/opencv2/features2d/features2d.hpp"
     "${OPENCV_MODULE_opencv_calib3d_LOCATION}/include/opencv2/calib3d/calib3d.hpp"
-    "${OPENCV_MODULE_opencv_objdetect_LOCATION}/include/opencv2/objdetect/objdetect.hpp")
+    "${OPENCV_MODULE_opencv_objdetect_LOCATION}/include/opencv2/objdetect/objdetect.hpp"
+    "${OPENCV_MODULE_opencv_contrib_LOCATION}/include/opencv2/contrib/contrib.hpp")
 
 if(HAVE_opencv_nonfree)
   list(APPEND opencv_hdrs     "${OPENCV_MODULE_opencv_nonfree_LOCATION}/include/opencv2/nonfree/features2d.hpp"
index 4924e9b..204380a 100644 (file)
@@ -9,6 +9,7 @@
 #include "numpy/ndarrayobject.h"
 
 #include "opencv2/core/core.hpp"
+#include "opencv2/contrib/contrib.hpp"
 #include "opencv2/flann/miniflann.hpp"
 #include "opencv2/imgproc/imgproc.hpp"
 #include "opencv2/calib3d/calib3d.hpp"
@@ -116,6 +117,9 @@ typedef cvflann::flann_algorithm_t cvflann_flann_algorithm_t;
 typedef Ptr<flann::IndexParams> Ptr_flann_IndexParams;
 typedef Ptr<flann::SearchParams> Ptr_flann_SearchParams;
 
+typedef Ptr<FaceRecognizer> Ptr_FaceRecognizer;
+typedef vector<Scalar> vector_Scalar;
+
 static PyObject* failmsgp(const char *fmt, ...)
 {
   char str[1000];
index 8bee6b5..a765612 100755 (executable)
@@ -11,6 +11,7 @@ opencv_hdr_list = [
 "../../video/include/opencv2/video/tracking.hpp",
 "../../video/include/opencv2/video/background_segm.hpp",
 "../../objdetect/include/opencv2/objdetect/objdetect.hpp",
+"../../contrib/include/opencv2/contrib/contrib.hpp",
 "../../highgui/include/opencv2/highgui/highgui.hpp"
 ]