Remerged the 2.4.0 branch

This commit is contained in:
Andrey Kamaev
2012-05-02 20:20:14 +00:00
parent 77717e1abc
commit 3a1f85d4e8
41 changed files with 2452 additions and 4857 deletions

View File

@@ -1,457 +1,442 @@
#include "converters.h"
#ifdef DEBUG
#include <android/log.h>
#define MODULE_LOG_TAG "OpenCV.converters"
#define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, MODULE_LOG_TAG, __VA_ARGS__))
#else //DEBUG
#define LOGD(...)
#endif //DEBUG
using namespace cv;
#define CHECK_MAT(cond) if(!(cond)){ LOGD("FAILED: " #cond); return; }
// vector_int
void Mat_to_vector_int(Mat& mat, vector<int>& v_int)
{
v_int.clear();
CHECK_MAT(mat.type()==CV_32SC1 && mat.cols==1);
v_int = (vector<int>) mat;
}
void vector_int_to_Mat(vector<int>& v_int, Mat& mat)
{
mat = Mat(v_int, true);
}
//vector_double
void Mat_to_vector_double(Mat& mat, vector<double>& v_double)
{
v_double.clear();
CHECK_MAT(mat.type()==CV_64FC1 && mat.cols==1);
v_double = (vector<double>) mat;
}
void vector_double_to_Mat(vector<double>& v_double, Mat& mat)
{
mat = Mat(v_double, true);
}
// vector_float
void Mat_to_vector_float(Mat& mat, vector<float>& v_float)
{
v_float.clear();
CHECK_MAT(mat.type()==CV_32FC1 && mat.cols==1);
v_float = (vector<float>) mat;
}
void vector_float_to_Mat(vector<float>& v_float, Mat& mat)
{
mat = Mat(v_float, true);
}
//vector_uchar
void Mat_to_vector_uchar(Mat& mat, vector<uchar>& v_uchar)
{
v_uchar.clear();
CHECK_MAT(mat.type()==CV_8UC1 && mat.cols==1);
v_uchar = (vector<uchar>) mat;
}
void vector_uchar_to_Mat(vector<uchar>& v_uchar, Mat& mat)
{
mat = Mat(v_uchar, true);
}
void Mat_to_vector_char(Mat& mat, vector<char>& v_char)
{
v_char.clear();
CHECK_MAT(mat.type()==CV_8SC1 && mat.cols==1);
v_char = (vector<char>) mat;
}
void vector_char_to_Mat(vector<char>& v_char, Mat& mat)
{
mat = Mat(v_char, true);
}
//vector_Rect
void Mat_to_vector_Rect(Mat& mat, vector<Rect>& v_rect)
{
v_rect.clear();
CHECK_MAT(mat.type()==CV_32SC4 && mat.cols==1);
v_rect = (vector<Rect>) mat;
}
void vector_Rect_to_Mat(vector<Rect>& v_rect, Mat& mat)
{
mat = Mat(v_rect, true);
}
//vector_Point
void Mat_to_vector_Point(Mat& mat, vector<Point>& v_point)
{
v_point.clear();
CHECK_MAT(mat.type()==CV_32SC2 && mat.cols==1);
v_point = (vector<Point>) mat;
}
//vector_Point2f
void Mat_to_vector_Point2f(Mat& mat, vector<Point2f>& v_point)
{
v_point.clear();
CHECK_MAT(mat.type()==CV_32FC2 && mat.cols==1);
v_point = (vector<Point2f>) mat;
}
//vector_Point2d
void Mat_to_vector_Point2d(Mat& mat, vector<Point2d>& v_point)
{
v_point.clear();
CHECK_MAT(mat.type()==CV_64FC2 && mat.cols==1);
v_point = (vector<Point2d>) mat;
}
//vector_Point3i
void Mat_to_vector_Point3i(Mat& mat, vector<Point3i>& v_point)
{
v_point.clear();
CHECK_MAT(mat.type()==CV_32SC3 && mat.cols==1);
v_point = (vector<Point3i>) mat;
}
//vector_Point3f
void Mat_to_vector_Point3f(Mat& mat, vector<Point3f>& v_point)
{
v_point.clear();
CHECK_MAT(mat.type()==CV_32FC3 && mat.cols==1);
v_point = (vector<Point3f>) mat;
}
//vector_Point3d
void Mat_to_vector_Point3d(Mat& mat, vector<Point3d>& v_point)
{
v_point.clear();
CHECK_MAT(mat.type()==CV_64FC3 && mat.cols==1);
v_point = (vector<Point3d>) mat;
}
void vector_Point_to_Mat(vector<Point>& v_point, Mat& mat)
{
mat = Mat(v_point, true);
}
void vector_Point2f_to_Mat(vector<Point2f>& v_point, Mat& mat)
{
mat = Mat(v_point, true);
}
void vector_Point2d_to_Mat(vector<Point2d>& v_point, Mat& mat)
{
mat = Mat(v_point, true);
}
void vector_Point3i_to_Mat(vector<Point3i>& v_point, Mat& mat)
{
mat = Mat(v_point, true);
}
void vector_Point3f_to_Mat(vector<Point3f>& v_point, Mat& mat)
{
mat = Mat(v_point, true);
}
void vector_Point3d_to_Mat(vector<Point3d>& v_point, Mat& mat)
{
mat = Mat(v_point, true);
}
#ifdef HAVE_OPENCV_FEATURES2D
//vector_KeyPoint
void Mat_to_vector_KeyPoint(Mat& mat, vector<KeyPoint>& v_kp)
{
v_kp.clear();
CHECK_MAT(mat.type()==CV_32FC(7) && mat.cols==1);
for(int i=0; i<mat.rows; i++)
{
Vec<float, 7> v = mat.at< Vec<float, 7> >(i, 0);
KeyPoint kp(v[0], v[1], v[2], v[3], v[4], (int)v[5], (int)v[6]);
v_kp.push_back(kp);
}
return;
}
void vector_KeyPoint_to_Mat(vector<KeyPoint>& v_kp, Mat& mat)
{
int count = v_kp.size();
mat.create(count, 1, CV_32FC(7));
for(int i=0; i<count; i++)
{
KeyPoint kp = v_kp[i];
mat.at< Vec<float, 7> >(i, 0) = Vec<float, 7>(kp.pt.x, kp.pt.y, kp.size, kp.angle, kp.response, kp.octave, kp.class_id);
}
}
#endif
//vector_Mat
void Mat_to_vector_Mat(cv::Mat& mat, std::vector<cv::Mat>& v_mat)
{
v_mat.clear();
if(mat.type() == CV_32SC2 && mat.cols == 1)
{
v_mat.reserve(mat.rows);
for(int i=0; i<mat.rows; i++)
{
Vec<int, 2> a = mat.at< Vec<int, 2> >(i, 0);
long long addr = (((long long)a[0])<<32) | a[1];
Mat& m = *( (Mat*) addr );
v_mat.push_back(m);
}
} else {
LOGD("Mat_to_vector_Mat() FAILED: mat.type() == CV_32SC2 && mat.cols == 1");
}
}
void vector_Mat_to_Mat(std::vector<cv::Mat>& v_mat, cv::Mat& mat)
{
int count = v_mat.size();
mat.create(count, 1, CV_32SC2);
for(int i=0; i<count; i++)
{
long long addr = (long long) new Mat(v_mat[i]);
mat.at< Vec<int, 2> >(i, 0) = Vec<int, 2>(addr>>32, addr&0xffffffff);
}
}
#ifdef HAVE_OPENCV_FEATURES2D
//vector_DMatch
void Mat_to_vector_DMatch(Mat& mat, vector<DMatch>& v_dm)
{
v_dm.clear();
CHECK_MAT(mat.type()==CV_32FC4 && mat.cols==1);
for(int i=0; i<mat.rows; i++)
{
Vec<float, 4> v = mat.at< Vec<float, 4> >(i, 0);
DMatch dm((int)v[0], (int)v[1], (int)v[2], v[3]);
v_dm.push_back(dm);
}
return;
}
void vector_DMatch_to_Mat(vector<DMatch>& v_dm, Mat& mat)
{
int count = v_dm.size();
mat.create(count, 1, CV_32FC4);
for(int i=0; i<count; i++)
{
DMatch dm = v_dm[i];
mat.at< Vec<float, 4> >(i, 0) = Vec<float, 4>(dm.queryIdx, dm.trainIdx, dm.imgIdx, dm.distance);
}
}
#endif
void Mat_to_vector_vector_Point(Mat& mat, vector< vector< Point > >& vv_pt)
{
vector<Mat> vm;
vm.reserve( mat.rows );
Mat_to_vector_Mat(mat, vm);
for(size_t i=0; i<vm.size(); i++)
{
vector<Point> vpt;
Mat_to_vector_Point(vm[i], vpt);
vv_pt.push_back(vpt);
}
}
void Mat_to_vector_vector_Point2f(Mat& mat, vector< vector< Point2f > >& vv_pt)
{
vector<Mat> vm;
vm.reserve( mat.rows );
Mat_to_vector_Mat(mat, vm);
for(size_t i=0; i<vm.size(); i++)
{
vector<Point2f> vpt;
Mat_to_vector_Point2f(vm[i], vpt);
vv_pt.push_back(vpt);
}
}
void Mat_to_vector_vector_Point3f(Mat& mat, vector< vector< Point3f > >& vv_pt)
{
vector<Mat> vm;
vm.reserve( mat.rows );
Mat_to_vector_Mat(mat, vm);
for(size_t i=0; i<vm.size(); i++)
{
vector<Point3f> vpt;
Mat_to_vector_Point3f(vm[i], vpt);
vv_pt.push_back(vpt);
}
}
#ifdef HAVE_OPENCV_FEATURES2D
void Mat_to_vector_vector_KeyPoint(Mat& mat, vector< vector< KeyPoint > >& vv_kp)
{
vector<Mat> vm;
vm.reserve( mat.rows );
Mat_to_vector_Mat(mat, vm);
for(size_t i=0; i<vm.size(); i++)
{
vector<KeyPoint> vkp;
Mat_to_vector_KeyPoint(vm[i], vkp);
vv_kp.push_back(vkp);
}
}
void vector_vector_KeyPoint_to_Mat(vector< vector< KeyPoint > >& vv_kp, Mat& mat)
{
vector<Mat> vm;
vm.reserve( vv_kp.size() );
for(size_t i=0; i<vv_kp.size(); i++)
{
Mat m;
vector_KeyPoint_to_Mat(vv_kp[i], m);
vm.push_back(m);
}
vector_Mat_to_Mat(vm, mat);
}
void Mat_to_vector_vector_DMatch(Mat& mat, vector< vector< DMatch > >& vv_dm)
{
vector<Mat> vm;
vm.reserve( mat.rows );
Mat_to_vector_Mat(mat, vm);
for(size_t i=0; i<vm.size(); i++)
{
vector<DMatch> vdm;
Mat_to_vector_DMatch(vm[i], vdm);
vv_dm.push_back(vdm);
}
}
void vector_vector_DMatch_to_Mat(vector< vector< DMatch > >& vv_dm, Mat& mat)
{
vector<Mat> vm;
vm.reserve( vv_dm.size() );
for(size_t i=0; i<vv_dm.size(); i++)
{
Mat m;
vector_DMatch_to_Mat(vv_dm[i], m);
vm.push_back(m);
}
vector_Mat_to_Mat(vm, mat);
}
#endif
void Mat_to_vector_vector_char(Mat& mat, vector< vector< char > >& vv_ch)
{
vector<Mat> vm;
vm.reserve( mat.rows );
Mat_to_vector_Mat(mat, vm);
for(size_t i=0; i<vm.size(); i++)
{
vector<char> vch;
Mat_to_vector_char(vm[i], vch);
vv_ch.push_back(vch);
}
}
void vector_vector_char_to_Mat(vector< vector< char > >& vv_ch, Mat& mat)
{
vector<Mat> vm;
vm.reserve( vv_ch.size() );
for(size_t i=0; i<vv_ch.size(); i++)
{
Mat m;
vector_char_to_Mat(vv_ch[i], m);
vm.push_back(m);
}
vector_Mat_to_Mat(vm, mat);
}
void vector_vector_Point_to_Mat(vector< vector< Point > >& vv_pt, Mat& mat)
{
vector<Mat> vm;
vm.reserve( vv_pt.size() );
for(size_t i=0; i<vv_pt.size(); i++)
{
Mat m;
vector_Point_to_Mat(vv_pt[i], m);
vm.push_back(m);
}
vector_Mat_to_Mat(vm, mat);
}
void vector_vector_Point2f_to_Mat(vector< vector< Point2f > >& vv_pt, Mat& mat)
{
vector<Mat> vm;
vm.reserve( vv_pt.size() );
for(size_t i=0; i<vv_pt.size(); i++)
{
Mat m;
vector_Point2f_to_Mat(vv_pt[i], m);
vm.push_back(m);
}
vector_Mat_to_Mat(vm, mat);
}
void vector_vector_Point_to_Mat(vector< vector< Point > >& vv_pt, Mat& mat)
{
vector<Mat> vm;
vm.reserve( vv_pt.size() );
for(size_t i=0; i<vv_pt.size(); i++)
{
Mat m;
vector_Point_to_Mat(vv_pt[i], m);
vm.push_back(m);
}
vector_Mat_to_Mat(vm, mat);
}
void vector_vector_Point3f_to_Mat(vector< vector< Point3f > >& vv_pt, Mat& mat)
{
vector<Mat> vm;
vm.reserve( vv_pt.size() );
for(size_t i=0; i<vv_pt.size(); i++)
{
Mat m;
vector_Point3f_to_Mat(vv_pt[i], m);
vm.push_back(m);
}
vector_Mat_to_Mat(vm, mat);
}
void vector_Vec4i_to_Mat(vector<Vec4i>& v_vec, Mat& mat)
{
mat = Mat(v_vec, true);
}
void vector_Vec4f_to_Mat(vector<Vec4f>& v_vec, Mat& mat)
{
mat = Mat(v_vec, true);
}
void vector_Vec6f_to_Mat(vector<Vec6f>& v_vec, Mat& mat)
{
mat = Mat(v_vec, true);
}
#include "converters.h"
#ifdef DEBUG
#include <android/log.h>
#define MODULE_LOG_TAG "OpenCV.converters"
#define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, MODULE_LOG_TAG, __VA_ARGS__))
#else //DEBUG
#define LOGD(...)
#endif //DEBUG
using namespace cv;
#define CHECK_MAT(cond) if(!(cond)){ LOGD("FAILED: " #cond); return; }
// vector_int
void Mat_to_vector_int(Mat& mat, vector<int>& v_int)
{
v_int.clear();
CHECK_MAT(mat.type()==CV_32SC1 && mat.cols==1);
v_int = (vector<int>) mat;
}
void vector_int_to_Mat(vector<int>& v_int, Mat& mat)
{
mat = Mat(v_int, true);
}
//vector_double
void Mat_to_vector_double(Mat& mat, vector<double>& v_double)
{
v_double.clear();
CHECK_MAT(mat.type()==CV_64FC1 && mat.cols==1);
v_double = (vector<double>) mat;
}
void vector_double_to_Mat(vector<double>& v_double, Mat& mat)
{
mat = Mat(v_double, true);
}
// vector_float
void Mat_to_vector_float(Mat& mat, vector<float>& v_float)
{
v_float.clear();
CHECK_MAT(mat.type()==CV_32FC1 && mat.cols==1);
v_float = (vector<float>) mat;
}
void vector_float_to_Mat(vector<float>& v_float, Mat& mat)
{
mat = Mat(v_float, true);
}
//vector_uchar
void Mat_to_vector_uchar(Mat& mat, vector<uchar>& v_uchar)
{
v_uchar.clear();
CHECK_MAT(mat.type()==CV_8UC1 && mat.cols==1);
v_uchar = (vector<uchar>) mat;
}
void vector_uchar_to_Mat(vector<uchar>& v_uchar, Mat& mat)
{
mat = Mat(v_uchar, true);
}
void Mat_to_vector_char(Mat& mat, vector<char>& v_char)
{
v_char.clear();
CHECK_MAT(mat.type()==CV_8SC1 && mat.cols==1);
v_char = (vector<char>) mat;
}
void vector_char_to_Mat(vector<char>& v_char, Mat& mat)
{
mat = Mat(v_char, true);
}
//vector_Rect
void Mat_to_vector_Rect(Mat& mat, vector<Rect>& v_rect)
{
v_rect.clear();
CHECK_MAT(mat.type()==CV_32SC4 && mat.cols==1);
v_rect = (vector<Rect>) mat;
}
void vector_Rect_to_Mat(vector<Rect>& v_rect, Mat& mat)
{
mat = Mat(v_rect, true);
}
//vector_Point
void Mat_to_vector_Point(Mat& mat, vector<Point>& v_point)
{
v_point.clear();
CHECK_MAT(mat.type()==CV_32SC2 && mat.cols==1);
v_point = (vector<Point>) mat;
}
//vector_Point2f
void Mat_to_vector_Point2f(Mat& mat, vector<Point2f>& v_point)
{
v_point.clear();
CHECK_MAT(mat.type()==CV_32FC2 && mat.cols==1);
v_point = (vector<Point2f>) mat;
}
//vector_Point2d
void Mat_to_vector_Point2d(Mat& mat, vector<Point2d>& v_point)
{
v_point.clear();
CHECK_MAT(mat.type()==CV_64FC2 && mat.cols==1);
v_point = (vector<Point2d>) mat;
}
//vector_Point3i
void Mat_to_vector_Point3i(Mat& mat, vector<Point3i>& v_point)
{
v_point.clear();
CHECK_MAT(mat.type()==CV_32SC3 && mat.cols==1);
v_point = (vector<Point3i>) mat;
}
//vector_Point3f
void Mat_to_vector_Point3f(Mat& mat, vector<Point3f>& v_point)
{
v_point.clear();
CHECK_MAT(mat.type()==CV_32FC3 && mat.cols==1);
v_point = (vector<Point3f>) mat;
}
//vector_Point3d
void Mat_to_vector_Point3d(Mat& mat, vector<Point3d>& v_point)
{
v_point.clear();
CHECK_MAT(mat.type()==CV_64FC3 && mat.cols==1);
v_point = (vector<Point3d>) mat;
}
void vector_Point_to_Mat(vector<Point>& v_point, Mat& mat)
{
mat = Mat(v_point, true);
}
void vector_Point2f_to_Mat(vector<Point2f>& v_point, Mat& mat)
{
mat = Mat(v_point, true);
}
void vector_Point2d_to_Mat(vector<Point2d>& v_point, Mat& mat)
{
mat = Mat(v_point, true);
}
void vector_Point3i_to_Mat(vector<Point3i>& v_point, Mat& mat)
{
mat = Mat(v_point, true);
}
void vector_Point3f_to_Mat(vector<Point3f>& v_point, Mat& mat)
{
mat = Mat(v_point, true);
}
void vector_Point3d_to_Mat(vector<Point3d>& v_point, Mat& mat)
{
mat = Mat(v_point, true);
}
#ifdef HAVE_OPENCV_FEATURES2D
//vector_KeyPoint
void Mat_to_vector_KeyPoint(Mat& mat, vector<KeyPoint>& v_kp)
{
v_kp.clear();
CHECK_MAT(mat.type()==CV_32FC(7) && mat.cols==1);
for(int i=0; i<mat.rows; i++)
{
Vec<float, 7> v = mat.at< Vec<float, 7> >(i, 0);
KeyPoint kp(v[0], v[1], v[2], v[3], v[4], (int)v[5], (int)v[6]);
v_kp.push_back(kp);
}
return;
}
void vector_KeyPoint_to_Mat(vector<KeyPoint>& v_kp, Mat& mat)
{
int count = v_kp.size();
mat.create(count, 1, CV_32FC(7));
for(int i=0; i<count; i++)
{
KeyPoint kp = v_kp[i];
mat.at< Vec<float, 7> >(i, 0) = Vec<float, 7>(kp.pt.x, kp.pt.y, kp.size, kp.angle, kp.response, kp.octave, kp.class_id);
}
}
#endif
//vector_Mat
void Mat_to_vector_Mat(cv::Mat& mat, std::vector<cv::Mat>& v_mat)
{
v_mat.clear();
if(mat.type() == CV_32SC2 && mat.cols == 1)
{
v_mat.reserve(mat.rows);
for(int i=0; i<mat.rows; i++)
{
Vec<int, 2> a = mat.at< Vec<int, 2> >(i, 0);
long long addr = (((long long)a[0])<<32) | a[1];
Mat& m = *( (Mat*) addr );
v_mat.push_back(m);
}
} else {
LOGD("Mat_to_vector_Mat() FAILED: mat.type() == CV_32SC2 && mat.cols == 1");
}
}
void vector_Mat_to_Mat(std::vector<cv::Mat>& v_mat, cv::Mat& mat)
{
int count = v_mat.size();
mat.create(count, 1, CV_32SC2);
for(int i=0; i<count; i++)
{
long long addr = (long long) new Mat(v_mat[i]);
mat.at< Vec<int, 2> >(i, 0) = Vec<int, 2>(addr>>32, addr&0xffffffff);
}
}
#ifdef HAVE_OPENCV_FEATURES2D
//vector_DMatch
void Mat_to_vector_DMatch(Mat& mat, vector<DMatch>& v_dm)
{
v_dm.clear();
CHECK_MAT(mat.type()==CV_32FC4 && mat.cols==1);
for(int i=0; i<mat.rows; i++)
{
Vec<float, 4> v = mat.at< Vec<float, 4> >(i, 0);
DMatch dm((int)v[0], (int)v[1], (int)v[2], v[3]);
v_dm.push_back(dm);
}
return;
}
void vector_DMatch_to_Mat(vector<DMatch>& v_dm, Mat& mat)
{
int count = v_dm.size();
mat.create(count, 1, CV_32FC4);
for(int i=0; i<count; i++)
{
DMatch dm = v_dm[i];
mat.at< Vec<float, 4> >(i, 0) = Vec<float, 4>(dm.queryIdx, dm.trainIdx, dm.imgIdx, dm.distance);
}
}
#endif
void Mat_to_vector_vector_Point(Mat& mat, vector< vector< Point > >& vv_pt)
{
vector<Mat> vm;
vm.reserve( mat.rows );
Mat_to_vector_Mat(mat, vm);
for(size_t i=0; i<vm.size(); i++)
{
vector<Point> vpt;
Mat_to_vector_Point(vm[i], vpt);
vv_pt.push_back(vpt);
}
}
void Mat_to_vector_vector_Point2f(Mat& mat, vector< vector< Point2f > >& vv_pt)
{
vector<Mat> vm;
vm.reserve( mat.rows );
Mat_to_vector_Mat(mat, vm);
for(size_t i=0; i<vm.size(); i++)
{
vector<Point2f> vpt;
Mat_to_vector_Point2f(vm[i], vpt);
vv_pt.push_back(vpt);
}
}
void Mat_to_vector_vector_Point3f(Mat& mat, vector< vector< Point3f > >& vv_pt)
{
vector<Mat> vm;
vm.reserve( mat.rows );
Mat_to_vector_Mat(mat, vm);
for(size_t i=0; i<vm.size(); i++)
{
vector<Point3f> vpt;
Mat_to_vector_Point3f(vm[i], vpt);
vv_pt.push_back(vpt);
}
}
#ifdef HAVE_OPENCV_FEATURES2D
void Mat_to_vector_vector_KeyPoint(Mat& mat, vector< vector< KeyPoint > >& vv_kp)
{
vector<Mat> vm;
vm.reserve( mat.rows );
Mat_to_vector_Mat(mat, vm);
for(size_t i=0; i<vm.size(); i++)
{
vector<KeyPoint> vkp;
Mat_to_vector_KeyPoint(vm[i], vkp);
vv_kp.push_back(vkp);
}
}
void vector_vector_KeyPoint_to_Mat(vector< vector< KeyPoint > >& vv_kp, Mat& mat)
{
vector<Mat> vm;
vm.reserve( vv_kp.size() );
for(size_t i=0; i<vv_kp.size(); i++)
{
Mat m;
vector_KeyPoint_to_Mat(vv_kp[i], m);
vm.push_back(m);
}
vector_Mat_to_Mat(vm, mat);
}
void Mat_to_vector_vector_DMatch(Mat& mat, vector< vector< DMatch > >& vv_dm)
{
vector<Mat> vm;
vm.reserve( mat.rows );
Mat_to_vector_Mat(mat, vm);
for(size_t i=0; i<vm.size(); i++)
{
vector<DMatch> vdm;
Mat_to_vector_DMatch(vm[i], vdm);
vv_dm.push_back(vdm);
}
}
void vector_vector_DMatch_to_Mat(vector< vector< DMatch > >& vv_dm, Mat& mat)
{
vector<Mat> vm;
vm.reserve( vv_dm.size() );
for(size_t i=0; i<vv_dm.size(); i++)
{
Mat m;
vector_DMatch_to_Mat(vv_dm[i], m);
vm.push_back(m);
}
vector_Mat_to_Mat(vm, mat);
}
#endif
void Mat_to_vector_vector_char(Mat& mat, vector< vector< char > >& vv_ch)
{
vector<Mat> vm;
vm.reserve( mat.rows );
Mat_to_vector_Mat(mat, vm);
for(size_t i=0; i<vm.size(); i++)
{
vector<char> vch;
Mat_to_vector_char(vm[i], vch);
vv_ch.push_back(vch);
}
}
void vector_vector_char_to_Mat(vector< vector< char > >& vv_ch, Mat& mat)
{
vector<Mat> vm;
vm.reserve( vv_ch.size() );
for(size_t i=0; i<vv_ch.size(); i++)
{
Mat m;
vector_char_to_Mat(vv_ch[i], m);
vm.push_back(m);
}
vector_Mat_to_Mat(vm, mat);
}
void vector_vector_Point_to_Mat(vector< vector< Point > >& vv_pt, Mat& mat)
{
vector<Mat> vm;
vm.reserve( vv_pt.size() );
for(size_t i=0; i<vv_pt.size(); i++)
{
Mat m;
vector_Point_to_Mat(vv_pt[i], m);
vm.push_back(m);
}
vector_Mat_to_Mat(vm, mat);
}
void vector_vector_Point2f_to_Mat(vector< vector< Point2f > >& vv_pt, Mat& mat)
{
vector<Mat> vm;
vm.reserve( vv_pt.size() );
for(size_t i=0; i<vv_pt.size(); i++)
{
Mat m;
vector_Point2f_to_Mat(vv_pt[i], m);
vm.push_back(m);
}
vector_Mat_to_Mat(vm, mat);
}
void vector_vector_Point3f_to_Mat(vector< vector< Point3f > >& vv_pt, Mat& mat)
{
vector<Mat> vm;
vm.reserve( vv_pt.size() );
for(size_t i=0; i<vv_pt.size(); i++)
{
Mat m;
vector_Point3f_to_Mat(vv_pt[i], m);
vm.push_back(m);
}
vector_Mat_to_Mat(vm, mat);
}
void vector_Vec4i_to_Mat(vector<Vec4i>& v_vec, Mat& mat)
{
mat = Mat(v_vec, true);
}
void vector_Vec4f_to_Mat(vector<Vec4f>& v_vec, Mat& mat)
{
mat = Mat(v_vec, true);
}
void vector_Vec6f_to_Mat(vector<Vec6f>& v_vec, Mat& mat)
{
mat = Mat(v_vec, true);
}

