Java API: calcOpticalFlowPyrLK() args types are changed to vector<>

Testing: 1130/0/585
pull/13383/head
Andrey Pavlenko 14 years ago
parent 0595ca7454
commit 8b16dbe791
  1. 76
      modules/java/android_test/src/org/opencv/test/video/videoTest.java
  2. 2
      modules/java/gen_java.py
  3. 10
      modules/java/src/cpp/converters.cpp
  4. 3
      modules/java/src/cpp/converters.h
  5. 23
      modules/java/src/java/utils+Converters.java

@ -1,10 +1,14 @@
package org.opencv.test.video; package org.opencv.test.video;
import java.util.ArrayList;
import java.util.List;
import org.opencv.core.Core; import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat; import org.opencv.core.Mat;
import org.opencv.core.Point;
import org.opencv.core.Size; import org.opencv.core.Size;
import org.opencv.test.OpenCVTestCase; import org.opencv.test.OpenCVTestCase;
import org.opencv.utils.Converters;
import org.opencv.video.Video; import org.opencv.video.Video;
public class videoTest extends OpenCVTestCase { public class videoTest extends OpenCVTestCase {
@ -17,9 +21,10 @@ public class videoTest extends OpenCVTestCase {
private Mat subLena1 = null; private Mat subLena1 = null;
private Mat subLena2 = null; private Mat subLena2 = null;
private Mat nextPts = null; List<Point> prevPts = null;
private Mat status = null; private List<Point> nextPts = null;
private Mat err = null; private List<Byte> status = null;
private List<Float> err = null;
@Override @Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
@ -33,9 +38,14 @@ public class videoTest extends OpenCVTestCase {
subLena1 = rgbLena.submat(shift1, h + shift1, shift1, w + shift1); subLena1 = rgbLena.submat(shift1, h + shift1, shift1, w + shift1);
subLena2 = rgbLena.submat(shift2, h + shift2, shift2, w + shift2); subLena2 = rgbLena.submat(shift2, h + shift2, shift2, w + shift2);
nextPts = new Mat(); prevPts = new ArrayList<Point>();
status = new Mat(); prevPts.add(new Point(1.0, 1.0));
err = new Mat(); prevPts.add(new Point(5.0, 5.0));
prevPts.add(new Point(10.0, 10.0));
nextPts = new ArrayList<Point>();
status = new ArrayList<Byte>();
err = new ArrayList<Float>();
} }
public void testCalcGlobalOrientation() { public void testCalcGlobalOrientation() {
@ -54,39 +64,37 @@ public class videoTest extends OpenCVTestCase {
fail("Not yet implemented"); fail("Not yet implemented");
} }
public void testCalcOpticalFlowPyrLKMatMatMatMatMatMat() { public void testCalcOpticalFlowPyrLKMatMatListOfPointListOfPointListOfByteListOfFloatSizeIntTermCriteriaDoubleIntDouble() {
Mat prevPts = new Mat(1, 3, CvType.CV_32FC2); fail("Not yet implemented");
prevPts.put(0, 0, 1.0, 1.0, 5.0, 5.0, 10.0, 10.0); }
Video.calcOpticalFlowPyrLK(subLena1, subLena2, prevPts, nextPts, status, err);
assertEquals(3, Core.countNonZero(status));
}
public void testCalcOpticalFlowPyrLKMatMatMatMatMatMatSize() {
Mat prevPts = new Mat(1, 3, CvType.CV_32FC2);
prevPts.put(0, 0, 1.0, 1.0, 5.0, 5.0, 10.0, 10.0);
Size sz = new Size(3, 3); public void testCalcOpticalFlowPyrLKMatMatListOfPointListOfPointListOfByteListOfFloatSizeIntTermCriteriaDoubleInt() {
Video.calcOpticalFlowPyrLK(subLena1, subLena2, prevPts, nextPts, status, err, sz); fail("Not yet implemented");
assertEquals(0, Core.countNonZero(status)); }
}
public void testCalcOpticalFlowPyrLKMatMatMatMatMatMatSizeInt() { public void testCalcOpticalFlowPyrLKMatMatListOfPointListOfPointListOfByteListOfFloatSizeIntTermCriteriaDouble() {
fail("Not yet implemented"); fail("Not yet implemented");
} }
public void testCalcOpticalFlowPyrLKMatMatMatMatMatMatSizeIntTermCriteria() { public void testCalcOpticalFlowPyrLKMatMatListOfPointListOfPointListOfByteListOfFloatSizeIntTermCriteria() {
fail("Not yet implemented"); fail("Not yet implemented");
} }
public void testCalcOpticalFlowPyrLKMatMatMatMatMatMatSizeIntTermCriteriaDouble() { public void testCalcOpticalFlowPyrLKMatMatListOfPointListOfPointListOfByteListOfFloatSizeInt() {
fail("Not yet implemented"); fail("Not yet implemented");
} }
public void testCalcOpticalFlowPyrLKMatMatMatMatMatMatSizeIntTermCriteriaDoubleInt() { public void testCalcOpticalFlowPyrLKMatMatListOfPointListOfPointListOfByteListOfFloatSize() {
fail("Not yet implemented"); Size sz = new Size(3, 3);
} Video.calcOpticalFlowPyrLK(subLena1, subLena2, prevPts, nextPts, status, err, sz);
assertEquals(0, Core.countNonZero( Converters.vector_uchar_to_Mat(status) ));
}
public void testCalcOpticalFlowPyrLKMatMatListOfPointListOfPointListOfByteListOfFloat() {
Video.calcOpticalFlowPyrLK(subLena1, subLena2, prevPts, nextPts, status, err);
assertEquals(3, Core.countNonZero( Converters.vector_uchar_to_Mat(status) ));
}
public void testCamShift() { public void testCamShift() {
fail("Not yet implemented"); fail("Not yet implemented");
} }

@ -478,6 +478,8 @@ func_arg_fix = {
'findHomography' : { 'srcPoints' : 'vector_Point2f', 'dstPoints' : 'vector_Point2f', }, 'findHomography' : { 'srcPoints' : 'vector_Point2f', 'dstPoints' : 'vector_Point2f', },
'solvePnP' : { 'objectPoints' : 'vector_Point3f', 'imagePoints' : 'vector_Point2f', }, 'solvePnP' : { 'objectPoints' : 'vector_Point3f', 'imagePoints' : 'vector_Point2f', },
'solvePnPRansac' : { 'objectPoints' : 'vector_Point3f', 'imagePoints' : 'vector_Point2f', }, 'solvePnPRansac' : { 'objectPoints' : 'vector_Point3f', 'imagePoints' : 'vector_Point2f', },
'calcOpticalFlowPyrLK' : { 'prevPts' : 'vector_Point2f', 'nextPts' : 'vector_Point2f',
'status' : 'vector_uchar', 'err' : 'vector_float', },
}, # '', i.e. no class }, # '', i.e. no class
} # func_arg_fix } # func_arg_fix

@ -67,6 +67,11 @@ void Mat_to_vector_uchar(Mat& mat, vector<uchar>& v_uchar)
v_uchar = (vector<uchar>) mat; 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) void Mat_to_vector_char(Mat& mat, vector<char>& v_char)
{ {
v_char.clear(); v_char.clear();
@ -74,6 +79,11 @@ void Mat_to_vector_char(Mat& mat, vector<char>& v_char)
v_char = (vector<char>) mat; v_char = (vector<char>) mat;
} }
void vector_char_to_Mat(vector<char>& v_char, Mat& mat)
{
mat = Mat(v_char, true);
}
//vector_Rect //vector_Rect

@ -15,7 +15,10 @@ void Mat_to_vector_float(cv::Mat& mat, std::vector<float>& v_float);
void vector_float_to_Mat(std::vector<float>& v_float, cv::Mat& mat); void vector_float_to_Mat(std::vector<float>& v_float, cv::Mat& mat);
void Mat_to_vector_uchar(cv::Mat& mat, std::vector<uchar>& v_uchar); void Mat_to_vector_uchar(cv::Mat& mat, std::vector<uchar>& v_uchar);
void vector_uchar_to_Mat(std::vector<uchar>& v_uchar, cv::Mat& mat);
void Mat_to_vector_char(cv::Mat& mat, std::vector<char>& v_char); void Mat_to_vector_char(cv::Mat& mat, std::vector<char>& v_char);
void vector_char_to_Mat(std::vector<char>& v_char, cv::Mat& mat);
void Mat_to_vector_Rect(cv::Mat& mat, std::vector<cv::Rect>& v_rect); void Mat_to_vector_Rect(cv::Mat& mat, std::vector<cv::Rect>& v_rect);
void vector_Rect_to_Mat(std::vector<cv::Rect>& v_rect, cv::Mat& mat); void vector_Rect_to_Mat(std::vector<cv::Rect>& v_rect, cv::Mat& mat);

@ -293,7 +293,7 @@ public class Converters {
float[] buff = new float[count]; float[] buff = new float[count];
m.get(0, 0, buff); m.get(0, 0, buff);
for(int i=0; i<count; i++) { for(int i=0; i<count; i++) {
fs.add( new Float(buff[i]) ); fs.add( buff[i] );
} }
} }
@ -314,6 +314,23 @@ public class Converters {
return res; return res;
} }
public static void Mat_to_vector_uchar(Mat m, List<Byte> us) {
if(us == null)
throw new java.lang.IllegalArgumentException("Output List can't be null");
int count = m.rows();
if( CvType.CV_8UC1 != m.type() || m.cols()!=1 )
throw new java.lang.IllegalArgumentException(
"CvType.CV_8UC1 != m.type() || m.cols()!=1\n" + m);
us.clear();
byte[] buff = new byte[count];
m.get(0, 0, buff);
for(int i=0; i<count; i++) {
us.add( buff[i] );
}
}
public static Mat vector_char_to_Mat(List<Byte> bs) { public static Mat vector_char_to_Mat(List<Byte> bs) {
Mat res; Mat res;
int count = (bs!=null) ? bs.size() : 0; int count = (bs!=null) ? bs.size() : 0;
@ -360,7 +377,7 @@ public class Converters {
int[] buff = new int[count]; int[] buff = new int[count];
m.get(0, 0, buff); m.get(0, 0, buff);
for(int i=0; i<count; i++) { for(int i=0; i<count; i++) {
is.add( new Integer(buff[i]) ); is.add( buff[i] );
} }
} }
@ -376,7 +393,7 @@ public class Converters {
byte[] buff = new byte[count]; byte[] buff = new byte[count];
m.get(0, 0, buff); m.get(0, 0, buff);
for(int i=0; i<count; i++) { for(int i=0; i<count; i++) {
bs.add( new Byte(buff[i]) ); bs.add( buff[i] );
} }
} }

Loading…
Cancel
Save