Java API: fixing Highgui and Video tests

This commit is contained in:
Andrey Pavlenko 2012-04-04 15:00:35 +00:00
parent cd8dfd6c5d
commit 5fefac7fe3
2 changed files with 18 additions and 24 deletions

View File

@ -1,8 +1,6 @@
package org.opencv.test.highgui;
import java.util.ArrayList;
import java.util.List;
import org.opencv.core.CvVectorByte;
import org.opencv.highgui.Highgui;
import org.opencv.test.OpenCVTestCase;
import org.opencv.test.OpenCVTestRunner;
@ -14,10 +12,10 @@ public class HighguiTest extends OpenCVTestCase {
}
public void testImencodeStringMatListOfByte() {
List<Byte> buf = new ArrayList<Byte>();
assertEquals(0, buf.size());
assertTrue( Highgui.imencode(".jpg", gray127, buf) );
assertFalse(0 == buf.size());
CvVectorByte buff = new CvVectorByte();
assertEquals(0, buff.size());
assertTrue( Highgui.imencode(".jpg", gray127, buff) );
assertFalse(0 == buff.total());
}
public void testImencodeStringMatListOfByteListOfInteger() {

View File

@ -1,27 +1,26 @@
package org.opencv.test.video;
import org.opencv.core.Core;
import org.opencv.core.CvVectorByte;
import org.opencv.core.CvVectorFloat;
import org.opencv.core.CvVectorPoint2f;
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;
import java.util.ArrayList;
import java.util.List;
public class VideoTest extends OpenCVTestCase {
private List<Float> err = null;
private CvVectorFloat err = null;
private int h;
private List<Point> nextPts = null;
List<Point> prevPts = null;
private CvVectorPoint2f nextPts = null;
private CvVectorPoint2f prevPts = null;
private int shift1;
private int shift2;
private List<Byte> status = null;
private CvVectorByte status = null;
private Mat subLena1 = null;
private Mat subLena2 = null;
private int w;
@ -38,14 +37,11 @@ public class VideoTest extends OpenCVTestCase {
subLena1 = rgbLena.submat(shift1, h + shift1, shift1, w + shift1);
subLena2 = rgbLena.submat(shift2, h + shift2, shift2, w + shift2);
prevPts = new ArrayList<Point>();
prevPts.add(new Point(11.0, 8.0));
prevPts.add(new Point(5.0, 5.0));
prevPts.add(new Point(10.0, 10.0));
prevPts = new CvVectorPoint2f(new Point(11d, 8d), new Point(5d, 5d), new Point(10d, 10d));
nextPts = new ArrayList<Point>();
status = new ArrayList<Byte>();
err = new ArrayList<Float>();
nextPts = new CvVectorPoint2f();
status = new CvVectorByte();
err = new CvVectorFloat();
}
public void testCalcGlobalOrientation() {
@ -66,13 +62,13 @@ public class VideoTest extends OpenCVTestCase {
public void testCalcOpticalFlowPyrLKMatMatListOfPointListOfPointListOfByteListOfFloat() {
Video.calcOpticalFlowPyrLK(subLena1, subLena2, prevPts, nextPts, status, err);
assertEquals(3, Core.countNonZero(Converters.vector_uchar_to_Mat(status)));
assertEquals(3, Core.countNonZero(status));
}
public void testCalcOpticalFlowPyrLKMatMatListOfPointListOfPointListOfByteListOfFloatSize() {
Size sz = new Size(3, 3);
Video.calcOpticalFlowPyrLK(subLena1, subLena2, prevPts, nextPts, status, err, sz, 3);
assertEquals(0, Core.countNonZero(Converters.vector_uchar_to_Mat(status)));
assertEquals(0, Core.countNonZero(status));
}