Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Vector of a class that heredity a standard OpenCV class

Hi all,

I try to run this code but I have some troubles. The code is the following:

class point3D_t : public cv::Point3f { };
class point2D_t : public cv::Point2f { };

int main(int argc, const char * argv[]) {

  std::vector<point3D_t> input;
  std::vector<point2D_t> output;

  cv::Mat R,T,K;
  std::vector<double> distCoeffs;

  cv::projectPoints(input, R, T, K, distCoeffs, output);

  return 0;

}

It gives me back as error in:

\#include <opencv2/opencv.hpp>
\#include "opencv2/core.hpp"
\#include "opencv2/core/traits.hpp"

template<typename _Tp> inline
_InputArray::_InputArray(const std::vector<_Tp>& vec)
{ init(FIXED_TYPE + STD_VECTOR + traits::Type<_Tp>::value + ACCESS_READ, &vec); }

this:

Incomplete definition of type 'cv::traits::Type<point3D_t>'

@mshabunin suggest me:

You have to specify cv::traits::Type<...> in your code to be able to use custom types like this

But I do not know what doesn't means.

Vector of a class that heredity a standard OpenCV class

Hi all,

I try to run this code but I have some troubles. The code is the following:

class point3D_t : public cv::Point3f { };
class point2D_t : public cv::Point2f { };

int main(int argc, const char * argv[]) {

  std::vector<point3D_t> input;
  std::vector<point2D_t> output;

  cv::Mat R,T,K;
  std::vector<double> distCoeffs;

  cv::projectPoints(input, R, T, K, distCoeffs, output);

  return 0;

}

It gives me back as error in:

\#include #include <opencv2/opencv.hpp>
\#include #include "opencv2/core.hpp"
\#include #include "opencv2/core/traits.hpp"

template<typename _Tp> inline
_InputArray::_InputArray(const std::vector<_Tp>& vec)
{ init(FIXED_TYPE + STD_VECTOR + traits::Type<_Tp>::value + ACCESS_READ, &vec); }

this:

Incomplete definition of type 'cv::traits::Type<point3D_t>'

@mshabunin suggest me:

You have to specify cv::traits::Type<...> in your code to be able to use custom types like this

But I do not know what doesn't means.

In the mean time I do that:

template <>
class cv::DataType<cv::Point2f> {

public:
  typedef cobbs::point2D_t value_type;
  typedef cobbs::point2D_t work_type;
  typedef float channel_type;

  enum { generic_type = 0,
    channels     = 2,
    fmt          = traits::SafeFmt<channel_type>::fmt + ((channels - 1) << 8)
  };

};

namespace cv::traits {
  template<>
  struct Depth<cobbs::point2D_t> { enum { value = Depth<cv::Point2f>::value }; };
  template<>
  struct Type<cobbs::point2D_t> { enum { value = CV_MAKETYPE(Depth<cobbs::point2D_t>::value, 2) }; };
}

and

template <>
class cv::DataType<cv::Point3f> {

public:
  typedef cobbs::point3D_t value_type;
  typedef cobbs::point3D_t work_type;
  typedef float channel_type;

  enum { generic_type = 0,
    channels     = 3,
    fmt          = traits::SafeFmt<channel_type>::fmt + ((channels - 1) << 8)
  };

};

namespace cv::traits {
  template<>
  struct Depth<cobbs::point3D_t> { enum { value = Depth<cv::Point3f>::value }; };
  template<>
  struct Type<cobbs::point3D_t> { enum { value = CV_MAKETYPE(Depth<cobbs::point3D_t>::value, 3) }; };
}

the error went away. However I have problem in run time. As if the memory was corrupted

Vector of a class that heredity a standard OpenCV class

Hi all,

I try to run this code but I have some troubles. The code is the following:

class point3D_t : public cv::Point3f { };


  public:

    int label;
    int frame;
    double value;

};

class point2D_t : public cv::Point2f { 

  public:

    int label;
    int frame;
    double value;

};

int main(int argc, const char * argv[]) {

  std::vector<point3D_t> input;
  std::vector<point2D_t> output;

  cv::Mat R,T,K;
  std::vector<double> distCoeffs;

  cv::projectPoints(input, R, T, K, distCoeffs, output);

  return 0;

}

It gives me back as error in:

#include <opencv2/opencv.hpp>
#include "opencv2/core.hpp"
#include "opencv2/core/traits.hpp"

template<typename _Tp> inline
_InputArray::_InputArray(const std::vector<_Tp>& vec)
{ init(FIXED_TYPE + STD_VECTOR + traits::Type<_Tp>::value + ACCESS_READ, &vec); }

this:

Incomplete definition of type 'cv::traits::Type<point3D_t>'

@mshabunin suggest me:

You have to specify cv::traits::Type<...> in your code to be able to use custom types like this

But I do not know what doesn't means.

In the mean time I do that:

template <>
class cv::DataType<cv::Point2f> {

public:
  typedef cobbs::point2D_t point2D_t value_type;
  typedef cobbs::point2D_t point2D_t work_type;
  typedef float channel_type;

  enum { generic_type = 0,
    channels     = 2,
    fmt          = traits::SafeFmt<channel_type>::fmt + ((channels - 1) << 8)
  };

};

namespace cv::traits {
  template<>
  struct Depth<cobbs::point2D_t> Depth<point2D_t> { enum { value = Depth<cv::Point2f>::value }; };
  template<>
  struct Type<cobbs::point2D_t> Type<point2D_t> { enum { value = CV_MAKETYPE(Depth<cobbs::point2D_t>::value, CV_MAKETYPE(Depth<point2D_t>::value, 2) }; };
}

and

template <>
class cv::DataType<cv::Point3f> {

public:
  typedef cobbs::point3D_t point3D_t value_type;
  typedef cobbs::point3D_t point3D_t work_type;
  typedef float channel_type;

  enum { generic_type = 0,
    channels     = 3,
    fmt          = traits::SafeFmt<channel_type>::fmt + ((channels - 1) << 8)
  };

};

namespace cv::traits {
  template<>
  struct Depth<cobbs::point3D_t> Depth<point3D_t> { enum { value = Depth<cv::Point3f>::value }; };
  template<>
  struct Type<cobbs::point3D_t> Type<point3D_t> { enum { value = CV_MAKETYPE(Depth<cobbs::point3D_t>::value, CV_MAKETYPE(Depth<point3D_t>::value, 3) }; };
}

the error went away. However I have problem in run time. As if the memory was corrupted

click to hide/show revision 4
retagged

updated 2020-05-18 01:39:49 -0600

berak gravatar image

Vector of a class that heredity a standard OpenCV class

Hi all,

I try to run this code but I have some troubles. The code is the following:

class point3D_t : public cv::Point3f { 

  public:

    int label;
    int frame;
    double value;

};

class point2D_t : public cv::Point2f { 

  public:

    int label;
    int frame;
    double value;

};

int main(int argc, const char * argv[]) {

  std::vector<point3D_t> input;
  std::vector<point2D_t> output;

  cv::Mat R,T,K;
  std::vector<double> distCoeffs;

  cv::projectPoints(input, R, T, K, distCoeffs, output);

  return 0;

}

It gives me back as error in:

#include <opencv2/opencv.hpp>
#include "opencv2/core.hpp"
#include "opencv2/core/traits.hpp"

template<typename _Tp> inline
_InputArray::_InputArray(const std::vector<_Tp>& vec)
{ init(FIXED_TYPE + STD_VECTOR + traits::Type<_Tp>::value + ACCESS_READ, &vec); }

this:

Incomplete definition of type 'cv::traits::Type<point3D_t>'

@mshabunin suggest me:

You have to specify cv::traits::Type<...> in your code to be able to use custom types like this

But I do not know what doesn't means.

In the mean time I do that:

template <>
class cv::DataType<cv::Point2f> {

public:
  typedef point2D_t value_type;
  typedef point2D_t work_type;
  typedef float channel_type;

