Java API: changing CvVectorXxx to MatOfXxx
This commit is contained in:
@@ -1,35 +0,0 @@
|
||||
package org.opencv.core;
|
||||
|
||||
public class CvVector extends Mat {
|
||||
protected int depth;
|
||||
protected int channels;
|
||||
|
||||
protected CvVector(int d, int ch) {
|
||||
super();
|
||||
depth = d;
|
||||
channels = ch;
|
||||
}
|
||||
|
||||
protected CvVector(int d, int ch, long addr) {
|
||||
super(addr);
|
||||
depth = d;
|
||||
channels = ch;
|
||||
if( !empty() && checkVector(channels, depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
protected CvVector(int d, int ch, Mat m) {
|
||||
super(m, Range.all());
|
||||
depth = d;
|
||||
channels = ch;
|
||||
if( !empty() && checkVector(channels, depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
protected void create(int cnt) {
|
||||
if(cnt>0)
|
||||
super.create(cnt, 1, CvType.makeType(depth, channels));
|
||||
}
|
||||
}
|
@@ -1,46 +0,0 @@
|
||||
package org.opencv.core;
|
||||
|
||||
public class CvVectorByte extends CvVector {
|
||||
private static final int _d = CvType.CV_8U;
|
||||
|
||||
public CvVectorByte(int ch) {
|
||||
super(_d, ch);
|
||||
}
|
||||
|
||||
public CvVectorByte() {
|
||||
this(1);
|
||||
}
|
||||
|
||||
public CvVectorByte(int ch, long addr) {
|
||||
super(_d, ch, addr);
|
||||
}
|
||||
|
||||
public CvVectorByte(long addr) {
|
||||
super(_d, 1, addr);
|
||||
}
|
||||
|
||||
public CvVectorByte(int ch, Mat m) {
|
||||
super(_d, ch, m);
|
||||
}
|
||||
|
||||
public CvVectorByte(int ch, byte[] a) {
|
||||
super(_d, ch);
|
||||
if(a!=null) {
|
||||
int cnt = a.length / ch;
|
||||
create(cnt);
|
||||
put(0, 0, a);
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] toPrimitiveArray(byte[] a) {
|
||||
int cnt = (int) total() * channels;
|
||||
if(cnt == 0)
|
||||
return new byte[0];//null;
|
||||
byte[] res = a;
|
||||
if(res==null || res.length<cnt)
|
||||
res = new byte[cnt];
|
||||
get(0, 0, res); //TODO: check ret val!
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
@@ -1,49 +0,0 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import org.opencv.features2d.DMatch;
|
||||
|
||||
public class CvVectorDMatch extends CvVectorFloat {
|
||||
private static final int _ch = 4; //xxxC4
|
||||
|
||||
public CvVectorDMatch() {
|
||||
super(_ch);
|
||||
}
|
||||
|
||||
public CvVectorDMatch(long addr) {
|
||||
super(_ch, addr);
|
||||
}
|
||||
|
||||
public CvVectorDMatch(Mat m) {
|
||||
super(_ch, m);
|
||||
}
|
||||
|
||||
public CvVectorDMatch(DMatch...a) {
|
||||
super(_ch);
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int cnt = a.length;
|
||||
create(cnt);
|
||||
float buff[] = new float[_ch * cnt];
|
||||
for(int i=0; i<cnt; i++) {
|
||||
DMatch m = a[i];
|
||||
buff[_ch*i+0] = m.queryIdx;
|
||||
buff[_ch*i+1] = m.trainIdx;
|
||||
buff[_ch*i+2] = m.imgIdx;
|
||||
buff[_ch*i+3] = m.distance;
|
||||
}
|
||||
put(0, 0, buff); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public DMatch[] toArray(DMatch[] a) {
|
||||
float buff[] = super.toPrimitiveArray(null);
|
||||
if(buff.length == 0)
|
||||
return new DMatch[0]; //null;
|
||||
int cnt = buff.length / _ch;
|
||||
DMatch[] res = a;
|
||||
if(a==null || a.length<cnt)
|
||||
res = new DMatch[cnt];
|
||||
for(int i=0; i<cnt; i++)
|
||||
res[i] = new DMatch((int) buff[_ch*i+0], (int) buff[_ch*i+1], (int) buff[_ch*i+2], buff[_ch*i+3]);
|
||||
return res;
|
||||
}
|
||||
}
|
@@ -1,41 +0,0 @@
|
||||
package org.opencv.core;
|
||||
|
||||
public class CvVectorDouble extends CvVector {
|
||||
private static final int _d = CvType.CV_64F;
|
||||
|
||||
public CvVectorDouble(int ch) {
|
||||
super(_d, ch);
|
||||
}
|
||||
|
||||
public CvVectorDouble() {
|
||||
this(1);
|
||||
}
|
||||
|
||||
public CvVectorDouble(int ch, long addr) {
|
||||
super(_d, ch, addr);
|
||||
}
|
||||
|
||||
public CvVectorDouble(int ch, Mat m) {
|
||||
super(_d, ch, m);
|
||||
}
|
||||
|
||||
public CvVectorDouble(int ch, double[] a) {
|
||||
super(_d, ch);
|
||||
if(a!=null) {
|
||||
int cnt = a.length / ch;
|
||||
create(cnt);
|
||||
put(0, 0, a);
|
||||
}
|
||||
}
|
||||
|
||||
public double[] toPrimitiveArray(double[] a) {
|
||||
int cnt = (int) total() * channels;
|
||||
if(cnt == 0)
|
||||
return new double[0];//null;
|
||||
double[] res = a;
|
||||
if(res==null || res.length<cnt)
|
||||
res = new double[cnt];
|
||||
get(0, 0, res); //TODO: check ret val!
|
||||
return res;
|
||||
}
|
||||
}
|
@@ -1,45 +0,0 @@
|
||||
package org.opencv.core;
|
||||
|
||||
public class CvVectorFloat extends CvVector {
|
||||
private static final int _d = CvType.CV_32F;
|
||||
|
||||
public CvVectorFloat(int ch) {
|
||||
super(_d, ch);
|
||||
}
|
||||
|
||||
public CvVectorFloat() {
|
||||
this(1);
|
||||
}
|
||||
|
||||
public CvVectorFloat(int ch, long addr) {
|
||||
super(_d, ch, addr);
|
||||
}
|
||||
|
||||
public CvVectorFloat(long addr) {
|
||||
super(_d, 1, addr);
|
||||
}
|
||||
|
||||
public CvVectorFloat(int ch, Mat m) {
|
||||
super(_d, ch, m);
|
||||
}
|
||||
|
||||
public CvVectorFloat(int ch, float[] a) {
|
||||
super(_d, ch);
|
||||
if(a!=null) {
|
||||
int cnt = a.length / ch;
|
||||
create(cnt);
|
||||
put(0, 0, a);
|
||||
}
|
||||
}
|
||||
|
||||
public float[] toPrimitiveArray(float[] a) {
|
||||
int cnt = (int) total() * channels;
|
||||
if(cnt == 0)
|
||||
return new float[0];//null;
|
||||
float[] res = a;
|
||||
if(res==null || res.length<cnt)
|
||||
res = new float[cnt];
|
||||
get(0, 0, res); //TODO: check ret val!
|
||||
return res;
|
||||
}
|
||||
}
|
@@ -1,22 +0,0 @@
|
||||
package org.opencv.core;
|
||||
|
||||
public class CvVectorFloat4 extends CvVectorFloat {
|
||||
private static final int _ch = 4; //xxxC4
|
||||
|
||||
public CvVectorFloat4() {
|
||||
super(_ch);
|
||||
}
|
||||
|
||||
public CvVectorFloat4(long addr) {
|
||||
super(_ch, addr);
|
||||
}
|
||||
|
||||
public CvVectorFloat4(Mat m) {
|
||||
super(_ch, m);
|
||||
}
|
||||
|
||||
public CvVectorFloat4(float[] a) {
|
||||
super(_ch, a);
|
||||
}
|
||||
|
||||
}
|
@@ -1,21 +0,0 @@
|
||||
package org.opencv.core;
|
||||
|
||||
public class CvVectorFloat6 extends CvVectorFloat {
|
||||
private static final int _ch = 6; //xxxC6
|
||||
|
||||
public CvVectorFloat6() {
|
||||
super(_ch);
|
||||
}
|
||||
|
||||
public CvVectorFloat6(long addr) {
|
||||
super(_ch, addr);
|
||||
}
|
||||
|
||||
public CvVectorFloat6(Mat m) {
|
||||
super(_ch, m);
|
||||
}
|
||||
|
||||
public CvVectorFloat6(float[] a) {
|
||||
super(_ch, a);
|
||||
}
|
||||
}
|
@@ -1,42 +0,0 @@
|
||||
package org.opencv.core;
|
||||
|
||||
|
||||
public class CvVectorInt extends CvVector {
|
||||
private static final int _d = CvType.CV_32S;
|
||||
|
||||
public CvVectorInt(int ch) {
|
||||
super(_d, ch);
|
||||
}
|
||||
|
||||
public CvVectorInt() {
|
||||
this(1);
|
||||
}
|
||||
|
||||
public CvVectorInt(int ch, long addr) {
|
||||
super(_d, ch, addr);
|
||||
}
|
||||
|
||||
public CvVectorInt(int ch, Mat m) {
|
||||
super(_d, ch, m);
|
||||
}
|
||||
|
||||
public CvVectorInt(int ch, int[] a) {
|
||||
super(_d, ch);
|
||||
if(a!=null) {
|
||||
int cnt = a.length / ch;
|
||||
create(cnt);
|
||||
put(0, 0, a);
|
||||
}
|
||||
}
|
||||
|
||||
public int[] toPrimitiveArray(int[] a) {
|
||||
int cnt = (int) total() * channels;
|
||||
if(cnt == 0)
|
||||
return new int[0];//null;
|
||||
int[] res = a;
|
||||
if(res==null || res.length<cnt)
|
||||
res = new int[cnt];
|
||||
get(0, 0, res); //TODO: check ret val!
|
||||
return res;
|
||||
}
|
||||
}
|
@@ -1,53 +0,0 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import org.opencv.features2d.KeyPoint;
|
||||
|
||||
public class CvVectorKeyPoint extends CvVectorFloat {
|
||||
private static final int _ch = 7; //xxxC7
|
||||
|
||||
public CvVectorKeyPoint() {
|
||||
super(_ch);
|
||||
}
|
||||
|
||||
public CvVectorKeyPoint(long addr) {
|
||||
super(_ch, addr);
|
||||
}
|
||||
|
||||
public CvVectorKeyPoint(Mat m) {
|
||||
super(_ch, m);
|
||||
}
|
||||
|
||||
public CvVectorKeyPoint(KeyPoint...a) {
|
||||
super(_ch);
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int cnt = a.length;
|
||||
create(cnt);
|
||||
float buff[] = new float[_ch * cnt];
|
||||
for(int i=0; i<cnt; 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;
|
||||
buff[_ch*i+3] = kp.angle;
|
||||
buff[_ch*i+4] = kp.response;
|
||||
buff[_ch*i+5] = kp.octave;
|
||||
buff[_ch*i+6] = kp.class_id;
|
||||
}
|
||||
put(0, 0, buff); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public KeyPoint[] toArray(KeyPoint[] a) {
|
||||
float buff[] = super.toPrimitiveArray(null);
|
||||
if(buff.length == 0)
|
||||
return new KeyPoint[0]; //null;
|
||||
int cnt = buff.length / _ch;
|
||||
KeyPoint[] res = a;
|
||||
if(a==null || a.length<cnt)
|
||||
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] );
|
||||
return res;
|
||||
}
|
||||
}
|
@@ -1,45 +0,0 @@
|
||||
package org.opencv.core;
|
||||
|
||||
public class CvVectorPoint extends CvVectorInt {
|
||||
private static final int _ch = 2; //xxxC2
|
||||
|
||||
public CvVectorPoint() {
|
||||
super(_ch);
|
||||
}
|
||||
|
||||
public CvVectorPoint(long addr) {
|
||||
super(_ch, addr);
|
||||
}
|
||||
|
||||
public CvVectorPoint(Mat m) {
|
||||
super(_ch, m);
|
||||
}
|
||||
|
||||
public CvVectorPoint(Point...a) {
|
||||
super(_ch);
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int cnt = a.length;
|
||||
create(cnt);
|
||||
int buff[] = new int[_ch * cnt];
|
||||
for(int i=0; i<cnt; i++) {
|
||||
Point p = a[i];
|
||||
buff[_ch*i+0] = (int) p.x;
|
||||
buff[_ch*i+1] = (int) p.y;
|
||||
}
|
||||
put(0, 0, buff); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public Point[] toArray(Point[] a) {
|
||||
int buff[] = super.toPrimitiveArray(null);
|
||||
if(buff.length == 0)
|
||||
return new Point[0]; //null;
|
||||
int cnt = buff.length / _ch;
|
||||
Point[] res = a;
|
||||
if(a==null || a.length<cnt)
|
||||
res = new Point[cnt];
|
||||
for(int i=0; i<cnt; i++)
|
||||
res[i] = new Point(buff[i*_ch], buff[i*_ch+1]);
|
||||
return res;
|
||||
}
|
||||
}
|
@@ -1,45 +0,0 @@
|
||||
package org.opencv.core;
|
||||
|
||||
public class CvVectorPoint2f extends CvVectorFloat {
|
||||
private static final int _ch = 2; //xxxC2
|
||||
|
||||
public CvVectorPoint2f() {
|
||||
super(_ch);
|
||||
}
|
||||
|
||||
public CvVectorPoint2f(long addr) {
|
||||
super(_ch, addr);
|
||||
}
|
||||
|
||||
public CvVectorPoint2f(Mat m) {
|
||||
super(_ch, m);
|
||||
}
|
||||
|
||||
public CvVectorPoint2f(Point...a) {
|
||||
super(_ch);
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int cnt = a.length;
|
||||
create(cnt);
|
||||
float buff[] = new float[_ch * cnt];
|
||||
for(int i=0; i<cnt; i++) {
|
||||
Point p = a[i];
|
||||
buff[_ch*i+0] = (float) p.x;
|
||||
buff[_ch*i+1] = (float) p.y;
|
||||
}
|
||||
put(0, 0, buff); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public Point[] toArray(Point[] a) {
|
||||
float buff[] = super.toPrimitiveArray(null);
|
||||
if(buff.length == 0)
|
||||
return new Point[0]; //null;
|
||||
int cnt = buff.length / _ch;
|
||||
Point[] res = a;
|
||||
if(a==null || a.length<cnt)
|
||||
res = new Point[cnt];
|
||||
for(int i=0; i<cnt; i++)
|
||||
res[i] = new Point(buff[i*_ch], buff[i*_ch+1]);
|
||||
return res;
|
||||
}
|
||||
}
|
@@ -1,46 +0,0 @@
|
||||
package org.opencv.core;
|
||||
|
||||
public class CvVectorPoint3 extends CvVectorInt {
|
||||
private static final int _ch = 3; //xxxC2
|
||||
|
||||
public CvVectorPoint3() {
|
||||
super(_ch);
|
||||
}
|
||||
|
||||
public CvVectorPoint3(long addr) {
|
||||
super(_ch, addr);
|
||||
}
|
||||
|
||||
public CvVectorPoint3(Mat m) {
|
||||
super(_ch, m);
|
||||
}
|
||||
|
||||
public CvVectorPoint3(Point3...a) {
|
||||
super(_ch);
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int cnt = a.length;
|
||||
create(cnt);
|
||||
int buff[] = new int[_ch * cnt];
|
||||
for(int i=0; i<cnt; 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;
|
||||
}
|
||||
put(0, 0, buff); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public Point3[] toArray(Point3[] a) {
|
||||
int buff[] = super.toPrimitiveArray(null);
|
||||
if(buff.length == 0)
|
||||
return new Point3[0]; //null;
|
||||
int cnt = buff.length / _ch;
|
||||
Point3[] res = a;
|
||||
if(a==null || a.length<cnt)
|
||||
res = new Point3[cnt];
|
||||
for(int i=0; i<cnt; i++)
|
||||
res[i] = new Point3(buff[i*_ch], buff[i*_ch+1], buff[i*_ch+2]);
|
||||
return res;
|
||||
}
|
||||
}
|
@@ -1,46 +0,0 @@
|
||||
package org.opencv.core;
|
||||
|
||||
public class CvVectorPoint3f extends CvVectorFloat {
|
||||
private static final int _ch = 3; //xxxC2
|
||||
|
||||
public CvVectorPoint3f() {
|
||||
super(_ch);
|
||||
}
|
||||
|
||||
public CvVectorPoint3f(long addr) {
|
||||
super(_ch, addr);
|
||||
}
|
||||
|
||||
public CvVectorPoint3f(Mat m) {
|
||||
super(_ch, m);
|
||||
}
|
||||
|
||||
public CvVectorPoint3f(Point3...a) {
|
||||
super(_ch);
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int cnt = a.length;
|
||||
create(cnt);
|
||||
float buff[] = new float[_ch * cnt];
|
||||
for(int i=0; i<cnt; 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;
|
||||
}
|
||||
put(0, 0, buff); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public Point3[] toArray(Point3[] a) {
|
||||
float buff[] = super.toPrimitiveArray(null);
|
||||
if(buff.length == 0)
|
||||
return new Point3[0]; //null;
|
||||
int cnt = buff.length / _ch;
|
||||
Point3[] res = a;
|
||||
if(a==null || a.length<cnt)
|
||||
res = new Point3[cnt];
|
||||
for(int i=0; i<cnt; i++)
|
||||
res[i] = new Point3(buff[i*_ch], buff[i*_ch+1], buff[i*_ch+2]);
|
||||
return res;
|
||||
}
|
||||
}
|
@@ -1,48 +0,0 @@
|
||||
package org.opencv.core;
|
||||
|
||||
|
||||
public class CvVectorRect extends CvVectorInt {
|
||||
private static final int _ch = 4; //xxxC4
|
||||
|
||||
public CvVectorRect() {
|
||||
super(_ch);
|
||||
}
|
||||
|
||||
public CvVectorRect(long addr) {
|
||||
super(_ch, addr);
|
||||
}
|
||||
|
||||
public CvVectorRect(Mat m) {
|
||||
super(_ch, m);
|
||||
}
|
||||
|
||||
public CvVectorRect(Rect...a) {
|
||||
super(_ch);
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int cnt = a.length;
|
||||
create(cnt);
|
||||
int buff[] = new int[_ch * cnt];
|
||||
for(int i=0; i<cnt; i++) {
|
||||
Rect r = a[i];
|
||||
buff[_ch*i] = r.x;
|
||||
buff[_ch*i+1] = r.y;
|
||||
buff[_ch*i+2] = r.width;
|
||||
buff[_ch*i+3] = r.height;
|
||||
}
|
||||
put(0, 0, buff); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public Rect[] toArray(Rect[] a) {
|
||||
int buff[] = super.toPrimitiveArray(null);
|
||||
if(buff.length == 0)
|
||||
return new Rect[0]; //null;
|
||||
int cnt = buff.length / _ch;
|
||||
Rect[] res = a;
|
||||
if(a==null || a.length<cnt)
|
||||
res = new Rect[cnt];
|
||||
for(int i=0; i<cnt; i++)
|
||||
res[i] = new Rect(buff[i*_ch], buff[i*_ch+1], buff[i*_ch+2], buff[i*_ch+3]);
|
||||
return res;
|
||||
}
|
||||
}
|
81
modules/java/src/java/core+MatOfByte.java
Normal file
81
modules/java/src/java/core+MatOfByte.java
Normal file
@@ -0,0 +1,81 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MatOfByte extends Mat {
|
||||
// 8UC(x)
|
||||
private static final int _depth = CvType.CV_8U;
|
||||
private final int _channels;
|
||||
|
||||
public MatOfByte(int channels) {
|
||||
super();
|
||||
_channels = channels;
|
||||
}
|
||||
|
||||
public MatOfByte() {
|
||||
this(1);
|
||||
}
|
||||
|
||||
public MatOfByte(int channels, long addr) {
|
||||
super(addr);
|
||||
_channels = channels;
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfByte(int channels, Mat m) {
|
||||
super(m, Range.all());
|
||||
_channels = channels;
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfByte(int channels, byte...a) {
|
||||
super();
|
||||
_channels = channels;
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public void alloc(int elemNumber) {
|
||||
if(elemNumber>0)
|
||||
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||
}
|
||||
|
||||
public void fromArray(byte...a) {
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int num = a.length / _channels;
|
||||
alloc(num);
|
||||
put(0, 0, a); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public byte[] toArray() {
|
||||
int num = (int) total();
|
||||
byte[] a = new byte[num * _channels];
|
||||
if(num == 0)
|
||||
return a;
|
||||
get(0, 0, a); //TODO: check ret val!
|
||||
return a;
|
||||
}
|
||||
|
||||
public void fromList(List<Byte> lb) {
|
||||
if(lb==null || lb.size()==0)
|
||||
return;
|
||||
Byte ab[] = lb.toArray(null);
|
||||
byte a[] = new byte[ab.length];
|
||||
for(int i=0; i<ab.length; i++)
|
||||
a[i] = ab[i];
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public List<Byte> toList() {
|
||||
byte[] a = toArray();
|
||||
Byte ab[] = new Byte[a.length];
|
||||
for(int i=0; i<a.length; i++)
|
||||
ab[i] = a[i];
|
||||
return Arrays.asList(ab);
|
||||
}
|
||||
}
|
79
modules/java/src/java/core+MatOfDMatch.java
Normal file
79
modules/java/src/java/core+MatOfDMatch.java
Normal file
@@ -0,0 +1,79 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.opencv.features2d.DMatch;
|
||||
|
||||
public class MatOfDMatch extends Mat {
|
||||
// 32FC4
|
||||
private static final int _depth = CvType.CV_32F;
|
||||
private static final int _channels = 4;
|
||||
|
||||
public MatOfDMatch() {
|
||||
super();
|
||||
}
|
||||
|
||||
public MatOfDMatch(long addr) {
|
||||
super(addr);
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfDMatch(Mat m) {
|
||||
super(m, Range.all());
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfDMatch(DMatch...ap) {
|
||||
super();
|
||||
fromArray(ap);
|
||||
}
|
||||
|
||||
public void alloc(int elemNumber) {
|
||||
if(elemNumber>0)
|
||||
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||
}
|
||||
|
||||
|
||||
public void fromArray(DMatch...a) {
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int num = a.length;
|
||||
alloc(num);
|
||||
float buff[] = new float[num * _channels];
|
||||
for(int i=0; i<num; i++) {
|
||||
DMatch m = a[i];
|
||||
buff[_channels*i+0] = m.queryIdx;
|
||||
buff[_channels*i+1] = m.trainIdx;
|
||||
buff[_channels*i+2] = m.imgIdx;
|
||||
buff[_channels*i+3] = m.distance;
|
||||
}
|
||||
put(0, 0, buff); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public DMatch[] toArray() {
|
||||
int num = (int) total();
|
||||
DMatch[] a = new DMatch[num];
|
||||
if(num == 0)
|
||||
return a;
|
||||
float buff[] = new float[num * _channels];
|
||||
get(0, 0, buff); //TODO: check ret val!
|
||||
for(int i=0; i<num; i++)
|
||||
a[i] = new DMatch((int) buff[_channels*i+0], (int) buff[_channels*i+1], (int) buff[_channels*i+2], buff[_channels*i+3]);
|
||||
return a;
|
||||
}
|
||||
|
||||
public void fromList(List<DMatch> ldm) {
|
||||
DMatch adm[] = ldm.toArray(null);
|
||||
fromArray(adm);
|
||||
}
|
||||
|
||||
public List<DMatch> toList() {
|
||||
DMatch[] adm = toArray();
|
||||
return Arrays.asList(adm);
|
||||
}
|
||||
}
|
81
modules/java/src/java/core+MatOfDouble.java
Normal file
81
modules/java/src/java/core+MatOfDouble.java
Normal file
@@ -0,0 +1,81 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MatOfDouble extends Mat {
|
||||
// 64FC(x)
|
||||
private static final int _depth = CvType.CV_64F;
|
||||
private final int _channels;
|
||||
|
||||
public MatOfDouble(int channels) {
|
||||
super();
|
||||
_channels = channels;
|
||||
}
|
||||
|
||||
public MatOfDouble() {
|
||||
this(1);
|
||||
}
|
||||
|
||||
public MatOfDouble(int channels, long addr) {
|
||||
super(addr);
|
||||
_channels = channels;
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfDouble(int channels, Mat m) {
|
||||
super(m, Range.all());
|
||||
_channels = channels;
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfDouble(int channels, double...a) {
|
||||
super();
|
||||
_channels = channels;
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public void alloc(int elemNumber) {
|
||||
if(elemNumber>0)
|
||||
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||
}
|
||||
|
||||
public void fromArray(double...a) {
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int num = a.length / _channels;
|
||||
alloc(num);
|
||||
put(0, 0, a); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public double[] toArray() {
|
||||
int num = (int) total();
|
||||
double[] a = new double[num * _channels];
|
||||
if(num == 0)
|
||||
return a;
|
||||
get(0, 0, a); //TODO: check ret val!
|
||||
return a;
|
||||
}
|
||||
|
||||
public void fromList(List<Double> lb) {
|
||||
if(lb==null || lb.size()==0)
|
||||
return;
|
||||
Double ab[] = lb.toArray(null);
|
||||
double a[] = new double[ab.length];
|
||||
for(int i=0; i<ab.length; i++)
|
||||
a[i] = ab[i];
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public List<Double> toList() {
|
||||
double[] a = toArray();
|
||||
Double ab[] = new Double[a.length];
|
||||
for(int i=0; i<a.length; i++)
|
||||
ab[i] = a[i];
|
||||
return Arrays.asList(ab);
|
||||
}
|
||||
}
|
81
modules/java/src/java/core+MatOfFloat.java
Normal file
81
modules/java/src/java/core+MatOfFloat.java
Normal file
@@ -0,0 +1,81 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MatOfFloat extends Mat {
|
||||
// 32FC(x)
|
||||
private static final int _depth = CvType.CV_32F;
|
||||
private final int _channels;
|
||||
|
||||
public MatOfFloat(int channels) {
|
||||
super();
|
||||
_channels = channels;
|
||||
}
|
||||
|
||||
public MatOfFloat() {
|
||||
this(1);
|
||||
}
|
||||
|
||||
public MatOfFloat(int channels, long addr) {
|
||||
super(addr);
|
||||
_channels = channels;
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfFloat(int channels, Mat m) {
|
||||
super(m, Range.all());
|
||||
_channels = channels;
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfFloat(int channels, float...a) {
|
||||
super();
|
||||
_channels = channels;
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public void alloc(int elemNumber) {
|
||||
if(elemNumber>0)
|
||||
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||
}
|
||||
|
||||
public void fromArray(float...a) {
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int num = a.length / _channels;
|
||||
alloc(num);
|
||||
put(0, 0, a); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public float[] toArray() {
|
||||
int num = (int) total();
|
||||
float[] a = new float[num * _channels];
|
||||
if(num == 0)
|
||||
return a;
|
||||
get(0, 0, a); //TODO: check ret val!
|
||||
return a;
|
||||
}
|
||||
|
||||
public void fromList(List<Float> lb) {
|
||||
if(lb==null || lb.size()==0)
|
||||
return;
|
||||
Float ab[] = lb.toArray(null);
|
||||
float a[] = new float[ab.length];
|
||||
for(int i=0; i<ab.length; i++)
|
||||
a[i] = ab[i];
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public List<Float> toList() {
|
||||
float[] a = toArray();
|
||||
Float ab[] = new Float[a.length];
|
||||
for(int i=0; i<a.length; i++)
|
||||
ab[i] = a[i];
|
||||
return Arrays.asList(ab);
|
||||
}
|
||||
}
|
82
modules/java/src/java/core+MatOfInt.java
Normal file
82
modules/java/src/java/core+MatOfInt.java
Normal file
@@ -0,0 +1,82 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class MatOfInt extends Mat {
|
||||
// 32SC(x)
|
||||
private static final int _depth = CvType.CV_32S;
|
||||
private final int _channels;
|
||||
|
||||
public MatOfInt(int channels) {
|
||||
super();
|
||||
_channels = channels;
|
||||
}
|
||||
|
||||
public MatOfInt() {
|
||||
this(1);
|
||||
}
|
||||
|
||||
public MatOfInt(int channels, long addr) {
|
||||
super(addr);
|
||||
_channels = channels;
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfInt(int channels, Mat m) {
|
||||
super(m, Range.all());
|
||||
_channels = channels;
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfInt(int channels, int...a) {
|
||||
super();
|
||||
_channels = channels;
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public void alloc(int elemNumber) {
|
||||
if(elemNumber>0)
|
||||
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||
}
|
||||
|
||||
public void fromArray(int...a) {
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int num = a.length / _channels;
|
||||
alloc(num);
|
||||
put(0, 0, a); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public int[] toArray() {
|
||||
int num = (int) total();
|
||||
int[] a = new int[num * _channels];
|
||||
if(num == 0)
|
||||
return a;
|
||||
get(0, 0, a); //TODO: check ret val!
|
||||
return a;
|
||||
}
|
||||
|
||||
public void fromList(List<Integer> lb) {
|
||||
if(lb==null || lb.size()==0)
|
||||
return;
|
||||
Integer ab[] = lb.toArray(null);
|
||||
int a[] = new int[ab.length];
|
||||
for(int i=0; i<ab.length; i++)
|
||||
a[i] = ab[i];
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public List<Integer> toList() {
|
||||
int[] a = toArray();
|
||||
Integer ab[] = new Integer[a.length];
|
||||
for(int i=0; i<a.length; i++)
|
||||
ab[i] = a[i];
|
||||
return Arrays.asList(ab);
|
||||
}
|
||||
}
|
82
modules/java/src/java/core+MatOfKeyPoint.java
Normal file
82
modules/java/src/java/core+MatOfKeyPoint.java
Normal file
@@ -0,0 +1,82 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.opencv.features2d.KeyPoint;
|
||||
|
||||
public class MatOfKeyPoint extends Mat {
|
||||
// 32FC7
|
||||
private static final int _depth = CvType.CV_32F;
|
||||
private static final int _channels = 7;
|
||||
|
||||
public MatOfKeyPoint() {
|
||||
super();
|
||||
}
|
||||
|
||||
public MatOfKeyPoint(long addr) {
|
||||
super(addr);
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfKeyPoint(Mat m) {
|
||||
super(m, Range.all());
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfKeyPoint(KeyPoint...a) {
|
||||
super();
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public void alloc(int elemNumber) {
|
||||
if(elemNumber>0)
|
||||
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||
}
|
||||
|
||||
public void fromArray(KeyPoint...a) {
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int num = a.length;
|
||||
alloc(num);
|
||||
float buff[] = new float[num * _channels];
|
||||
for(int i=0; i<num; i++) {
|
||||
KeyPoint kp = a[i];
|
||||
buff[_channels*i+0] = (float) kp.pt.x;
|
||||
buff[_channels*i+1] = (float) kp.pt.y;
|
||||
buff[_channels*i+2] = kp.size;
|
||||
buff[_channels*i+3] = kp.angle;
|
||||
buff[_channels*i+4] = kp.response;
|
||||
buff[_channels*i+5] = kp.octave;
|
||||
buff[_channels*i+6] = kp.class_id;
|
||||
}
|
||||
put(0, 0, buff); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public KeyPoint[] toArray() {
|
||||
int num = (int) total();
|
||||
KeyPoint[] a = new KeyPoint[num];
|
||||
if(num == 0)
|
||||
return a;
|
||||
float buff[] = new float[num * _channels];
|
||||
get(0, 0, buff); //TODO: check ret val!
|
||||
for(int i=0; i<num; i++)
|
||||
a[i] = new KeyPoint( buff[_channels*i+0], buff[_channels*i+1], buff[_channels*i+2], buff[_channels*i+3],
|
||||
buff[_channels*i+4], (int) buff[_channels*i+5], (int) buff[_channels*i+6] );
|
||||
return a;
|
||||
}
|
||||
|
||||
public void fromList(List<KeyPoint> lkp) {
|
||||
KeyPoint akp[] = lkp.toArray(null);
|
||||
fromArray(akp);
|
||||
}
|
||||
|
||||
public List<KeyPoint> toList() {
|
||||
KeyPoint[] akp = toArray();
|
||||
return Arrays.asList(akp);
|
||||
}
|
||||
}
|
74
modules/java/src/java/core+MatOfPoint.java
Normal file
74
modules/java/src/java/core+MatOfPoint.java
Normal file
@@ -0,0 +1,74 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MatOfPoint extends Mat {
|
||||
// 32SC2
|
||||
private static final int _depth = CvType.CV_32S;
|
||||
private static final int _channels = 2;
|
||||
|
||||
public MatOfPoint() {
|
||||
super();
|
||||
}
|
||||
|
||||
public MatOfPoint(long addr) {
|
||||
super(addr);
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfPoint(Mat m) {
|
||||
super(m, Range.all());
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfPoint(Point...a) {
|
||||
super();
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public void alloc(int elemNumber) {
|
||||
if(elemNumber>0)
|
||||
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||
}
|
||||
|
||||
public void fromArray(Point...a) {
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int num = a.length;
|
||||
alloc(num);
|
||||
int buff[] = new int[num * _channels];
|
||||
for(int i=0; i<num; i++) {
|
||||
Point p = a[i];
|
||||
buff[_channels*i+0] = (int) p.x;
|
||||
buff[_channels*i+1] = (int) p.y;
|
||||
}
|
||||
put(0, 0, buff); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public Point[] toArray() {
|
||||
int num = (int) total();
|
||||
Point[] ap = new Point[num];
|
||||
if(num == 0)
|
||||
return ap;
|
||||
int buff[] = new int[num * _channels];
|
||||
get(0, 0, buff); //TODO: check ret val!
|
||||
for(int i=0; i<num; i++)
|
||||
ap[i] = new Point(buff[i*_channels], buff[i*_channels+1]);
|
||||
return ap;
|
||||
}
|
||||
|
||||
public void fromList(List<Point> lp) {
|
||||
Point ap[] = lp.toArray(null);
|
||||
fromArray(ap);
|
||||
}
|
||||
|
||||
public List<Point> toList() {
|
||||
Point[] ap = toArray();
|
||||
return Arrays.asList(ap);
|
||||
}
|
||||
}
|
74
modules/java/src/java/core+MatOfPoint2f.java
Normal file
74
modules/java/src/java/core+MatOfPoint2f.java
Normal file
@@ -0,0 +1,74 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MatOfPoint2f extends Mat {
|
||||
// 32FC2
|
||||
private static final int _depth = CvType.CV_32F;
|
||||
private static final int _channels = 2;
|
||||
|
||||
public MatOfPoint2f() {
|
||||
super();
|
||||
}
|
||||
|
||||
public MatOfPoint2f(long addr) {
|
||||
super(addr);
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfPoint2f(Mat m) {
|
||||
super(m, Range.all());
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfPoint2f(Point...a) {
|
||||
super();
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public void alloc(int elemNumber) {
|
||||
if(elemNumber>0)
|
||||
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||
}
|
||||
|
||||
public void fromArray(Point...a) {
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int num = a.length;
|
||||
alloc(num);
|
||||
float buff[] = new float[num * _channels];
|
||||
for(int i=0; i<num; i++) {
|
||||
Point p = a[i];
|
||||
buff[_channels*i+0] = (float) p.x;
|
||||
buff[_channels*i+1] = (float) p.y;
|
||||
}
|
||||
put(0, 0, buff); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public Point[] toArray() {
|
||||
int num = (int) total();
|
||||
Point[] ap = new Point[num];
|
||||
if(num == 0)
|
||||
return ap;
|
||||
float buff[] = new float[num * _channels];
|
||||
get(0, 0, buff); //TODO: check ret val!
|
||||
for(int i=0; i<num; i++)
|
||||
ap[i] = new Point(buff[i*_channels], buff[i*_channels+1]);
|
||||
return ap;
|
||||
}
|
||||
|
||||
public void fromList(List<Point> lp) {
|
||||
Point ap[] = lp.toArray(null);
|
||||
fromArray(ap);
|
||||
}
|
||||
|
||||
public List<Point> toList() {
|
||||
Point[] ap = toArray();
|
||||
return Arrays.asList(ap);
|
||||
}
|
||||
}
|
75
modules/java/src/java/core+MatOfPoint3.java
Normal file
75
modules/java/src/java/core+MatOfPoint3.java
Normal file
@@ -0,0 +1,75 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MatOfPoint3 extends Mat {
|
||||
// 32SC3
|
||||
private static final int _depth = CvType.CV_32S;
|
||||
private static final int _channels = 3;
|
||||
|
||||
public MatOfPoint3() {
|
||||
super();
|
||||
}
|
||||
|
||||
public MatOfPoint3(long addr) {
|
||||
super(addr);
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfPoint3(Mat m) {
|
||||
super(m, Range.all());
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfPoint3(Point3...a) {
|
||||
super();
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public void alloc(int elemNumber) {
|
||||
if(elemNumber>0)
|
||||
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||
}
|
||||
|
||||
public void fromArray(Point3...a) {
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int num = a.length;
|
||||
alloc(num);
|
||||
int buff[] = new int[num * _channels];
|
||||
for(int i=0; i<num; i++) {
|
||||
Point3 p = a[i];
|
||||
buff[_channels*i+0] = (int) p.x;
|
||||
buff[_channels*i+1] = (int) p.y;
|
||||
buff[_channels*i+2] = (int) p.z;
|
||||
}
|
||||
put(0, 0, buff); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public Point3[] toArray() {
|
||||
int num = (int) total();
|
||||
Point3[] ap = new Point3[num];
|
||||
if(num == 0)
|
||||
return ap;
|
||||
int buff[] = new int[num * _channels];
|
||||
get(0, 0, buff); //TODO: check ret val!
|
||||
for(int i=0; i<num; i++)
|
||||
ap[i] = new Point3(buff[i*_channels], buff[i*_channels+1], buff[i*_channels+2]);
|
||||
return ap;
|
||||
}
|
||||
|
||||
public void fromList(List<Point3> lp) {
|
||||
Point3 ap[] = lp.toArray(null);
|
||||
fromArray(ap);
|
||||
}
|
||||
|
||||
public List<Point3> toList() {
|
||||
Point3[] ap = toArray();
|
||||
return Arrays.asList(ap);
|
||||
}
|
||||
}
|
75
modules/java/src/java/core+MatOfPoint3f.java
Normal file
75
modules/java/src/java/core+MatOfPoint3f.java
Normal file
@@ -0,0 +1,75 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class MatOfPoint3f extends Mat {
|
||||
// 32FC3
|
||||
private static final int _depth = CvType.CV_32F;
|
||||
private static final int _channels = 3;
|
||||
|
||||
public MatOfPoint3f() {
|
||||
super();
|
||||
}
|
||||
|
||||
public MatOfPoint3f(long addr) {
|
||||
super(addr);
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfPoint3f(Mat m) {
|
||||
super(m, Range.all());
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfPoint3f(Point3...a) {
|
||||
super();
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public void alloc(int elemNumber) {
|
||||
if(elemNumber>0)
|
||||
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||
}
|
||||
|
||||
public void fromArray(Point3...a) {
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int num = a.length;
|
||||
alloc(num);
|
||||
float buff[] = new float[num * _channels];
|
||||
for(int i=0; i<num; i++) {
|
||||
Point3 p = a[i];
|
||||
buff[_channels*i+0] = (float) p.x;
|
||||
buff[_channels*i+1] = (float) p.y;
|
||||
buff[_channels*i+2] = (float) p.z;
|
||||
}
|
||||
put(0, 0, buff); //TODO: check ret val!
|
||||
}
|
||||
|
||||
public Point3[] toArray() {
|
||||
int num = (int) total();
|
||||
Point3[] ap = new Point3[num];
|
||||
if(num == 0)
|
||||
return ap;
|
||||
float buff[] = new float[num * _channels];
|
||||
get(0, 0, buff); //TODO: check ret val!
|
||||
for(int i=0; i<num; i++)
|
||||
ap[i] = new Point3(buff[i*_channels], buff[i*_channels+1], buff[i*_channels+2]);
|
||||
return ap;
|
||||
}
|
||||
|
||||
public void fromList(List<Point3> lp) {
|
||||
Point3 ap[] = lp.toArray(null);
|
||||
fromArray(ap);
|
||||
}
|
||||
|
||||
public List<Point3> toList() {
|
||||
Point3[] ap = toArray();
|
||||
return Arrays.asList(ap);
|
||||
}
|
||||
}
|
77
modules/java/src/java/core+MatOfRect.java
Normal file
77
modules/java/src/java/core+MatOfRect.java
Normal file
@@ -0,0 +1,77 @@
|
||||
package org.opencv.core;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class MatOfRect extends Mat {
|
||||
// 32SC4
|
||||
private static final int _depth = CvType.CV_32S;
|
||||
private static final int _channels = 4;
|
||||
|
||||
public MatOfRect() {
|
||||
super();
|
||||
}
|
||||
|
||||
public MatOfRect(long addr) {
|
||||
super(addr);
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfRect(Mat m) {
|
||||
super(m, Range.all());
|
||||
if(checkVector(_channels, _depth) < 0 )
|
||||
throw new IllegalArgumentException("Incomatible Mat");
|
||||
//FIXME: do we need release() here?
|
||||
}
|
||||
|
||||
public MatOfRect(Rect...a) {
|
||||
super();
|
||||
fromArray(a);
|
||||
}
|
||||
|
||||
public void alloc(int elemNumber) {
|
||||
if(elemNumber>0)
|
||||
super.create(elemNumber, 1, CvType.makeType(_depth, _channels));
|
||||
}
|
||||
|
||||
public void fromArray(Rect...a) {
|
||||
if(a==null || a.length==0)
|
||||
return;
|
||||
int num = a.length;
|
||||
alloc(num);
|
||||
int buff[] = new int[num * _channels];
|
||||
for(int i=0; i<num; i++) {
|
||||
Rect r = a[i];
|
||||
buff[_channels*i+0] = (int) r.x;
|
||||
buff[_channels*i+1] = (int) r.y;
|
||||
buff[_channels*i+2] = (int) r.width;
|
||||
buff[_channels*i+3] = (int) r.height;
|
||||
}
|
||||
put(0, 0, buff); //TODO: check ret val!
|
||||
}
|
||||
|
||||
|
||||
public Rect[] toArray() {
|
||||
int num = (int) total();
|
||||
Rect[] a = new Rect[num];
|
||||
if(num == 0)
|
||||
return a;
|
||||
int buff[] = new int[num * _channels];
|
||||
get(0, 0, buff); //TODO: check ret val!
|
||||
for(int i=0; i<num; i++)
|
||||
a[i] = new Rect(buff[i*_channels], buff[i*_channels+1], buff[i*_channels+2], buff[i*_channels+3]);
|
||||
return a;
|
||||
}
|
||||
public void fromList(List<Rect> lr) {
|
||||
Rect ap[] = lr.toArray(null);
|
||||
fromArray(ap);
|
||||
}
|
||||
|
||||
public List<Rect> toList() {
|
||||
Rect[] ar = toArray();
|
||||
return Arrays.asList(ar);
|
||||
}
|
||||
}
|
@@ -4,15 +4,15 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.opencv.core.CvType;
|
||||
import org.opencv.core.CvVectorPoint2f;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.MatOfByte;
|
||||
import org.opencv.core.MatOfDMatch;
|
||||
import org.opencv.core.MatOfKeyPoint;
|
||||
import org.opencv.core.MatOfPoint;
|
||||
import org.opencv.core.MatOfPoint2f;
|
||||
import org.opencv.core.Point;
|
||||
import org.opencv.core.Point3;
|
||||
import org.opencv.core.Rect;
|
||||
import org.opencv.core.CvVectorByte;
|
||||
import org.opencv.core.CvVectorDMatch;
|
||||
import org.opencv.core.CvVectorKeyPoint;
|
||||
import org.opencv.core.CvVectorPoint;
|
||||
import org.opencv.features2d.DMatch;
|
||||
import org.opencv.features2d.KeyPoint;
|
||||
|
||||
@@ -475,11 +475,11 @@ public class Converters {
|
||||
}
|
||||
|
||||
// vector_vector_Point
|
||||
public static Mat vector_vector_Point_to_Mat(List<CvVectorPoint> pts, List<Mat> mats) {
|
||||
public static Mat vector_vector_Point_to_Mat(List<MatOfPoint> pts, List<Mat> mats) {
|
||||
Mat res;
|
||||
int lCount = (pts != null) ? pts.size() : 0;
|
||||
if (lCount > 0) {
|
||||
for (CvVectorPoint vpt : pts)
|
||||
for (MatOfPoint vpt : pts)
|
||||
mats.add(vpt);
|
||||
res = vector_Mat_to_Mat(mats);
|
||||
} else {
|
||||
@@ -488,7 +488,7 @@ public class Converters {
|
||||
return res;
|
||||
}
|
||||
|
||||
public static void Mat_to_vector_vector_Point(Mat m, List<CvVectorPoint> pts) {
|
||||
public static void Mat_to_vector_vector_Point(Mat m, List<MatOfPoint> pts) {
|
||||
if (pts == null)
|
||||
throw new java.lang.IllegalArgumentException("Output List can't be null");
|
||||
|
||||
@@ -498,13 +498,13 @@ public class Converters {
|
||||
List<Mat> mats = new ArrayList<Mat>(m.rows());
|
||||
Mat_to_vector_Mat(m, mats);
|
||||
for (Mat mi : mats) {
|
||||
CvVectorPoint pt = new CvVectorPoint(mi);
|
||||
MatOfPoint pt = new MatOfPoint(mi);
|
||||
pts.add(pt);
|
||||
}
|
||||
}
|
||||
|
||||
// vector_vector_Point2f
|
||||
public static void Mat_to_vector_vector_Point2f(Mat m, List<CvVectorPoint2f> pts) {
|
||||
public static void Mat_to_vector_vector_Point2f(Mat m, List<MatOfPoint2f> pts) {
|
||||
if (pts == null)
|
||||
throw new java.lang.IllegalArgumentException("Output List can't be null");
|
||||
|
||||
@@ -514,17 +514,17 @@ public class Converters {
|
||||
List<Mat> mats = new ArrayList<Mat>(m.rows());
|
||||
Mat_to_vector_Mat(m, mats);
|
||||
for (Mat mi : mats) {
|
||||
CvVectorPoint2f pt = new CvVectorPoint2f(mi);
|
||||
MatOfPoint2f pt = new MatOfPoint2f(mi);
|
||||
pts.add(pt);
|
||||
}
|
||||
}
|
||||
|
||||
// vector_vector_KeyPoint
|
||||
public static Mat vector_vector_KeyPoint_to_Mat(List<CvVectorKeyPoint> kps, List<Mat> mats) {
|
||||
public static Mat vector_vector_KeyPoint_to_Mat(List<MatOfKeyPoint> kps, List<Mat> mats) {
|
||||
Mat res;
|
||||
int lCount = (kps != null) ? kps.size() : 0;
|
||||
if (lCount > 0) {
|
||||
for (CvVectorKeyPoint vkp : kps)
|
||||
for (MatOfKeyPoint vkp : kps)
|
||||
mats.add(vkp);
|
||||
res = vector_Mat_to_Mat(mats);
|
||||
} else {
|
||||
@@ -533,7 +533,7 @@ public class Converters {
|
||||
return res;
|
||||
}
|
||||
|
||||
public static void Mat_to_vector_vector_KeyPoint(Mat m, List<CvVectorKeyPoint> kps) {
|
||||
public static void Mat_to_vector_vector_KeyPoint(Mat m, List<MatOfKeyPoint> kps) {
|
||||
if (kps == null)
|
||||
throw new java.lang.IllegalArgumentException("Output List can't be null");
|
||||
|
||||
@@ -543,7 +543,7 @@ public class Converters {
|
||||
List<Mat> mats = new ArrayList<Mat>(m.rows());
|
||||
Mat_to_vector_Mat(m, mats);
|
||||
for (Mat mi : mats) {
|
||||
CvVectorKeyPoint vkp = new CvVectorKeyPoint(mi);
|
||||
MatOfKeyPoint vkp = new MatOfKeyPoint(mi);
|
||||
kps.add(vkp);
|
||||
}
|
||||
}
|
||||
@@ -618,11 +618,11 @@ public class Converters {
|
||||
}
|
||||
|
||||
// vector_vector_DMatch
|
||||
public static Mat vector_vector_DMatch_to_Mat(List<CvVectorDMatch> lvdm, List<Mat> mats) {
|
||||
public static Mat vector_vector_DMatch_to_Mat(List<MatOfDMatch> lvdm, List<Mat> mats) {
|
||||
Mat res;
|
||||
int lCount = (lvdm != null) ? lvdm.size() : 0;
|
||||
if (lCount > 0) {
|
||||
for (CvVectorDMatch vdm : lvdm)
|
||||
for (MatOfDMatch vdm : lvdm)
|
||||
mats.add(vdm);
|
||||
res = vector_Mat_to_Mat(mats);
|
||||
} else {
|
||||
@@ -631,7 +631,7 @@ public class Converters {
|
||||
return res;
|
||||
}
|
||||
|
||||
public static void Mat_to_vector_vector_DMatch(Mat m, List<CvVectorDMatch> lvdm) {
|
||||
public static void Mat_to_vector_vector_DMatch(Mat m, List<MatOfDMatch> lvdm) {
|
||||
if (lvdm == null)
|
||||
throw new java.lang.IllegalArgumentException("Output List can't be null");
|
||||
|
||||
@@ -642,17 +642,17 @@ public class Converters {
|
||||
Mat_to_vector_Mat(m, mats);
|
||||
lvdm.clear();
|
||||
for (Mat mi : mats) {
|
||||
CvVectorDMatch vdm = new CvVectorDMatch(mi);
|
||||
MatOfDMatch vdm = new MatOfDMatch(mi);
|
||||
lvdm.add(vdm);
|
||||
}
|
||||
}
|
||||
|
||||
// vector_vector_char
|
||||
public static Mat vector_vector_char_to_Mat(List<CvVectorByte> lvb, List<Mat> mats) {
|
||||
public static Mat vector_vector_char_to_Mat(List<MatOfByte> lvb, List<Mat> mats) {
|
||||
Mat res;
|
||||
int lCount = (lvb != null) ? lvb.size() : 0;
|
||||
if (lCount > 0) {
|
||||
for (CvVectorByte vb : lvb)
|
||||
for (MatOfByte vb : lvb)
|
||||
mats.add(vb);
|
||||
res = vector_Mat_to_Mat(mats);
|
||||
} else {
|
||||
|
Reference in New Issue
Block a user