View File

@@ -68,7 +68,6 @@ void vector_vector_Point_to_Mat(std::vector< std::vector< cv::Point > >& vv_pt,
void Mat_to_vector_vector_Point2f(cv::Mat& mat, std::vector< std::vector< cv::Point2f > >& vv_pt);
void vector_vector_Point2f_to_Mat(std::vector< std::vector< cv::Point2f > >& vv_pt, cv::Mat& mat);
void vector_vector_Point_to_Mat(std::vector< std::vector< cv::Point > >& vv_pt, cv::Mat& mat);
void Mat_to_vector_vector_Point3f(cv::Mat& mat, std::vector< std::vector< cv::Point3f > >& vv_pt);
void vector_vector_Point3f_to_Mat(std::vector< std::vector< cv::Point3f > >& vv_pt, cv::Mat& mat);

View File

@@ -4,38 +4,34 @@ import java.util.Arrays;
import java.util.List;
public class MatOfByte extends Mat {
// 8UC(x)
private static final int _depth = CvType.CV_8U;
private final int _channels;
public MatOfByte(int channels) {
super();
_channels = channels;
}
// 8UC(x)
private static final int _depth = CvType.CV_8U;
private static final int _channels = 1;
public MatOfByte() {
this(1);
}
public MatOfByte(int channels, long addr) {
super(addr);
_channels = channels;
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public MatOfByte(int channels, Mat m) {
super(m, Range.all());
_channels = channels;
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public MatOfByte(int channels, byte...a) {
super();
_channels = channels;
}
protected MatOfByte(long addr) {
super(addr);
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public static MatOfByte fromNativeAddr(long addr) {
return new MatOfByte(addr);
}
public MatOfByte(Mat m) {
super(m, Range.all());
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public MatOfByte(byte...a) {
super();
fromArray(a);
}
@@ -51,9 +47,11 @@ public class MatOfByte extends Mat {
alloc(num);
put(0, 0, a); //TODO: check ret val!
}
public byte[] toArray() {
int num = (int) total();
int num = checkVector(_channels, _depth);
if(num < 0)
throw new RuntimeException("Native Mat has unexpected type or size: " + toString());
byte[] a = new byte[num * _channels];
if(num == 0)
return a;
@@ -62,20 +60,20 @@ public class MatOfByte extends Mat {
}
public void fromList(List<Byte> lb) {
if(lb==null || lb.size()==0)
return;
Byte ab[] = lb.toArray(null);
byte a[] = new byte[ab.length];
for(int i=0; i<ab.length; i++)
a[i] = ab[i];
fromArray(a);
if(lb==null || lb.size()==0)
return;
Byte ab[] = lb.toArray(new Byte[0]);
byte a[] = new byte[ab.length];
for(int i=0; i<ab.length; i++)
a[i] = ab[i];
fromArray(a);
}
public List<Byte> toList() {
byte[] a = toArray();
Byte ab[] = new Byte[a.length];
for(int i=0; i<a.length; i++)
ab[i] = a[i];
return Arrays.asList(ab);
byte[] a = toArray();
Byte ab[] = new Byte[a.length];
for(int i=0; i<a.length; i++)
ab[i] = a[i];
return Arrays.asList(ab);
}
}

View File

@@ -6,23 +6,27 @@ import java.util.List;
import org.opencv.features2d.DMatch;
public class MatOfDMatch extends Mat {
// 32FC4
private static final int _depth = CvType.CV_32F;
private static final int _channels = 4;
// 32FC4
private static final int _depth = CvType.CV_32F;
private static final int _channels = 4;
public MatOfDMatch() {
super();
}
public MatOfDMatch(long addr) {
protected MatOfDMatch(long addr) {
super(addr);
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public static MatOfDMatch fromNativeAddr(long addr) {
return new MatOfDMatch(addr);
}
public MatOfDMatch(Mat m) {
super(m, Range.all());
super(m, Range.all());
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
@@ -32,7 +36,7 @@ public class MatOfDMatch extends Mat {
super();
fromArray(ap);
}
public void alloc(int elemNumber) {
if(elemNumber>0)
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
@@ -68,12 +72,12 @@ public class MatOfDMatch extends Mat {
}
public void fromList(List<DMatch> ldm) {
DMatch adm[] = ldm.toArray(null);
fromArray(adm);
DMatch adm[] = ldm.toArray(new DMatch[0]);
fromArray(adm);
}
public List<DMatch> toList() {
DMatch[] adm = toArray();
return Arrays.asList(adm);
DMatch[] adm = toArray();
return Arrays.asList(adm);
}
}

View File

@@ -4,38 +4,34 @@ import java.util.Arrays;
import java.util.List;
public class MatOfDouble extends Mat {
// 64FC(x)
private static final int _depth = CvType.CV_64F;
private final int _channels;
public MatOfDouble(int channels) {
super();
_channels = channels;
}
// 64FC(x)
private static final int _depth = CvType.CV_64F;
private static final int _channels = 1;
public MatOfDouble() {
this(1);
}
public MatOfDouble(int channels, long addr) {
super(addr);
_channels = channels;
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public MatOfDouble(int channels, Mat m) {
super(m, Range.all());
_channels = channels;
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public MatOfDouble(int channels, double...a) {
super();
_channels = channels;
}
protected MatOfDouble(long addr) {
super(addr);
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public static MatOfDouble fromNativeAddr(long addr) {
return new MatOfDouble(addr);
}
public MatOfDouble(Mat m) {
super(m, Range.all());
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public MatOfDouble(double...a) {
super();
fromArray(a);
}
@@ -51,9 +47,11 @@ public class MatOfDouble extends Mat {
alloc(num);
put(0, 0, a); //TODO: check ret val!
}
public double[] toArray() {
int num = (int) total();
int num = checkVector(_channels, _depth);
if(num < 0)
throw new RuntimeException("Native Mat has unexpected type or size: " + toString());
double[] a = new double[num * _channels];
if(num == 0)
return a;
@@ -62,20 +60,20 @@ public class MatOfDouble extends Mat {
}
public void fromList(List<Double> lb) {
if(lb==null || lb.size()==0)
return;
Double ab[] = lb.toArray(null);
double a[] = new double[ab.length];
for(int i=0; i<ab.length; i++)
a[i] = ab[i];
fromArray(a);
if(lb==null || lb.size()==0)
return;
Double ab[] = lb.toArray(new Double[0]);
double a[] = new double[ab.length];
for(int i=0; i<ab.length; i++)
a[i] = ab[i];
fromArray(a);
}
public List<Double> toList() {
double[] a = toArray();
Double ab[] = new Double[a.length];
for(int i=0; i<a.length; i++)
ab[i] = a[i];
return Arrays.asList(ab);
double[] a = toArray();
Double ab[] = new Double[a.length];
for(int i=0; i<a.length; i++)
ab[i] = a[i];
return Arrays.asList(ab);
}
}

View File

@@ -4,38 +4,34 @@ import java.util.Arrays;
import java.util.List;
public class MatOfFloat extends Mat {
// 32FC(x)
private static final int _depth = CvType.CV_32F;
private final int _channels;
public MatOfFloat(int channels) {
super();
_channels = channels;
}
// 32FC1
private static final int _depth = CvType.CV_32F;
private static final int _channels = 1;
public MatOfFloat() {
this(1);
}
public MatOfFloat(int channels, long addr) {
super(addr);
_channels = channels;
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public MatOfFloat(int channels, Mat m) {
super(m, Range.all());
_channels = channels;
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public MatOfFloat(int channels, float...a) {
super();
_channels = channels;
}
protected MatOfFloat(long addr) {
super(addr);
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public static MatOfFloat fromNativeAddr(long addr) {
return new MatOfFloat(addr);
}
public MatOfFloat(Mat m) {
super(m, Range.all());
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public MatOfFloat(float...a) {
super();
fromArray(a);
}
@@ -51,9 +47,11 @@ public class MatOfFloat extends Mat {
alloc(num);
put(0, 0, a); //TODO: check ret val!
}
public float[] toArray() {
int num = (int) total();
int num = checkVector(_channels, _depth);
if(num < 0)
throw new RuntimeException("Native Mat has unexpected type or size: " + toString());
float[] a = new float[num * _channels];
if(num == 0)
return a;
@@ -62,20 +60,20 @@ public class MatOfFloat extends Mat {
}
public void fromList(List<Float> lb) {
if(lb==null || lb.size()==0)
return;
Float ab[] = lb.toArray(null);
float a[] = new float[ab.length];
for(int i=0; i<ab.length; i++)
a[i] = ab[i];
fromArray(a);
if(lb==null || lb.size()==0)
return;
Float ab[] = lb.toArray(new Float[0]);
float a[] = new float[ab.length];
for(int i=0; i<ab.length; i++)
a[i] = ab[i];
fromArray(a);
}
public List<Float> toList() {
float[] a = toArray();
Float ab[] = new Float[a.length];
for(int i=0; i<a.length; i++)
ab[i] = a[i];
return Arrays.asList(ab);
float[] a = toArray();
Float ab[] = new Float[a.length];
for(int i=0; i<a.length; i++)
ab[i] = a[i];
return Arrays.asList(ab);
}
}

View File

@@ -5,38 +5,34 @@ import java.util.List;
public class MatOfInt extends Mat {
// 32SC(x)
private static final int _depth = CvType.CV_32S;
private final int _channels;
public MatOfInt(int channels) {
super();
_channels = channels;
}
// 32SC1
private static final int _depth = CvType.CV_32S;
private static final int _channels = 1;
public MatOfInt() {
this(1);
}
public MatOfInt(int channels, long addr) {
super(addr);
_channels = channels;
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public MatOfInt(int channels, Mat m) {
super(m, Range.all());
_channels = channels;
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public MatOfInt(int channels, int...a) {
super();
_channels = channels;
}
protected MatOfInt(long addr) {
super(addr);
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public static MatOfInt fromNativeAddr(long addr) {
return new MatOfInt(addr);
}
public MatOfInt(Mat m) {
super(m, Range.all());
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public MatOfInt(int...a) {
super();
fromArray(a);
}
@@ -52,9 +48,11 @@ public class MatOfInt extends Mat {
alloc(num);
put(0, 0, a); //TODO: check ret val!
}
public int[] toArray() {
int num = (int) total();
int num = checkVector(_channels, _depth);
if(num < 0)
throw new RuntimeException("Native Mat has unexpected type or size: " + toString());
int[] a = new int[num * _channels];
if(num == 0)
return a;
@@ -63,20 +61,20 @@ public class MatOfInt extends Mat {
}
public void fromList(List<Integer> lb) {
if(lb==null || lb.size()==0)
return;
Integer ab[] = lb.toArray(null);
int a[] = new int[ab.length];
for(int i=0; i<ab.length; i++)
a[i] = ab[i];
fromArray(a);
if(lb==null || lb.size()==0)
return;
Integer ab[] = lb.toArray(new Integer[0]);
int a[] = new int[ab.length];
for(int i=0; i<ab.length; i++)
a[i] = ab[i];
fromArray(a);
}
public List<Integer> toList() {
int[] a = toArray();
Integer ab[] = new Integer[a.length];
for(int i=0; i<a.length; i++)
ab[i] = a[i];
return Arrays.asList(ab);
int[] a = toArray();
Integer ab[] = new Integer[a.length];
for(int i=0; i<a.length; i++)
ab[i] = a[i];
return Arrays.asList(ab);
}
}

View File

@@ -6,23 +6,27 @@ import java.util.List;
import org.opencv.features2d.KeyPoint;
public class MatOfKeyPoint extends Mat {
// 32FC7
private static final int _depth = CvType.CV_32F;
private static final int _channels = 7;
// 32FC7
private static final int _depth = CvType.CV_32F;
private static final int _channels = 7;
public MatOfKeyPoint() {
super();
}
public MatOfKeyPoint(long addr) {
protected MatOfKeyPoint(long addr) {
super(addr);
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public static MatOfKeyPoint fromNativeAddr(long addr) {
return new MatOfKeyPoint(addr);
}
public MatOfKeyPoint(Mat m) {
super(m, Range.all());
super(m, Range.all());
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
@@ -32,7 +36,7 @@ public class MatOfKeyPoint extends Mat {
super();
fromArray(a);
}
public void alloc(int elemNumber) {
if(elemNumber>0)
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
@@ -71,12 +75,12 @@ public class MatOfKeyPoint extends Mat {
}
public void fromList(List<KeyPoint> lkp) {
KeyPoint akp[] = lkp.toArray(null);
fromArray(akp);
KeyPoint akp[] = lkp.toArray(new KeyPoint[0]);
fromArray(akp);
}
public List<KeyPoint> toList() {
KeyPoint[] akp = toArray();
return Arrays.asList(akp);
KeyPoint[] akp = toArray();
return Arrays.asList(akp);
}
}

View File

@@ -4,23 +4,27 @@ import java.util.Arrays;
import java.util.List;
public class MatOfPoint extends Mat {
// 32SC2
private static final int _depth = CvType.CV_32S;
private static final int _channels = 2;
// 32SC2
private static final int _depth = CvType.CV_32S;
private static final int _channels = 2;
public MatOfPoint() {
super();
}
public MatOfPoint(long addr) {
protected MatOfPoint(long addr) {
super(addr);
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public static MatOfPoint fromNativeAddr(long addr) {
return new MatOfPoint(addr);
}
public MatOfPoint(Mat m) {
super(m, Range.all());
super(m, Range.all());
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
@@ -30,7 +34,7 @@ public class MatOfPoint extends Mat {
super();
fromArray(a);
}
public void alloc(int elemNumber) {
if(elemNumber>0)
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
@@ -49,7 +53,7 @@ public class MatOfPoint extends Mat {
}
put(0, 0, buff); //TODO: check ret val!
}
public Point[] toArray() {
int num = (int) total();
Point[] ap = new Point[num];
@@ -63,12 +67,12 @@ public class MatOfPoint extends Mat {
}
public void fromList(List<Point> lp) {
Point ap[] = lp.toArray(null);
fromArray(ap);
Point ap[] = lp.toArray(new Point[0]);
fromArray(ap);
}
public List<Point> toList() {
Point[] ap = toArray();
return Arrays.asList(ap);
Point[] ap = toArray();
return Arrays.asList(ap);
}
}

View File

@@ -4,23 +4,27 @@ import java.util.Arrays;
import java.util.List;
public class MatOfPoint2f extends Mat {
// 32FC2
private static final int _depth = CvType.CV_32F;
private static final int _channels = 2;
// 32FC2
private static final int _depth = CvType.CV_32F;
private static final int _channels = 2;
public MatOfPoint2f() {
super();
}
public MatOfPoint2f(long addr) {
protected MatOfPoint2f(long addr) {
super(addr);
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public static MatOfPoint2f fromNativeAddr(long addr) {
return new MatOfPoint2f(addr);
}
public MatOfPoint2f(Mat m) {
super(m, Range.all());
super(m, Range.all());
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
@@ -30,7 +34,7 @@ public class MatOfPoint2f extends Mat {
super();
fromArray(a);
}
public void alloc(int elemNumber) {
if(elemNumber>0)
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
@@ -49,7 +53,7 @@ public class MatOfPoint2f extends Mat {
}
put(0, 0, buff); //TODO: check ret val!
}
public Point[] toArray() {
int num = (int) total();
Point[] ap = new Point[num];
@@ -63,12 +67,12 @@ public class MatOfPoint2f extends Mat {
}
public void fromList(List<Point> lp) {
Point ap[] = lp.toArray(null);
fromArray(ap);
Point ap[] = lp.toArray(new Point[0]);
fromArray(ap);
}
public List<Point> toList() {
Point[] ap = toArray();
return Arrays.asList(ap);
Point[] ap = toArray();
return Arrays.asList(ap);
}
}

View File

@@ -4,23 +4,27 @@ import java.util.Arrays;
import java.util.List;
public class MatOfPoint3 extends Mat {
// 32SC3
private static final int _depth = CvType.CV_32S;
private static final int _channels = 3;
// 32SC3
private static final int _depth = CvType.CV_32S;
private static final int _channels = 3;
public MatOfPoint3() {
super();
}
public MatOfPoint3(long addr) {
protected MatOfPoint3(long addr) {
super(addr);
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public static MatOfPoint3 fromNativeAddr(long addr) {
return new MatOfPoint3(addr);
}
public MatOfPoint3(Mat m) {
super(m, Range.all());
super(m, Range.all());
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
@@ -30,7 +34,7 @@ public class MatOfPoint3 extends Mat {
super();
fromArray(a);
}
public void alloc(int elemNumber) {
if(elemNumber>0)
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
@@ -50,7 +54,7 @@ public class MatOfPoint3 extends Mat {
}
put(0, 0, buff); //TODO: check ret val!
}
public Point3[] toArray() {
int num = (int) total();
Point3[] ap = new Point3[num];
@@ -64,12 +68,12 @@ public class MatOfPoint3 extends Mat {
}
public void fromList(List<Point3> lp) {
Point3 ap[] = lp.toArray(null);
fromArray(ap);
Point3 ap[] = lp.toArray(new Point3[0]);
fromArray(ap);
}
public List<Point3> toList() {
Point3[] ap = toArray();
return Arrays.asList(ap);
Point3[] ap = toArray();
return Arrays.asList(ap);
}
}

View File

@@ -4,23 +4,27 @@ import java.util.Arrays;
import java.util.List;
public class MatOfPoint3f extends Mat {
// 32FC3
private static final int _depth = CvType.CV_32F;
private static final int _channels = 3;
// 32FC3
private static final int _depth = CvType.CV_32F;
private static final int _channels = 3;
public MatOfPoint3f() {
super();
}
public MatOfPoint3f(long addr) {
protected MatOfPoint3f(long addr) {
super(addr);
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public static MatOfPoint3f fromNativeAddr(long addr) {
return new MatOfPoint3f(addr);
}
public MatOfPoint3f(Mat m) {
super(m, Range.all());
super(m, Range.all());
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
@@ -30,7 +34,7 @@ public class MatOfPoint3f extends Mat {
super();
fromArray(a);
}
public void alloc(int elemNumber) {
if(elemNumber>0)
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
@@ -50,7 +54,7 @@ public class MatOfPoint3f extends Mat {
}
put(0, 0, buff); //TODO: check ret val!
}
public Point3[] toArray() {
int num = (int) total();
Point3[] ap = new Point3[num];
@@ -64,12 +68,12 @@ public class MatOfPoint3f extends Mat {
}
public void fromList(List<Point3> lp) {
Point3 ap[] = lp.toArray(null);
fromArray(ap);
Point3 ap[] = lp.toArray(new Point3[0]);
fromArray(ap);
}
public List<Point3> toList() {
Point3[] ap = toArray();
return Arrays.asList(ap);
Point3[] ap = toArray();
return Arrays.asList(ap);
}
}

View File

@@ -5,23 +5,27 @@ import java.util.List;
public class MatOfRect extends Mat {
// 32SC4
private static final int _depth = CvType.CV_32S;
private static final int _channels = 4;
// 32SC4
private static final int _depth = CvType.CV_32S;
private static final int _channels = 4;
public MatOfRect() {
super();
}
public MatOfRect(long addr) {
protected MatOfRect(long addr) {
super(addr);
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
}
public static MatOfRect fromNativeAddr(long addr) {
return new MatOfRect(addr);
}
public MatOfRect(Mat m) {
super(m, Range.all());
super(m, Range.all());
if(checkVector(_channels, _depth) < 0 )
throw new IllegalArgumentException("Incomatible Mat");
//FIXME: do we need release() here?
@@ -31,7 +35,7 @@ public class MatOfRect extends Mat {
super();
fromArray(a);
}
public void alloc(int elemNumber) {
if(elemNumber>0)
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
@@ -44,7 +48,7 @@ public class MatOfRect extends Mat {
alloc(num);
int buff[] = new int[num * _channels];
for(int i=0; i<num; i++) {
Rect r = a[i];
Rect r = a[i];
buff[_channels*i+0] = (int) r.x;
buff[_channels*i+1] = (int) r.y;
buff[_channels*i+2] = (int) r.width;
@@ -52,7 +56,7 @@ public class MatOfRect extends Mat {
}
put(0, 0, buff); //TODO: check ret val!
}
public Rect[] toArray() {
int num = (int) total();
@@ -66,12 +70,12 @@ public class MatOfRect extends Mat {
return a;
}
public void fromList(List<Rect> lr) {
Rect ap[] = lr.toArray(null);
fromArray(ap);
Rect ap[] = lr.toArray(new Rect[0]);
fromArray(ap);
}
public List<Rect> toList() {
Rect[] ar = toArray();
return Arrays.asList(ar);
Rect[] ar = toArray();
return Arrays.asList(ar);
}
}