Java API: fixed input List<List<smth>> arguments
This commit is contained in:
parent
f9ef92d45a
commit
92afe9e40a
@ -1,6 +1,7 @@
|
||||
package org.opencv.test.core;
|
||||
|
||||
import org.opencv.core.Core;
|
||||
import org.opencv.core.CvException;
|
||||
import org.opencv.core.CvType;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.Range;
|
||||
@ -175,11 +176,19 @@ public class MatTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testDiagMat() {
|
||||
Mat diagVector = new Mat(matSize, 1, CvType.CV_32F, new Scalar(1));
|
||||
|
||||
dst = Mat.diag(diagVector);
|
||||
|
||||
assertMatEqual(grayE_32f, dst, EPS);
|
||||
}
|
||||
|
||||
public void testDiagMat_sqrMatrix() {
|
||||
try {
|
||||
dst = Mat.diag(gray255);
|
||||
|
||||
truth = new Mat(1, matSize, CvType.CV_8U, new Scalar(255));
|
||||
|
||||
assertMatEqual(truth, dst);
|
||||
} catch (CvException e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
public void testDot() {
|
||||
|
@ -1,9 +1,5 @@
|
||||
package org.opencv.test.utils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.opencv.core.CvType;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.Point;
|
||||
@ -12,9 +8,11 @@ import org.opencv.core.Rect;
|
||||
import org.opencv.features2d.DMatch;
|
||||
import org.opencv.features2d.KeyPoint;
|
||||
import org.opencv.test.OpenCVTestCase;
|
||||
import org.opencv.test.OpenCVTestRunner;
|
||||
import org.opencv.utils.Converters;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ConvertersTest extends OpenCVTestCase {
|
||||
|
||||
public void testMat_to_vector_char() {
|
||||
@ -481,17 +479,6 @@ public class ConvertersTest extends OpenCVTestCase {
|
||||
|
||||
public void testVector_vector_char_to_Mat() {
|
||||
fail("Not yet implemented");
|
||||
List<List<Byte>> llb = new ArrayList<List<Byte>>();
|
||||
byte value1 = 1;
|
||||
byte value2 = 2;
|
||||
byte value3 = 3;
|
||||
byte value4 = 4;
|
||||
llb.add(Arrays.asList(new Byte(value1), new Byte(value2), new Byte(value3), new Byte(value4)));
|
||||
|
||||
dst = Converters.vector_vector_char_to_Mat(llb);
|
||||
|
||||
OpenCVTestRunner.Log(dst.toString());
|
||||
OpenCVTestRunner.Log(dst.dump());
|
||||
}
|
||||
|
||||
public void testVector_vector_DMatch_to_Mat() {
|
||||
@ -503,13 +490,6 @@ public class ConvertersTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testVector_vector_Point_to_Mat() {
|
||||
List<List<Point>> points = new ArrayList<List<Point>>();
|
||||
points.add(Arrays.asList(new Point(1, 1), new Point(7, 1), new Point(7, 6), new Point(1, 6),
|
||||
new Point(5, 5), new Point(8, 9)));
|
||||
|
||||
dst = Converters.vector_vector_Point_to_Mat(points);
|
||||
// TODO: returns random dst matrix
|
||||
// assertMatEqual();
|
||||
fail("Not yet implemented");
|
||||
|
||||
}
|
||||
|
@ -1137,6 +1137,11 @@ extern "C" {
|
||||
c_prologue.append( type_dict[a.ctype]["jni_var"] % {"n" : a.name} + ";" )
|
||||
c_prologue.append( "Mat& %(n)s_mat = *((Mat*)%(n)s_mat_nativeObj)" % {"n" : a.name} + ";" )
|
||||
if "I" in a.out or not a.out:
|
||||
if a.ctype.startswith("vector_vector_"):
|
||||
self.classes[fi.classname or self.Module].imports.add("java.util.ArrayList")
|
||||
j_prologue.append( "List<Mat> %(n)s_tmplm = new ArrayList<Mat>((%(n)s != null) ? %(n)s.size() : 0);" % {"n" : a.name } )
|
||||
j_prologue.append( "Mat %(n)s_mat = Converters.%(t)s_to_Mat(%(n)s, %(n)s_tmplm);" % {"n" : a.name, "t" : a.ctype} )
|
||||
else:
|
||||
j_prologue.append( "Mat %(n)s_mat = Converters.%(t)s_to_Mat(%(n)s);" % {"n" : a.name, "t" : a.ctype} )
|
||||
c_prologue.append( "Mat_to_%(t)s( %(n)s_mat, %(n)s );" % {"n" : a.name, "t" : a.ctype} )
|
||||
else:
|
||||
@ -1246,8 +1251,8 @@ extern "C" {
|
||||
ret = ret, \
|
||||
ret_val = ret_val, \
|
||||
tail = tail, \
|
||||
prologue = " ".join(j_prologue), \
|
||||
epilogue = " ".join(j_epilogue), \
|
||||
prologue = "\n ".join(j_prologue), \
|
||||
epilogue = "\n ".join(j_epilogue), \
|
||||
static=static, \
|
||||
j_type=type_dict[fi.ctype]["j_type"], \
|
||||
j_name=fi.jname, \
|
||||
|
@ -214,6 +214,7 @@ 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);
|
||||
|
@ -108,7 +108,7 @@ public class Mat {
|
||||
public Mat(Mat m, Rect roi)
|
||||
{
|
||||
|
||||
nativeObj = n_Mat(m.nativeObj, roi.x, roi.y, roi.width, roi.height);
|
||||
nativeObj = n_Mat(m.nativeObj, roi.x, roi.x + roi.width, roi.y, roi.y + roi.height);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -470,11 +470,10 @@ public class Converters {
|
||||
}
|
||||
|
||||
// vector_vector_Point
|
||||
public static Mat vector_vector_Point_to_Mat(List<List<Point>> pts) {
|
||||
public static Mat vector_vector_Point_to_Mat(List<List<Point>> pts, List<Mat> mats) {
|
||||
Mat res;
|
||||
int lCount = (pts != null) ? pts.size() : 0;
|
||||
if (lCount > 0) {
|
||||
List<Mat> mats = new ArrayList<Mat>(lCount);
|
||||
for (List<Point> lpt : pts)
|
||||
mats.add(vector_Point_to_Mat(lpt));
|
||||
res = vector_Mat_to_Mat(mats);
|
||||
@ -484,12 +483,28 @@ public class Converters {
|
||||
return res;
|
||||
}
|
||||
|
||||
// vector_vector_Point2f
|
||||
public static void Mat_to_vector_vector_Point2f(Mat m, List<List<Point>> pts) {
|
||||
if (pts == null)
|
||||
throw new java.lang.IllegalArgumentException("Output List can't be null");
|
||||
|
||||
if (m == null)
|
||||
throw new java.lang.IllegalArgumentException("Input Mat can't be null");
|
||||
|
||||
List<Mat> mats = new ArrayList<Mat>(m.rows());
|
||||
Mat_to_vector_Mat(m, mats);
|
||||
List<Point> pt = new ArrayList<Point>();
|
||||
for (Mat mi : mats) {
|
||||
Mat_to_vector_Point2f(mi, pt);
|
||||
pts.add(pt);
|
||||
}
|
||||
}
|
||||
|
||||
// vector_vector_KeyPoint
|
||||
public static Mat vector_vector_KeyPoint_to_Mat(List<List<KeyPoint>> kps) {
|
||||
public static Mat vector_vector_KeyPoint_to_Mat(List<List<KeyPoint>> kps, List<Mat> mats) {
|
||||
Mat res;
|
||||
int lCount = (kps != null) ? kps.size() : 0;
|
||||
if (lCount > 0) {
|
||||
List<Mat> mats = new ArrayList<Mat>(lCount);
|
||||
for (List<KeyPoint> lkp : kps)
|
||||
mats.add(vector_KeyPoint_to_Mat(lkp));
|
||||
res = vector_Mat_to_Mat(mats);
|
||||
@ -569,11 +584,10 @@ public class Converters {
|
||||
}
|
||||
|
||||
// vector_vector_DMatch
|
||||
public static Mat vector_vector_DMatch_to_Mat(List<List<DMatch>> lldm) {
|
||||
public static Mat vector_vector_DMatch_to_Mat(List<List<DMatch>> lldm, List<Mat> mats) {
|
||||
Mat res;
|
||||
int lCount = (lldm != null) ? lldm.size() : 0;
|
||||
if (lCount > 0) {
|
||||
List<Mat> mats = new ArrayList<Mat>(lCount);
|
||||
for (List<DMatch> ldm : lldm)
|
||||
mats.add(vector_DMatch_to_Mat(ldm));
|
||||
res = vector_Mat_to_Mat(mats);
|
||||
@ -600,11 +614,10 @@ public class Converters {
|
||||
}
|
||||
|
||||
// vector_vector_char
|
||||
public static Mat vector_vector_char_to_Mat(List<List<Byte>> llb) {
|
||||
public static Mat vector_vector_char_to_Mat(List<List<Byte>> llb, List<Mat> mats) {
|
||||
Mat res;
|
||||
int lCount = (llb != null) ? llb.size() : 0;
|
||||
if (lCount > 0) {
|
||||
List<Mat> mats = new ArrayList<Mat>(lCount);
|
||||
for (List<Byte> lb : llb)
|
||||
mats.add(vector_char_to_Mat(lb));
|
||||
res = vector_Mat_to_Mat(mats);
|
||||
|
Loading…
Reference in New Issue
Block a user