Added to Java API classes Range and CvSlice.

pull/13383/head
Leonid Beynenson 14 years ago
parent a69bd80b99
commit d60349b1fc
  1. 3
      modules/java/android_test/src/org/opencv/test/highgui/VideoCaptureTest.java
  2. 6
      modules/java/gen_java.py
  3. 68
      modules/java/src/java/Range.java

@ -4,7 +4,6 @@ import org.opencv.highgui;
import org.opencv.highgui.VideoCapture;
import org.opencv.test.OpenCVTestCase;
import org.opencv.test.OpenCVTestRunner;
public class VideoCaptureTest extends OpenCVTestCase {
@ -102,7 +101,7 @@ public class VideoCaptureTest extends OpenCVTestCase {
capture.release();
assertTrue(isSucceed);
assertFalse(dst.empty());
OpenCVTestRunner.Log(dst.toString());
//OpenCVTestRunner.Log(dst.toString());
assertEquals(1, dst.channels());
}

@ -58,6 +58,12 @@ type_dict = {
"Scalar" : { "j_type" : "Scalar", "jn_args" : (("double", ".v0"), ("double", ".v1"), ("double", ".v2"), ("double", ".v3")),
"jni_var" : "cv::Scalar %(n)s(%(n)s_v0, %(n)s_v1, %(n)s_v2, %(n)s_v3)",
"suffix" : "DDDD"},
"Range" : { "j_type" : "Range", "jn_args" : (("int", ".start"), ("int", ".end")),
"jni_var" : "cv::Range %(n)s(%(n)s_start, %(n)s_end)",
"suffix" : "II"},
"CvSlice" : { "j_type" : "Range", "jn_args" : (("int", ".start"), ("int", ".end")),
"jni_var" : "cv::Range %(n)s(%(n)s_start, %(n)s_end)",
"suffix" : "II"},
"string" : { "j_type" : "java.lang.String", "jn_type" : "java.lang.String",
"jni_type" : "jstring", "jni_name" : "n_%(n)s",
"jni_var" : 'const char* utf_%(n)s = env->GetStringUTFChars(%(n)s, 0); std::string n_%(n)s( utf_%(n)s ? utf_%(n)s : "" ); env->ReleaseStringUTFChars(%(n)s, utf_%(n)s)',

@ -0,0 +1,68 @@
package org.opencv;
//javadoc:Range
public class Range {
public int start, end;
public Range(int s, int e) {
this.start = s;
this.end = e;
}
public Range() {
this(0, 0);
}
public int size() {
return end-start;
}
public boolean empty() {
return start==end;
}
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;
}
@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 + ")";
}
}
Loading…
Cancel
Save