Merge branch '2.4'
authorAndrey Kamaev <andrey.kamaev@itseez.com>
Thu, 25 Oct 2012 11:32:48 +0000 (15:32 +0400)
committerAndrey Kamaev <andrey.kamaev@itseez.com>
Thu, 25 Oct 2012 11:32:48 +0000 (15:32 +0400)
1  2 
modules/core/include/opencv2/core/core.hpp
modules/core/src/algorithm.cpp

@@@ -1345,7 -1345,9 +1345,7 @@@ public
      virtual int channels(int i=-1) const;
      virtual bool empty() const;
  
 -#ifdef OPENCV_CAN_BREAK_BINARY_COMPATIBILITY
 -    virtual ~_InputArray();
 -#endif
 +    /*virtual*/ ~_InputArray();
  
      int flags;
      void* obj;
@@@ -1400,14 -1402,16 +1400,14 @@@ public
      virtual bool fixedType() const;
      virtual bool needed() const;
      virtual Mat& getMatRef(int i=-1) const;
 -    /*virtual*/ gpu::GpuMat& getGpuMatRef() const;
 +    virtual gpu::GpuMat& getGpuMatRef() const;
      virtual void create(Size sz, int type, int i=-1, bool allowTransposed=false, int fixedDepthMask=0) const;
      virtual void create(int rows, int cols, int type, int i=-1, bool allowTransposed=false, int fixedDepthMask=0) const;
      virtual void create(int dims, const int* size, int type, int i=-1, bool allowTransposed=false, int fixedDepthMask=0) const;
      virtual void release() const;
      virtual void clear() const;
  
 -#ifdef OPENCV_CAN_BREAK_BINARY_COMPATIBILITY
 -    virtual ~_OutputArray();
 -#endif
 +    /*virtual*/ ~_OutputArray();
  };
  
  typedef const _InputArray& InputArray;
