Java API: converter for vector<KeyPoint> is fixed; test for inRange() improved

This commit is contained in:
Andrey Pavlenko 2011-07-28 14:08:55 +00:00
parent ec1023813f
commit d2080a117e
2 changed files with 18 additions and 10 deletions

View File

@ -666,8 +666,16 @@ public class coreTest extends OpenCVTestCase {
}
public void testInRange() {
Core.inRange(gray0, gray0, gray1, dst);
assertMatEqual(gray255, dst);
gray0.put(1, 1, 100, 150, 200);
Mat lo = new Mat(1, 1, CvType.CV_8UC1, new Scalar(120));
Mat hi = new Mat(1, 1, CvType.CV_8UC1, new Scalar(160));
Core.inRange(gray0, lo, hi, dst);
byte vals[] = new byte[3];
dst.get(1, 1, vals);
assertEquals(0, vals[0]);
assertEquals(-1, vals[1]);
assertEquals(0, vals[2]);
assertEquals(1, Core.countNonZero(dst));
}
public void testInsertChannel() {

View File

@ -72,7 +72,7 @@ public class Converters {
int count = m.rows();
if( CvType.CV_32SC2 != m.type() || m.cols()!=1 )
throw new java.lang.IllegalArgumentException(
"CvType.CV_32SC2 != m.type() || m.cols()!=1\n" + m );
"CvType.CV_32SC2 != m.type() || m.cols()!=1\n" + m );
pts.clear();
int[] buff = new int[2*count];
@ -106,7 +106,7 @@ public class Converters {
int count = m.rows();
if( CvType.CV_32SC2 != m.type() || m.cols()!=1 )
throw new java.lang.IllegalArgumentException(
"CvType.CV_32SC2 != m.type() || m.cols()!=1\n" + m);
"CvType.CV_32SC2 != m.type() || m.cols()!=1\n" + m);
mats.clear();
int[] buff = new int[count*2];
@ -140,7 +140,7 @@ public class Converters {
int count = m.rows();
if( CvType.CV_32FC1 != m.type() || m.rows()!=1 )
throw new java.lang.IllegalArgumentException(
"CvType.CV_32FC1 != m.type() || m.rows()!=1\n" + m);
"CvType.CV_32FC1 != m.type() || m.rows()!=1\n" + m);
fs.clear();
float[] buff = new float[count];
@ -190,7 +190,7 @@ public class Converters {
int count = m.rows();
if( CvType.CV_32SC1 != m.type() || m.cols()!=1 )
throw new java.lang.IllegalArgumentException(
"CvType.CV_32SC1 != m.type() || m.cols()!=1\n" + m);
"CvType.CV_32SC1 != m.type() || m.cols()!=1\n" + m);
is.clear();
int[] buff = new int[count];
@ -226,7 +226,7 @@ public class Converters {
int count = m.rows();
if(CvType.CV_32SC4 != m.type() || m.cols()!=1 )
throw new java.lang.IllegalArgumentException(
"CvType.CV_32SC4 != m.type() || m.rows()!=1\n" + m);
"CvType.CV_32SC4 != m.type() || m.rows()!=1\n" + m);
rs.clear();
int[] buff = new int[4*count];
@ -266,14 +266,14 @@ public class Converters {
int count = m.rows();
if( CvType.CV_64FC(7) != m.type() || m.cols()!=1 )
throw new java.lang.IllegalArgumentException(
"CvType.CV_64FC(7) != m.type() || m.cols()!=1\n" + m);
"CvType.CV_64FC(7) != m.type() || m.cols()!=1\n" + m);
kps.clear();
double[] buff = new double[7*count];
m.get(0, 0, buff);
for(int i=0; i<count; i++) {
kps.add( new KeyPoint( (float)buff[4*i], (float)buff[4*i+1], (float)buff[4*i+2], (float)buff[4*i+3],
(float)buff[4*i+4], (int)buff[4*i+5], (int)buff[4*i+6] ) );
kps.add( new KeyPoint( (float)buff[7*i], (float)buff[7*i+1], (float)buff[7*i+2], (float)buff[7*i+3],
(float)buff[7*i+4], (int)buff[7*i+5], (int)buff[7*i+6] ) );
}
}