Java API: converter for vector<KeyPoint> is fixed; test for inRange() improved
This commit is contained in:
parent
ec1023813f
commit
d2080a117e
@ -666,8 +666,16 @@ public class coreTest extends OpenCVTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testInRange() {
|
public void testInRange() {
|
||||||
Core.inRange(gray0, gray0, gray1, dst);
|
gray0.put(1, 1, 100, 150, 200);
|
||||||
assertMatEqual(gray255, dst);
|
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() {
|
public void testInsertChannel() {
|
||||||
|
@ -72,7 +72,7 @@ public class Converters {
|
|||||||
int count = m.rows();
|
int count = m.rows();
|
||||||
if( CvType.CV_32SC2 != m.type() || m.cols()!=1 )
|
if( CvType.CV_32SC2 != m.type() || m.cols()!=1 )
|
||||||
throw new java.lang.IllegalArgumentException(
|
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();
|
pts.clear();
|
||||||
int[] buff = new int[2*count];
|
int[] buff = new int[2*count];
|
||||||
@ -106,7 +106,7 @@ public class Converters {
|
|||||||
int count = m.rows();
|
int count = m.rows();
|
||||||
if( CvType.CV_32SC2 != m.type() || m.cols()!=1 )
|
if( CvType.CV_32SC2 != m.type() || m.cols()!=1 )
|
||||||
throw new java.lang.IllegalArgumentException(
|
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();
|
mats.clear();
|
||||||
int[] buff = new int[count*2];
|
int[] buff = new int[count*2];
|
||||||
@ -140,7 +140,7 @@ public class Converters {
|
|||||||
int count = m.rows();
|
int count = m.rows();
|
||||||
if( CvType.CV_32FC1 != m.type() || m.rows()!=1 )
|
if( CvType.CV_32FC1 != m.type() || m.rows()!=1 )
|
||||||
throw new java.lang.IllegalArgumentException(
|
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();
|
fs.clear();
|
||||||
float[] buff = new float[count];
|
float[] buff = new float[count];
|
||||||
@ -190,7 +190,7 @@ public class Converters {
|
|||||||
int count = m.rows();
|
int count = m.rows();
|
||||||
if( CvType.CV_32SC1 != m.type() || m.cols()!=1 )
|
if( CvType.CV_32SC1 != m.type() || m.cols()!=1 )
|
||||||
throw new java.lang.IllegalArgumentException(
|
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();
|
is.clear();
|
||||||
int[] buff = new int[count];
|
int[] buff = new int[count];
|
||||||
@ -226,7 +226,7 @@ public class Converters {
|
|||||||
int count = m.rows();
|
int count = m.rows();
|
||||||
if(CvType.CV_32SC4 != m.type() || m.cols()!=1 )
|
if(CvType.CV_32SC4 != m.type() || m.cols()!=1 )
|
||||||
throw new java.lang.IllegalArgumentException(
|
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();
|
rs.clear();
|
||||||
int[] buff = new int[4*count];
|
int[] buff = new int[4*count];
|
||||||
@ -266,14 +266,14 @@ public class Converters {
|
|||||||
int count = m.rows();
|
int count = m.rows();
|
||||||
if( CvType.CV_64FC(7) != m.type() || m.cols()!=1 )
|
if( CvType.CV_64FC(7) != m.type() || m.cols()!=1 )
|
||||||
throw new java.lang.IllegalArgumentException(
|
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();
|
kps.clear();
|
||||||
double[] buff = new double[7*count];
|
double[] buff = new double[7*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++) {
|
||||||
kps.add( new KeyPoint( (float)buff[4*i], (float)buff[4*i+1], (float)buff[4*i+2], (float)buff[4*i+3],
|
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[4*i+4], (int)buff[4*i+5], (int)buff[4*i+6] ) );
|
(float)buff[7*i+4], (int)buff[7*i+5], (int)buff[7*i+6] ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user