  enum { generic_type = 0,
    channels     = 2,
    fmt          = traits::SafeFmt<channel_type>::fmt + ((channels - 1) << 8)
  };

};

namespace cv::traits {
  template<>
  struct Depth<point2D_t> { enum { value = Depth<cv::Point2f>::value }; };
  template<>
  struct Type<point2D_t> { enum { value = CV_MAKETYPE(Depth<point2D_t>::value, 2) }; };
}

and

template <>
class cv::DataType<cv::Point3f> {

public:
  typedef point3D_t value_type;
  typedef point3D_t work_type;
  typedef float channel_type;

  enum { generic_type = 0,
    channels     = 3,
    fmt          = traits::SafeFmt<channel_type>::fmt + ((channels - 1) << 8)
  };

};

namespace cv::traits {
  template<>
  struct Depth<point3D_t> { enum { value = Depth<cv::Point3f>::value }; };
  template<>
  struct Type<point3D_t> { enum { value = CV_MAKETYPE(Depth<point3D_t>::value, 3) }; };
}

the error went away. However I have problem in run time. As if the memory was corrupted

click to hide/show revision 5
None

updated 2020-05-18 05:50:32 -0600

berak gravatar image

Vector of a class that heredity a standard OpenCV class

Hi all,

I try to run this code but I have some troubles. The code is the following:

class point3D_t : public cv::Point3f { 

  public:

    int label;
    int frame;
    double value;

};

class point2D_t : public cv::Point2f { 

  public:

    int label;
    int frame;
    double value;

};

int main(int argc, const char * argv[]) {

  std::vector<point3D_t> input;
  std::vector<point2D_t> output;

  cv::Mat R,T,K;
  std::vector<double> distCoeffs;

  cv::projectPoints(input, R, T, K, distCoeffs, output);

  return 0;

}

It gives me back as error in:

#include <opencv2/opencv.hpp>
#include "opencv2/core.hpp"
#include "opencv2/core/traits.hpp"

template<typename _Tp> inline
_InputArray::_InputArray(const std::vector<_Tp>& vec)
{ init(FIXED_TYPE + STD_VECTOR + traits::Type<_Tp>::value + ACCESS_READ, &vec); }

this:

Incomplete definition of type 'cv::traits::Type<point3D_t>'

@mshabunin suggest me:

You have to specify cv::traits::Type<...> in your code to be able to use custom types like this

But I do not know what doesn't means.

In the mean time I do that:

template <>
class cv::DataType<cv::Point2f> {

public:
  typedef point2D_t value_type;
  typedef point2D_t work_type;
  typedef float channel_type;

  enum { generic_type = 0,
    channels     = 2,
    fmt          = traits::SafeFmt<channel_type>::fmt + ((channels - 1) << 8)
  };

};

namespace cv::traits {
  template<>
  struct Depth<point2D_t> { enum { value = Depth<cv::Point2f>::value }; };
  template<>
  struct Type<point2D_t> { enum { value = CV_MAKETYPE(Depth<point2D_t>::value, 2) }; };
}

and

template <>
class cv::DataType<cv::Point3f> {

public:
  typedef point3D_t value_type;
  typedef point3D_t work_type;
  typedef float channel_type;

  enum { generic_type = 0,
    channels     = 3,
    fmt          = traits::SafeFmt<channel_type>::fmt + ((channels - 1) << 8)
  };

};

namespace cv::traits {
  template<>
  struct Depth<point3D_t> { enum { value = Depth<cv::Point3f>::value }; };
  template<>
  struct Type<point3D_t> { enum { value = CV_MAKETYPE(Depth<point3D_t>::value, 3) }; };
}

the error went away. However I have problem in run time. As if the memory was corrupted