@@@ -2139,11 -2143,15 +2139,11 @@@ CV_EXPORTS_W void reduce(InputArray src
  
  //! makes multi-channel array out of several single-channel arrays
  CV_EXPORTS void merge(const Mat* mv, size_t count, OutputArray dst);
 -CV_EXPORTS void merge(const vector<Mat>& mv, OutputArray dst );
 -
  //! makes multi-channel array out of several single-channel arrays
  CV_EXPORTS_W void merge(InputArrayOfArrays mv, OutputArray dst);
  
  //! copies each plane of a multi-channel array to a dedicated array
  CV_EXPORTS void split(const Mat& src, Mat* mvbegin);
 -CV_EXPORTS void split(const Mat& m, vector<Mat>& mv );
 -
  //! copies each plane of a multi-channel array to a dedicated array
  CV_EXPORTS_W void split(InputArray m, OutputArrayOfArrays mv);
  
@@@ -2380,7 -2388,7 +2380,7 @@@ public
      PCA(InputArray data, InputArray mean, int flags, double retainedVariance);
      //! operator that performs PCA. The previously stored data, if any, is released
      PCA& operator()(InputArray data, InputArray mean, int flags, int maxComponents=0);
 -    PCA& computeVar(InputArray data, InputArray mean, int flags, double retainedVariance);
 +    PCA& operator()(InputArray data, InputArray mean, int flags, double retainedVariance);
      //! projects vector from the original space to the principal components subspace
      Mat project(InputArray vec) const;
      //! projects vector from the original space to the principal components subspace
  CV_EXPORTS_W void PCACompute(InputArray data, CV_OUT InputOutputArray mean,
                               OutputArray eigenvectors, int maxComponents=0);
  
 -CV_EXPORTS_W void PCAComputeVar(InputArray data, CV_OUT InputOutputArray mean,
 +CV_EXPORTS_W void PCACompute(InputArray data, CV_OUT InputOutputArray mean,
                               OutputArray eigenvectors, double retainedVariance);
  
  CV_EXPORTS_W void PCAProject(InputArray data, InputArray mean,
@@@ -2562,7 -2570,7 +2562,7 @@@ CV_EXPORTS_W void fillPoly(InputOutputA
                             Point offset=Point() );
  
  //! draws one or more polygonal curves
 -CV_EXPORTS void polylines(Mat& img, const Point** pts, const int* npts,
 +CV_EXPORTS void polylines(Mat& img, const Point* const* pts, const int* npts,
                            int ncontours, bool isClosed, const Scalar& color,
                            int thickness=1, int lineType=8, int shift=0 );
  
@@@ -2570,13 -2578,6 +2570,13 @@@ CV_EXPORTS_W void polylines(InputOutput
                              bool isClosed, const Scalar& color,
                              int thickness=1, int lineType=8, int shift=0 );
  
 +//! draws contours in the image
 +CV_EXPORTS_W void drawContours( InputOutputArray image, InputArrayOfArrays contours,
 +                              int contourIdx, const Scalar& color,
 +                              int thickness=1, int lineType=8,
 +                              InputArray hierarchy=noArray(),
 +                              int maxLevel=INT_MAX, Point offset=Point() );
 +
  //! clips the line segment by the rectangle Rect(0, 0, imgSize.width, imgSize.height)
  CV_EXPORTS bool clipLine(Size imgSize, CV_IN_OUT Point& pt1, CV_IN_OUT Point& pt2);
  
@@@ -4010,7 -4011,7 +4010,7 @@@ public
      //! closes the file and releases all the memory buffers
      CV_WRAP virtual void release();
      //! closes the file, releases all the memory buffers and returns the text string
 -    CV_WRAP string releaseAndGetString();
 +    CV_WRAP virtual string releaseAndGetString();
  
      //! returns the first element of the top-level mapping
      CV_WRAP FileNode getFirstTopLevelNode() const;
@@@ -4340,15 -4341,24 +4340,24 @@@ public
      CV_WRAP vector<Mat> getMatVector(const string& name) const;
      CV_WRAP Ptr<Algorithm> getAlgorithm(const string& name) const;
  
-     CV_WRAP_AS(setInt) void set(const string& name, int value);
-     CV_WRAP_AS(setDouble) void set(const string& name, double value);
-     CV_WRAP_AS(setBool) void set(const string& name, bool value);
-     CV_WRAP_AS(setString) void set(const string& name, const string& value);
-     CV_WRAP_AS(setMat) void set(const string& name, const Mat& value);
-     CV_WRAP_AS(setMatVector) void set(const string& name, const vector<Mat>& value);
-     CV_WRAP_AS(setAlgorithm) void set(const string& name, const Ptr<Algorithm>& value);
+     void set(const string& name, int value);
+     void set(const string& name, double value);
+     void set(const string& name, bool value);
+     void set(const string& name, const string& value);
+     void set(const string& name, const Mat& value);
+     void set(const string& name, const vector<Mat>& value);
+     void set(const string& name, const Ptr<Algorithm>& value);
      template<typename _Tp> void set(const string& name, const Ptr<_Tp>& value);
  
+     CV_WRAP void setInt(const string& name, int value);
+     CV_WRAP void setDouble(const string& name, double value);
+     CV_WRAP void setBool(const string& name, bool value);
+     CV_WRAP void setString(const string& name, const string& value);
+     CV_WRAP void setMat(const string& name, const Mat& value);
+     CV_WRAP void setMatVector(const string& name, const vector<Mat>& value);
+     CV_WRAP void setAlgorithm(const string& name, const Ptr<Algorithm>& value);
+     template<typename _Tp> void setAlgorithm(const string& name, const Ptr<_Tp>& value);
      void set(const char* name, int value);
      void set(const char* name, double value);
      void set(const char* name, bool value);
      void set(const char* name, const Ptr<Algorithm>& value);
      template<typename _Tp> void set(const char* name, const Ptr<_Tp>& value);
  
+     void setInt(const char* name, int value);
+     void setDouble(const char* name, double value);
+     void setBool(const char* name, bool value);
+     void setString(const char* name, const string& value);
+     void setMat(const char* name, const Mat& value);
+     void setMatVector(const char* name, const vector<Mat>& value);
+     void setAlgorithm(const char* name, const Ptr<Algorithm>& value);
+     template<typename _Tp> void setAlgorithm(const char* name, const Ptr<_Tp>& value);
      CV_WRAP string paramHelp(const string& name) const;
      int paramType(const char* name) const;
      CV_WRAP int paramType(const string& name) const;
@@@ -4404,6 -4423,11 +4422,6 @@@ public
                    void (Algorithm::*setter)(int)=0,
                    const string& help=string());
      void addParam(Algorithm& algo, const char* name,
 -                  short& value, bool readOnly=false,
 -                  int (Algorithm::*getter)()=0,
 -                  void (Algorithm::*setter)(int)=0,
 -                  const string& help=string());
 -    void addParam(Algorithm& algo, const char* name,
                    bool& value, bool readOnly=false,
                    int (Algorithm::*getter)()=0,
                    void (Algorithm::*setter)(int)=0,
@@@ -4452,7 -4476,7 +4470,7 @@@ protected
  
  struct CV_EXPORTS Param
  {
 -    enum { INT=0, BOOLEAN=1, REAL=2, STRING=3, MAT=4, MAT_VECTOR=5, ALGORITHM=6, FLOAT=7, UNSIGNED_INT=8, UINT64=9, SHORT=10 };
 +    enum { INT=0, BOOLEAN=1, REAL=2, STRING=3, MAT=4, MAT_VECTOR=5, ALGORITHM=6, FLOAT=7, UNSIGNED_INT=8, UINT64=9 };
  
      Param();
      Param(int _type, bool _readonly, int _offset,
@@@ -4483,6 -4507,14 +4501,6 @@@ template<> struct ParamType<int
      enum { type = Param::INT };
  };
  
 -template<> struct ParamType<short>
 -{
 -    typedef int const_param_type;
 -    typedef int member_type;
 -
 -    enum { type = Param::SHORT };
 -};
 -
  template<> struct ParamType<double>
  {
      typedef double const_param_type;
@@@ -4548,49 -4580,113 +4566,49 @@@ template<> struct ParamType<uint64
  };
  
  
 -/*!
 -"\nThe CommandLineParser class is designed for command line arguments parsing\n"
 -           "Keys map: \n"
 -           "Before you start to work with CommandLineParser you have to create a map for keys.\n"
 -           "    It will look like this\n"
 -           "    const char* keys =\n"
 -           "    {\n"
 -           "        {    s|  string|  123asd |string parameter}\n"
 -           "        {    d|  digit |  100    |digit parameter }\n"
 -           "        {    c|noCamera|false    |without camera  }\n"
 -           "        {    1|        |some text|help            }\n"
 -           "        {    2|        |333      |another help    }\n"
 -           "    };\n"
 -           "Usage syntax: \n"
 -           "    \"{\" - start of parameter string.\n"
 -           "    \"}\" - end of parameter string\n"
 -           "    \"|\" - separator between short name, full name, default value and help\n"
 -           "Supported syntax: \n"
 -           "    --key1=arg1  <If a key with '--' must has an argument\n"
 -           "                  you have to assign it through '=' sign.> \n"
 -           "<If the key with '--' doesn't have any argument, it means that it is a bool key>\n"
 -           "    -key2=arg2   <If a key with '-' must has an argument \n"
 -           "                  you have to assign it through '=' sign.> \n"
 -           "If the key with '-' doesn't have any argument, it means that it is a bool key\n"
 -           "    key3                 <This key can't has any parameter> \n"
 -           "Usage: \n"
 -           "      Imagine that the input parameters are next:\n"
 -           "                -s=string_value --digit=250 --noCamera lena.jpg 10000\n"
 -           "    CommandLineParser parser(argc, argv, keys) - create a parser object\n"
 -           "    parser.get<string>(\"s\" or \"string\") will return you first parameter value\n"
 -           "    parser.get<string>(\"s\", false or \"string\", false) will return you first parameter value\n"
 -           "                                                                without spaces in end and begin\n"
 -           "    parser.get<int>(\"d\" or \"digit\") will return you second parameter value.\n"
 -           "                    It also works with 'unsigned int', 'double', and 'float' types>\n"
 -           "    parser.get<bool>(\"c\" or \"noCamera\") will return you true .\n"
 -           "                                If you enter this key in commandline>\n"
 -           "                                It return you false otherwise.\n"
 -           "    parser.get<string>(\"1\") will return you the first argument without parameter (lena.jpg) \n"
 -           "    parser.get<int>(\"2\") will return you the second argument without parameter (10000)\n"
 -           "                          It also works with 'unsigned int', 'double', and 'float' types \n"
 -*/
 +// The CommandLineParser class is designed for command line arguments parsing
 +
  class CV_EXPORTS CommandLineParser
  {
 -    public:
 +public:
 +    CommandLineParser(int argc, const char* const argv[], const string& keys);
 +    CommandLineParser(const CommandLineParser& parser);
 +    CommandLineParser& operator = (const CommandLineParser& parser);
  
 -    //! the default constructor
 -      CommandLineParser(int argc, const char* const argv[], const char* key_map);
 +    string getPathToApplication() const;
  
 -    //! get parameter, you can choose: delete spaces in end and begin or not
 -    template<typename _Tp>
 -    _Tp get(const std::string& name, bool space_delete=true)
 +    template <typename T>
 +    T get(const string& name, bool space_delete = true) const
      {
 -        if (!has(name))
 -        {
 -            return _Tp();
 -        }
 -        std::string str = getString(name);
 -        return analyzeValue<_Tp>(str, space_delete);
 +        T val = T();
 +        getByName(name, space_delete, ParamType<T>::type, (void*)&val);
 +        return val;
      }
  
 -    //! print short name, full name, current value and help for all params
 -    void printParams();
 -
 -    protected:
 -    std::map<std::string, std::vector<std::string> > data;
 -    std::string getString(const std::string& name);
 -
 -    bool has(const std::string& keys);
 -
 -    template<typename _Tp>
 -    _Tp analyzeValue(const std::string& str, bool space_delete=false);
 -
 -    template<typename _Tp>
 -    static _Tp getData(const std::string& str)
 +    template <typename T>
 +    T get(int index, bool space_delete = true) const
      {
 -        _Tp res;
 -        std::stringstream s1(str);
 -        s1 >> res;
 -        return res;
 +        T val = T();
 +        getByIndex(index, space_delete, ParamType<T>::type, (void*)&val);
 +        return val;
      }
  
 -    template<typename _Tp>
 -     _Tp fromStringNumber(const std::string& str);//the default conversion function for numbers
 +    bool has(const string& name) const;
  
 -    };
 -
 -template<> CV_EXPORTS
 -bool CommandLineParser::get<bool>(const std::string& name, bool space_delete);
 -
 -template<> CV_EXPORTS
 -std::string CommandLineParser::analyzeValue<std::string>(const std::string& str, bool space_delete);
 -
 -template<> CV_EXPORTS
 -int CommandLineParser::analyzeValue<int>(const std::string& str, bool space_delete);
 -
 -template<> CV_EXPORTS
 -unsigned int CommandLineParser::analyzeValue<unsigned int>(const std::string& str, bool space_delete);
 +    bool check() const;
  
 -template<> CV_EXPORTS
 -uint64 CommandLineParser::analyzeValue<uint64>(const std::string& str, bool space_delete);
 +    void about(const string& message);
  
 -template<> CV_EXPORTS
 -float CommandLineParser::analyzeValue<float>(const std::string& str, bool space_delete);
 +    void printMessage() const;
 +    void printErrors() const;
  
 -template<> CV_EXPORTS
 -double CommandLineParser::analyzeValue<double>(const std::string& str, bool space_delete);
 +protected:
 +    void getByName(const string& name, bool space_delete, int type, void* dst) const;
 +    void getByIndex(int index, bool space_delete, int type, void* dst) const;
  
 +    struct Impl;
 +    Impl* impl;
 +};
  
  /////////////////////////////// Parallel Primitives //////////////////////////////////
  
@@@ -114,7 -114,7 +114,7 @@@ template<typename _ValueTp> inline cons
              b = c;
      }
  
-     if( strcmp(vec.vec[a].first.c_str(), key) == 0 )
+     if( ( a < vec.vec.size() ) && ( strcmp(vec.vec[a].first.c_str(), key) == 0 ))
          return &vec.vec[a].second;
      return 0;
  }
@@@ -251,6 -251,79 +251,79 @@@ void Algorithm::set(const char* paramet
      info()->set(this, parameter, ParamType<Algorithm>::type, &value);
  }
  
+ void Algorithm::setInt(const string& parameter, int value)
+ {
+     info()->set(this, parameter.c_str(), ParamType<int>::type, &value);
+ }
+ void Algorithm::setDouble(const string& parameter, double value)
+ {
+     info()->set(this, parameter.c_str(), ParamType<double>::type, &value);
+ }
+ void Algorithm::setBool(const string& parameter, bool value)
+ {
+     info()->set(this, parameter.c_str(), ParamType<bool>::type, &value);
+ }
+ void Algorithm::setString(const string& parameter, const string& value)
+ {
+     info()->set(this, parameter.c_str(), ParamType<string>::type, &value);
+ }
+ void Algorithm::setMat(const string& parameter, const Mat& value)
+ {
+     info()->set(this, parameter.c_str(), ParamType<Mat>::type, &value);
+ }
+ void Algorithm::setMatVector(const string& parameter, const vector<Mat>& value)
+ {
+     info()->set(this, parameter.c_str(), ParamType<vector<Mat> >::type, &value);
+ }
+ void Algorithm::setAlgorithm(const string& parameter, const Ptr<Algorithm>& value)
+ {
+     info()->set(this, parameter.c_str(), ParamType<Algorithm>::type, &value);
+ }
+ void Algorithm::setInt(const char* parameter, int value)
+ {
+     info()->set(this, parameter, ParamType<int>::type, &value);
+ }
+ void Algorithm::setDouble(const char* parameter, double value)
+ {
+     info()->set(this, parameter, ParamType<double>::type, &value);
+ }
+ void Algorithm::setBool(const char* parameter, bool value)
+ {
+     info()->set(this, parameter, ParamType<bool>::type, &value);
+ }
+ void Algorithm::setString(const char* parameter, const string& value)
+ {
+     info()->set(this, parameter, ParamType<string>::type, &value);
+ }
+ void Algorithm::setMat(const char* parameter, const Mat& value)
+ {
+     info()->set(this, parameter, ParamType<Mat>::type, &value);
+ }
+ void Algorithm::setMatVector(const char* parameter, const vector<Mat>& value)
+ {
+     info()->set(this, parameter, ParamType<vector<Mat> >::type, &value);
+ }
+ void Algorithm::setAlgorithm(const char* parameter, const Ptr<Algorithm>& value)
+ {
+     info()->set(this, parameter, ParamType<Algorithm>::type, &value);
+ }
  int Algorithm::getInt(const string& parameter) const
  {
      return get<int>(parameter);
@@@ -441,6 -514,68 +514,59 @@@ union GetSetPara
      void (Algorithm::*set_algo)(const Ptr<Algorithm>&);
  };
  
 -        case Param::SHORT: return "short";
+ static string getNameOfType(int argType);
+ static string getNameOfType(int argType)
+ {
+     switch(argType)
+     {
+         case Param::INT: return "integer";
 -    else if (paramType == Param::SHORT)
 -    {
 -        message += "so it should be set by integer value, ";
 -    }
+         case Param::BOOLEAN: return "boolean";
+         case Param::REAL: return "double";
+         case Param::STRING: return "string";
+         case Param::MAT: return "cv::Mat";
+         case Param::MAT_VECTOR: return "std::vector<cv::Mat>";
+         case Param::ALGORITHM: return "algorithm";
+         default: CV_Error(CV_StsBadArg, "Wrong argument type");
+     }
+     return "";
+ }
+ static string getErrorMessageForWrongArgumentInSetter(string algoName, string paramName, int paramType, int argType);
+ static string getErrorMessageForWrongArgumentInSetter(string algoName, string paramName, int paramType, int argType)
+ {
+     string message = string("Argument error: the setter")
+         + " method was called for the parameter '" + paramName + "' of the algorithm '" + algoName
+         +"', the parameter has " + getNameOfType(paramType) + " type, ";
+     if (paramType == Param::INT || paramType == Param::BOOLEAN || paramType == Param::REAL)
+     {
+         message += "so it should be set by integer, boolean, or double value, ";
+     }
 -    else if (paramType == Param::SHORT)
 -    {
 -        message += "so it should be get as integer value, ";
 -    }
+     message += "but the setter was called with " + getNameOfType(argType) + " value";
+     return message;
+ }
+ static string getErrorMessageForWrongArgumentInGetter(string algoName, string paramName, int paramType, int argType);
+ static string getErrorMessageForWrongArgumentInGetter(string algoName, string paramName, int paramType, int argType)
+ {
+     string message = string("Argument error: the getter")
+         + " method was called for the parameter '" + paramName + "' of the algorithm '" + algoName
+         +"', the parameter has " + getNameOfType(paramType) + " type, ";
+     if (paramType == Param::BOOLEAN)
+     {
+         message += "so it should be get as integer, boolean, or double value, ";
+     }
+     else if (paramType == Param::INT)
+     {
+         message += "so it should be get as integer or double value, ";
+     }
+     message += "but the getter was called to get a " + getNameOfType(argType) + " value";
+     return message;
+ }
  void AlgorithmInfo::set(Algorithm* algo, const char* parameter, int argType, const void* value, bool force) const
  {
      const Param* p = findstr(data->params, parameter);
  
      if( argType == Param::INT || argType == Param::BOOLEAN || argType == Param::REAL )
      {
-         CV_Assert( p->type == Param::INT || p->type == Param::REAL || p->type == Param::BOOLEAN );
 -        if ( !( p->type == Param::INT || p->type == Param::REAL || p->type == Param::BOOLEAN || (p->type == Param::SHORT && argType == Param::INT)) )
++        if ( !( p->type == Param::INT || p->type == Param::REAL || p->type == Param::BOOLEAN) )
+         {
+             string message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
+             CV_Error(CV_StsBadArg, message);
+         }
  
          if( p->type == Param::INT )
          {
              int val = argType == Param::INT ? *(const int*)value :
 -            argType == Param::BOOLEAN ? (int)*(const bool*)value :
 -            saturate_cast<int>(*(const double*)value);
 +                argType == Param::BOOLEAN ? (int)*(const bool*)value :
 +                saturate_cast<int>(*(const double*)value);
              if( p->setter )
                  (algo->*f.set_int)(val);
              else
                  *(int*)((uchar*)algo + p->offset) = val;
          }
 -        else if( p->type == Param::SHORT )
 -        {
 -            int val = *(const int*)value;
 -            if( p->setter )
 -                (algo->*f.set_int)(val);
 -            else
 -                *(short*)((uchar*)algo + p->offset) = (short)val;
 -        }
          else if( p->type == Param::BOOLEAN )
          {
              bool val = argType == Param::INT ? *(const int*)value != 0 :
      }
      else if( argType == Param::STRING )
      {
-         CV_Assert( p->type == Param::STRING );
+         if( p->type != Param::STRING )
+         {
+             string message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
+             CV_Error(CV_StsBadArg, message);
+         }
  
          const string& val = *(const string*)value;
          if( p->setter )
      }
      else if( argType == Param::MAT )
      {
-         CV_Assert( p->type == Param::MAT );
+         if( p->type != Param::MAT )
+         {
+             string message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
+             CV_Error(CV_StsBadArg, message);
+         }
  
          const Mat& val = *(const Mat*)value;
          if( p->setter )
      }
      else if( argType == Param::MAT_VECTOR )
      {
-         CV_Assert( p->type == Param::MAT_VECTOR );
+         if( p->type != Param::MAT_VECTOR )
+         {
+             string message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
+             CV_Error(CV_StsBadArg, message);
+         }
  
          const vector<Mat>& val = *(const vector<Mat>*)value;
          if( p->setter )
      }
      else if( argType == Param::ALGORITHM )
      {
-         CV_Assert( p->type == Param::ALGORITHM );
+         if( p->type != Param::ALGORITHM )
+         {
+             string message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
+             CV_Error(CV_StsBadArg, message);
+         }
  
          const Ptr<Algorithm>& val = *(const Ptr<Algorithm>*)value;
          if( p->setter )
@@@ -546,7 -709,11 +692,11 @@@ void AlgorithmInfo::get(const Algorithm
      {
          if( p->type == Param::INT )
          {
-             CV_Assert( argType == Param::INT || argType == Param::REAL );
+             if (!( argType == Param::INT || argType == Param::REAL ))
+             {
+                 string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
+                 CV_Error(CV_StsBadArg, message);
+             }
              int val = p->getter ? (algo->*f.get_int)() : *(int*)((uchar*)algo + p->offset);
  
              if( argType == Param::INT )
              else
                  *(double*)value = val;
          }
 -        else if( p->type == Param::SHORT )
 -        {
 -            if( argType != Param::INT )
 -            {
 -                string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
 -                CV_Error(CV_StsBadArg, message);
 -            }
 -            int val = p->getter ? (algo->*f.get_int)() : *(short*)((uchar*)algo + p->offset);
 -
 -            *(int*)value = val;
 -        }
          else if( p->type == Param::BOOLEAN )
          {
-             CV_Assert( argType == Param::INT || argType == Param::BOOLEAN || argType == Param::REAL );
+             if (!( argType == Param::INT || argType == Param::BOOLEAN || argType == Param::REAL ))
+             {
+                 string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
+                 CV_Error(CV_StsBadArg, message);
+             }
              bool val = p->getter ? (algo->*f.get_bool)() : *(bool*)((uchar*)algo + p->offset);
  
              if( argType == Param::INT )
          }
          else
          {
-             CV_Assert( argType == Param::REAL );
+             if( argType != Param::REAL )
+             {
+                 string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
+                 CV_Error(CV_StsBadArg, message);
+             }
              double val = p->getter ? (algo->*f.get_double)() : *(double*)((uchar*)algo + p->offset);
  
              *(double*)value = val;
      }
      else if( argType == Param::STRING )
      {
-         CV_Assert( p->type == Param::STRING );
+         if( p->type != Param::STRING )
+         {
+             string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
+             CV_Error(CV_StsBadArg, message);
+         }
  
          *(string*)value = p->getter ? (algo->*f.get_string)() :
              *(string*)((uchar*)algo + p->offset);
      }
      else if( argType == Param::MAT )
      {
-         CV_Assert( p->type == Param::MAT );
+         if( p->type != Param::MAT )
+         {
+             string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
+             CV_Error(CV_StsBadArg, message);
+         }
  
          *(Mat*)value = p->getter ? (algo->*f.get_mat)() :
              *(Mat*)((uchar*)algo + p->offset);
      }
      else if( argType == Param::MAT_VECTOR )
      {
-         CV_Assert( p->type == Param::MAT_VECTOR );
+         if( p->type != Param::MAT_VECTOR )
+         {
+             string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
+             CV_Error(CV_StsBadArg, message);
+         }
  
          *(vector<Mat>*)value = p->getter ? (algo->*f.get_mat_vector)() :
          *(vector<Mat>*)((uchar*)algo + p->offset);
      }
      else if( argType == Param::ALGORITHM )
      {
-         CV_Assert( p->type == Param::ALGORITHM );
+         if( p->type != Param::ALGORITHM )
+         {
+             string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
+             CV_Error(CV_StsBadArg, message);
+         }
  
          *(Ptr<Algorithm>*)value = p->getter ? (algo->*f.get_algo)() :
              *(Ptr<Algorithm>*)((uchar*)algo + p->offset);
@@@ -639,7 -841,7 +813,7 @@@ void AlgorithmInfo::addParam_(Algorithm
      CV_Assert( argType == Param::INT || argType == Param::BOOLEAN ||
                 argType == Param::REAL || argType == Param::STRING ||
                 argType == Param::MAT || argType == Param::MAT_VECTOR ||
 -               argType == Param::ALGORITHM || argType == Param::SHORT );
 +               argType == Param::ALGORITHM );
      data->params.add(string(parameter), Param(argType, readOnly,
                       (int)((size_t)value - (size_t)(void*)&algo),
                       getter, setter, help));
  void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
                               int& value, bool readOnly,
                               int (Algorithm::*getter)(),
 -                             void (Algorithm::*setter)(int),
 -                             const string& help)
 -{
 -    addParam_(algo, parameter, ParamType<int>::type, &value, readOnly,
 -              (Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
 -}
 -
 -void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
 -                             short& value, bool readOnly,
 -                             int (Algorithm::*getter)(),
                               void (Algorithm::*setter)(int),
                               const string& help)
  {