Commit 1991440c authored by Andrey Kamaev's avatar Andrey Kamaev

Java API:

* fixed manually ported classes;
* added vector<vector<Point>> support;
* changed argument types for 3 functions;
* finished tests for org.opencv.core.Core class.
parent 6d907581
...@@ -23,15 +23,15 @@ import org.opencv.highgui.Highgui; ...@@ -23,15 +23,15 @@ import org.opencv.highgui.Highgui;
public class OpenCVTestCase extends TestCase { public class OpenCVTestCase extends TestCase {
protected static int matSize = 10; protected static final int matSize = 10;
protected static double EPS = 0.001; protected static final double EPS = 0.001;
protected static double weakEPS = 0.5; protected static final double weakEPS = 0.5;
protected static Mat dst; protected Mat dst;
protected static Mat truth; protected Mat truth;
protected static Scalar colorBlack; protected Scalar colorBlack;
protected static Scalar colorWhite; protected Scalar colorWhite;
// Naming notation: <channels info>_[depth]_[dimensions]_value // Naming notation: <channels info>_[depth]_[dimensions]_value
// examples: gray0 - single channel 8U 2d Mat filled with 0 // examples: gray0 - single channel 8U 2d Mat filled with 0
...@@ -42,42 +42,42 @@ public class OpenCVTestCase extends TestCase { ...@@ -42,42 +42,42 @@ public class OpenCVTestCase extends TestCase {
// - rename matrices // - rename matrices
// - create methods gray0() and create src1 explicitly // - create methods gray0() and create src1 explicitly
// - create some masks // - create some masks
// - use truth member everywhere // - use truth member everywhere - remove truth from base class - each test fixture should use own truth filed
protected static Mat gray0; protected Mat gray0;
protected static Mat gray1; protected Mat gray1;
protected static Mat gray2; protected Mat gray2;
protected static Mat gray3; protected Mat gray3;
protected static Mat gray9; protected Mat gray9;
protected static Mat gray127; protected Mat gray127;
protected static Mat gray128; protected Mat gray128;
protected static Mat gray255; protected Mat gray255;
protected static Mat grayRnd; protected Mat grayRnd;
protected static Mat gray_16u_256; protected Mat gray_16u_256;
protected static Mat gray_16s_1024; protected Mat gray_16s_1024;
protected static Mat gray0_32f; protected Mat gray0_32f;
protected static Mat gray1_32f; protected Mat gray1_32f;
protected static Mat gray3_32f; protected Mat gray3_32f;
protected static Mat gray9_32f; protected Mat gray9_32f;
protected static Mat gray255_32f; protected Mat gray255_32f;
protected static Mat grayE_32f; protected Mat grayE_32f;
protected static Mat grayRnd_32f; protected Mat grayRnd_32f;
protected static Mat gray0_32f_1d; protected Mat gray0_32f_1d;
protected static Mat gray0_64f; protected Mat gray0_64f;
protected static Mat gray0_64f_1d; protected Mat gray0_64f_1d;
protected static Mat rgba0; protected Mat rgba0;
protected static Mat rgba128; protected Mat rgba128;
protected static Mat rgbLena; protected Mat rgbLena;
protected static Mat grayChess; protected Mat grayChess;
protected static Mat v1; protected Mat v1;
protected static Mat v2; protected Mat v2;
@Override @Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
......
...@@ -12,8 +12,7 @@ import java.io.File; ...@@ -12,8 +12,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
/** /**
* This only class is Android specific. The original idea about test order * This only class is Android specific.
* randomization is from marek.defecinski blog.
* *
* @see <a href="http://opencv.itseez.com">OpenCV</a> * @see <a href="http://opencv.itseez.com">OpenCV</a>
*/ */
...@@ -49,7 +48,7 @@ public class OpenCVTestRunner extends InstrumentationTestRunner { ...@@ -49,7 +48,7 @@ public class OpenCVTestRunner extends InstrumentationTestRunner {
} }
static public void Log(Mat m) { static public void Log(Mat m) {
Log.e(TAG, m + "\n" + m.dump()); Log.e(TAG, m + "\n " + m.dump());
} }
@Override @Override
...@@ -59,6 +58,9 @@ public class OpenCVTestRunner extends InstrumentationTestRunner { ...@@ -59,6 +58,9 @@ public class OpenCVTestRunner extends InstrumentationTestRunner {
CHESS_PATH = Utils.ExportResource(context, R.drawable.chessboard); CHESS_PATH = Utils.ExportResource(context, R.drawable.chessboard);
LBPCASCADE_FRONTALFACE_PATH = Utils.ExportResource(context, R.raw.lbpcascade_frontalface); LBPCASCADE_FRONTALFACE_PATH = Utils.ExportResource(context, R.raw.lbpcascade_frontalface);
/*
* The original idea about test order randomization is from marek.defecinski blog.
*/
// List<TestCase> testCases = androidTestRunner.getTestCases(); // List<TestCase> testCases = androidTestRunner.getTestCases();
// Collections.shuffle(testCases); //shuffle the tests order // Collections.shuffle(testCases); //shuffle the tests order
......
...@@ -96,5 +96,12 @@ public class Point3Test extends OpenCVTestCase { ...@@ -96,5 +96,12 @@ public class Point3Test extends OpenCVTestCase {
assertEquals(6., p1.y); assertEquals(6., p1.y);
assertEquals(10., p1.z); assertEquals(10., p1.z);
} }
public void testToString() {
String actual = p1.toString();
String expected = "{2.0, 2.0, 2.0}";
assertEquals(expected, actual);
}
} }
...@@ -165,5 +165,11 @@ public class RotatedRectTest extends OpenCVTestCase { ...@@ -165,5 +165,11 @@ public class RotatedRectTest extends OpenCVTestCase {
public void testSet() { public void testSet() {
fail("Not yet implemented"); fail("Not yet implemented");
} }
public void testToString() {
String actual = new RotatedRect(new Point(1,2), new Size(10,12), 4.5).toString();
String expected = "{ {1.0, 2.0} 10x12 * 4.5 }";
assertEquals(expected, actual);
}
} }
...@@ -100,5 +100,11 @@ public class ScalarTest extends OpenCVTestCase { ...@@ -100,5 +100,11 @@ public class ScalarTest extends OpenCVTestCase {
s1.set(vals); s1.set(vals);
assertEquals(s2, s1); assertEquals(s2, s1);
} }
public void testToString() {
String actual = s2.toString();
String expected = "[1.0, 1.0, 1.0, 1.0]";
assertEquals(expected, actual);
}
} }
...@@ -83,5 +83,11 @@ public class SizeTest extends OpenCVTestCase { ...@@ -83,5 +83,11 @@ public class SizeTest extends OpenCVTestCase {
assertEquals(2.0, sz1.width); assertEquals(2.0, sz1.width);
assertEquals(4.0, sz1.height); assertEquals(4.0, sz1.height);
} }
public void testToString() {
String actual = sz1.toString();
String expected = "10x10";
assertEquals(expected, actual);
}
} }
...@@ -16,7 +16,7 @@ public class ConvertersTest extends OpenCVTestCase { ...@@ -16,7 +16,7 @@ public class ConvertersTest extends OpenCVTestCase {
public void testMat_to_vector_char() { public void testMat_to_vector_char() {
fail("Not yet implemented"); fail("Not yet implemented");
} }
public void testMat_to_vector_DMatch() { public void testMat_to_vector_DMatch() {
fail("Not yet implemented"); fail("Not yet implemented");
} }
...@@ -291,4 +291,8 @@ public class ConvertersTest extends OpenCVTestCase { ...@@ -291,4 +291,8 @@ public class ConvertersTest extends OpenCVTestCase {
fail("Not yet implemented"); fail("Not yet implemented");
} }
public void testVector_vector_Point_to_Mat() {
fail("Not yet implemented");
}
} }
...@@ -118,7 +118,13 @@ missing_consts = \ ...@@ -118,7 +118,13 @@ missing_consts = \
('CV_32S', 4 ), ('CV_32S', 4 ),
('CV_32F', 5 ), ('CV_64F', 6 ), ('CV_32F', 5 ), ('CV_64F', 6 ),
('CV_USRTYPE1', 7 ), ('CV_USRTYPE1', 7 ),
) # private ), # private
'public' :
(
('SVD_MODIFY_A', 1), ('SVD_NO_UV', 2), ('SVD_FULL_UV', 4),
('FILLED', -1),
('LINE_AA', 16), ('LINE_8', 8), ('LINE_4', 4),
) #public
}, # Core }, # Core
"Imgproc": "Imgproc":
...@@ -184,25 +190,26 @@ type_dict = { ...@@ -184,25 +190,26 @@ type_dict = {
# "complex" : { j_type : "?", jn_args : (("", ""),), jn_name : "", jni_var : "", jni_name : "", "suffix" : "?" }, # "complex" : { j_type : "?", jn_args : (("", ""),), jn_name : "", jni_var : "", jni_name : "", "suffix" : "?" },
"vector_Point" : { "j_type" : "List<Point>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Point> %(n)s", "suffix" : "J" }, "vector_Point" : { "j_type" : "List<Point>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Point> %(n)s", "suffix" : "J" },
"vector_Point2f": { "j_type" : "List<Point>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Point2f> %(n)s", "suffix" : "J" }, "vector_Point2f" : { "j_type" : "List<Point>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Point2f> %(n)s", "suffix" : "J" },
"vector_Point2d": { "j_type" : "List<Point>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Point2d> %(n)s", "suffix" : "J" }, "vector_Point2d" : { "j_type" : "List<Point>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Point2d> %(n)s", "suffix" : "J" },
"vector_Point3i": { "j_type" : "List<Point3>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Point3i> %(n)s", "suffix" : "J" }, "vector_Point3i" : { "j_type" : "List<Point3>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Point3i> %(n)s", "suffix" : "J" },
"vector_Point3f": { "j_type" : "List<Point3>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Point3f> %(n)s", "suffix" : "J" }, "vector_Point3f" : { "j_type" : "List<Point3>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Point3f> %(n)s", "suffix" : "J" },
"vector_Point3d": { "j_type" : "List<Point3>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Point3d> %(n)s", "suffix" : "J" }, "vector_Point3d" : { "j_type" : "List<Point3>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Point3d> %(n)s", "suffix" : "J" },
"vector_Mat" : { "j_type" : "List<Mat>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Mat> %(n)s", "suffix" : "J" }, "vector_Mat" : { "j_type" : "List<Mat>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Mat> %(n)s", "suffix" : "J" },
"vector_KeyPoint":{ "j_type" : "List<KeyPoint>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<KeyPoint> %(n)s", "suffix" : "J" }, "vector_KeyPoint" : { "j_type" : "List<KeyPoint>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<KeyPoint> %(n)s", "suffix" : "J" },
"vector_DMatch" : { "j_type" : "List<DMatch>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<DMatch> %(n)s", "suffix" : "J" }, "vector_DMatch" : { "j_type" : "List<DMatch>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<DMatch> %(n)s", "suffix" : "J" },
"vector_Rect" : { "j_type" : "List<Rect>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Rect> %(n)s", "suffix" : "J" }, "vector_Rect" : { "j_type" : "List<Rect>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<Rect> %(n)s", "suffix" : "J" },
"vector_uchar" : { "j_type" : "List<Byte>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<uchar> %(n)s", "suffix" : "J" }, "vector_uchar" : { "j_type" : "List<Byte>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<uchar> %(n)s", "suffix" : "J" },
"vector_char" : { "j_type" : "List<Byte>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<char> %(n)s", "suffix" : "J" }, "vector_char" : { "j_type" : "List<Byte>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<char> %(n)s", "suffix" : "J" },
"vector_int" : { "j_type" : "List<Integer>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<int> %(n)s", "suffix" : "J" }, "vector_int" : { "j_type" : "List<Integer>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<int> %(n)s", "suffix" : "J" },
"vector_float" : { "j_type" : "List<Float>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<float> %(n)s", "suffix" : "J" }, "vector_float" : { "j_type" : "List<Float>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<float> %(n)s", "suffix" : "J" },
"vector_double" : { "j_type" : "List<Double>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<double> %(n)s", "suffix" : "J" }, "vector_double" : { "j_type" : "List<Double>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector<double> %(n)s", "suffix" : "J" },
"vector_vector_KeyPoint":{ "j_type" : "List<List<KeyPoint>>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector< vector<KeyPoint> > %(n)s" }, "vector_vector_KeyPoint": { "j_type" : "List<List<KeyPoint>>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector< vector<KeyPoint> > %(n)s" },
"vector_vector_DMatch" : { "j_type" : "List<List<DMatch>>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector< vector<DMatch> > %(n)s" }, "vector_vector_DMatch" : { "j_type" : "List<List<DMatch>>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector< vector<DMatch> > %(n)s" },
"vector_vector_char" : { "j_type" : "List<List<Byte>>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector< vector<char> > %(n)s" }, "vector_vector_char" : { "j_type" : "List<List<Byte>>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector< vector<char> > %(n)s" },
"vector_vector_Point" : { "j_type" : "List<List<Point>>", "jn_type" : "long", "jni_type" : "jlong", "jni_var" : "vector< vector<Point> > %(n)s" },
"Mat" : { "j_type" : "Mat", "jn_type" : "long", "jn_args" : (("__int64", ".nativeObj"),), "Mat" : { "j_type" : "Mat", "jn_type" : "long", "jn_args" : (("__int64", ".nativeObj"),),
"jni_var" : "Mat& %(n)s = *((Mat*)%(n)s_nativeObj)", "jni_var" : "Mat& %(n)s = *((Mat*)%(n)s_nativeObj)",
...@@ -678,6 +685,9 @@ func_arg_fix = { ...@@ -678,6 +685,9 @@ func_arg_fix = {
'calcOpticalFlowPyrLK' : { 'prevPts' : 'vector_Point2f', 'nextPts' : 'vector_Point2f', 'calcOpticalFlowPyrLK' : { 'prevPts' : 'vector_Point2f', 'nextPts' : 'vector_Point2f',
'status' : 'vector_uchar', 'err' : 'vector_float', }, 'status' : 'vector_uchar', 'err' : 'vector_float', },
'fitEllipse' : { 'points' : 'vector_Point2f', }, 'fitEllipse' : { 'points' : 'vector_Point2f', },
'fillPoly' : { 'pts' : 'vector_vector_Point', },
'polylines' : { 'pts' : 'vector_vector_Point', },
'fillConvexPoly' : { 'points' : 'vector_Point', },
}, # '', i.e. no class }, # '', i.e. no class
} # func_arg_fix } # func_arg_fix
......
...@@ -39,7 +39,9 @@ class JavadocGenerator(object): ...@@ -39,7 +39,9 @@ class JavadocGenerator(object):
module = "unknown" module = "unknown"
try: try:
for l in inf.readlines(): for l in inf.readlines():
if l.lstrip().startswith(self.javadoc_marker): org = l
l = l.replace(" ", "").replace("\t", "")#remove all whitespace
if l.startswith(self.javadoc_marker):
marker = self.parceJavadocMarker(l) marker = self.parceJavadocMarker(l)
self.markers_processed += 1 self.markers_processed += 1
decl = self.definitions.get(marker[0],None) decl = self.definitions.get(marker[0],None)
...@@ -55,7 +57,7 @@ class JavadocGenerator(object): ...@@ -55,7 +57,7 @@ class JavadocGenerator(object):
elif show_errors: elif show_errors:
print >> sys.stderr, "gen_javadoc error: could not find documentation for %s (module: %s)" % (l.lstrip()[len(self.javadoc_marker):-1].strip(), module) print >> sys.stderr, "gen_javadoc error: could not find documentation for %s (module: %s)" % (l.lstrip()[len(self.javadoc_marker):-1].strip(), module)
else: else:
outf.write(l.replace("\t", " ").rstrip()+"\n") outf.write(org.replace("\t", " ").rstrip()+"\n")
except: except:
inf.close() inf.close()
outf.close() outf.close()
......
...@@ -416,9 +416,9 @@ JNIEXPORT jstring JNICALL Java_org_opencv_highgui_VideoCapture_n_1getSupportedPr ...@@ -416,9 +416,9 @@ JNIEXPORT jstring JNICALL Java_org_opencv_highgui_VideoCapture_n_1getSupportedPr
LOGD("highgui::VideoCapture_n_1set()"); LOGD("highgui::VideoCapture_n_1set()");
#endif // DEBUG #endif // DEBUG
VideoCapture* me = (VideoCapture*) self; //TODO: check for NULL VideoCapture* me = (VideoCapture*) self; //TODO: check for NULL
double addr = me->get(CV_CAP_PROP_SUPPORTED_PREVIEW_SIZES_STRING); union {double prop; const char* name;} u;
char* result = *((char**)&addr); u.prop = me->get(CV_CAP_PROP_SUPPORTED_PREVIEW_SIZES_STRING);
return env->NewStringUTF(result); return env->NewStringUTF(u.name);
} catch(cv::Exception e) { } catch(cv::Exception e) {
#ifdef DEBUG #ifdef DEBUG
LOGD("highgui::VideoCapture_n_1getSupportedPreviewSizes() catched cv::Exception: %s", e.what()); LOGD("highgui::VideoCapture_n_1getSupportedPreviewSizes() catched cv::Exception: %s", e.what());
......
...@@ -264,6 +264,19 @@ void vector_DMatch_to_Mat(vector<DMatch>& v_dm, Mat& mat) ...@@ -264,6 +264,19 @@ void vector_DMatch_to_Mat(vector<DMatch>& v_dm, Mat& mat)
} }
} }
void Mat_to_vector_vector_Point(Mat& mat, vector< vector< Point > >& vv_pt)
{
vector<Mat> vm;
vm.reserve( mat.rows );
Mat_to_vector_Mat(mat, vm);
for(size_t i=0; i<vm.size(); i++)
{
vector<Point> vpt;
Mat_to_vector_Point(vm[i], vpt);
vv_pt.push_back(vpt);
}
}
void Mat_to_vector_vector_KeyPoint(Mat& mat, vector< vector< KeyPoint > >& vv_kp) void Mat_to_vector_vector_KeyPoint(Mat& mat, vector< vector< KeyPoint > >& vv_kp)
{ {
vector<Mat> vm; vector<Mat> vm;
......
...@@ -55,3 +55,5 @@ void vector_vector_DMatch_to_Mat(std::vector< std::vector< cv::DMatch > >& vv_dm ...@@ -55,3 +55,5 @@ void vector_vector_DMatch_to_Mat(std::vector< std::vector< cv::DMatch > >& vv_dm
void Mat_to_vector_vector_char(cv::Mat& mat, std::vector< std::vector< char > >& vv_ch); void Mat_to_vector_vector_char(cv::Mat& mat, std::vector< std::vector< char > >& vv_ch);
void vector_vector_char_to_Mat(std::vector< std::vector< char > >& vv_ch, cv::Mat& mat); void vector_vector_char_to_Mat(std::vector< std::vector< char > >& vv_ch, cv::Mat& mat);
void Mat_to_vector_vector_Point(cv::Mat& mat, std::vector< std::vector< cv::Point > >& vv_pt);
package org.opencv.core; package org.opencv.core;
public class CvException extends RuntimeException { public class CvException extends RuntimeException {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public CvException(String msg) { public CvException(String msg) {
super(msg); super(msg);
} }
@Override @Override
public String toString() { public String toString() {
return "CvException [" + super.toString() + "]"; return "CvException [" + super.toString() + "]";
} }
} }
package org.opencv.core; package org.opencv.core;
public final class CvType { public final class CvType {
// type depth constants // type depth constants
public static final int CV_8U = 0, CV_8S = 1, public static final int
CV_16U = 2, CV_16S = 3, CV_8U = 0, CV_8S = 1,
CV_32S = 4, CV_16U = 2, CV_16S = 3,
CV_32F = 5, CV_32S = 4,
CV_64F = 6, CV_32F = 5,
CV_USRTYPE1=7; CV_64F = 6,
CV_USRTYPE1 = 7;
// predefined type constants // predefined type constants
public static final int public static final int
CV_8UC1 = CV_8UC(1), CV_8UC2 = CV_8UC(2), CV_8UC3 = CV_8UC(3), CV_8UC4 = CV_8UC(4), CV_8UC1 = CV_8UC(1), CV_8UC2 = CV_8UC(2), CV_8UC3 = CV_8UC(3), CV_8UC4 = CV_8UC(4),
CV_8SC1 = CV_8SC(1), CV_8SC2 = CV_8SC(2), CV_8SC3 = CV_8SC(3), CV_8SC4 = CV_8SC(4), CV_8SC1 = CV_8SC(1), CV_8SC2 = CV_8SC(2), CV_8SC3 = CV_8SC(3), CV_8SC4 = CV_8SC(4),
CV_16UC1 = CV_16UC(1), CV_16UC2 = CV_16UC(2), CV_16UC3 = CV_16UC(3), CV_16UC4 = CV_16UC(4), CV_16UC1 = CV_16UC(1), CV_16UC2 = CV_16UC(2), CV_16UC3 = CV_16UC(3), CV_16UC4 = CV_16UC(4),
CV_16SC1 = CV_16SC(1), CV_16SC2 = CV_16SC(2), CV_16SC3 = CV_16SC(3), CV_16SC4 = CV_16SC(4), CV_16SC1 = CV_16SC(1), CV_16SC2 = CV_16SC(2), CV_16SC3 = CV_16SC(3), CV_16SC4 = CV_16SC(4),
CV_32SC1 = CV_32SC(1), CV_32SC2 = CV_32SC(2), CV_32SC3 = CV_32SC(3), CV_32SC4 = CV_32SC(4), CV_32SC1 = CV_32SC(1), CV_32SC2 = CV_32SC(2), CV_32SC3 = CV_32SC(3), CV_32SC4 = CV_32SC(4),
CV_32FC1 = CV_32FC(1), CV_32FC2 = CV_32FC(2), CV_32FC3 = CV_32FC(3), CV_32FC4 = CV_32FC(4), CV_32FC1 = CV_32FC(1), CV_32FC2 = CV_32FC(2), CV_32FC3 = CV_32FC(3), CV_32FC4 = CV_32FC(4),
CV_64FC1 = CV_64FC(1), CV_64FC2 = CV_64FC(2), CV_64FC3 = CV_64FC(3), CV_64FC4 = CV_64FC(4); CV_64FC1 = CV_64FC(1), CV_64FC2 = CV_64FC(2), CV_64FC3 = CV_64FC(3), CV_64FC4 = CV_64FC(4);
private static final int CV_CN_MAX = 512, CV_CN_SHIFT = 3, CV_DEPTH_MAX = (1 << CV_CN_SHIFT); private static final int CV_CN_MAX = 512, CV_CN_SHIFT = 3, CV_DEPTH_MAX = (1 << CV_CN_SHIFT);
public static final int makeType(int depth, int channels) { public static final int makeType(int depth, int channels) {
if(channels<=0 || channels>=CV_CN_MAX) { if (channels <= 0 || channels >= CV_CN_MAX) {
throw new java.lang.UnsupportedOperationException( throw new java.lang.UnsupportedOperationException(
"Channels count should be 1.." + (CV_CN_MAX-1) ); "Channels count should be 1.." + (CV_CN_MAX - 1));
} }
if(depth<0 || depth>=CV_DEPTH_MAX) { if (depth < 0 || depth >= CV_DEPTH_MAX) {
throw new java.lang.UnsupportedOperationException( throw new java.lang.UnsupportedOperationException(
"Data type depth should be 0.." + (CV_DEPTH_MAX-1) ); "Data type depth should be 0.." + (CV_DEPTH_MAX - 1));
} }
return (depth & (CV_DEPTH_MAX-1)) + ((channels-1) << CV_CN_SHIFT); return (depth & (CV_DEPTH_MAX - 1)) + ((channels - 1) << CV_CN_SHIFT);
} }
public static final int CV_8UC(int ch) {
return makeType(CV_8U, ch);
}
public static final int CV_8UC(int ch) { return makeType(CV_8U, ch); } public static final int CV_8SC(int ch) {
return makeType(CV_8S, ch);
public static final int CV_8SC(int ch) { return makeType(CV_8S, ch); } }
public static final int CV_16UC(int ch) { return makeType(CV_16U, ch); } public static final int CV_16UC(int ch) {
return makeType(CV_16U, ch);
}
public static final int CV_16SC(int ch) { return makeType(CV_16S, ch); } public static final int CV_16SC(int ch) {
return makeType(CV_16S, ch);
}
public static final int CV_32SC(int ch) { return makeType(CV_32S, ch); } public static final int CV_32SC(int ch) {
return makeType(CV_32S, ch);
}
public static final int CV_32FC(int ch) { return makeType(CV_32F, ch); } public static final int CV_32FC(int ch) {
return makeType(CV_32F, ch);
}
public static final int CV_64FC(int ch) { return makeType(CV_64F, ch); } public static final int CV_64FC(int ch) {
return makeType(CV_64F, ch);
}
public static final int channels(int type) { return (type >> CV_CN_SHIFT) + 1; } public static final int channels(int type) {
return (type >> CV_CN_SHIFT) + 1;
}
public static final int depth(int type) { return type & (CV_DEPTH_MAX-1); } public static final int depth(int type) {
return type & (CV_DEPTH_MAX - 1);
}
public static final boolean isInteger(int type) { return depth(type) < CV_32F; } public static final boolean isInteger(int type) {
return depth(type) < CV_32F;
}
public static final int ELEM_SIZE(int type) { public static final int ELEM_SIZE(int type) {
switch (depth(type)) { switch (depth(type)) {
case CV_8U: case CV_8U:
case CV_8S: case CV_8S:
return channels(type); return channels(type);
case CV_16U: case CV_16U:
case CV_16S: case CV_16S:
return 2 * channels(type); return 2 * channels(type);
case CV_32S: case CV_32S:
case CV_32F: case CV_32F:
return 4 * channels(type); return 4 * channels(type);
case CV_64F: case CV_64F:
return 8 * channels(type); return 8 * channels(type);
default: default:
throw new java.lang.UnsupportedOperationException( throw new java.lang.UnsupportedOperationException(
"Unsupported CvType value: " + type ); "Unsupported CvType value: " + type);
} }
} }
public static final String typeToString(int type) { public static final String typeToString(int type) {
String s; String s;
switch (depth(type)) { switch (depth(type)) {
case CV_8U: case CV_8U:
s = "CV_8U"; s = "CV_8U";
break; break;
case CV_8S: case CV_8S:
s = "CV_8S"; s = "CV_8S";
break; break;
case CV_16U: case CV_16U:
s = "CV_16U"; s = "CV_16U";
break; break;
case CV_16S: case CV_16S:
s = "CV_16S"; s = "CV_16S";
break; break;
case CV_32S: case CV_32S:
s = "CV_32S"; s = "CV_32S";
break; break;
case CV_32F: case CV_32F:
s = "CV_32F"; s = "CV_32F";
break; break;
case CV_64F: case CV_64F:
s = "CV_64F"; s = "CV_64F";
break; break;
default: case CV_USRTYPE1:
s = "CV_USRTYPE1"; s = "CV_USRTYPE1";
break;
default:
throw new java.lang.UnsupportedOperationException(
"Unsupported CvType value: " + type);
} }
int ch = channels(type); int ch = channels(type);
if(ch<=4) return s + "C" + ch; if (ch <= 4)
else return s + "C(" + ch + ")"; return s + "C" + ch;
else
return s + "C(" + ch + ")";
} }
} }
This diff is collapsed.
...@@ -18,17 +18,17 @@ public class Point { ...@@ -18,17 +18,17 @@ public class Point {
this(); this();
set(vals); set(vals);
} }
public void set(double[] vals) { public void set(double[] vals) {
if(vals!=null) { if (vals != null) {
x = vals.length>0 ? vals[0] : 0; x = vals.length > 0 ? vals[0] : 0;
y = vals.length>1 ? vals[1] : 0; y = vals.length > 1 ? vals[1] : 0;
} else { } else {
x = 0; x = 0;
y = 0; y = 0;
} }
} }
public Point clone() { public Point clone() {
return new Point(x, y); return new Point(x, y);
} }
...@@ -52,7 +52,7 @@ public class Point { ...@@ -52,7 +52,7 @@ public class Point {
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true; if (this == obj) return true;
if ( ! (obj instanceof Point) ) return false; if (!(obj instanceof Point)) return false;
Point it = (Point) obj; Point it = (Point) obj;
return x == it.x && y == it.y; return x == it.x && y == it.y;
} }
...@@ -61,10 +61,8 @@ public class Point { ...@@ -61,10 +61,8 @@ public class Point {
return r.contains(this); return r.contains(this);
} }
@Override @Override
public String toString() { public String toString() {
if (this == null) return "null";
return "{" + x + ", " + y + "}"; return "{" + x + ", " + y + "}";
} }
} }
...@@ -25,16 +25,17 @@ public class Point3 { ...@@ -25,16 +25,17 @@ public class Point3 {
this(); this();
set(vals); set(vals);
} }
public void set(double[] vals) { public void set(double[] vals) {
if(vals!=null) { if (vals != null) {
x = vals.length>0 ? vals[0] : 0; x = vals.length > 0 ? vals[0] : 0;
y = vals.length>1 ? vals[1] : 0; y = vals.length > 1 ? vals[1] : 0;
z = vals.length>2 ? vals[2] : 0; z = vals.length > 2 ? vals[2] : 0;
} else { } else {
x = 0; x = 0;
y = 0; y = 0;
z = 0; z = 0;
} }
} }
public Point3 clone() { public Point3 clone() {
...@@ -70,4 +71,9 @@ public class Point3 { ...@@ -70,4 +71,9 @@ public class Point3 {
Point3 it = (Point3) obj; Point3 it = (Point3) obj;
return x == it.x && y == it.y && z == it.z; return x == it.x && y == it.y && z == it.z;
} }
@Override
public String toString() {
return "{" + x + ", " + y + ", " + z + "}";
}
} }
...@@ -2,7 +2,7 @@ package org.opencv.core; ...@@ -2,7 +2,7 @@ package org.opencv.core;
//javadoc:Range //javadoc:Range
public class Range { public class Range {
public int start, end; public int start, end;
public Range(int s, int e) { public Range(int s, int e) {
...@@ -13,31 +13,32 @@ public class Range { ...@@ -13,31 +13,32 @@ public class Range {
public Range() { public Range() {
this(0, 0); this(0, 0);
} }
public Range(double[] vals) { public Range(double[] vals) {
this();
set(vals); set(vals);
} }
public void set(double[] vals) { public void set(double[] vals) {
if(vals!=null) { if (vals != null) {
start = vals.length>0 ? (int)vals[0] : 0; start = vals.length > 0 ? (int) vals[0] : 0;
end = vals.length>1 ? (int)vals[1] : 0; end = vals.length > 1 ? (int) vals[1] : 0;
} else { } else {
start = 0; start = 0;
end = 0; end = 0;
} }
} }
public int size() { public int size() {
return end-start; return empty() ? 0 : end - start;
} }
public boolean empty() { public boolean empty() {
return start==end; return end <= start;
} }
public static Range all() { public static Range all() {
return new Range(Integer.MIN_VALUE , Integer.MAX_VALUE); return new Range(Integer.MIN_VALUE, Integer.MAX_VALUE);
} }
public Range intersection(Range r1) { public Range intersection(Range r1) {
...@@ -45,15 +46,15 @@ public class Range { ...@@ -45,15 +46,15 @@ public class Range {
r.end = Math.max(r.end, r.start); r.end = Math.max(r.end, r.start);
return r; return r;
} }
public Range shift(int delta) { public Range shift(int delta) {
return new Range(start+delta, end+delta); return new Range(start + delta, end + delta);
} }
public Range clone() { public Range clone() {
return new Range(start, end); return new Range(start, end);
} }
@Override @Override
public int hashCode() { public int hashCode() {
final int prime = 31; final int prime = 31;
...@@ -76,7 +77,6 @@ public class Range { ...@@ -76,7 +77,6 @@ public class Range {
@Override @Override
public String toString() { public String toString() {
if (this == null) return "null";
return "[" + start + ", " + end + ")"; return "[" + start + ", " + end + ")";
} }
} }
...@@ -24,25 +24,25 @@ public class Rect { ...@@ -24,25 +24,25 @@ public class Rect {
} }
public Rect(Point p, Size s) { public Rect(Point p, Size s) {
this((int)p.x, (int)p.y, (int)s.width, (int)s.height); this((int) p.x, (int) p.y, (int) s.width, (int) s.height);
} }
public Rect(double[] vals) { public Rect(double[] vals) {
this();
set(vals); set(vals);
} }
public void set(double[] vals) { public void set(double[] vals) {
if(vals!=null) { if (vals != null) {
x = vals.length>0 ? (int)vals[0] : 0; x = vals.length > 0 ? (int) vals[0] : 0;
y = vals.length>1 ? (int)vals[1] : 0; y = vals.length > 1 ? (int) vals[1] : 0;
width = vals.length>2 ? (int)vals[2] : 0; width = vals.length > 2 ? (int) vals[2] : 0;
height = vals.length>3 ? (int)vals[3] : 0; height = vals.length > 3 ? (int) vals[3] : 0;
} else { } else {
x = 0; x = 0;
y = 0; y = 0;
width = 0; width = 0;
height = 0; height = 0;
} }
} }
public Rect clone() { public Rect clone() {
...@@ -95,7 +95,6 @@ public class Rect { ...@@ -95,7 +95,6 @@ public class Rect {
@Override @Override
public String toString() { public String toString() {
if (this == null) return "null"; return "{" + x + ", " + y + ", " + width + "x" + height + "}";
return "{" + x + ", " + y + ", " + width + "x" + height+"}";
} }
} }
...@@ -23,54 +23,54 @@ public class RotatedRect { ...@@ -23,54 +23,54 @@ public class RotatedRect {
this(); this();
set(vals); set(vals);
} }
public void set(double[] vals) { public void set(double[] vals) {
if(vals!=null) { if (vals != null) {
center.x = vals.length>0 ? (double)vals[0] : 0; center.x = vals.length > 0 ? (double) vals[0] : 0;
center.y = vals.length>1 ? (double)vals[1] : 0; center.y = vals.length > 1 ? (double) vals[1] : 0;
size.width = vals.length>2 ? (double)vals[2] : 0; size.width = vals.length > 2 ? (double) vals[2] : 0;
size.height = vals.length>3 ? (double)vals[3] : 0; size.height = vals.length > 3 ? (double) vals[3] : 0;
angle = vals.length>4 ? (double)vals[4] : 0; angle = vals.length > 4 ? (double) vals[4] : 0;
} else { } else {
center.x = 0; center.x = 0;
center.x = 0; center.x = 0;
size.width = 0; size.width = 0;
size.height = 0; size.height = 0;
angle = 0; angle = 0;
} }
} }
public void points(Point pt[]) public void points(Point pt[])
{ {
double _angle = angle*Math.PI/180.0; double _angle = angle * Math.PI / 180.0;
double b = (double)Math.cos(_angle)*0.5f; double b = (double) Math.cos(_angle) * 0.5f;
double a = (double)Math.sin(_angle)*0.5f; double a = (double) Math.sin(_angle) * 0.5f;
pt[0] = new Point( pt[0] = new Point(
center.x - a*size.height - b*size.width, center.x - a * size.height - b * size.width,
center.y + b*size.height - a*size.width); center.y + b * size.height - a * size.width);
pt[1] = new Point( pt[1] = new Point(
center.x + a*size.height - b*size.width, center.x + a * size.height - b * size.width,
center.y - b*size.height - a*size.width); center.y - b * size.height - a * size.width);
pt[2] = new Point( pt[2] = new Point(
2*center.x - pt[0].x, 2 * center.x - pt[0].x,
2*center.y - pt[0].y); 2 * center.y - pt[0].y);
pt[3] = new Point( pt[3] = new Point(
2*center.x - pt[1].x, 2 * center.x - pt[1].x,
2*center.y - pt[1].y); 2 * center.y - pt[1].y);
} }
public Rect boundingRect() public Rect boundingRect()
{ {
Point pt[] = new Point[4]; Point pt[] = new Point[4];
points(pt); points(pt);
Rect r=new Rect((int)Math.floor(Math.min(Math.min(Math.min(pt[0].x, pt[1].x), pt[2].x), pt[3].x)), Rect r = new Rect((int) Math.floor(Math.min(Math.min(Math.min(pt[0].x, pt[1].x), pt[2].x), pt[3].x)),
(int)Math.floor(Math.min(Math.min(Math.min(pt[0].y, pt[1].y), pt[2].y), pt[3].y)), (int) Math.floor(Math.min(Math.min(Math.min(pt[0].y, pt[1].y), pt[2].y), pt[3].y)),
(int)Math.ceil(Math.max(Math.max(Math.max(pt[0].x, pt[1].x), pt[2].x), pt[3].x)), (int) Math.ceil(Math.max(Math.max(Math.max(pt[0].x, pt[1].x), pt[2].x), pt[3].x)),
(int)Math.ceil(Math.max(Math.max(Math.max(pt[0].y, pt[1].y), pt[2].y), pt[3].y))); (int) Math.ceil(Math.max(Math.max(Math.max(pt[0].y, pt[1].y), pt[2].y), pt[3].y)));
r.width -= r.x - 1; r.width -= r.x - 1;
r.height -= r.y - 1; r.height -= r.y - 1;
return r; return r;
...@@ -105,4 +105,9 @@ public class RotatedRect { ...@@ -105,4 +105,9 @@ public class RotatedRect {
RotatedRect it = (RotatedRect) obj; RotatedRect it = (RotatedRect) obj;
return center.equals(it.center) && size.equals(it.size) && angle == it.angle; return center.equals(it.center) && size.equals(it.size) && angle == it.angle;
} }
@Override
public String toString() {
return "{ " + center + " " + size + " * " + angle + " }";
}
} }
...@@ -6,32 +6,38 @@ public class Scalar { ...@@ -6,32 +6,38 @@ public class Scalar {
public double val[]; public double val[];
public Scalar(double v0, double v1, double v2, double v3) { public Scalar(double v0, double v1, double v2, double v3) {
this.val = new double[] {v0, v1, v2, v3}; val = new double[] { v0, v1, v2, v3 };
} }
public Scalar(double v0, double v1, double v2) { public Scalar(double v0, double v1, double v2) {
this.val = new double[] {v0, v1, v2, 0}; val = new double[] { v0, v1, v2, 0 };
} }
public Scalar(double v0, double v1) { public Scalar(double v0, double v1) {
this.val = new double[] {v0, v1, 0, 0}; val = new double[] { v0, v1, 0, 0 };
} }
public Scalar(double v0) { public Scalar(double v0) {
this.val = new double[] {v0, 0, 0, 0}; val = new double[] { v0, 0, 0, 0 };
} }
public Scalar(double[] vals) { public Scalar(double[] vals) {
this.val = new double[4]; if (vals != null && vals.length == 4)
set(vals); val = vals.clone();
else {
val = new double[4];
set(vals);
}
} }
public void set(double[] vals) { public void set(double[] vals) {
if(vals!=null) { if (vals != null) {
this.val[0] = vals.length>0 ? vals[0] : 0; val[0] = vals.length > 0 ? vals[0] : 0;
this.val[1] = vals.length>1 ? vals[1] : 0; val[1] = vals.length > 1 ? vals[1] : 0;
this.val[2] = vals.length>2 ? vals[2] : 0; val[2] = vals.length > 2 ? vals[2] : 0;
this.val[3] = vals.length>3 ? vals[3] : 0; val[3] = vals.length > 3 ? vals[3] : 0;
} } else
val[0] = val[1] = val[2] = val[3] = 0;
} }
public static Scalar all(double v) { public static Scalar all(double v) {
...@@ -43,13 +49,14 @@ public class Scalar { ...@@ -43,13 +49,14 @@ public class Scalar {
} }
public Scalar mul(Scalar it, double scale) { public Scalar mul(Scalar it, double scale) {
return new Scalar( val[0] * it.val[0] * scale, val[1] * it.val[1] * scale, return new Scalar(val[0] * it.val[0] * scale, val[1] * it.val[1] * scale,
val[2] * it.val[2] * scale, val[3] * it.val[3] * scale ); val[2] * it.val[2] * scale, val[3] * it.val[3] * scale);
} }
public Scalar mul(Scalar it) { public Scalar mul(Scalar it) {
return mul(it, 1); return mul(it, 1);
} }
public Scalar conj() { public Scalar conj() {
return new Scalar(val[0], -val[1], -val[2], -val[3]); return new Scalar(val[0], -val[1], -val[2], -val[3]);
} }
...@@ -58,22 +65,26 @@ public class Scalar { ...@@ -58,22 +65,26 @@ public class Scalar {
return val[1] == 0 && val[2] == 0 && val[3] == 0; return val[1] == 0 && val[2] == 0 && val[3] == 0;
} }
@Override @Override
public int hashCode() { public int hashCode() {
final int prime = 31; final int prime = 31;
int result = 1; int result = 1;
result = prime * result + java.util.Arrays.hashCode(val); result = prime * result + java.util.Arrays.hashCode(val);
return result; return result;
} }
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (this == obj) return true; if (this == obj) return true;
if (!(obj instanceof Scalar)) return false; if (!(obj instanceof Scalar)) return false;
Scalar it = (Scalar) obj; Scalar it = (Scalar) obj;
if (!java.util.Arrays.equals(val, it.val)) return false; if (!java.util.Arrays.equals(val, it.val)) return false;
return true; return true;
} }
@Override
public String toString() {
return "[" + val[0] + ", " + val[1] + ", " + val[2] + ", " + val[3] + "]";
}
} }
...@@ -15,20 +15,20 @@ public class Size { ...@@ -15,20 +15,20 @@ public class Size {
} }
public Size(Point p) { public Size(Point p) {
width = (double) p.x; width = p.x;
height = (double) p.y; height = p.y;
} }
public Size(double[] vals) { public Size(double[] vals) {
this();
set(vals); set(vals);
} }
public void set(double[] vals) { public void set(double[] vals) {
if(vals!=null) { if (vals != null) {
width = vals.length>0 ? vals[0] : 0; width = vals.length > 0 ? vals[0] : 0;
height = vals.length>1 ? vals[1] : 0; height = vals.length > 1 ? vals[1] : 0;
} else { } else {
width = 0; width = 0;
height = 0; height = 0;
} }
} }
...@@ -61,4 +61,9 @@ public class Size { ...@@ -61,4 +61,9 @@ public class Size {
return width == it.width && height == it.height; return width == it.width && height == it.height;
} }
@Override
public String toString() {
return (int)width + "x" + (int)height;
}
} }
...@@ -3,33 +3,59 @@ package org.opencv.core; ...@@ -3,33 +3,59 @@ package org.opencv.core;
//javadoc:TermCriteria //javadoc:TermCriteria
public class TermCriteria { public class TermCriteria {
/**
* the maximum number of iterations or elements to compute
*/
public static final int COUNT = 1;
/**
* the maximum number of iterations or elements to compute
*/
public static final int MAX_ITER = COUNT;
/**
* the desired accuracy or change in parameters at which the iterative algorithm stops
*/
public static final int EPS = 2;
public int type; public int type;
public int maxCount; public int maxCount;
public double epsilon; public double epsilon;
public TermCriteria(int t, int c, double e) { /**
this.type = t; * Termination criteria in iterative algorithms
this.maxCount = c; *
this.epsilon = e; * @param type
* the type of termination criteria: COUNT, EPS or COUNT + EPS
* @param maxCount
* the maximum number of iterations/elements
* @param epsilon
* the desired accuracy
*/
public TermCriteria(int type, int maxCount, double epsilon) {
this.type = type;
this.maxCount = maxCount;
this.epsilon = epsilon;
} }
/**
* Termination criteria in iterative algorithms
*/
public TermCriteria() { public TermCriteria() {
this(0, 0, 0.0); this(0, 0, 0.0);
} }
public TermCriteria(double[] vals) { public TermCriteria(double[] vals) {
this();
set(vals); set(vals);
} }
public void set(double[] vals) { public void set(double[] vals) {
if(vals!=null) { if (vals != null) {
type = vals.length>0 ? (int)vals[0] : 0; type = vals.length > 0 ? (int) vals[0] : 0;
maxCount = vals.length>1 ? (int)vals[1] : 0; maxCount = vals.length > 1 ? (int) vals[1] : 0;
epsilon = vals.length>2 ? (double)vals[2] : 0; epsilon = vals.length > 2 ? (double) vals[2] : 0;
} else { } else {
type = 0; type = 0;
maxCount = 0; maxCount = 0;
epsilon = 0; epsilon = 0;
} }
} }
...@@ -56,7 +82,7 @@ public class TermCriteria { ...@@ -56,7 +82,7 @@ public class TermCriteria {
if (this == obj) return true; if (this == obj) return true;
if (!(obj instanceof TermCriteria)) return false; if (!(obj instanceof TermCriteria)) return false;
TermCriteria it = (TermCriteria) obj; TermCriteria it = (TermCriteria) obj;
return type == it.type && maxCount == it.maxCount && epsilon== it.epsilon; return type == it.type && maxCount == it.maxCount && epsilon == it.epsilon;
} }
@Override @Override
......
package org.opencv.features2d; package org.opencv.features2d;
//C++: class DMatch //C++: class DMatch
//javadoc: DMatch
/**
* Struct for matching: query descriptor index, train descriptor index, train
* image index and distance between descriptors.
*/
public class DMatch { public class DMatch {
//javadoc: DMatch::queryIdx /**
public int queryIdx; * query descriptor index
//javadoc: DMatch::trainIdx */
public int trainIdx; public int queryIdx;
//javadoc: DMatch::imgIdx /**
public int imgIdx; * train descriptor index
//javadoc: DMatch::distance */
public float distance; public int trainIdx;
/**
* train image index
//javadoc: DMatch::DMatch() */
public int imgIdx;
// javadoc: DMatch::distance
public float distance;
// javadoc: DMatch::DMatch()
public DMatch() { public DMatch() {
this(-1, -1, Float.MAX_VALUE); this(-1, -1, Float.MAX_VALUE);
}
public DMatch( int _queryIdx, int _trainIdx, float _distance ) {
queryIdx = _queryIdx;
trainIdx = _trainIdx;
imgIdx = -1;
distance = _distance;
} }
// javadoc: DMatch::DMatch(_queryIdx, _trainIdx, _distance)
public DMatch( int _queryIdx, int _trainIdx, int _imgIdx, float _distance ) { public DMatch(int _queryIdx, int _trainIdx, float _distance) {
queryIdx = _queryIdx; queryIdx = _queryIdx;
trainIdx = _trainIdx; trainIdx = _trainIdx;
imgIdx = _imgIdx; imgIdx = -1;
distance = _distance; distance = _distance;
} }
// less is better // javadoc: DMatch::DMatch(_queryIdx, _trainIdx, _imgIdx, _distance)
public DMatch(int _queryIdx, int _trainIdx, int _imgIdx, float _distance) {
queryIdx = _queryIdx;
trainIdx = _trainIdx;
imgIdx = _imgIdx;
distance = _distance;
}
/**
* less is better
*/
boolean lessThan(DMatch it) { boolean lessThan(DMatch it) {
return distance < it.distance; return distance < it.distance;
} }
@Override
@Override public String toString() {
public String toString() { return "DMatch [queryIdx=" + queryIdx + ", trainIdx=" + trainIdx
return "DMatch [queryIdx=" + queryIdx + ", trainIdx=" + trainIdx + ", imgIdx=" + imgIdx + ", distance=" + distance + "]";
+ ", imgIdx=" + imgIdx + ", distance=" + distance + "]"; }
}
} }
...@@ -4,66 +4,80 @@ import org.opencv.core.Point; ...@@ -4,66 +4,80 @@ import org.opencv.core.Point;
//javadoc: KeyPoint //javadoc: KeyPoint
public class KeyPoint { public class KeyPoint {
//javadoc: KeyPoint::pt /**
* coordinates of the keypoint
*/
public Point pt; public Point pt;
//javadoc: KeyPoint::size /**
* diameter of the meaningful keypoint neighborhood
*/
public float size; public float size;
//javadoc: KeyPoint::angle /**
* computed orientation of the keypoint (-1 if not applicable)
*/
public float angle; public float angle;
//javadoc: KeyPoint::response /**
* the response by which the most strong keypoints have been selected. Can
* be used for further sorting or subsampling
*/
public float response; public float response;
//javadoc: KeyPoint::octave /**
* octave (pyramid layer) from which the keypoint has been extracted
*/
public int octave; public int octave;
//javadoc: KeyPoint::class_id /**
public int class_id; * object id that can be used to clustered keypoints by an object they
* belong to
*/
public int class_id;
//javadoc: KeyPoint::KeyPoint(x, y, _size, _angle, _response, _octave, _class_id) // javadoc:KeyPoint::KeyPoint(x,y,_size,_angle,_response,_octave,_class_id)
public KeyPoint(float x, float y, float _size, float _angle, float _response, int _octave, int _class_id) public KeyPoint(float x, float y, float _size, float _angle, float _response, int _octave, int _class_id)
{ {
pt = new Point(x, y); pt = new Point(x, y);
size = _size; size = _size;
angle = _angle; angle = _angle;
response = _response; response = _response;
octave = _octave; octave = _octave;
class_id = _class_id; class_id = _class_id;
} }
//javadoc: KeyPoint::KeyPoint() // javadoc: KeyPoint::KeyPoint()
public KeyPoint() public KeyPoint()
{ {
this(0, 0, 0, -1, 0, 0, -1); this(0, 0, 0, -1, 0, 0, -1);
} }
//javadoc: KeyPoint::KeyPoint(x, y, _size, _angle, _response, _octave) // javadoc: KeyPoint::KeyPoint(x, y, _size, _angle, _response, _octave)
public KeyPoint(float x, float y, float _size, float _angle, float _response, int _octave) public KeyPoint(float x, float y, float _size, float _angle, float _response, int _octave)
{ {
this(x, y, _size, _angle, _response, _octave, -1); this(x, y, _size, _angle, _response, _octave, -1);
} }
//javadoc: KeyPoint::KeyPoint(x, y, _size, _angle, _response) // javadoc: KeyPoint::KeyPoint(x, y, _size, _angle, _response)
public KeyPoint(float x, float y, float _size, float _angle, float _response) public KeyPoint(float x, float y, float _size, float _angle, float _response)
{ {
this(x, y, _size, _angle, _response, 0, -1); this(x, y, _size, _angle, _response, 0, -1);
} }
//javadoc: KeyPoint::KeyPoint(x, y, _size, _angle) // javadoc: KeyPoint::KeyPoint(x, y, _size, _angle)
public KeyPoint(float x, float y, float _size, float _angle) public KeyPoint(float x, float y, float _size, float _angle)
{ {
this(x, y, _size, _angle, 0, 0, -1); this(x, y, _size, _angle, 0, 0, -1);
} }
//javadoc: KeyPoint::KeyPoint(x, y, _size) // javadoc: KeyPoint::KeyPoint(x, y, _size)
public KeyPoint(float x, float y, float _size) public KeyPoint(float x, float y, float _size)
{ {
this(x, y, _size, -1, 0, 0, -1); this(x, y, _size, -1, 0, 0, -1);
} }
@Override @Override
public String toString() { public String toString() {
return "KeyPoint [pt=" + pt + ", size=" + size + ", angle=" + angle return "KeyPoint [pt=" + pt + ", size=" + size + ", angle=" + angle
+ ", response=" + response + ", octave=" + octave + ", response=" + response + ", octave=" + octave
+ ", class_id=" + class_id + "]"; + ", class_id=" + class_id + "]";
} }
} }
...@@ -11,172 +11,183 @@ import org.opencv.core.Size; ...@@ -11,172 +11,183 @@ import org.opencv.core.Size;
public class VideoCapture { public class VideoCapture {
protected final long nativeObj; protected final long nativeObj;
protected VideoCapture(long addr) { nativeObj = addr; }
protected VideoCapture(long addr) {
nativeObj = addr;
}
// //
// C++: VideoCapture::VideoCapture() // C++: VideoCapture::VideoCapture()
// //
//javadoc: VideoCapture::VideoCapture() // javadoc: VideoCapture::VideoCapture()
public VideoCapture() public VideoCapture()
{ {
nativeObj = n_VideoCapture(); nativeObj = n_VideoCapture();
return; return;
} }
// //
// C++: VideoCapture::VideoCapture(int device) // C++: VideoCapture::VideoCapture(int device)
// //
//javadoc: VideoCapture::VideoCapture(device) // javadoc: VideoCapture::VideoCapture(device)
public VideoCapture(int device) public VideoCapture(int device)
{ {
nativeObj = n_VideoCapture(device); nativeObj = n_VideoCapture(device);
return; return;
} }
// //
// C++: double VideoCapture::get(int propId) // C++: double VideoCapture::get(int propId)
// //
//javadoc: VideoCapture::get(propId) /**
public double get(int propId) * Returns the specified "VideoCapture" property
*
* Note: When querying a property that is not supported by the backend used by
* the "VideoCapture" class, value 0 is returned.
*
* @param propId Property identifier. It can be one of the following:
* * CV_CAP_PROP_FRAME_WIDTH Width of the frames in the video stream.
* * CV_CAP_PROP_FRAME_HEIGHT Height of the frames in the video stream.
*
* @see <a href="http://opencv.itseez.com/modules/highgui/doc/reading_and_writing_images_and_video.html#videocapture-get">org.opencv.highgui.VideoCapture.get</a>
*/
public double get(int propId)
{ {
double retVal = n_get(nativeObj, propId); double retVal = n_get(nativeObj, propId);
return retVal; return retVal;
} }
public List<Size> getSupportedPreviewSizes() public List<Size> getSupportedPreviewSizes()
{ {
String[] sizes_str = n_getSupportedPreviewSizes(nativeObj).split(","); String[] sizes_str = n_getSupportedPreviewSizes(nativeObj).split(",");
List<Size> sizes = new LinkedList<Size>(); List<Size> sizes = new LinkedList<Size>();
for(String str : sizes_str){ for (String str : sizes_str) {
String[] wh = str.split("x"); String[] wh = str.split("x");
sizes.add(new Size(Double.parseDouble(wh[0]), Double.parseDouble(wh[1]))); sizes.add(new Size(Double.parseDouble(wh[0]), Double.parseDouble(wh[1])));
} }
return sizes; return sizes;
} }
// //
// C++: bool VideoCapture::grab() // C++: bool VideoCapture::grab()
// //
//javadoc: VideoCapture::grab() // javadoc: VideoCapture::grab()
public boolean grab() public boolean grab()
{ {
boolean retVal = n_grab(nativeObj); boolean retVal = n_grab(nativeObj);
return retVal; return retVal;
} }
// //
// C++: bool VideoCapture::isOpened() // C++: bool VideoCapture::isOpened()
// //
//javadoc: VideoCapture::isOpened() // javadoc: VideoCapture::isOpened()
public boolean isOpened() public boolean isOpened()
{ {
boolean retVal = n_isOpened(nativeObj); boolean retVal = n_isOpened(nativeObj);
return retVal; return retVal;
} }
// //
// C++: bool VideoCapture::open(int device) // C++: bool VideoCapture::open(int device)
// //
//javadoc: VideoCapture::open(device) // javadoc: VideoCapture::open(device)
public boolean open(int device) public boolean open(int device)
{ {
boolean retVal = n_open(nativeObj, device); boolean retVal = n_open(nativeObj, device);
return retVal; return retVal;
} }
// //
// C++: bool VideoCapture::read(Mat image) // C++: bool VideoCapture::read(Mat image)
// //
//javadoc: VideoCapture::read(image) // javadoc: VideoCapture::read(image)
public boolean read(Mat image) public boolean read(Mat image)
{ {
boolean retVal = n_read(nativeObj, image.nativeObj); boolean retVal = n_read(nativeObj, image.nativeObj);
return retVal; return retVal;
} }
// //
// C++: void VideoCapture::release() // C++: void VideoCapture::release()
// //
//javadoc: VideoCapture::release() // javadoc: VideoCapture::release()
public void release() public void release()
{ {
n_release(nativeObj); n_release(nativeObj);
return; return;
} }
// //
// C++: bool VideoCapture::retrieve(Mat image, int channel = 0) // C++: bool VideoCapture::retrieve(Mat image, int channel = 0)
// //
//javadoc: VideoCapture::retrieve(image, channel) // javadoc: VideoCapture::retrieve(image, channel)
public boolean retrieve(Mat image, int channel) public boolean retrieve(Mat image, int channel)
{ {
boolean retVal = n_retrieve(nativeObj, image.nativeObj, channel); boolean retVal = n_retrieve(nativeObj, image.nativeObj, channel);
return retVal; return retVal;
} }
//javadoc: VideoCapture::retrieve(image) // javadoc: VideoCapture::retrieve(image)
public boolean retrieve(Mat image) public boolean retrieve(Mat image)
{ {
boolean retVal = n_retrieve(nativeObj, image.nativeObj); boolean retVal = n_retrieve(nativeObj, image.nativeObj);
return retVal; return retVal;
} }
// //
// C++: bool VideoCapture::set(int propId, double value) // C++: bool VideoCapture::set(int propId, double value)
// //
//javadoc: VideoCapture::set(propId, value) /**
public boolean set(int propId, double value) * Sets a property in the "VideoCapture".
*
* @param propId Property identifier. It can be one of the following:
* * CV_CAP_PROP_FRAME_WIDTH Width of the frames in the video stream.
* * CV_CAP_PROP_FRAME_HEIGHT Height of the frames in the video stream.
* @param value Value of the property.
*
* @see <a href="http://opencv.itseez.com/modules/highgui/doc/reading_and_writing_images_and_video.html#videocapture-set">org.opencv.highgui.VideoCapture.set</a>
*/
public boolean set(int propId, double value)
{ {
boolean retVal = n_set(nativeObj, propId, value); boolean retVal = n_set(nativeObj, propId, value);
return retVal; return retVal;
} }
@Override @Override
protected void finalize() throws Throwable { protected void finalize() throws Throwable {
n_delete(nativeObj); n_delete(nativeObj);
...@@ -185,43 +196,46 @@ public class VideoCapture { ...@@ -185,43 +196,46 @@ public class VideoCapture {
// native stuff // native stuff
static { System.loadLibrary("opencv_java"); } static {
System.loadLibrary("opencv_java");
}
// C++: VideoCapture::VideoCapture() // C++: VideoCapture::VideoCapture()
private static native long n_VideoCapture(); private static native long n_VideoCapture();
// C++: VideoCapture::VideoCapture(string filename) // C++: VideoCapture::VideoCapture(string filename)
private static native long n_VideoCapture(java.lang.String filename); private static native long n_VideoCapture(java.lang.String filename);
// C++: VideoCapture::VideoCapture(int device) // C++: VideoCapture::VideoCapture(int device)
private static native long n_VideoCapture(int device); private static native long n_VideoCapture(int device);
// C++: double VideoCapture::get(int propId) // C++: double VideoCapture::get(int propId)
private static native double n_get(long nativeObj, int propId); private static native double n_get(long nativeObj, int propId);
// C++: bool VideoCapture::grab() // C++: bool VideoCapture::grab()
private static native boolean n_grab(long nativeObj); private static native boolean n_grab(long nativeObj);
// C++: bool VideoCapture::isOpened() // C++: bool VideoCapture::isOpened()
private static native boolean n_isOpened(long nativeObj); private static native boolean n_isOpened(long nativeObj);
// C++: bool VideoCapture::open(string filename) // C++: bool VideoCapture::open(string filename)
private static native boolean n_open(long nativeObj, java.lang.String filename); private static native boolean n_open(long nativeObj, java.lang.String filename);
// C++: bool VideoCapture::open(int device) // C++: bool VideoCapture::open(int device)
private static native boolean n_open(long nativeObj, int device); private static native boolean n_open(long nativeObj, int device);
// C++: bool VideoCapture::read(Mat image) // C++: bool VideoCapture::read(Mat image)
private static native boolean n_read(long nativeObj, long image_nativeObj); private static native boolean n_read(long nativeObj, long image_nativeObj);
// C++: void VideoCapture::release() // C++: void VideoCapture::release()
private static native void n_release(long nativeObj); private static native void n_release(long nativeObj);
// C++: bool VideoCapture::retrieve(Mat image, int channel = 0) // C++: bool VideoCapture::retrieve(Mat image, int channel = 0)
private static native boolean n_retrieve(long nativeObj, long image_nativeObj, int channel); private static native boolean n_retrieve(long nativeObj, long image_nativeObj, int channel);
private static native boolean n_retrieve(long nativeObj, long image_nativeObj); private static native boolean n_retrieve(long nativeObj, long image_nativeObj);
// C++: bool VideoCapture::set(int propId, double value) // C++: bool VideoCapture::set(int propId, double value)
private static native boolean n_set(long nativeObj, int propId, double value); private static native boolean n_set(long nativeObj, int propId, double value);
private static native String n_getSupportedPreviewSizes(long nativeObj); private static native String n_getSupportedPreviewSizes(long nativeObj);
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment