mirror of
https://github.com/opencv/opencv.git
synced 2024-11-29 05:29:54 +08:00
Java API: calcOpticalFlowPyrLK() args types are changed to vector<>
Testing: 1130/0/585
This commit is contained in:
parent
0595ca7454
commit
8b16dbe791
@ -1,10 +1,14 @@
|
||||
package org.opencv.test.video;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.opencv.core.Core;
|
||||
import org.opencv.core.CvType;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.Point;
|
||||
import org.opencv.core.Size;
|
||||
import org.opencv.test.OpenCVTestCase;
|
||||
import org.opencv.utils.Converters;
|
||||
import org.opencv.video.Video;
|
||||
|
||||
public class videoTest extends OpenCVTestCase {
|
||||
@ -17,9 +21,10 @@ public class videoTest extends OpenCVTestCase {
|
||||
private Mat subLena1 = null;
|
||||
private Mat subLena2 = null;
|
||||
|
||||
private Mat nextPts = null;
|
||||
private Mat status = null;
|
||||
private Mat err = null;
|
||||
List<Point> prevPts = null;
|
||||
private List<Point> nextPts = null;
|
||||
private List<Byte> status = null;
|
||||
private List<Float> err = null;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
@ -33,9 +38,14 @@ public class videoTest extends OpenCVTestCase {
|
||||
subLena1 = rgbLena.submat(shift1, h + shift1, shift1, w + shift1);
|
||||
subLena2 = rgbLena.submat(shift2, h + shift2, shift2, w + shift2);
|
||||
|
||||
nextPts = new Mat();
|
||||
status = new Mat();
|
||||
err = new Mat();
|
||||
prevPts = new ArrayList<Point>();
|
||||
prevPts.add(new Point(1.0, 1.0));
|
||||
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() {
|
||||
@ -54,39 +64,37 @@ public class videoTest extends OpenCVTestCase {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
public void testCalcOpticalFlowPyrLKMatMatMatMatMatMat() {
|
||||
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);
|
||||
public void testCalcOpticalFlowPyrLKMatMatListOfPointListOfPointListOfByteListOfFloatSizeIntTermCriteriaDoubleIntDouble() {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
Video.calcOpticalFlowPyrLK(subLena1, subLena2, prevPts, nextPts, status, err);
|
||||
assertEquals(3, Core.countNonZero(status));
|
||||
}
|
||||
public void testCalcOpticalFlowPyrLKMatMatListOfPointListOfPointListOfByteListOfFloatSizeIntTermCriteriaDoubleInt() {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
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);
|
||||
public void testCalcOpticalFlowPyrLKMatMatListOfPointListOfPointListOfByteListOfFloatSizeIntTermCriteriaDouble() {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
public void testCalcOpticalFlowPyrLKMatMatListOfPointListOfPointListOfByteListOfFloatSizeIntTermCriteria() {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
public void testCalcOpticalFlowPyrLKMatMatListOfPointListOfPointListOfByteListOfFloatSizeInt() {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
public void testCalcOpticalFlowPyrLKMatMatListOfPointListOfPointListOfByteListOfFloatSize() {
|
||||
Size sz = new Size(3, 3);
|
||||
Video.calcOpticalFlowPyrLK(subLena1, subLena2, prevPts, nextPts, status, err, sz);
|
||||
assertEquals(0, Core.countNonZero(status));
|
||||
}
|
||||
|
||||
public void testCalcOpticalFlowPyrLKMatMatMatMatMatMatSizeInt() {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
public void testCalcOpticalFlowPyrLKMatMatMatMatMatMatSizeIntTermCriteria() {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
public void testCalcOpticalFlowPyrLKMatMatMatMatMatMatSizeIntTermCriteriaDouble() {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
public void testCalcOpticalFlowPyrLKMatMatMatMatMatMatSizeIntTermCriteriaDoubleInt() {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
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() {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
@ -478,6 +478,8 @@ func_arg_fix = {
|
||||
'findHomography' : { 'srcPoints' : 'vector_Point2f', 'dstPoints' : 'vector_Point2f', },
|
||||
'solvePnP' : { '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
|
||||
} # func_arg_fix
|
||||
|
||||
|
@ -67,6 +67,11 @@ void Mat_to_vector_uchar(Mat& mat, vector<uchar>& v_uchar)
|
||||
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();
|
||||
@ -74,6 +79,11 @@ void Mat_to_vector_char(Mat& mat, vector<char>& v_char)
|
||||
v_char = (vector<char>) mat;
|
||||
}
|
||||
|
||||
void vector_char_to_Mat(vector<char>& v_char, Mat& mat)
|
||||
{
|
||||
mat = Mat(v_char, true);
|
||||
}
|
||||
|
||||
|
||||
//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 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 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 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];
|
||||
m.get(0, 0, buff);
|
||||
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;
|
||||
}
|
||||
|
||||
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) {
|
||||
Mat res;
|
||||
int count = (bs!=null) ? bs.size() : 0;
|
||||
@ -360,7 +377,7 @@ public class Converters {
|
||||
int[] buff = new int[count];
|
||||
m.get(0, 0, buff);
|
||||
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];
|
||||
m.get(0, 0, buff);
|
||||
for(int i=0; i<count; i++) {
|
||||
bs.add( new Byte(buff[i]) );
|
||||
bs.add( buff[i] );
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user