Added setters to Java API
This commit is contained in:
parent
c1dab7bf6e
commit
8625b5689d
@ -16,12 +16,19 @@ public class Point {
|
||||
|
||||
public Point(double[] vals) {
|
||||
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);
|
||||
}
|
||||
|
@ -23,10 +23,17 @@ public class Point3 {
|
||||
|
||||
public Point3(double[] vals) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -13,6 +13,20 @@ public class Range {
|
||||
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 int size() {
|
||||
return end-start;
|
||||
|
@ -29,11 +29,19 @@ public class Rect {
|
||||
|
||||
public Rect(double[] vals) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,12 +19,21 @@ public class RotatedRect {
|
||||
|
||||
public RotatedRect(double[] vals) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,11 +25,19 @@ public class Scalar {
|
||||
}
|
||||
|
||||
public Scalar(double[] vals) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,9 +21,15 @@ public class Size {
|
||||
|
||||
public Size(double[] vals) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,10 +19,17 @@ public class TermCriteria {
|
||||
|
||||
public TermCriteria(double[] vals) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user