Added setters to Java API
This commit is contained in:
parent
c1dab7bf6e
commit
8625b5689d
@ -15,12 +15,19 @@ public class Point {
|
||||
}
|
||||
|
||||
public Point(double[] vals) {
|
||||
this();
|
||||
if(vals!=null) {
|
||||
x = vals.length>0 ? vals[0] : 0;
|
||||
y = vals.length>1 ? vals[1] : 0;
|
||||
}
|
||||
this();
|
||||
set(vals);
|
||||
}
|
||||
public void set(double[] vals) {
|
||||
if(vals!=null) {
|
||||
x = vals.length>0 ? vals[0] : 0;
|
||||
y = vals.length>1 ? vals[1] : 0;
|
||||
} else {
|
||||
x = 0;
|
||||
y = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Point clone() {
|
||||
return new Point(x, y);
|
||||
|
@ -22,12 +22,19 @@ public class Point3 {
|
||||
}
|
||||
|
||||
public Point3(double[] vals) {
|
||||
this();
|
||||
if(vals!=null) {
|
||||
x = vals.length>0 ? vals[0] : 0;
|
||||
y = vals.length>1 ? vals[1] : 0;
|
||||
z = vals.length>2 ? vals[2] : 0;
|
||||
}
|
||||
this();
|
||||
set(vals);
|
||||
}
|
||||
public void set(double[] vals) {
|
||||
if(vals!=null) {
|
||||
x = vals.length>0 ? vals[0] : 0;
|
||||
y = vals.length>1 ? vals[1] : 0;
|
||||
z = vals.length>2 ? vals[2] : 0;
|
||||
} else {
|
||||
x = 0;
|
||||
y = 0;
|
||||
z = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public Point3 clone() {
|
||||
|
@ -2,67 +2,81 @@ package org.opencv;
|
||||
|
||||
//javadoc:Range
|
||||
public class Range {
|
||||
|
||||
public int start, end;
|
||||
|
||||
public int start, end;
|
||||
|
||||
public Range(int s, int e) {
|
||||
this.start = s;
|
||||
this.end = e;
|
||||
public Range(int s, int e) {
|
||||
this.start = s;
|
||||
this.end = e;
|
||||
}
|
||||
|
||||
public Range() {
|
||||
this(0, 0);
|
||||
}
|
||||
public Range(double[] vals) {
|
||||
this();
|
||||
set(vals);
|
||||
}
|
||||
public void set(double[] vals) {
|
||||
if(vals!=null) {
|
||||
start = vals.length>0 ? (int)vals[0] : 0;
|
||||
end = vals.length>1 ? (int)vals[1] : 0;
|
||||
} else {
|
||||
start = 0;
|
||||
end = 0;
|
||||
}
|
||||
|
||||
public Range() {
|
||||
this(0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return end-start;
|
||||
}
|
||||
public int size() {
|
||||
return end-start;
|
||||
}
|
||||
|
||||
public boolean empty() {
|
||||
return start==end;
|
||||
}
|
||||
public boolean empty() {
|
||||
return start==end;
|
||||
}
|
||||
|
||||
public static Range all() {
|
||||
return new Range(Integer.MIN_VALUE , Integer.MAX_VALUE);
|
||||
}
|
||||
public static Range all() {
|
||||
return new Range(Integer.MIN_VALUE , Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
public Range intersection(Range r1) {
|
||||
Range r = new Range(Math.max(r1.start, this.start), Math.min(r1.end, this.end));
|
||||
r.end = Math.max(r.end, r.start);
|
||||
return r;
|
||||
}
|
||||
public Range shift(int delta) {
|
||||
return new Range(start+delta, end+delta);
|
||||
}
|
||||
|
||||
|
||||
public Range clone() {
|
||||
return new Range(start, end);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
long temp;
|
||||
temp = Double.doubleToLongBits(start);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(end);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
return result;
|
||||
}
|
||||
public Range intersection(Range r1) {
|
||||
Range r = new Range(Math.max(r1.start, this.start), Math.min(r1.end, this.end));
|
||||
r.end = Math.max(r.end, r.start);
|
||||
return r;
|
||||
}
|
||||
public Range shift(int delta) {
|
||||
return new Range(start+delta, end+delta);
|
||||
}
|
||||
|
||||
|
||||
public Range clone() {
|
||||
return new Range(start, end);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
long temp;
|
||||
temp = Double.doubleToLongBits(start);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
temp = Double.doubleToLongBits(end);
|
||||
result = prime * result + (int) (temp ^ (temp >>> 32));
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof Range)) return false;
|
||||
Range it = (Range) obj;
|
||||
return start == it.start && end == it.end;
|
||||
}
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof Range)) return false;
|
||||
Range it = (Range) obj;
|
||||
return start == it.start && end == it.end;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (this == null) return "null";
|
||||
return "[" + start + ", " + end + ")";
|
||||
}
|
||||
@Override
|
||||
public String toString() {
|
||||
if (this == null) return "null";
|
||||
return "[" + start + ", " + end + ")";
|
||||
}
|
||||
}
|
||||
|
@ -28,13 +28,21 @@ public class Rect {
|
||||
}
|
||||
|
||||
public Rect(double[] vals) {
|
||||
this();
|
||||
if(vals!=null) {
|
||||
x = vals.length>0 ? (int)vals[0] : 0;
|
||||
y = vals.length>1 ? (int)vals[1] : 0;
|
||||
width = vals.length>2 ? (int)vals[2] : 0;
|
||||
height = vals.length>3 ? (int)vals[3] : 0;
|
||||
}
|
||||
this();
|
||||
set(vals);
|
||||
}
|
||||
public void set(double[] vals) {
|
||||
if(vals!=null) {
|
||||
x = vals.length>0 ? (int)vals[0] : 0;
|
||||
y = vals.length>1 ? (int)vals[1] : 0;
|
||||
width = vals.length>2 ? (int)vals[2] : 0;
|
||||
height = vals.length>3 ? (int)vals[3] : 0;
|
||||
} else {
|
||||
x = 0;
|
||||
y = 0;
|
||||
width = 0;
|
||||
height = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public Rect clone() {
|
||||
|
@ -18,14 +18,23 @@ public class RotatedRect {
|
||||
}
|
||||
|
||||
public RotatedRect(double[] vals) {
|
||||
this();
|
||||
if(vals!=null) {
|
||||
center.x = vals.length>0 ? (int)vals[0] : 0;
|
||||
center.x = vals.length>1 ? (int)vals[1] : 0;
|
||||
size.width = vals.length>2 ? (int)vals[2] : 0;
|
||||
size.height = vals.length>3 ? (int)vals[3] : 0;
|
||||
angle = vals.length>4 ? (int)vals[4] : 0;
|
||||
}
|
||||
this();
|
||||
set(vals);
|
||||
}
|
||||
public void set(double[] vals) {
|
||||
if(vals!=null) {
|
||||
center.x = vals.length>0 ? (int)vals[0] : 0;
|
||||
center.x = vals.length>1 ? (int)vals[1] : 0;
|
||||
size.width = vals.length>2 ? (int)vals[2] : 0;
|
||||
size.height = vals.length>3 ? (int)vals[3] : 0;
|
||||
angle = vals.length>4 ? (int)vals[4] : 0;
|
||||
} else {
|
||||
center.x = 0;
|
||||
center.x = 0;
|
||||
size.width = 0;
|
||||
size.height = 0;
|
||||
angle = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void points(Point pt[])
|
||||
|
@ -25,12 +25,20 @@ public class Scalar {
|
||||
}
|
||||
|
||||
public Scalar(double[] vals) {
|
||||
if(vals!=null) {
|
||||
v0 = vals.length>0 ? (int)vals[0] : 0;
|
||||
v1 = vals.length>1 ? (int)vals[1] : 0;
|
||||
v2 = vals.length>2 ? (int)vals[2] : 0;
|
||||
v3 = vals.length>3 ? (int)vals[3] : 0;
|
||||
}
|
||||
set(vals);
|
||||
}
|
||||
public void set(double[] vals) {
|
||||
if(vals!=null) {
|
||||
v0 = vals.length>0 ? (int)vals[0] : 0;
|
||||
v1 = vals.length>1 ? (int)vals[1] : 0;
|
||||
v2 = vals.length>2 ? (int)vals[2] : 0;
|
||||
v3 = vals.length>3 ? (int)vals[3] : 0;
|
||||
} else {
|
||||
v0 = 0;
|
||||
v1 = 0;
|
||||
v2 = 0;
|
||||
v3 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static Scalar all(double v) {
|
||||
|
@ -20,11 +20,17 @@ public class Size {
|
||||
}
|
||||
|
||||
public Size(double[] vals) {
|
||||
this();
|
||||
if(vals!=null) {
|
||||
width = vals.length>0 ? vals[0] : 0;
|
||||
height = vals.length>1 ? vals[1] : 0;
|
||||
}
|
||||
this();
|
||||
set(vals);
|
||||
}
|
||||
public void set(double[] vals) {
|
||||
if(vals!=null) {
|
||||
width = vals.length>0 ? vals[0] : 0;
|
||||
height = vals.length>1 ? vals[1] : 0;
|
||||
} else {
|
||||
width = 0;
|
||||
height = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public double area() {
|
||||
|
@ -18,12 +18,19 @@ public class TermCriteria {
|
||||
}
|
||||
|
||||
public TermCriteria(double[] vals) {
|
||||
this();
|
||||
if(vals!=null) {
|
||||
type = vals.length>0 ? (int)vals[0] : 0;
|
||||
maxCount = vals.length>1 ? (int)vals[1] : 0;
|
||||
epsilon = vals.length>2 ? (double)vals[2] : 0;
|
||||
}
|
||||
this();
|
||||
set(vals);
|
||||
}
|
||||
public void set(double[] vals) {
|
||||
if(vals!=null) {
|
||||
type = vals.length>0 ? (int)vals[0] : 0;
|
||||
maxCount = vals.length>1 ? (int)vals[1] : 0;
|
||||
epsilon = vals.length>2 ? (double)vals[2] : 0;
|
||||
} else {
|
||||
type = 0;
|
||||
maxCount = 0;
|
||||
epsilon = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public TermCriteria clone() {
|
||||
|
Loading…
Reference in New Issue
Block a user