Merge remote-tracking branch 'origin/2.4' into merge-2.4

Conflicts:
	cmake/OpenCVModule.cmake
	doc/tutorials/calib3d/camera_calibration/camera_calibration.rst
	doc/tutorials/features2d/feature_detection/feature_detection.rst
	doc/tutorials/features2d/feature_flann_matcher/feature_flann_matcher.rst
	doc/tutorials/features2d/feature_homography/feature_homography.rst
	modules/core/include/opencv2/core/operations.hpp
	modules/core/src/arithm.cpp
	modules/gpu/perf/perf_video.cpp
	modules/imgproc/include/opencv2/imgproc/imgproc.hpp
	modules/java/generator/gen_java.py
	modules/java/generator/src/cpp/VideoCapture.cpp
	modules/nonfree/src/opencl/surf.cl
	modules/ocl/include/opencv2/ocl/ocl.hpp
	modules/ocl/perf/perf_haar.cpp
	modules/ocl/perf/perf_precomp.hpp
	modules/ocl/src/color.cpp
	modules/ocl/src/filtering.cpp
	modules/ocl/test/test_color.cpp
	modules/ocl/test/test_objdetect.cpp
	modules/python/src2/cv2.cpp
	samples/gpu/CMakeLists.txt
	samples/gpu/super_resolution.cpp
This commit is contained in:
Roman Donchenko
2013-08-19 14:08:34 +04:00
148 changed files with 1855 additions and 2753 deletions

View File

@@ -12,7 +12,7 @@ class_ignore_list = (
#core
"FileNode", "FileStorage", "KDTree", "KeyPoint", "DMatch",
#highgui
"VideoWriter", "VideoCapture",
"VideoWriter",
)
const_ignore_list = (
@@ -510,6 +510,54 @@ JNIEXPORT jdoubleArray JNICALL Java_org_opencv_core_Core_n_1getTextSize
"resizeWindow" : {'j_code' : '', 'jn_code' : '', 'cpp_code' : '' },
}, # Highgui
'VideoCapture' :
{
"getSupportedPreviewSizes" :
{
'j_code' :
"""
public java.util.List<org.opencv.core.Size> getSupportedPreviewSizes()
{
String[] sizes_str = getSupportedPreviewSizes_0(nativeObj).split(",");
java.util.List<org.opencv.core.Size> sizes = new java.util.ArrayList<org.opencv.core.Size>(sizes_str.length);
for (String str : sizes_str) {
String[] wh = str.split("x");
sizes.add(new org.opencv.core.Size(Double.parseDouble(wh[0]), Double.parseDouble(wh[1])));
}
return sizes;
}
""",
'jn_code' :
"""\n private static native String getSupportedPreviewSizes_0(long nativeObj);\n""",
'cpp_code' :
"""
JNIEXPORT jstring JNICALL Java_org_opencv_highgui_VideoCapture_getSupportedPreviewSizes_10
(JNIEnv *env, jclass, jlong self);
JNIEXPORT jstring JNICALL Java_org_opencv_highgui_VideoCapture_getSupportedPreviewSizes_10
(JNIEnv *env, jclass, jlong self)
{
static const char method_name[] = "highgui::VideoCapture_getSupportedPreviewSizes_10()";
try {
LOGD(%s, method_name);
VideoCapture* me = (VideoCapture*) self; //TODO: check for NULL
union {double prop; const char* name;} u;
u.prop = me->get(CAP_PROP_ANDROID_PREVIEW_SIZES_STRING);
return env->NewStringUTF(u.name);
} catch(const std::exception &e) {
throwJavaException(env, &e, method_name);
} catch (...) {
throwJavaException(env, 0, method_name);
}
return env->NewStringUTF("");
}
""",
}, # getSupportedPreviewSizes
}, # VideoCapture
}
# { class : { func : { arg_name : {"ctype" : ctype, "attrib" : [attrib]} } } }
@@ -898,21 +946,51 @@ public class %(jc)s {
self.add_func(decl)
self.cpp_code = StringIO()
self.cpp_code.write("""
self.cpp_code.write(Template("""
//
// This file is auto-generated, please don't edit!
//
#define LOG_TAG "org.opencv.%(m)s"
#define LOG_TAG "org.opencv.$m"
#include "common.h"
#include "opencv2/%(m)s.hpp"
#include "opencv2/opencv_modules.hpp"
#ifdef HAVE_OPENCV_$M
#include <string>
#include "opencv2/$m.hpp"
using namespace cv;
/// throw java exception
static void throwJavaException(JNIEnv *env, const std::exception *e, const char *method) {
std::string what = "unknown exception";
jclass je = 0;
if(e) {
std::string exception_type = "std::exception";
if(dynamic_cast<const cv::Exception*>(e)) {
exception_type = "cv::Exception";
je = env->FindClass("org/opencv/core/CvException");
}
what = exception_type + ": " + e->what();
}
if(!je) je = env->FindClass("java/lang/Exception");
env->ThrowNew(je, what.c_str());
LOGE("%s caught %s", method, what.c_str());
(void)method; // avoid "unused" warning
}
extern "C" {
""" % {'m' : module} )
""").substitute( m = module, M = module.upper() ) )
# generate code for the classes
for name in self.classes.keys():
@@ -927,7 +1005,7 @@ extern "C" {
java_code = Template(java_code).substitute(imports = imports)
self.save("%s/%s+%s.java" % (output_path, module, self.classes[name].jname), java_code)
self.cpp_code.write( '\n} // extern "C"\n' )
self.cpp_code.write( '\n} // extern "C"\n\n#endif // HAVE_OPENCV_%s\n' % module.upper() )
self.save(output_path+"/"+module+".cpp", self.cpp_code.getvalue())
# report
@@ -1293,23 +1371,18 @@ JNIEXPORT $rtype JNICALL Java_org_opencv_${module}_${clazz}_$fname ($argst);
JNIEXPORT $rtype JNICALL Java_org_opencv_${module}_${clazz}_$fname
($args)
{
static const char method_name[] = "$module::$fname()";
try {
LOGD("$module::$fname()");
LOGD("%s", method_name);
$prologue
$retval$cvname( $cvargs );
$epilogue$ret
} catch(cv::Exception e) {
LOGD("$module::$fname() catched cv::Exception: %s", e.what());
jclass je = env->FindClass("org/opencv/core/CvException");
if(!je) je = env->FindClass("java/lang/Exception");
env->ThrowNew(je, e.what());
$default
} catch(const std::exception &e) {
throwJavaException(env, &e, method_name);
} catch (...) {
LOGD("$module::$fname() catched unknown exception (...)");
jclass je = env->FindClass("java/lang/Exception");
env->ThrowNew(je, "Unknown exception in JNI code {$module::$fname()}");
$default
throwJavaException(env, 0, method_name);
}
$default
}
@@ -1442,4 +1515,3 @@ if __name__ == "__main__":
#print "Generating module '" + module + "' from headers:\n\t" + "\n\t".join(srcfiles)
generator = JavaWrapperGenerator()
generator.gen(srcfiles, module, dstdir)