1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-28 14:53:03 +04:00

Java API: new types and converters are added, jni suffixes changed

This commit is contained in:
Andrey Pavlenko
2011-08-02 14:56:47 +00:00
parent 99b8e2db14
commit 2c5e79507d
4 changed files with 160 additions and 56 deletions
+33
View File
@@ -67,6 +67,13 @@ void Mat_to_vector_uchar(Mat& mat, vector<uchar>& v_uchar)
v_uchar = (vector<uchar>) mat;
}
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;
}
//vector_Rect
@@ -220,3 +227,29 @@ void vector_Mat_to_Mat(std::vector<cv::Mat>& v_mat, cv::Mat& mat)
mat.at< Vec<int, 2> >(i, 0) = Vec<int, 2>(addr>>32, addr&0xffffffff);
}
}
//vector_DMatch
void Mat_to_vector_DMatch(Mat& mat, vector<DMatch>& v_dm)
{
v_dm.clear();
CHECK_MAT(mat.type()==CV_64FC4 && mat.cols==1);
for(int i=0; i<mat.rows; i++)
{
Vec<double, 4> v = mat.at< Vec<double, 4> >(i, 0);
DMatch dm((int)v[0], (int)v[1], (int)v[2], (float)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_64FC4);
for(int i=0; i<count; i++)
{
DMatch dm = v_dm[i];
mat.at< Vec<double, 4> >(i, 0) = Vec<double, 4>(dm.queryIdx, dm.trainIdx, dm.imgIdx, dm.distance);
}
}