Java API: minor bug-fixes and improvements in CvVector-s and tests

This commit is contained in:
Andrey Pavlenko
2012-04-05 08:41:03 +00:00
parent 4ee2c486eb
commit 0c45a5add2
19 changed files with 89 additions and 72 deletions

View File

@@ -8,7 +8,7 @@ public class CvVectorByte extends CvVector {
}
public CvVectorByte() {
super(_d, 1);
this(1);
}
public CvVectorByte(int ch, long addr) {
@@ -32,7 +32,7 @@ public class CvVectorByte extends CvVector {
}
}
public byte[] toArray(byte[] a) {
public byte[] toPrimitiveArray(byte[] a) {
int cnt = (int) total() * channels;
if(cnt == 0)
return new byte[0];//null;

View File

@@ -25,7 +25,7 @@ public class CvVectorDMatch extends CvVectorFloat {
create(cnt);
float buff[] = new float[_ch * cnt];
for(int i=0; i<cnt; i++) {
DMatch m = a[i];
DMatch m = a[i];
buff[_ch*i+0] = m.queryIdx;
buff[_ch*i+1] = m.trainIdx;
buff[_ch*i+2] = m.imgIdx;
@@ -35,7 +35,7 @@ public class CvVectorDMatch extends CvVectorFloat {
}
public DMatch[] toArray(DMatch[] a) {
float buff[] = super.toArray(null);
float buff[] = super.toPrimitiveArray(null);
if(buff.length == 0)
return new DMatch[0]; //null;
int cnt = buff.length / _ch;

View File

@@ -1,14 +1,14 @@
package org.opencv.core;
public class CvVectorDouble extends CvVector {
private static final int _d = CvType.CV_64F;
private static final int _d = CvType.CV_64F;
public CvVectorDouble(int ch) {
super(_d, ch);
}
public CvVectorDouble() {
super(_d, 1);
this(1);
}
public CvVectorDouble(int ch, long addr) {
@@ -22,13 +22,13 @@ public class CvVectorDouble extends CvVector {
public CvVectorDouble(int ch, double[] a) {
super(_d, ch);
if(a!=null) {
int cnt = a.length / ch;
create(cnt);
put(0, 0, a);
int cnt = a.length / ch;
create(cnt);
put(0, 0, a);
}
}
public double[] toArray(double[] a) {
public double[] toPrimitiveArray(double[] a) {
int cnt = (int) total() * channels;
if(cnt == 0)
return new double[0];//null;

View File

@@ -8,7 +8,7 @@ public class CvVectorFloat extends CvVector {
}
public CvVectorFloat() {
super(_d, 1);
this(1);
}
public CvVectorFloat(int ch, long addr) {
@@ -32,7 +32,7 @@ public class CvVectorFloat extends CvVector {
}
}
public float[] toArray(float[] a) {
public float[] toPrimitiveArray(float[] a) {
int cnt = (int) total() * channels;
if(cnt == 0)
return new float[0];//null;

View File

@@ -2,14 +2,14 @@ package org.opencv.core;
public class CvVectorInt extends CvVector {
private static final int _d = CvType.CV_32S;
private static final int _d = CvType.CV_32S;
public CvVectorInt(int ch) {
super(_d, ch);
}
public CvVectorInt() {
super(_d, 1);
this(1);
}
public CvVectorInt(int ch, long addr) {
@@ -23,13 +23,13 @@ public class CvVectorInt extends CvVector {
public CvVectorInt(int ch, int[] a) {
super(_d, ch);
if(a!=null) {
int cnt = a.length / ch;
create(cnt);
put(0, 0, a);
int cnt = a.length / ch;
create(cnt);
put(0, 0, a);
}
}
public int[] toArray(int[] a) {
public int[] toPrimitiveArray(int[] a) {
int cnt = (int) total() * channels;
if(cnt == 0)
return new int[0];//null;

View File

@@ -25,7 +25,7 @@ public class CvVectorKeyPoint extends CvVectorFloat {
create(cnt);
float buff[] = new float[_ch * cnt];
for(int i=0; i<cnt; i++) {
KeyPoint kp = a[i];
KeyPoint kp = a[i];
buff[_ch*i+0] = (float) kp.pt.x;
buff[_ch*i+1] = (float) kp.pt.y;
buff[_ch*i+2] = kp.size;
@@ -38,7 +38,7 @@ public class CvVectorKeyPoint extends CvVectorFloat {
}
public KeyPoint[] toArray(KeyPoint[] a) {
float buff[] = super.toArray(null);
float buff[] = super.toPrimitiveArray(null);
if(buff.length == 0)
return new KeyPoint[0]; //null;
int cnt = buff.length / _ch;
@@ -47,7 +47,7 @@ public class CvVectorKeyPoint extends CvVectorFloat {
res = new KeyPoint[cnt];
for(int i=0; i<cnt; i++)
res[i] = new KeyPoint( buff[_ch*i+0], buff[_ch*i+1], buff[_ch*i+2], buff[_ch*i+3],
buff[_ch*i+4], (int) buff[_ch*i+5], (int) buff[_ch*i+6] );
buff[_ch*i+4], (int) buff[_ch*i+5], (int) buff[_ch*i+6] );
return res;
}
}

View File

@@ -23,7 +23,7 @@ public class CvVectorPoint extends CvVectorInt {
create(cnt);
int buff[] = new int[_ch * cnt];
for(int i=0; i<cnt; i++) {
Point p = a[i];
Point p = a[i];
buff[_ch*i+0] = (int) p.x;
buff[_ch*i+1] = (int) p.y;
}
@@ -31,7 +31,7 @@ public class CvVectorPoint extends CvVectorInt {
}
public Point[] toArray(Point[] a) {
int buff[] = super.toArray(null);
int buff[] = super.toPrimitiveArray(null);
if(buff.length == 0)
return new Point[0]; //null;
int cnt = buff.length / _ch;

View File

@@ -23,7 +23,7 @@ public class CvVectorPoint2f extends CvVectorFloat {
create(cnt);
float buff[] = new float[_ch * cnt];
for(int i=0; i<cnt; i++) {
Point p = a[i];
Point p = a[i];
buff[_ch*i+0] = (float) p.x;
buff[_ch*i+1] = (float) p.y;
}
@@ -31,7 +31,7 @@ public class CvVectorPoint2f extends CvVectorFloat {
}
public Point[] toArray(Point[] a) {
float buff[] = super.toArray(null);
float buff[] = super.toPrimitiveArray(null);
if(buff.length == 0)
return new Point[0]; //null;
int cnt = buff.length / _ch;

View File

@@ -23,7 +23,7 @@ public class CvVectorPoint3 extends CvVectorInt {
create(cnt);
int buff[] = new int[_ch * cnt];
for(int i=0; i<cnt; i++) {
Point3 p = a[i];
Point3 p = a[i];
buff[_ch*i] = (int) p.x;
buff[_ch*i+1] = (int) p.y;
buff[_ch*i+2] = (int) p.z;
@@ -32,7 +32,7 @@ public class CvVectorPoint3 extends CvVectorInt {
}
public Point3[] toArray(Point3[] a) {
int buff[] = super.toArray(null);
int buff[] = super.toPrimitiveArray(null);
if(buff.length == 0)
return new Point3[0]; //null;
int cnt = buff.length / _ch;

View File

@@ -23,7 +23,7 @@ public class CvVectorPoint3f extends CvVectorFloat {
create(cnt);
float buff[] = new float[_ch * cnt];
for(int i=0; i<cnt; i++) {
Point3 p = a[i];
Point3 p = a[i];
buff[_ch*i] = (float) p.x;
buff[_ch*i+1] = (float) p.y;
buff[_ch*i+2] = (float) p.z;
@@ -32,7 +32,7 @@ public class CvVectorPoint3f extends CvVectorFloat {
}
public Point3[] toArray(Point3[] a) {
float buff[] = super.toArray(null);
float buff[] = super.toPrimitiveArray(null);
if(buff.length == 0)
return new Point3[0]; //null;
int cnt = buff.length / _ch;

View File

@@ -24,7 +24,7 @@ public class CvVectorRect extends CvVectorInt {
create(cnt);
int buff[] = new int[_ch * cnt];
for(int i=0; i<cnt; i++) {
Rect r = a[i];
Rect r = a[i];
buff[_ch*i] = r.x;
buff[_ch*i+1] = r.y;
buff[_ch*i+2] = r.width;
@@ -34,7 +34,7 @@ public class CvVectorRect extends CvVectorInt {
}
public Rect[] toArray(Rect[] a) {
int buff[] = super.toArray(null);
int buff[] = super.toPrimitiveArray(null);
if(buff.length == 0)
return new Rect[0]; //null;
int cnt = buff.length / _ch;