Created
June 9, 2016 23:48
-
-
Save shashachu/8d99b2f5315ae62d2422b93d26d82ebc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/card.io/build.gradle b/card.io/build.gradle | |
index 2e8b492..c36f952 100644 | |
--- a/card.io/build.gradle | |
+++ b/card.io/build.gradle | |
@@ -13,7 +13,6 @@ def getBuildVersion = { -> | |
ext { | |
sdkDir = android.plugin.sdkFolder | |
- ndkDir = android.plugin.ndkFolder | |
adb = new File("${sdkDir}/platform-tools/adb") | |
build_time = new Date().format("MM/dd/yyyy HH:mm:ss Z") | |
@@ -37,11 +36,6 @@ android { | |
testApplicationId 'io.card.development' | |
} | |
- sourceSets.main { | |
- jni.srcDirs = [] | |
- jniLibs.srcDir 'src/main/libs' | |
- } | |
- | |
buildTypes { | |
debug { | |
} | |
@@ -51,30 +45,6 @@ android { | |
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-build.cfg' | |
} | |
} | |
- | |
- task cleanNative(type: Exec, description: 'Clean JNI object files') { | |
- commandLine "$ndkDir/ndk-build", | |
- '-C', file('src/main/jni').absolutePath, | |
- 'clean' | |
- } | |
- clean.dependsOn cleanNative | |
- | |
- task buildNative(type: Exec, description: 'Compile JNI source via NDK') { | |
- commandLine "$ndkDir/ndk-build", | |
- '-C', file('src/main/jni').absolutePath, | |
- '-j', Runtime.runtime.availableProcessors(), | |
- 'all' | |
- } | |
- tasks.withType(JavaCompile) { | |
- compileTask -> compileTask.dependsOn buildNative | |
- } | |
- | |
- tasks.whenTaskAdded { theTask -> | |
- if (theTask.name == "packageReleaseJniLibs" | |
- || theTask.name == "packageDebugJniLibs") { | |
- theTask.dependsOn(buildNative) | |
- } | |
- } | |
} | |
dependencies { | |
diff --git a/card.io/src/main/java/io/card/payment/CardIOActivity.java b/card.io/src/main/java/io/card/payment/CardIOActivity.java | |
index f42755a..20fecdf 100644 | |
--- a/card.io/src/main/java/io/card/payment/CardIOActivity.java | |
+++ b/card.io/src/main/java/io/card/payment/CardIOActivity.java | |
@@ -201,6 +201,10 @@ public final class CardIOActivity extends Activity { | |
*/ | |
public static final String EXTRA_KEEP_APPLICATION_THEME = "io.card.payment.keepApplicationTheme"; | |
+ /** | |
+ * String extra. Optional. The additional path that should be searched for the native lib files. | |
+ */ | |
+ public static final String EXTRA_LIB_SEARCH_PATH = "io.card.payment.libSearchPath"; | |
/** | |
* Boolean extra. Used for testing only. | |
@@ -284,6 +288,8 @@ public final class CardIOActivity extends Activity { | |
static private int numActivityAllocations = 0; | |
+ public static String libSearchPath = null; | |
+ | |
private CardScanner mCardScanner; | |
private boolean manualEntryFallbackOrForced = false; | |
@@ -321,6 +327,8 @@ public final class CardIOActivity extends Activity { | |
final Intent clientData = this.getIntent(); | |
+ libSearchPath = clientData.getStringExtra(EXTRA_LIB_SEARCH_PATH); | |
+ | |
useApplicationTheme = getIntent().getBooleanExtra(CardIOActivity.EXTRA_KEEP_APPLICATION_THEME, false); | |
ActivityHelper.setActivityTheme(this, useApplicationTheme); | |
diff --git a/card.io/src/main/java/io/card/payment/CardScanner.java b/card.io/src/main/java/io/card/payment/CardScanner.java | |
index b9743cf..5feb49e 100644 | |
--- a/card.io/src/main/java/io/card/payment/CardScanner.java | |
+++ b/card.io/src/main/java/io/card/payment/CardScanner.java | |
@@ -11,9 +11,11 @@ import android.graphics.Rect; | |
import android.hardware.Camera; | |
import android.hardware.Camera.Parameters; | |
import android.hardware.Camera.Size; | |
+import android.os.Build; | |
import android.util.Log; | |
import android.view.SurfaceHolder; | |
+import java.io.File; | |
import java.io.IOException; | |
import java.lang.ref.WeakReference; | |
import java.util.HashMap; | |
@@ -116,26 +118,31 @@ class CardScanner implements Camera.PreviewCallback, Camera.AutoFocusCallback, | |
Log.i(Util.PUBLIC_LOG_TAG, "card.io " + BuildConfig.PRODUCT_VERSION + " " + BuildConfig.BUILD_TIME); | |
try { | |
- System.loadLibrary("cardioDecider"); | |
+ // This is pretty gross! | |
+ String searchPath = CardIOActivity.libSearchPath; | |
+ if (searchPath != null && searchPath.length() != 0 && !searchPath.endsWith("/")) { | |
+ searchPath += "/"; | |
+ } | |
+ tryLoadLibrary("cardioDecider", searchPath); | |
Log.d(Util.PUBLIC_LOG_TAG, "Loaded card.io decider library."); | |
Log.d(Util.PUBLIC_LOG_TAG, " nUseNeon(): " + nUseNeon()); | |
Log.d(Util.PUBLIC_LOG_TAG, " nUseTegra():" + nUseTegra()); | |
Log.d(Util.PUBLIC_LOG_TAG, " nUseX86(): " + nUseX86()); | |
if (usesSupportedProcessorArch()) { | |
- System.loadLibrary("opencv_core"); | |
+ tryLoadLibrary("opencv_core", searchPath); | |
Log.d(Util.PUBLIC_LOG_TAG, "Loaded opencv core library"); | |
- System.loadLibrary("opencv_imgproc"); | |
+ tryLoadLibrary("opencv_imgproc", searchPath); | |
Log.d(Util.PUBLIC_LOG_TAG, "Loaded opencv imgproc library"); | |
} | |
if (nUseNeon()) { | |
- System.loadLibrary("cardioRecognizer"); | |
+ tryLoadLibrary("cardioRecognizer", searchPath); | |
Log.i(Util.PUBLIC_LOG_TAG, "Loaded card.io NEON library"); | |
} else if (nUseX86()) { | |
- System.loadLibrary("cardioRecognizer"); | |
+ tryLoadLibrary("cardioRecognizer", searchPath); | |
Log.i(Util.PUBLIC_LOG_TAG, "Loaded card.io x86 library"); | |
} else if (nUseTegra()) { | |
- System.loadLibrary("cardioRecognizer_tegra2"); | |
+ tryLoadLibrary("cardioRecognizer_tegra2", searchPath); | |
Log.i(Util.PUBLIC_LOG_TAG, "Loaded card.io Tegra2 library"); | |
} else { | |
Log.w(Util.PUBLIC_LOG_TAG, | |
@@ -149,6 +156,7 @@ class CardScanner implements Camera.PreviewCallback, Camera.AutoFocusCallback, | |
} | |
} | |
+ | |
private static boolean usesSupportedProcessorArch() { | |
return nUseNeon() || nUseTegra() || nUseX86(); | |
} | |
@@ -169,6 +177,22 @@ class CardScanner implements Camera.PreviewCallback, Camera.AutoFocusCallback, | |
nSetup(mSuppressScan, MIN_FOCUS_SCORE); | |
} | |
+ private static void tryLoadLibrary(String libraryName, String searchPath) throws UnsatisfiedLinkError { | |
+ try { | |
+ System.loadLibrary(libraryName); | |
+ } catch (UnsatisfiedLinkError e) { | |
+ if (searchPath == null || searchPath.length() == 0) { | |
+ throw e; | |
+ } | |
+ String fullPath = searchPath + Build.CPU_ABI + File.separator + System.mapLibraryName(libraryName); | |
+ Log.d(Util.PUBLIC_LOG_TAG, "loadLibrary failed for library " + libraryName + | |
+ ". Trying " + fullPath); | |
+ // If we couldn't find the library in the normal places and we have an additional | |
+ // search path, try loading from there. | |
+ System.load(fullPath); | |
+ } | |
+ } | |
+ | |
/** | |
* Connect or reconnect to camera. If fails, sleeps and tries again. Returns <code>true</code> if successful, | |
* <code>false</code> if maxTimeout passes. | |
diff --git a/card.io/src/main/jni/Android.mk b/card.io/src/main/jni/Android.mk | |
deleted file mode 100644 | |
index 3283224..0000000 | |
--- a/card.io/src/main/jni/Android.mk | |
+++ /dev/null | |
@@ -1,111 +0,0 @@ | |
-# card.io Android NDK makefile | |
-# | |
-# See the file "LICENSE.md" for the full license governing this code. | |
-# | |
-# Builds three targets: | |
-# - Static library for ARMv7 with NEON vector coprocessor (most devices) | |
-# - Static library for ARMv7 without coprocessor. (NVidia Tegra2 processor, maybe others) | |
-# - Very small static library to help figure out compatibility & work around some Android 4.0 bugs. | |
- | |
-LOCAL_PATH := $(call my-dir) | |
-LOCAL_DMZ_DIR := card.io-dmz | |
- | |
-# --- declare opencv prebuilt static libs --------------------------------- | |
-ifneq (,$(filter $(TARGET_ARCH_ABI),armeabi-v7a x86 arm64-v8a x86_64)) | |
- | |
-include $(CLEAR_VARS) | |
-LOCAL_MODULE := opencv_core | |
-LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libopencv_core.so | |
-include $(PREBUILT_SHARED_LIBRARY) | |
- | |
-include $(CLEAR_VARS) | |
-LOCAL_MODULE := opencv_imgproc | |
-LOCAL_SRC_FILES := lib/$(TARGET_ARCH_ABI)/libopencv_imgproc.so | |
-LOCAL_SHARED_LIBRARIES := opencv_core | |
-include $(PREBUILT_SHARED_LIBRARY) | |
- | |
-endif | |
- | |
-# --- libcardioRecognizer.so -------------------------------------------------------- | |
-# (neon version) | |
- | |
-ifeq (1,1) | |
- | |
-include $(CLEAR_VARS) | |
-ifneq (,$(filter $(TARGET_ARCH_ABI),armeabi-v7a x86 arm64-v8a x86_64)) | |
- | |
-LOCAL_MODULE := cardioRecognizer | |
-LOCAL_LDLIBS := -llog -L$(SYSROOT)/usr/lib -lz -ljnigraphics | |
-LOCAL_SHARED_LIBRARIES := cpufeatures opencv_imgproc opencv_core | |
- | |
-LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(LOCAL_DMZ_DIR) $(LOCAL_PATH)/$(LOCAL_DMZ_DIR)/cv | |
-LOCAL_SRC_FILES := $(LOCAL_DMZ_DIR)/dmz_all.cpp nativeRecognizer.cpp | |
- | |
-LOCAL_CPPFLAGS := -DSCAN_EXPIRY=1 | |
- | |
-ifeq ($(TARGET_ARCH_ABI), armeabi-v7a) | |
-LOCAL_CPPFLAGS += -DANDROID_HAS_NEON=1 | |
-LOCAL_ARM_NEON := true | |
-endif | |
- | |
-ifneq (,$(filter $(TARGET_ARCH_ABI), arm64-v8a x86_64)) | |
-LOCAL_CFLAGS += -DANDROID_HAS_NEON=0 ## 64-bit changed register names - requires asm fixes | |
-endif | |
- | |
-include $(BUILD_SHARED_LIBRARY) | |
-endif | |
- | |
-endif | |
- | |
-# build tegra compatible lib | |
-# (no neon, limit to 16 VFP registers) | |
- | |
-ifeq (1,1) | |
- | |
-include $(CLEAR_VARS) | |
-ifneq (,$(filter $(TARGET_ARCH_ABI),armeabi-v7a x86 arm64-v8a x86_64)) | |
- | |
-LOCAL_MODULE := cardioRecognizer_tegra2 | |
-LOCAL_LDLIBS := -llog -L$(SYSROOT)/usr/lib -lz -ljnigraphics | |
-LOCAL_SHARED_LIBRARIES := cpufeatures opencv_imgproc opencv_core | |
- | |
-LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(LOCAL_DMZ_DIR) $(LOCAL_PATH)/$(LOCAL_DMZ_DIR)/cv | |
-LOCAL_SRC_FILES := $(LOCAL_DMZ_DIR)/dmz_all.cpp nativeRecognizer.cpp | |
- | |
-ifeq ($(TARGET_ARCH_ABI), x86) #we're generating an empty libcardioRecognizer_tegra2.so for x86 devices, so the list of .so files is the same for armeabi-v7a and x86 folders. This is to avoid any fallback to arm versions. | |
-LOCAL_C_INCLUDES := | |
-LOCAL_SRC_FILES := | |
-endif | |
- | |
-# Note: setting -mfloat-abi=hard will generate libs that cannot be linked with built in Android ones. So don't. | |
-LOCAL_CPPFLAGS := -DANDROID_HAS_NEON=0 -mfpu=vfpv3-d16 | |
-LOCAL_ARM_NEON := false | |
- | |
-include $(BUILD_SHARED_LIBRARY) | |
- | |
-endif | |
- | |
-endif | |
- | |
-# --- libcardioDecider.so ------------------------------------------------------------ | |
- | |
-ifneq (,$(filter $(TARGET_ARCH_ABI), armeabi armeabi-v7a mips x86 arm64-v8a x86_64)) | |
- | |
-include $(CLEAR_VARS) | |
- | |
-LOCAL_MODULE := cardioDecider | |
-LOCAL_LDLIBS := -llog | |
-LOCAL_SHARED_LIBRARIES := cpufeatures | |
- | |
-LOCAL_C_INCLUDES := $(LOCAL_PATH)/$(LOCAL_DMZ_DIR) | |
-LOCAL_SRC_FILES := $(LOCAL_DMZ_DIR)/processor_support.cpp nativeDecider.cpp | |
- | |
-LOCAL_CFLAGS := -DANDROID_DMZ=1 -DANDROID_HAS_NEON=1 | |
- | |
-include $(BUILD_SHARED_LIBRARY) | |
-endif | |
- | |
-# ------------ | |
- | |
-$(call import-module,android/cpufeatures) | |
- | |
diff --git a/card.io/src/main/jni/Application.mk b/card.io/src/main/jni/Application.mk | |
deleted file mode 100644 | |
index 8903d41..0000000 | |
--- a/card.io/src/main/jni/Application.mk | |
+++ /dev/null | |
@@ -1,27 +0,0 @@ | |
-# card.io Application.mk | |
-# | |
-# See the file "LICENSE.md" for the full license governing this code. | |
- | |
-APP_STL := gnustl_static | |
-APP_PLATFORM := android-8 | |
- | |
-NDK_TOOLCHAIN_VERSION := clang | |
- | |
-## RELEASE | |
- | |
-# Build both all native supported architectures... | |
-# BUT, we will make a runtime decision to use the vision module. | |
-APP_ABI := all | |
-APP_CFLAGS += -O3 | |
- | |
-## DEBUG | |
-#APP_ABI := armeabi-v7a | |
-#APP_CFLAGS += -UNDEBUG -O0 -g -ggdb | |
-#APP_OPTIM := debug | |
-#APP_CPPFLAGS += -DDMZ_DEBUG=1 | |
- | |
- | |
-# disable "mangling of 'va_list' has changed in GCC 4.4" warning. | |
-#APP_CFLAGS += -Wno-psabi | |
- | |
-APP_CPPFLAGS += -DANDROID_DMZ=1 | |
diff --git a/card.io/src/main/jni/README.md b/card.io/src/main/jni/README.md | |
deleted file mode 100644 | |
index 5af8f4b..0000000 | |
--- a/card.io/src/main/jni/README.md | |
+++ /dev/null | |
@@ -1,24 +0,0 @@ | |
-# Native layer | |
- | |
-The core computer vision code is in the DMZ, and is shared across iOS and Android. | |
- | |
-## Architectures | |
- | |
-Android has the unique feature of offering multiple processors, each with potentially different configurations. | |
- | |
-For the ARM architecture we support ARMv7a processors, both with NEON and VFPv3-d16 configurations. NEON SIMD configurations are a superset of VFPv3. NEON configurations have 32 VFP registers, while other non-NEON (notably those based on nVidia Tegra2) have only 16 VFP registers. Since we want the performance provided by NEON (if available), we ship two versions of our native layer. Our libs use OpenCV, but only lightly, so both link to shared VFPv3-d16 OpenCV libraries. | |
- | |
-## OpenCV | |
- | |
-Compiled OpenCV libs (libopencv_core.so and libopencv_imgproc.so) are kept in git, so rebuilding OpenCV is not strictly necessary. However, should you wish to do so, simply run 'card.io-Android-source/opencv/build_opencv.sh'. The script will, if necessary, download, build, install the libs into their place in 'card.io-Android-source/card.io/src/main/jni'. | |
- | |
-## Building | |
- | |
-### Prerequisites | |
- | |
-- Android NDK tools installed. | |
-- Clang toolchain | |
- | |
-### Compile | |
- | |
-If everything is set up properly, the NDK build will be invoked by gradle when card.io is built. But for debugging, you can use `./gradlew buildNative` to kick off just this portion of the build. | |
\ No newline at end of file | |
diff --git a/card.io/src/main/jni/card.io-dmz b/card.io/src/main/jni/card.io-dmz | |
deleted file mode 160000 | |
index 2efa16c..0000000 | |
--- a/card.io/src/main/jni/card.io-dmz | |
+++ /dev/null | |
@@ -1 +0,0 @@ | |
-Subproject commit 2efa16c5792fda1ee6351b67961b17608ad7514c | |
diff --git a/card.io/src/main/jni/glesExperimental.cpp b/card.io/src/main/jni/glesExperimental.cpp | |
deleted file mode 100644 | |
index 83ca778..0000000 | |
--- a/card.io/src/main/jni/glesExperimental.cpp | |
+++ /dev/null | |
@@ -1,101 +0,0 @@ | |
- | |
-/* glesExperimental.cpp | |
- * See the file "LICENSE.md" for the full license governing this code. | |
- */ | |
- | |
-#include <jni.h> | |
-#include <android/log.h> | |
-#include "dmz/dmz.h" | |
-#include "dmz/dmz_debug.h" | |
-#include "dmz/processor_support.h" | |
-#include "dmz/cv/warp.h" | |
-#include "opencv2/core/core_c.h" // needed for IplImage | |
- | |
-#define DEBUG_TAG "card.io native experimental" | |
- | |
-JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { | |
- return JNI_VERSION_1_6; | |
-} | |
- | |
-extern "C" | |
-JNIEXPORT void JNICALL Java_io_card_development_NativeGLESWarp_nSetup(JNIEnv *env, jobject thiz, jint width, jint height) { | |
- llcv_gles_setup(kCreditCardTargetWidth, kCreditCardTargetHeight); | |
-} | |
- | |
-extern "C" | |
-JNIEXPORT jint JNICALL Java_io_card_development_NativeGLESWarp_nCardWidth(JNIEnv *env, jobject thiz) { | |
- return kCreditCardTargetWidth; | |
-} | |
- | |
-extern "C" | |
-JNIEXPORT jint JNICALL Java_io_card_development_NativeGLESWarp_nCardHeight(JNIEnv *env, jobject thiz) { | |
- return kCreditCardTargetHeight; | |
-} | |
- | |
-extern "C" | |
-JNIEXPORT jboolean JNICALL Java_io_card_development_NativeGLESWarp_nWarp(JNIEnv *env, jobject thiz, | |
- jbyteArray jbImage, jint width, jint height, jintArray jCorners, jobject dinfo, jstring dInfoClassName) | |
-{ | |
- jint *jCornerBytes = env->GetIntArrayElements(jCorners, 0); | |
- | |
- IplImage *image = cvCreateImageHeader(cvSize(width, height), IPL_DEPTH_8U, 4); | |
- | |
- jbyte *jBytes = env->GetByteArrayElements(jbImage, 0); | |
- image->imageData = (char *)jBytes; | |
- | |
- IplImage *card = cvCreateImage( cvSize(kCreditCardTargetWidth, kCreditCardTargetHeight), IPL_DEPTH_8U, 4 ); | |
- | |
- CvPoint2D32f corners[4]; | |
- for (int i = 0; i < 4; i++) { | |
- corners[i].x = (float)jCornerBytes[2 * i + 0]; | |
- corners[i].y = (float)jCornerBytes[2 * i + 1]; | |
- } | |
- | |
- llcv_warp_perspective(image, corners, NULL, card); | |
- | |
- int size = card->width * card->height * card->nChannels; | |
- | |
- dmz_debug_log("need array sized %i x %i x %i (%i)", card->width, card->height, card->nChannels, size); | |
- | |
- jclass clazz; | |
- jfieldID fid; | |
- | |
- const char *nativeDInfoClassName = env->GetStringUTFChars(dInfoClassName, 0); | |
- clazz = env->FindClass(nativeDInfoClassName); | |
- env->ReleaseStringUTFChars(dInfoClassName, nativeDInfoClassName); | |
- | |
- if (clazz) { | |
- fid = env->GetFieldID(clazz, "cardImageWidth", "I"); | |
- if (fid) { | |
- env->SetIntField(dinfo, fid, card->width); | |
- } | |
- | |
- fid = env->GetFieldID(clazz, "cardImageHeight", "I"); | |
- if (fid) { | |
- env->SetIntField(dinfo, fid, card->height); | |
- } | |
- | |
- fid = env->GetFieldID(clazz, "cardImageRGB", "[B"); | |
- if (fid) { | |
- dmz_debug_log("- card->nSize: %d", card->nSize); | |
- dmz_debug_log("- card->width: %d", card->width); | |
- dmz_debug_log("- card->height: %d", card->height); | |
- dmz_debug_log("- card->nChannels: %d", card->nChannels); | |
- dmz_debug_log("- card->depth: %d", card->depth); | |
- | |
- jbyteArray jb = env->NewByteArray(size); | |
- env->SetByteArrayRegion(jb, 0, size, (jbyte *)card->imageData); | |
- env->SetObjectField(dinfo, fid, jb); | |
- } | |
- | |
- } | |
- cvReleaseImageHeader(&image); | |
- cvReleaseImage(&card); | |
- | |
- return (jboolean) true; | |
-} | |
- | |
-extern "C" | |
-JNIEXPORT void JNICALL Java_io_card_development_NativeGLESWarp_nCleanup(JNIEnv *env, jobject thiz) { | |
- llcv_gles_teardown(); | |
-} | |
diff --git a/card.io/src/main/jni/lib/arm64-v8a/libopencv_core.so b/card.io/src/main/jni/lib/arm64-v8a/libopencv_core.so | |
deleted file mode 100755 | |
index ff7bc70..0000000 | |
Binary files a/card.io/src/main/jni/lib/arm64-v8a/libopencv_core.so and /dev/null differ | |
diff --git a/card.io/src/main/jni/lib/arm64-v8a/libopencv_imgproc.so b/card.io/src/main/jni/lib/arm64-v8a/libopencv_imgproc.so | |
deleted file mode 100755 | |
index c557ac3..0000000 | |
Binary files a/card.io/src/main/jni/lib/arm64-v8a/libopencv_imgproc.so and /dev/null differ | |
diff --git a/card.io/src/main/jni/lib/armeabi-v7a/libopencv_core.so b/card.io/src/main/jni/lib/armeabi-v7a/libopencv_core.so | |
deleted file mode 100755 | |
index 3d33242..0000000 | |
Binary files a/card.io/src/main/jni/lib/armeabi-v7a/libopencv_core.so and /dev/null differ | |
diff --git a/card.io/src/main/jni/lib/armeabi-v7a/libopencv_imgproc.so b/card.io/src/main/jni/lib/armeabi-v7a/libopencv_imgproc.so | |
deleted file mode 100755 | |
index 08b9645..0000000 | |
Binary files a/card.io/src/main/jni/lib/armeabi-v7a/libopencv_imgproc.so and /dev/null differ | |
diff --git a/card.io/src/main/jni/lib/x86/libopencv_core.so b/card.io/src/main/jni/lib/x86/libopencv_core.so | |
deleted file mode 100755 | |
index 85d70e5..0000000 | |
Binary files a/card.io/src/main/jni/lib/x86/libopencv_core.so and /dev/null differ | |
diff --git a/card.io/src/main/jni/lib/x86/libopencv_imgproc.so b/card.io/src/main/jni/lib/x86/libopencv_imgproc.so | |
deleted file mode 100755 | |
index b98b492..0000000 | |
Binary files a/card.io/src/main/jni/lib/x86/libopencv_imgproc.so and /dev/null differ | |
diff --git a/card.io/src/main/jni/lib/x86_64/libopencv_core.so b/card.io/src/main/jni/lib/x86_64/libopencv_core.so | |
deleted file mode 100755 | |
index 1fb24b6..0000000 | |
Binary files a/card.io/src/main/jni/lib/x86_64/libopencv_core.so and /dev/null differ | |
diff --git a/card.io/src/main/jni/lib/x86_64/libopencv_imgproc.so b/card.io/src/main/jni/lib/x86_64/libopencv_imgproc.so | |
deleted file mode 100755 | |
index 3f43f86..0000000 | |
Binary files a/card.io/src/main/jni/lib/x86_64/libopencv_imgproc.so and /dev/null differ | |
diff --git a/card.io/src/main/jni/nativeDecider.cpp b/card.io/src/main/jni/nativeDecider.cpp | |
deleted file mode 100644 | |
index 2277dbd..0000000 | |
--- a/card.io/src/main/jni/nativeDecider.cpp | |
+++ /dev/null | |
@@ -1,31 +0,0 @@ | |
- | |
-/* nativeDecider.cpp | |
- * See the file "LICENSE.md" for the full license governing this code. | |
- */ | |
- | |
-#include <jni.h> | |
- | |
-#include "processor_support.h" | |
- | |
-#define DEBUG_TAG "native" | |
- | |
-extern "C" | |
-JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { | |
- return JNI_VERSION_1_6; | |
-} | |
- | |
-extern "C" jboolean JNICALL Java_io_card_payment_CardScanner_nUseNeon() { | |
- return (dmz_has_neon_runtime()); | |
-} | |
- | |
-extern "C" jboolean JNICALL Java_io_card_payment_CardScanner_nUseTegra() { | |
- return (dmz_use_vfp3_16()); | |
-} | |
- | |
-extern "C" jboolean JNICALL Java_io_card_payment_CardScanner_nUseX86() { | |
-#if defined __i386__ || defined __x86_64__ | |
- return true; | |
-#else | |
- return false; | |
-#endif | |
-} | |
\ No newline at end of file | |
diff --git a/card.io/src/main/jni/nativeRecognizer.cpp b/card.io/src/main/jni/nativeRecognizer.cpp | |
deleted file mode 100644 | |
index 3a0ce6e..0000000 | |
--- a/card.io/src/main/jni/nativeRecognizer.cpp | |
+++ /dev/null | |
@@ -1,386 +0,0 @@ | |
- | |
-/* nativeRecognizer.java | |
- * See the file "LICENSE.md" for the full license governing this code. | |
- */ | |
- | |
-#include <stdio.h> | |
-#include <string.h> | |
-#include <jni.h> | |
-#include <android/log.h> | |
-#include <android/bitmap.h> | |
- | |
-#include "opencv2/core/core_c.h" | |
-#include "opencv2/imgproc/imgproc_c.h" | |
- | |
-#include "dmz.h" | |
-#include "processor_support.h" | |
-#include "dmz_debug.h" | |
-#include "cv/warp.h" | |
- | |
-#include "scan/scan.h" | |
- | |
-#define DEBUG_TAG "card.io native" | |
- | |
-static dmz_context* dmz = NULL; | |
-static int dmz_refcount = 0; | |
- | |
-static ScannerState scannerState; | |
-static bool detectOnly; | |
-static bool flipped; | |
-static bool lastFrameWasUsable; | |
-static float minFocusScore; | |
- | |
-static struct { | |
- jclass classRef; | |
- jfieldID top; | |
- jfieldID bottom; | |
- jfieldID left; | |
- jfieldID right; | |
-} rectId; | |
- | |
-static struct { | |
- jclass classRef; | |
- jfieldID complete; | |
- jfieldID topEdge; | |
- jfieldID bottomEdge; | |
- jfieldID leftEdge; | |
- jfieldID rightEdge; | |
- jfieldID focusScore; | |
- jfieldID prediction; | |
- jfieldID expiry_month; | |
- jfieldID expiry_year; | |
- jfieldID detectedCard; | |
-} detectionInfoId; | |
- | |
-static struct { | |
- jclass classRef; | |
- jfieldID flipped; | |
- jfieldID yoff; | |
- jfieldID xoff; | |
-} creditCardId; | |
- | |
-static struct { | |
- jclass classRef; | |
- jmethodID edgeUpdateCallback; | |
-} cardScannerId; | |
- | |
-extern "C" | |
-JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) { | |
- JNIEnv* env; | |
- jint status = vm->GetEnv( (void**) &env, JNI_VERSION_1_6); | |
- if (status != JNI_OK) | |
- return -1; | |
- | |
- /* find class ref and field IDs. | |
- * class refs must be explicitly stated as global. | |
- * field IDs could change with a new classloader, but this method will get called in that case. | |
- * see http://www.milk.com/kodebase/dalvik-docs-mirror/docs/jni-tips.html | |
- */ | |
- | |
- jclass myClass = env->FindClass("io/card/payment/CardScanner"); | |
- if (!myClass) { | |
- dmz_error_log("Couldn't find CardScanner from JNI"); | |
- return -1; | |
- } | |
- cardScannerId.classRef = (jclass)env->NewGlobalRef(myClass); | |
- cardScannerId.edgeUpdateCallback = env->GetMethodID(myClass, "onEdgeUpdate", "(Lio/card/payment/DetectionInfo;)V"); | |
- if (!cardScannerId.edgeUpdateCallback) { | |
- dmz_error_log("Couldn't find edge update callback"); | |
- return -1; | |
- } | |
- | |
- jclass rectClass = env->FindClass("android/graphics/Rect"); | |
- if (!rectClass) { | |
- dmz_error_log("Couldn't find Rect class"); | |
- return -1; | |
- } | |
- rectId.classRef = (jclass)env->NewGlobalRef(rectClass); | |
- rectId.top = env->GetFieldID(rectClass, "top", "I"); | |
- rectId.bottom = env->GetFieldID(rectClass, "bottom", "I"); | |
- rectId.left = env->GetFieldID(rectClass, "left", "I"); | |
- rectId.right = env->GetFieldID(rectClass, "right", "I"); | |
- | |
- if (!(rectId.top && rectId.bottom && rectId.left && rectId.right)) { | |
- dmz_error_log("Couldn't find square class"); | |
- return -1; | |
- } | |
- | |
- jclass creditCardClass = (jclass)env->FindClass("io/card/payment/CreditCard"); | |
- if (creditCardClass == NULL) { | |
- dmz_error_log("Couldn't find CreditCard class"); | |
- return -1; | |
- } | |
- creditCardId.classRef = (jclass)env->NewGlobalRef(creditCardClass); | |
- creditCardId.flipped = env->GetFieldID(creditCardClass, "flipped", "Z"); | |
- creditCardId.yoff = env->GetFieldID(creditCardClass, "yoff", "I"); | |
- creditCardId.xoff = env->GetFieldID(creditCardClass, "xoff", "[I"); | |
- if (!( creditCardId.flipped && creditCardId.yoff && creditCardId.xoff )) { | |
- dmz_error_log("at least one filed was not found for CreditCard"); | |
- return -1; | |
- } | |
- | |
- jclass dInfoClass = env->FindClass("io/card/payment/DetectionInfo"); | |
- if (dInfoClass == NULL) { | |
- dmz_error_log("Couldn't find DetectionInfo class"); | |
- return -1; | |
- } | |
- detectionInfoId.classRef = (jclass)env->NewGlobalRef(dInfoClass); | |
- detectionInfoId.complete = env->GetFieldID(dInfoClass, "complete", "Z"); | |
- detectionInfoId.topEdge = env->GetFieldID(dInfoClass, "topEdge", "Z"); | |
- detectionInfoId.bottomEdge = env->GetFieldID(dInfoClass, "bottomEdge", "Z"); | |
- detectionInfoId.leftEdge = env->GetFieldID(dInfoClass, "leftEdge", "Z"); | |
- detectionInfoId.rightEdge = env->GetFieldID(dInfoClass, "rightEdge", "Z"); | |
- detectionInfoId.focusScore = env->GetFieldID(dInfoClass, "focusScore", "F"); | |
- detectionInfoId.prediction = env->GetFieldID(dInfoClass, "prediction", "[I"); | |
- detectionInfoId.expiry_month = env->GetFieldID(dInfoClass, "expiry_month", "I"); | |
- detectionInfoId.expiry_year = env->GetFieldID(dInfoClass, "expiry_year", "I"); | |
- detectionInfoId.detectedCard = env->GetFieldID(dInfoClass, "detectedCard", "Lio/card/payment/CreditCard;"); | |
- | |
- if (!(detectionInfoId.complete && detectionInfoId.topEdge && detectionInfoId.bottomEdge | |
- && detectionInfoId.leftEdge && detectionInfoId.rightEdge | |
- && detectionInfoId.focusScore && detectionInfoId.prediction | |
- && detectionInfoId.expiry_month && detectionInfoId.expiry_year | |
- && detectionInfoId.detectedCard | |
- )) { | |
- dmz_error_log("at least one field was not found for DetectionInfo"); | |
- return -1; | |
- } | |
- | |
- return JNI_VERSION_1_6; | |
-} | |
- | |
-extern "C" | |
-JNIEXPORT void JNICALL Java_io_card_payment_CardScanner_nSetup(JNIEnv *env, jobject thiz, | |
- jboolean shouldOnlyDetectCard, jfloat jMinFocusScore) { | |
- dmz_debug_log("Java_io_card_payment_CardScanner_nSetup"); | |
- dmz_trace_log("dmz trace enabled"); | |
- | |
- | |
- detectOnly = shouldOnlyDetectCard; | |
- minFocusScore = jMinFocusScore; | |
- flipped = false; | |
- lastFrameWasUsable = false; | |
- | |
- if (dmz == NULL) { | |
- dmz = dmz_context_create(); | |
- scanner_initialize(&scannerState); | |
- } | |
- else { | |
- scanner_reset(&scannerState); | |
- } | |
- dmz_refcount++; | |
- | |
- cvSetErrMode(CV_ErrModeParent); | |
-} | |
- | |
-extern "C" | |
-JNIEXPORT void JNICALL Java_io_card_payment_CardScanner_nResetAnalytics(JNIEnv *env, jobject thiz) { | |
- scanner_reset(&scannerState); | |
-} | |
- | |
-extern "C" | |
-JNIEXPORT void JNICALL Java_io_card_payment_CardScanner_nCleanup(JNIEnv *env, jobject thiz) { | |
- dmz_debug_log("Java_io_card_payment_CardScanner_nCleanup"); | |
- | |
- if (dmz_refcount == 1) { | |
- scanner_destroy(&scannerState); | |
- dmz_context_destroy(dmz); | |
- dmz = NULL; | |
- } | |
- dmz_refcount--; | |
-} | |
- | |
-extern "C" | |
-JNIEXPORT void JNICALL Java_io_card_payment_CardScanner_nGetGuideFrame(JNIEnv *env, jobject thiz, | |
- jint orientation, jint width, jint height, jobject rect) | |
-{ | |
- dmz_trace_log("Java_io_card_payment_CardScanner_nGetGuideFrame"); | |
- | |
- dmz_rect dr = dmz_guide_frame(orientation, width, height); | |
- | |
- env->SetIntField(rect, rectId.top, dr.y); | |
- env->SetIntField(rect, rectId.left, dr.x); | |
- env->SetIntField(rect, rectId.bottom, dr.y + dr.h); | |
- env->SetIntField(rect, rectId.right, dr.x + dr.w); | |
-} | |
- | |
-void updateEdgeDetectDisplay(JNIEnv* env, jobject thiz, jobject dinfo, dmz_edges found_edges) { | |
- env->SetBooleanField(dinfo, detectionInfoId.topEdge, found_edges.top.found); | |
- env->SetBooleanField(dinfo, detectionInfoId.bottomEdge, found_edges.bottom.found); | |
- env->SetBooleanField(dinfo, detectionInfoId.leftEdge, found_edges.left.found); | |
- env->SetBooleanField(dinfo, detectionInfoId.rightEdge, found_edges.right.found); | |
- | |
- env->CallVoidMethod(thiz, cardScannerId.edgeUpdateCallback, dinfo); | |
-} | |
- | |
-void setScanCardNumberResult(JNIEnv* env, jobject dinfo, ScannerResult* scanResult) { | |
- | |
- jint numbers[16]; | |
- jint offsets[16]; | |
- for (int i = 0; i < scanResult->n_numbers; i++) { | |
- numbers[i] = scanResult->predictions(i); | |
- dmz_debug_log("prediction[%i]= %i", i, scanResult->predictions(i)); | |
- offsets[i] = scanResult->hseg.offsets[i]; | |
- dmz_debug_log("offsets[%i]= %i", i, scanResult->hseg.offsets[i]); | |
- } | |
- | |
- jobject digitArray = env->GetObjectField(dinfo, detectionInfoId.prediction); | |
- dmz_debug_log("setting prediction array region"); | |
- env->SetIntArrayRegion((jintArray)digitArray, 0, scanResult->n_numbers, numbers); | |
- | |
- jobject cardObj = env->GetObjectField(dinfo, detectionInfoId.detectedCard); | |
- dmz_debug_log("got cardObj: %x", cardObj); | |
- env->SetIntField(cardObj, creditCardId.yoff, scanResult->vseg.y_offset); | |
- | |
- jobject xoffArray = env->GetObjectField(cardObj, creditCardId.xoff); | |
- dmz_debug_log("setting xoffset array region: %x", xoffArray); | |
- env->SetIntArrayRegion((jintArray)xoffArray, 0, scanResult->n_numbers, offsets); | |
- | |
- dmz_debug_log("setting expiry to %i/%i", scanResult->expiry_month, scanResult->expiry_year); | |
- env->SetIntField(dinfo, detectionInfoId.expiry_month, scanResult->expiry_month); | |
- env->SetIntField(dinfo, detectionInfoId.expiry_year, scanResult->expiry_year); | |
- | |
- dmz_debug_log("setting detectionInfoId.complete=true"); | |
- env->SetBooleanField(dinfo, detectionInfoId.complete, true); | |
- | |
- dmz_debug_log("done in setScanCardNumberResult()"); | |
-} | |
- | |
-void logDinfo(JNIEnv* env, jobject dinfo) { | |
- dmz_debug_log("dinfo: complete=%i", env->GetBooleanField(dinfo, detectionInfoId.complete)); | |
- | |
- jintArray digitArray = (jintArray) env->GetObjectField(dinfo, detectionInfoId.prediction); | |
- dmz_debug_log("dinfo: prediction[0-3]=%i%i%i%i...", | |
- env->GetIntArrayElements(digitArray, NULL)[0], | |
- env->GetIntArrayElements(digitArray, NULL)[1], | |
- env->GetIntArrayElements(digitArray, NULL)[2], | |
- env->GetIntArrayElements(digitArray, NULL)[3]); | |
-} | |
- | |
-void setDetectedCardImage(JNIEnv* env, jobject jCardResultBitmap, IplImage* cardY, IplImage* cb, IplImage* cr, | |
- dmz_corner_points corner_points, int orientation) { | |
- | |
- char* pixels = NULL; | |
- | |
- AndroidBitmapInfo bmInfo; | |
- int bmRes = AndroidBitmap_getInfo(env, jCardResultBitmap, &bmInfo); | |
- // Yes, it really is defined as _RESUT_ ... figures. <sigh> | |
- bool validCardInfo = (bmRes == ANDROID_BITMAP_RESUT_SUCCESS); | |
- if (!validCardInfo) { | |
- dmz_error_log("AndroidBitmap_getInfo() failed! error=%i", bmRes); | |
- } | |
- if (validCardInfo && bmInfo.format != ANDROID_BITMAP_FORMAT_RGBA_8888) { | |
- dmz_error_log("the dmz was given a bitmap that is not RGBA_8888"); | |
- validCardInfo = false; | |
- } | |
- | |
- bmRes = AndroidBitmap_lockPixels(env, jCardResultBitmap, (void**) &pixels ); | |
- if (bmRes != ANDROID_BITMAP_RESUT_SUCCESS) { | |
- dmz_error_log("couldn't lock bitmap:%i", bmRes); | |
- } | |
- else { | |
- IplImage* bigCb = NULL; | |
- dmz_transform_card(NULL, cb, corner_points, orientation, true, &bigCb); | |
- | |
- IplImage* bigCr = NULL; | |
- dmz_transform_card(NULL, cr, corner_points, orientation, true, &bigCr); | |
- | |
- IplImage* cardResult = cvCreateImageHeader(cvSize(bmInfo.width, bmInfo.height), IPL_DEPTH_8U, 4); | |
- cvSetData(cardResult, pixels, bmInfo.stride); | |
- | |
- dmz_YCbCr_to_RGB(cardY, bigCb, bigCr, &cardResult); | |
- AndroidBitmap_unlockPixels(env, jCardResultBitmap); | |
- | |
- cvReleaseImageHeader(&cardResult); | |
- cvReleaseImage(&bigCb); | |
- cvReleaseImage(&bigCr); | |
- } | |
-} | |
- | |
-/* This method forms the core of card.io scanning. All others (nCardDetected & nGetFocusScore) */ | |
-extern "C" | |
-JNIEXPORT void JNICALL Java_io_card_payment_CardScanner_nScanFrame(JNIEnv *env, jobject thiz, | |
- jbyteArray jb, jint width, jint height, jint orientation, jobject dinfo, | |
- jobject jCardResultBitmap, jboolean jScanExpiry) { | |
- dmz_trace_log("Java_io_card_payment_CardScanner_nScanFrame ... width:%i height:%i orientation:%i", width, height, orientation); | |
- | |
- if (orientation == 0) { | |
- dmz_error_log("orientation is 0. Nothing good can come from this."); | |
- return; | |
- } | |
- | |
- if (flipped) { | |
- orientation = dmz_opposite_orientation(orientation); | |
- } | |
- | |
- FrameScanResult result; | |
- | |
- IplImage *image = cvCreateImageHeader(cvSize(width, height), IPL_DEPTH_8U, 1); | |
- jbyte *jBytes = env->GetByteArrayElements(jb, 0); | |
- image->imageData = (char *)jBytes; | |
- | |
- float focusScore = dmz_focus_score(image, false); | |
- env->SetFloatField(dinfo, detectionInfoId.focusScore, focusScore); | |
- dmz_trace_log("focus score: %f", focusScore); | |
- if (focusScore >= minFocusScore) { | |
- | |
- IplImage *cbcr = cvCreateImageHeader(cvSize(width / 2, height / 2), IPL_DEPTH_8U, 2); | |
- cbcr->imageData = ((char *)jBytes) + width * height; | |
- IplImage *cb, *cr; | |
- | |
- // Note: cr and cb are reversed here because Android uses android.graphics.ImageFormat.NV21. This is actually YCrCb rather than YCbCr! | |
- dmz_deinterleave_uint8_c2(cbcr, &cr, &cb); | |
- | |
- cvReleaseImageHeader(&cbcr); | |
- | |
- dmz_edges found_edges; | |
- dmz_corner_points corner_points; | |
- bool cardDetected = dmz_detect_edges(image, cb, cr, | |
- orientation, | |
- &found_edges, &corner_points | |
- ); | |
- | |
- updateEdgeDetectDisplay(env, thiz, dinfo, found_edges); | |
- | |
- if (cardDetected) { | |
- IplImage *cardY = NULL; | |
- dmz_transform_card(NULL, image, corner_points, orientation, false, &cardY); | |
- | |
- if (!detectOnly) { | |
- result.focus_score = focusScore; | |
- result.flipped = flipped; | |
- scanner_add_frame_with_expiry(&scannerState, cardY, jScanExpiry, &result); | |
- if (result.usable) { | |
- ScannerResult scanResult; | |
- scanner_result(&scannerState, &scanResult); | |
- | |
- if (scanResult.complete) { | |
- setScanCardNumberResult(env, dinfo, &scanResult); | |
- logDinfo(env, dinfo); | |
- } | |
- } | |
- else if (result.upside_down) { | |
- flipped = !flipped; | |
- } | |
- } | |
- | |
- setDetectedCardImage(env, jCardResultBitmap, cardY, cb, cr, corner_points, orientation); | |
- cvReleaseImage(&cardY); | |
- } | |
- | |
- cvReleaseImage(&cb); | |
- cvReleaseImage(&cr); | |
- } | |
- | |
- cvReleaseImageHeader(&image); | |
- env->ReleaseByteArrayElements(jb, jBytes, 0); | |
-} | |
- | |
-extern "C" | |
-JNIEXPORT jint JNICALL Java_io_card_payment_CardScanner_nGetNumFramesScanned(JNIEnv *env, jobject thiz) { | |
- return scannerState.session_analytics.num_frames_scanned; | |
-} | |
- | |
- | |
- | |
- | |
diff --git a/card.io/src/main/jni/opencv2/core/core.hpp b/card.io/src/main/jni/opencv2/core/core.hpp | |
deleted file mode 100644 | |
index a2bb752..0000000 | |
--- a/card.io/src/main/jni/opencv2/core/core.hpp | |
+++ /dev/null | |
@@ -1,4582 +0,0 @@ | |
-/*! \file core.hpp | |
- \brief The Core Functionality | |
- */ | |
-/*M/////////////////////////////////////////////////////////////////////////////////////// | |
-// | |
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. | |
-// | |
-// By downloading, copying, installing or using the software you agree to this license. | |
-// If you do not agree to this license, do not download, install, | |
-// copy or use the software. | |
-// | |
-// | |
-// License Agreement | |
-// For Open Source Computer Vision Library | |
-// | |
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. | |
-// Copyright (C) 2009-2011, Willow Garage Inc., all rights reserved. | |
-// Third party copyrights are property of their respective owners. | |
-// | |
-// Redistribution and use in source and binary forms, with or without modification, | |
-// are permitted provided that the following conditions are met: | |
-// | |
-// * Redistribution's of source code must retain the above copyright notice, | |
-// this list of conditions and the following disclaimer. | |
-// | |
-// * Redistribution's in binary form must reproduce the above copyright notice, | |
-// this list of conditions and the following disclaimer in the documentation | |
-// and/or other materials provided with the distribution. | |
-// | |
-// * The name of the copyright holders may not be used to endorse or promote products | |
-// derived from this software without specific prior written permission. | |
-// | |
-// This software is provided by the copyright holders and contributors "as is" and | |
-// any express or implied warranties, including, but not limited to, the implied | |
-// warranties of merchantability and fitness for a particular purpose are disclaimed. | |
-// In no event shall the Intel Corporation or contributors be liable for any direct, | |
-// indirect, incidental, special, exemplary, or consequential damages | |
-// (including, but not limited to, procurement of substitute goods or services; | |
-// loss of use, data, or profits; or business interruption) however caused | |
-// and on any theory of liability, whether in contract, strict liability, | |
-// or tort (including negligence or otherwise) arising in any way out of | |
-// the use of this software, even if advised of the possibility of such damage. | |
-// | |
-//M*/ | |
- | |
-#ifndef __OPENCV_CORE_HPP__ | |
-#define __OPENCV_CORE_HPP__ | |
- | |
-#include "opencv2/core/types_c.h" | |
-#include "opencv2/core/version.hpp" | |
- | |
-#ifdef __cplusplus | |
- | |
-#ifndef SKIP_INCLUDES | |
-#include <limits.h> | |
-#include <algorithm> | |
-#include <cmath> | |
-#include <cstddef> | |
-#include <complex> | |
-#include <map> | |
-#include <new> | |
-#include <string> | |
-#include <vector> | |
-#include <sstream> | |
-#endif // SKIP_INCLUDES | |
- | |
-/*! \namespace cv | |
- Namespace where all the C++ OpenCV functionality resides | |
-*/ | |
-namespace cv { | |
- | |
-#undef abs | |
-#undef min | |
-#undef max | |
-#undef Complex | |
- | |
-using std::vector; | |
-using std::string; | |
-using std::ptrdiff_t; | |
- | |
-template<typename _Tp> class CV_EXPORTS Size_; | |
-template<typename _Tp> class CV_EXPORTS Point_; | |
-template<typename _Tp> class CV_EXPORTS Rect_; | |
-template<typename _Tp, int cn> class CV_EXPORTS Vec; | |
-template<typename _Tp, int m, int n> class CV_EXPORTS Matx; | |
- | |
-typedef std::string String; | |
-typedef std::basic_string<wchar_t> WString; | |
- | |
-class Mat; | |
-class SparseMat; | |
-typedef Mat MatND; | |
- | |
-class GlBuffer; | |
-class GlTexture; | |
-class GlArrays; | |
-class GlCamera; | |
- | |
-namespace gpu { | |
- class GpuMat; | |
-} | |
- | |
-class CV_EXPORTS MatExpr; | |
-class CV_EXPORTS MatOp_Base; | |
-class CV_EXPORTS MatArg; | |
-class CV_EXPORTS MatConstIterator; | |
- | |
-template<typename _Tp> class CV_EXPORTS Mat_; | |
-template<typename _Tp> class CV_EXPORTS MatIterator_; | |
-template<typename _Tp> class CV_EXPORTS MatConstIterator_; | |
-template<typename _Tp> class CV_EXPORTS MatCommaInitializer_; | |
- | |
-CV_EXPORTS string fromUtf16(const WString& str); | |
-CV_EXPORTS WString toUtf16(const string& str); | |
- | |
-CV_EXPORTS string format( const char* fmt, ... ); | |
-CV_EXPORTS string tempfile( const char* suffix CV_DEFAULT(0)); | |
- | |
-// matrix decomposition types | |
-enum { DECOMP_LU=0, DECOMP_SVD=1, DECOMP_EIG=2, DECOMP_CHOLESKY=3, DECOMP_QR=4, DECOMP_NORMAL=16 }; | |
-enum { NORM_INF=1, NORM_L1=2, NORM_L2=4, NORM_L2SQR=5, NORM_HAMMING=6, NORM_HAMMING2=7, NORM_TYPE_MASK=7, NORM_RELATIVE=8, NORM_MINMAX=32 }; | |
-enum { CMP_EQ=0, CMP_GT=1, CMP_GE=2, CMP_LT=3, CMP_LE=4, CMP_NE=5 }; | |
-enum { GEMM_1_T=1, GEMM_2_T=2, GEMM_3_T=4 }; | |
-enum { DFT_INVERSE=1, DFT_SCALE=2, DFT_ROWS=4, DFT_COMPLEX_OUTPUT=16, DFT_REAL_OUTPUT=32, | |
- DCT_INVERSE = DFT_INVERSE, DCT_ROWS=DFT_ROWS }; | |
- | |
- | |
-/*! | |
- The standard OpenCV exception class. | |
- Instances of the class are thrown by various functions and methods in the case of critical errors. | |
- */ | |
-class CV_EXPORTS Exception : public std::exception | |
-{ | |
-public: | |
- /*! | |
- Default constructor | |
- */ | |
- Exception(); | |
- /*! | |
- Full constructor. Normally the constuctor is not called explicitly. | |
- Instead, the macros CV_Error(), CV_Error_() and CV_Assert() are used. | |
- */ | |
- Exception(int _code, const string& _err, const string& _func, const string& _file, int _line); | |
- virtual ~Exception() throw(); | |
- | |
- /*! | |
- \return the error description and the context as a text string. | |
- */ | |
- virtual const char *what() const throw(); | |
- void formatMessage(); | |
- | |
- string msg; ///< the formatted error message | |
- | |
- int code; ///< error code @see CVStatus | |
- string err; ///< error description | |
- string func; ///< function name. Available only when the compiler supports __func__ macro | |
- string file; ///< source file name where the error has occured | |
- int line; ///< line number in the source file where the error has occured | |
-}; | |
- | |
- | |
-//! Signals an error and raises the exception. | |
- | |
-/*! | |
- By default the function prints information about the error to stderr, | |
- then it either stops if setBreakOnError() had been called before or raises the exception. | |
- It is possible to alternate error processing by using redirectError(). | |
- | |
- \param exc the exception raisen. | |
- */ | |
-CV_EXPORTS void error( const Exception& exc ); | |
- | |
-//! Sets/resets the break-on-error mode. | |
- | |
-/*! | |
- When the break-on-error mode is set, the default error handler | |
- issues a hardware exception, which can make debugging more convenient. | |
- | |
- \return the previous state | |
- */ | |
-CV_EXPORTS bool setBreakOnError(bool flag); | |
- | |
-typedef int (CV_CDECL *ErrorCallback)( int status, const char* func_name, | |
- const char* err_msg, const char* file_name, | |
- int line, void* userdata ); | |
- | |
-//! Sets the new error handler and the optional user data. | |
- | |
-/*! | |
- The function sets the new error handler, called from cv::error(). | |
- | |
- \param errCallback the new error handler. If NULL, the default error handler is used. | |
- \param userdata the optional user data pointer, passed to the callback. | |
- \param prevUserdata the optional output parameter where the previous user data pointer is stored | |
- | |
- \return the previous error handler | |
-*/ | |
-CV_EXPORTS ErrorCallback redirectError( ErrorCallback errCallback, | |
- void* userdata=0, void** prevUserdata=0); | |
- | |
-#ifdef __GNUC__ | |
-#define CV_Error( code, msg ) cv::error( cv::Exception(code, msg, __func__, __FILE__, __LINE__) ) | |
-#define CV_Error_( code, args ) cv::error( cv::Exception(code, cv::format args, __func__, __FILE__, __LINE__) ) | |
-#define CV_Assert( expr ) if((expr)) ; else cv::error( cv::Exception(CV_StsAssert, #expr, __func__, __FILE__, __LINE__) ) | |
-#else | |
-#define CV_Error( code, msg ) cv::error( cv::Exception(code, msg, "", __FILE__, __LINE__) ) | |
-#define CV_Error_( code, args ) cv::error( cv::Exception(code, cv::format args, "", __FILE__, __LINE__) ) | |
-#define CV_Assert( expr ) if((expr)) ; else cv::error( cv::Exception(CV_StsAssert, #expr, "", __FILE__, __LINE__) ) | |
-#endif | |
- | |
-#ifdef _DEBUG | |
-#define CV_DbgAssert(expr) CV_Assert(expr) | |
-#else | |
-#define CV_DbgAssert(expr) | |
-#endif | |
- | |
-CV_EXPORTS void setNumThreads(int nthreads); | |
-CV_EXPORTS int getNumThreads(); | |
-CV_EXPORTS int getThreadNum(); | |
- | |
-CV_EXPORTS_W const std::string& getBuildInformation(); | |
- | |
-//! Returns the number of ticks. | |
- | |
-/*! | |
- The function returns the number of ticks since the certain event (e.g. when the machine was turned on). | |
- It can be used to initialize cv::RNG or to measure a function execution time by reading the tick count | |
- before and after the function call. The granularity of ticks depends on the hardware and OS used. Use | |
- cv::getTickFrequency() to convert ticks to seconds. | |
-*/ | |
-CV_EXPORTS_W int64 getTickCount(); | |
- | |
-/*! | |
- Returns the number of ticks per seconds. | |
- | |
- The function returns the number of ticks (as returned by cv::getTickCount()) per second. | |
- The following code computes the execution time in milliseconds: | |
- | |
- \code | |
- double exec_time = (double)getTickCount(); | |
- // do something ... | |
- exec_time = ((double)getTickCount() - exec_time)*1000./getTickFrequency(); | |
- \endcode | |
-*/ | |
-CV_EXPORTS_W double getTickFrequency(); | |
- | |
-/*! | |
- Returns the number of CPU ticks. | |
- | |
- On platforms where the feature is available, the function returns the number of CPU ticks | |
- since the certain event (normally, the system power-on moment). Using this function | |
- one can accurately measure the execution time of very small code fragments, | |
- for which cv::getTickCount() granularity is not enough. | |
-*/ | |
-CV_EXPORTS_W int64 getCPUTickCount(); | |
- | |
-/*! | |
- Returns SSE etc. support status | |
- | |
- The function returns true if certain hardware features are available. | |
- Currently, the following features are recognized: | |
- - CV_CPU_MMX - MMX | |
- - CV_CPU_SSE - SSE | |
- - CV_CPU_SSE2 - SSE 2 | |
- - CV_CPU_SSE3 - SSE 3 | |
- - CV_CPU_SSSE3 - SSSE 3 | |
- - CV_CPU_SSE4_1 - SSE 4.1 | |
- - CV_CPU_SSE4_2 - SSE 4.2 | |
- - CV_CPU_POPCNT - POPCOUNT | |
- - CV_CPU_AVX - AVX | |
- | |
- \note {Note that the function output is not static. Once you called cv::useOptimized(false), | |
- most of the hardware acceleration is disabled and thus the function will returns false, | |
- until you call cv::useOptimized(true)} | |
-*/ | |
-CV_EXPORTS_W bool checkHardwareSupport(int feature); | |
- | |
-//! returns the number of CPUs (including hyper-threading) | |
-CV_EXPORTS_W int getNumberOfCPUs(); | |
- | |
-/*! | |
- Allocates memory buffer | |
- | |
- This is specialized OpenCV memory allocation function that returns properly aligned memory buffers. | |
- The usage is identical to malloc(). The allocated buffers must be freed with cv::fastFree(). | |
- If there is not enough memory, the function calls cv::error(), which raises an exception. | |
- | |
- \param bufSize buffer size in bytes | |
- \return the allocated memory buffer. | |
-*/ | |
-CV_EXPORTS void* fastMalloc(size_t bufSize); | |
- | |
-/*! | |
- Frees the memory allocated with cv::fastMalloc | |
- | |
- This is the corresponding deallocation function for cv::fastMalloc(). | |
- When ptr==NULL, the function has no effect. | |
-*/ | |
-CV_EXPORTS void fastFree(void* ptr); | |
- | |
-template<typename _Tp> static inline _Tp* allocate(size_t n) | |
-{ | |
- return new _Tp[n]; | |
-} | |
- | |
-template<typename _Tp> static inline void deallocate(_Tp* ptr, size_t) | |
-{ | |
- delete[] ptr; | |
-} | |
- | |
-/*! | |
- Aligns pointer by the certain number of bytes | |
- | |
- This small inline function aligns the pointer by the certian number of bytes by shifting | |
- it forward by 0 or a positive offset. | |
-*/ | |
-template<typename _Tp> static inline _Tp* alignPtr(_Tp* ptr, int n=(int)sizeof(_Tp)) | |
-{ | |
- return (_Tp*)(((size_t)ptr + n-1) & -n); | |
-} | |
- | |
-/*! | |
- Aligns buffer size by the certain number of bytes | |
- | |
- This small inline function aligns a buffer size by the certian number of bytes by enlarging it. | |
-*/ | |
-static inline size_t alignSize(size_t sz, int n) | |
-{ | |
- return (sz + n-1) & -n; | |
-} | |
- | |
-/*! | |
- Turns on/off available optimization | |
- | |
- The function turns on or off the optimized code in OpenCV. Some optimization can not be enabled | |
- or disabled, but, for example, most of SSE code in OpenCV can be temporarily turned on or off this way. | |
- | |
- \note{Since optimization may imply using special data structures, it may be unsafe | |
- to call this function anywhere in the code. Instead, call it somewhere at the top level.} | |
-*/ | |
-CV_EXPORTS_W void setUseOptimized(bool onoff); | |
- | |
-/*! | |
- Returns the current optimization status | |
- | |
- The function returns the current optimization status, which is controlled by cv::setUseOptimized(). | |
-*/ | |
-CV_EXPORTS_W bool useOptimized(); | |
- | |
-/*! | |
- The STL-compilant memory Allocator based on cv::fastMalloc() and cv::fastFree() | |
-*/ | |
-template<typename _Tp> class CV_EXPORTS Allocator | |
-{ | |
-public: | |
- typedef _Tp value_type; | |
- typedef value_type* pointer; | |
- typedef const value_type* const_pointer; | |
- typedef value_type& reference; | |
- typedef const value_type& const_reference; | |
- typedef size_t size_type; | |
- typedef ptrdiff_t difference_type; | |
- template<typename U> class rebind { typedef Allocator<U> other; }; | |
- | |
- explicit Allocator() {} | |
- ~Allocator() {} | |
- explicit Allocator(Allocator const&) {} | |
- template<typename U> | |
- explicit Allocator(Allocator<U> const&) {} | |
- | |
- // address | |
- pointer address(reference r) { return &r; } | |
- const_pointer address(const_reference r) { return &r; } | |
- | |
- pointer allocate(size_type count, const void* =0) | |
- { return reinterpret_cast<pointer>(fastMalloc(count * sizeof (_Tp))); } | |
- | |
- void deallocate(pointer p, size_type) {fastFree(p); } | |
- | |
- size_type max_size() const | |
- { return max(static_cast<_Tp>(-1)/sizeof(_Tp), 1); } | |
- | |
- void construct(pointer p, const _Tp& v) { new(static_cast<void*>(p)) _Tp(v); } | |
- void destroy(pointer p) { p->~_Tp(); } | |
-}; | |
- | |
-/////////////////////// Vec (used as element of multi-channel images ///////////////////// | |
- | |
-/*! | |
- A helper class for cv::DataType | |
- | |
- The class is specialized for each fundamental numerical data type supported by OpenCV. | |
- It provides DataDepth<T>::value constant. | |
-*/ | |
-template<typename _Tp> class CV_EXPORTS DataDepth {}; | |
- | |
-template<> class DataDepth<bool> { public: enum { value = CV_8U, fmt=(int)'u' }; }; | |
-template<> class DataDepth<uchar> { public: enum { value = CV_8U, fmt=(int)'u' }; }; | |
-template<> class DataDepth<schar> { public: enum { value = CV_8S, fmt=(int)'c' }; }; | |
-template<> class DataDepth<char> { public: enum { value = CV_8S, fmt=(int)'c' }; }; | |
-template<> class DataDepth<ushort> { public: enum { value = CV_16U, fmt=(int)'w' }; }; | |
-template<> class DataDepth<short> { public: enum { value = CV_16S, fmt=(int)'s' }; }; | |
-template<> class DataDepth<int> { public: enum { value = CV_32S, fmt=(int)'i' }; }; | |
-// this is temporary solution to support 32-bit unsigned integers | |
-template<> class DataDepth<unsigned> { public: enum { value = CV_32S, fmt=(int)'i' }; }; | |
-template<> class DataDepth<float> { public: enum { value = CV_32F, fmt=(int)'f' }; }; | |
-template<> class DataDepth<double> { public: enum { value = CV_64F, fmt=(int)'d' }; }; | |
-template<typename _Tp> class DataDepth<_Tp*> { public: enum { value = CV_USRTYPE1, fmt=(int)'r' }; }; | |
- | |
- | |
-////////////////////////////// Small Matrix /////////////////////////// | |
- | |
-/*! | |
- A short numerical vector. | |
- | |
- This template class represents short numerical vectors (of 1, 2, 3, 4 ... elements) | |
- on which you can perform basic arithmetical operations, access individual elements using [] operator etc. | |
- The vectors are allocated on stack, as opposite to std::valarray, std::vector, cv::Mat etc., | |
- which elements are dynamically allocated in the heap. | |
- | |
- The template takes 2 parameters: | |
- -# _Tp element type | |
- -# cn the number of elements | |
- | |
- In addition to the universal notation like Vec<float, 3>, you can use shorter aliases | |
- for the most popular specialized variants of Vec, e.g. Vec3f ~ Vec<float, 3>. | |
- */ | |
- | |
-struct CV_EXPORTS Matx_AddOp {}; | |
-struct CV_EXPORTS Matx_SubOp {}; | |
-struct CV_EXPORTS Matx_ScaleOp {}; | |
-struct CV_EXPORTS Matx_MulOp {}; | |
-struct CV_EXPORTS Matx_MatMulOp {}; | |
-struct CV_EXPORTS Matx_TOp {}; | |
- | |
-template<typename _Tp, int m, int n> class CV_EXPORTS Matx | |
-{ | |
-public: | |
- typedef _Tp value_type; | |
- typedef Matx<_Tp, MIN(m, n), 1> diag_type; | |
- typedef Matx<_Tp, m, n> mat_type; | |
- enum { depth = DataDepth<_Tp>::value, rows = m, cols = n, channels = rows*cols, | |
- type = CV_MAKETYPE(depth, channels) }; | |
- | |
- //! default constructor | |
- Matx(); | |
- | |
- Matx(_Tp v0); //!< 1x1 matrix | |
- Matx(_Tp v0, _Tp v1); //!< 1x2 or 2x1 matrix | |
- Matx(_Tp v0, _Tp v1, _Tp v2); //!< 1x3 or 3x1 matrix | |
- Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3); //!< 1x4, 2x2 or 4x1 matrix | |
- Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4); //!< 1x5 or 5x1 matrix | |
- Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5); //!< 1x6, 2x3, 3x2 or 6x1 matrix | |
- Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6); //!< 1x7 or 7x1 matrix | |
- Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7); //!< 1x8, 2x4, 4x2 or 8x1 matrix | |
- Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8); //!< 1x9, 3x3 or 9x1 matrix | |
- Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9); //!< 1x10, 2x5 or 5x2 or 10x1 matrix | |
- Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, | |
- _Tp v4, _Tp v5, _Tp v6, _Tp v7, | |
- _Tp v8, _Tp v9, _Tp v10, _Tp v11); //!< 1x12, 2x6, 3x4, 4x3, 6x2 or 12x1 matrix | |
- Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, | |
- _Tp v4, _Tp v5, _Tp v6, _Tp v7, | |
- _Tp v8, _Tp v9, _Tp v10, _Tp v11, | |
- _Tp v12, _Tp v13, _Tp v14, _Tp v15); //!< 1x16, 4x4 or 16x1 matrix | |
- explicit Matx(const _Tp* vals); //!< initialize from a plain array | |
- | |
- static Matx all(_Tp alpha); | |
- static Matx zeros(); | |
- static Matx ones(); | |
- static Matx eye(); | |
- static Matx diag(const diag_type& d); | |
- static Matx randu(_Tp a, _Tp b); | |
- static Matx randn(_Tp a, _Tp b); | |
- | |
- //! dot product computed with the default precision | |
- _Tp dot(const Matx<_Tp, m, n>& v) const; | |
- | |
- //! dot product computed in double-precision arithmetics | |
- double ddot(const Matx<_Tp, m, n>& v) const; | |
- | |
- //! convertion to another data type | |
- template<typename T2> operator Matx<T2, m, n>() const; | |
- | |
- //! change the matrix shape | |
- template<int m1, int n1> Matx<_Tp, m1, n1> reshape() const; | |
- | |
- //! extract part of the matrix | |
- template<int m1, int n1> Matx<_Tp, m1, n1> get_minor(int i, int j) const; | |
- | |
- //! extract the matrix row | |
- Matx<_Tp, 1, n> row(int i) const; | |
- | |
- //! extract the matrix column | |
- Matx<_Tp, m, 1> col(int i) const; | |
- | |
- //! extract the matrix diagonal | |
- diag_type diag() const; | |
- | |
- //! transpose the matrix | |
- Matx<_Tp, n, m> t() const; | |
- | |
- //! invert matrix the matrix | |
- Matx<_Tp, n, m> inv(int method=DECOMP_LU) const; | |
- | |
- //! solve linear system | |
- template<int l> Matx<_Tp, n, l> solve(const Matx<_Tp, m, l>& rhs, int flags=DECOMP_LU) const; | |
- Vec<_Tp, n> solve(const Vec<_Tp, m>& rhs, int method) const; | |
- | |
- //! multiply two matrices element-wise | |
- Matx<_Tp, m, n> mul(const Matx<_Tp, m, n>& a) const; | |
- | |
- //! element access | |
- const _Tp& operator ()(int i, int j) const; | |
- _Tp& operator ()(int i, int j); | |
- | |
- //! 1D element access | |
- const _Tp& operator ()(int i) const; | |
- _Tp& operator ()(int i); | |
- | |
- Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_AddOp); | |
- Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_SubOp); | |
- template<typename _T2> Matx(const Matx<_Tp, m, n>& a, _T2 alpha, Matx_ScaleOp); | |
- Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_MulOp); | |
- template<int l> Matx(const Matx<_Tp, m, l>& a, const Matx<_Tp, l, n>& b, Matx_MatMulOp); | |
- Matx(const Matx<_Tp, n, m>& a, Matx_TOp); | |
- | |
- _Tp val[m*n]; //< matrix elements | |
-}; | |
- | |
- | |
-typedef Matx<float, 1, 2> Matx12f; | |
-typedef Matx<double, 1, 2> Matx12d; | |
-typedef Matx<float, 1, 3> Matx13f; | |
-typedef Matx<double, 1, 3> Matx13d; | |
-typedef Matx<float, 1, 4> Matx14f; | |
-typedef Matx<double, 1, 4> Matx14d; | |
-typedef Matx<float, 1, 6> Matx16f; | |
-typedef Matx<double, 1, 6> Matx16d; | |
- | |
-typedef Matx<float, 2, 1> Matx21f; | |
-typedef Matx<double, 2, 1> Matx21d; | |
-typedef Matx<float, 3, 1> Matx31f; | |
-typedef Matx<double, 3, 1> Matx31d; | |
-typedef Matx<float, 4, 1> Matx41f; | |
-typedef Matx<double, 4, 1> Matx41d; | |
-typedef Matx<float, 6, 1> Matx61f; | |
-typedef Matx<double, 6, 1> Matx61d; | |
- | |
-typedef Matx<float, 2, 2> Matx22f; | |
-typedef Matx<double, 2, 2> Matx22d; | |
-typedef Matx<float, 2, 3> Matx23f; | |
-typedef Matx<double, 2, 3> Matx23d; | |
-typedef Matx<float, 3, 2> Matx32f; | |
-typedef Matx<double, 3, 2> Matx32d; | |
- | |
-typedef Matx<float, 3, 3> Matx33f; | |
-typedef Matx<double, 3, 3> Matx33d; | |
- | |
-typedef Matx<float, 3, 4> Matx34f; | |
-typedef Matx<double, 3, 4> Matx34d; | |
-typedef Matx<float, 4, 3> Matx43f; | |
-typedef Matx<double, 4, 3> Matx43d; | |
- | |
-typedef Matx<float, 4, 4> Matx44f; | |
-typedef Matx<double, 4, 4> Matx44d; | |
-typedef Matx<float, 6, 6> Matx66f; | |
-typedef Matx<double, 6, 6> Matx66d; | |
- | |
- | |
-/*! | |
- A short numerical vector. | |
- | |
- This template class represents short numerical vectors (of 1, 2, 3, 4 ... elements) | |
- on which you can perform basic arithmetical operations, access individual elements using [] operator etc. | |
- The vectors are allocated on stack, as opposite to std::valarray, std::vector, cv::Mat etc., | |
- which elements are dynamically allocated in the heap. | |
- | |
- The template takes 2 parameters: | |
- -# _Tp element type | |
- -# cn the number of elements | |
- | |
- In addition to the universal notation like Vec<float, 3>, you can use shorter aliases | |
- for the most popular specialized variants of Vec, e.g. Vec3f ~ Vec<float, 3>. | |
-*/ | |
-template<typename _Tp, int cn> class CV_EXPORTS Vec : public Matx<_Tp, cn, 1> | |
-{ | |
-public: | |
- typedef _Tp value_type; | |
- enum { depth = DataDepth<_Tp>::value, channels = cn, type = CV_MAKETYPE(depth, channels) }; | |
- | |
- //! default constructor | |
- Vec(); | |
- | |
- Vec(_Tp v0); //!< 1-element vector constructor | |
- Vec(_Tp v0, _Tp v1); //!< 2-element vector constructor | |
- Vec(_Tp v0, _Tp v1, _Tp v2); //!< 3-element vector constructor | |
- Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3); //!< 4-element vector constructor | |
- Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4); //!< 5-element vector constructor | |
- Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5); //!< 6-element vector constructor | |
- Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6); //!< 7-element vector constructor | |
- Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7); //!< 8-element vector constructor | |
- Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8); //!< 9-element vector constructor | |
- Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5, _Tp v6, _Tp v7, _Tp v8, _Tp v9); //!< 10-element vector constructor | |
- explicit Vec(const _Tp* values); | |
- | |
- Vec(const Vec<_Tp, cn>& v); | |
- | |
- static Vec all(_Tp alpha); | |
- | |
- //! per-element multiplication | |
- Vec mul(const Vec<_Tp, cn>& v) const; | |
- | |
- //! conjugation (makes sense for complex numbers and quaternions) | |
- Vec conj() const; | |
- | |
- /*! | |
- cross product of the two 3D vectors. | |
- | |
- For other dimensionalities the exception is raised | |
- */ | |
- Vec cross(const Vec& v) const; | |
- //! convertion to another data type | |
- template<typename T2> operator Vec<T2, cn>() const; | |
- //! conversion to 4-element CvScalar. | |
- operator CvScalar() const; | |
- | |
- /*! element access */ | |
- const _Tp& operator [](int i) const; | |
- _Tp& operator[](int i); | |
- const _Tp& operator ()(int i) const; | |
- _Tp& operator ()(int i); | |
- | |
- Vec(const Matx<_Tp, cn, 1>& a, const Matx<_Tp, cn, 1>& b, Matx_AddOp); | |
- Vec(const Matx<_Tp, cn, 1>& a, const Matx<_Tp, cn, 1>& b, Matx_SubOp); | |
- template<typename _T2> Vec(const Matx<_Tp, cn, 1>& a, _T2 alpha, Matx_ScaleOp); | |
-}; | |
- | |
- | |
-/* \typedef | |
- | |
- Shorter aliases for the most popular specializations of Vec<T,n> | |
-*/ | |
-typedef Vec<uchar, 2> Vec2b; | |
-typedef Vec<uchar, 3> Vec3b; | |
-typedef Vec<uchar, 4> Vec4b; | |
- | |
-typedef Vec<short, 2> Vec2s; | |
-typedef Vec<short, 3> Vec3s; | |
-typedef Vec<short, 4> Vec4s; | |
- | |
-typedef Vec<ushort, 2> Vec2w; | |
-typedef Vec<ushort, 3> Vec3w; | |
-typedef Vec<ushort, 4> Vec4w; | |
- | |
-typedef Vec<int, 2> Vec2i; | |
-typedef Vec<int, 3> Vec3i; | |
-typedef Vec<int, 4> Vec4i; | |
-typedef Vec<int, 6> Vec6i; | |
-typedef Vec<int, 8> Vec8i; | |
- | |
-typedef Vec<float, 2> Vec2f; | |
-typedef Vec<float, 3> Vec3f; | |
-typedef Vec<float, 4> Vec4f; | |
-typedef Vec<float, 6> Vec6f; | |
- | |
-typedef Vec<double, 2> Vec2d; | |
-typedef Vec<double, 3> Vec3d; | |
-typedef Vec<double, 4> Vec4d; | |
-typedef Vec<double, 6> Vec6d; | |
- | |
- | |
-//////////////////////////////// Complex ////////////////////////////// | |
- | |
-/*! | |
- A complex number class. | |
- | |
- The template class is similar and compatible with std::complex, however it provides slightly | |
- more convenient access to the real and imaginary parts using through the simple field access, as opposite | |
- to std::complex::real() and std::complex::imag(). | |
-*/ | |
-template<typename _Tp> class CV_EXPORTS Complex | |
-{ | |
-public: | |
- | |
- //! constructors | |
- Complex(); | |
- Complex( _Tp _re, _Tp _im=0 ); | |
- Complex( const std::complex<_Tp>& c ); | |
- | |
- //! conversion to another data type | |
- template<typename T2> operator Complex<T2>() const; | |
- //! conjugation | |
- Complex conj() const; | |
- //! conversion to std::complex | |
- operator std::complex<_Tp>() const; | |
- | |
- _Tp re, im; //< the real and the imaginary parts | |
-}; | |
- | |
- | |
-/*! | |
- \typedef | |
-*/ | |
-typedef Complex<float> Complexf; | |
-typedef Complex<double> Complexd; | |
- | |
- | |
-//////////////////////////////// Point_ //////////////////////////////// | |
- | |
-/*! | |
- template 2D point class. | |
- | |
- The class defines a point in 2D space. Data type of the point coordinates is specified | |
- as a template parameter. There are a few shorter aliases available for user convenience. | |
- See cv::Point, cv::Point2i, cv::Point2f and cv::Point2d. | |
-*/ | |
-template<typename _Tp> class CV_EXPORTS Point_ | |
-{ | |
-public: | |
- typedef _Tp value_type; | |
- | |
- // various constructors | |
- Point_(); | |
- Point_(_Tp _x, _Tp _y); | |
- Point_(const Point_& pt); | |
- Point_(const CvPoint& pt); | |
- Point_(const CvPoint2D32f& pt); | |
- Point_(const Size_<_Tp>& sz); | |
- Point_(const Vec<_Tp, 2>& v); | |
- | |
- Point_& operator = (const Point_& pt); | |
- //! conversion to another data type | |
- template<typename _Tp2> operator Point_<_Tp2>() const; | |
- | |
- //! conversion to the old-style C structures | |
- operator CvPoint() const; | |
- operator CvPoint2D32f() const; | |
- operator Vec<_Tp, 2>() const; | |
- | |
- //! dot product | |
- _Tp dot(const Point_& pt) const; | |
- //! dot product computed in double-precision arithmetics | |
- double ddot(const Point_& pt) const; | |
- //! cross-product | |
- double cross(const Point_& pt) const; | |
- //! checks whether the point is inside the specified rectangle | |
- bool inside(const Rect_<_Tp>& r) const; | |
- | |
- _Tp x, y; //< the point coordinates | |
-}; | |
- | |
-/*! | |
- template 3D point class. | |
- | |
- The class defines a point in 3D space. Data type of the point coordinates is specified | |
- as a template parameter. | |
- | |
- \see cv::Point3i, cv::Point3f and cv::Point3d | |
-*/ | |
-template<typename _Tp> class CV_EXPORTS Point3_ | |
-{ | |
-public: | |
- typedef _Tp value_type; | |
- | |
- // various constructors | |
- Point3_(); | |
- Point3_(_Tp _x, _Tp _y, _Tp _z); | |
- Point3_(const Point3_& pt); | |
- explicit Point3_(const Point_<_Tp>& pt); | |
- Point3_(const CvPoint3D32f& pt); | |
- Point3_(const Vec<_Tp, 3>& v); | |
- | |
- Point3_& operator = (const Point3_& pt); | |
- //! conversion to another data type | |
- template<typename _Tp2> operator Point3_<_Tp2>() const; | |
- //! conversion to the old-style CvPoint... | |
- operator CvPoint3D32f() const; | |
- //! conversion to cv::Vec<> | |
- operator Vec<_Tp, 3>() const; | |
- | |
- //! dot product | |
- _Tp dot(const Point3_& pt) const; | |
- //! dot product computed in double-precision arithmetics | |
- double ddot(const Point3_& pt) const; | |
- //! cross product of the 2 3D points | |
- Point3_ cross(const Point3_& pt) const; | |
- | |
- _Tp x, y, z; //< the point coordinates | |
-}; | |
- | |
-//////////////////////////////// Size_ //////////////////////////////// | |
- | |
-/*! | |
- The 2D size class | |
- | |
- The class represents the size of a 2D rectangle, image size, matrix size etc. | |
- Normally, cv::Size ~ cv::Size_<int> is used. | |
-*/ | |
-template<typename _Tp> class CV_EXPORTS Size_ | |
-{ | |
-public: | |
- typedef _Tp value_type; | |
- | |
- //! various constructors | |
- Size_(); | |
- Size_(_Tp _width, _Tp _height); | |
- Size_(const Size_& sz); | |
- Size_(const CvSize& sz); | |
- Size_(const CvSize2D32f& sz); | |
- Size_(const Point_<_Tp>& pt); | |
- | |
- Size_& operator = (const Size_& sz); | |
- //! the area (width*height) | |
- _Tp area() const; | |
- | |
- //! conversion of another data type. | |
- template<typename _Tp2> operator Size_<_Tp2>() const; | |
- | |
- //! conversion to the old-style OpenCV types | |
- operator CvSize() const; | |
- operator CvSize2D32f() const; | |
- | |
- _Tp width, height; // the width and the height | |
-}; | |
- | |
-//////////////////////////////// Rect_ //////////////////////////////// | |
- | |
-/*! | |
- The 2D up-right rectangle class | |
- | |
- The class represents a 2D rectangle with coordinates of the specified data type. | |
- Normally, cv::Rect ~ cv::Rect_<int> is used. | |
-*/ | |
-template<typename _Tp> class CV_EXPORTS Rect_ | |
-{ | |
-public: | |
- typedef _Tp value_type; | |
- | |
- //! various constructors | |
- Rect_(); | |
- Rect_(_Tp _x, _Tp _y, _Tp _width, _Tp _height); | |
- Rect_(const Rect_& r); | |
- Rect_(const CvRect& r); | |
- Rect_(const Point_<_Tp>& org, const Size_<_Tp>& sz); | |
- Rect_(const Point_<_Tp>& pt1, const Point_<_Tp>& pt2); | |
- | |
- Rect_& operator = ( const Rect_& r ); | |
- //! the top-left corner | |
- Point_<_Tp> tl() const; | |
- //! the bottom-right corner | |
- Point_<_Tp> br() const; | |
- | |
- //! size (width, height) of the rectangle | |
- Size_<_Tp> size() const; | |
- //! area (width*height) of the rectangle | |
- _Tp area() const; | |
- | |
- //! conversion to another data type | |
- template<typename _Tp2> operator Rect_<_Tp2>() const; | |
- //! conversion to the old-style CvRect | |
- operator CvRect() const; | |
- | |
- //! checks whether the rectangle contains the point | |
- bool contains(const Point_<_Tp>& pt) const; | |
- | |
- _Tp x, y, width, height; //< the top-left corner, as well as width and height of the rectangle | |
-}; | |
- | |
- | |
-/*! | |
- \typedef | |
- | |
- shorter aliases for the most popular cv::Point_<>, cv::Size_<> and cv::Rect_<> specializations | |
-*/ | |
-typedef Point_<int> Point2i; | |
-typedef Point2i Point; | |
-typedef Size_<int> Size2i; | |
-typedef Size2i Size; | |
-typedef Rect_<int> Rect; | |
-typedef Point_<float> Point2f; | |
-typedef Point_<double> Point2d; | |
-typedef Size_<float> Size2f; | |
-typedef Point3_<int> Point3i; | |
-typedef Point3_<float> Point3f; | |
-typedef Point3_<double> Point3d; | |
- | |
- | |
-/*! | |
- The rotated 2D rectangle. | |
- | |
- The class represents rotated (i.e. not up-right) rectangles on a plane. | |
- Each rectangle is described by the center point (mass center), length of each side | |
- (represented by cv::Size2f structure) and the rotation angle in degrees. | |
-*/ | |
-class CV_EXPORTS RotatedRect | |
-{ | |
-public: | |
- //! various constructors | |
- RotatedRect(); | |
- RotatedRect(const Point2f& _center, const Size2f& _size, float _angle); | |
- RotatedRect(const CvBox2D& box); | |
- | |
- //! returns 4 vertices of the rectangle | |
- void points(Point2f pts[]) const; | |
- //! returns the minimal up-right rectangle containing the rotated rectangle | |
- Rect boundingRect() const; | |
- //! conversion to the old-style CvBox2D structure | |
- operator CvBox2D() const; | |
- | |
- Point2f center; //< the rectangle mass center | |
- Size2f size; //< width and height of the rectangle | |
- float angle; //< the rotation angle. When the angle is 0, 90, 180, 270 etc., the rectangle becomes an up-right rectangle. | |
-}; | |
- | |
-//////////////////////////////// Scalar_ /////////////////////////////// | |
- | |
-/*! | |
- The template scalar class. | |
- | |
- This is partially specialized cv::Vec class with the number of elements = 4, i.e. a short vector of four elements. | |
- Normally, cv::Scalar ~ cv::Scalar_<double> is used. | |
-*/ | |
-template<typename _Tp> class CV_EXPORTS Scalar_ : public Vec<_Tp, 4> | |
-{ | |
-public: | |
- //! various constructors | |
- Scalar_(); | |
- Scalar_(_Tp v0, _Tp v1, _Tp v2=0, _Tp v3=0); | |
- Scalar_(const CvScalar& s); | |
- Scalar_(_Tp v0); | |
- | |
- //! returns a scalar with all elements set to v0 | |
- static Scalar_<_Tp> all(_Tp v0); | |
- //! conversion to the old-style CvScalar | |
- operator CvScalar() const; | |
- | |
- //! conversion to another data type | |
- template<typename T2> operator Scalar_<T2>() const; | |
- | |
- //! per-element product | |
- Scalar_<_Tp> mul(const Scalar_<_Tp>& t, double scale=1 ) const; | |
- | |
- // returns (v0, -v1, -v2, -v3) | |
- Scalar_<_Tp> conj() const; | |
- | |
- // returns true iff v1 == v2 == v3 == 0 | |
- bool isReal() const; | |
-}; | |
- | |
-typedef Scalar_<double> Scalar; | |
- | |
-CV_EXPORTS void scalarToRawData(const Scalar& s, void* buf, int type, int unroll_to=0); | |
- | |
-//////////////////////////////// Range ///////////////////////////////// | |
- | |
-/*! | |
- The 2D range class | |
- | |
- This is the class used to specify a continuous subsequence, i.e. part of a contour, or a column span in a matrix. | |
-*/ | |
-class CV_EXPORTS Range | |
-{ | |
-public: | |
- Range(); | |
- Range(int _start, int _end); | |
- Range(const CvSlice& slice); | |
- int size() const; | |
- bool empty() const; | |
- static Range all(); | |
- operator CvSlice() const; | |
- | |
- int start, end; | |
-}; | |
- | |
-/////////////////////////////// DataType //////////////////////////////// | |
- | |
-/*! | |
- Informative template class for OpenCV "scalars". | |
- | |
- The class is specialized for each primitive numerical type supported by OpenCV (such as unsigned char or float), | |
- as well as for more complex types, like cv::Complex<>, std::complex<>, cv::Vec<> etc. | |
- The common property of all such types (called "scalars", do not confuse it with cv::Scalar_) | |
- is that each of them is basically a tuple of numbers of the same type. Each "scalar" can be represented | |
- by the depth id (CV_8U ... CV_64F) and the number of channels. | |
- OpenCV matrices, 2D or nD, dense or sparse, can store "scalars", | |
- as long as the number of channels does not exceed CV_CN_MAX. | |
-*/ | |
-template<typename _Tp> class DataType | |
-{ | |
-public: | |
- typedef _Tp value_type; | |
- typedef value_type work_type; | |
- typedef value_type channel_type; | |
- typedef value_type vec_type; | |
- enum { generic_type = 1, depth = -1, channels = 1, fmt=0, | |
- type = CV_MAKETYPE(depth, channels) }; | |
-}; | |
- | |
-template<> class DataType<bool> | |
-{ | |
-public: | |
- typedef bool value_type; | |
- typedef int work_type; | |
- typedef value_type channel_type; | |
- typedef value_type vec_type; | |
- enum { generic_type = 0, depth = DataDepth<channel_type>::value, channels = 1, | |
- fmt=DataDepth<channel_type>::fmt, | |
- type = CV_MAKETYPE(depth, channels) }; | |
-}; | |
- | |
-template<> class DataType<uchar> | |
-{ | |
-public: | |
- typedef uchar value_type; | |
- typedef int work_type; | |
- typedef value_type channel_type; | |
- typedef value_type vec_type; | |
- enum { generic_type = 0, depth = DataDepth<channel_type>::value, channels = 1, | |
- fmt=DataDepth<channel_type>::fmt, | |
- type = CV_MAKETYPE(depth, channels) }; | |
-}; | |
- | |
-template<> class DataType<schar> | |
-{ | |
-public: | |
- typedef schar value_type; | |
- typedef int work_type; | |
- typedef value_type channel_type; | |
- typedef value_type vec_type; | |
- enum { generic_type = 0, depth = DataDepth<channel_type>::value, channels = 1, | |
- fmt=DataDepth<channel_type>::fmt, | |
- type = CV_MAKETYPE(depth, channels) }; | |
-}; | |
- | |
-template<> class DataType<char> | |
-{ | |
-public: | |
- typedef schar value_type; | |
- typedef int work_type; | |
- typedef value_type channel_type; | |
- typedef value_type vec_type; | |
- enum { generic_type = 0, depth = DataDepth<channel_type>::value, channels = 1, | |
- fmt=DataDepth<channel_type>::fmt, | |
- type = CV_MAKETYPE(depth, channels) }; | |
-}; | |
- | |
-template<> class DataType<ushort> | |
-{ | |
-public: | |
- typedef ushort value_type; | |
- typedef int work_type; | |
- typedef value_type channel_type; | |
- typedef value_type vec_type; | |
- enum { generic_type = 0, depth = DataDepth<channel_type>::value, channels = 1, | |
- fmt=DataDepth<channel_type>::fmt, | |
- type = CV_MAKETYPE(depth, channels) }; | |
-}; | |
- | |
-template<> class DataType<short> | |
-{ | |
-public: | |
- typedef short value_type; | |
- typedef int work_type; | |
- typedef value_type channel_type; | |
- typedef value_type vec_type; | |
- enum { generic_type = 0, depth = DataDepth<channel_type>::value, channels = 1, | |
- fmt=DataDepth<channel_type>::fmt, | |
- type = CV_MAKETYPE(depth, channels) }; | |
-}; | |
- | |
-template<> class DataType<int> | |
-{ | |
-public: | |
- typedef int value_type; | |
- typedef value_type work_type; | |
- typedef value_type channel_type; | |
- typedef value_type vec_type; | |
- enum { generic_type = 0, depth = DataDepth<channel_type>::value, channels = 1, | |
- fmt=DataDepth<channel_type>::fmt, | |
- type = CV_MAKETYPE(depth, channels) }; | |
-}; | |
- | |
-template<> class DataType<float> | |
-{ | |
-public: | |
- typedef float value_type; | |
- typedef value_type work_type; | |
- typedef value_type channel_type; | |
- typedef value_type vec_type; | |
- enum { generic_type = 0, depth = DataDepth<channel_type>::value, channels = 1, | |
- fmt=DataDepth<channel_type>::fmt, | |
- type = CV_MAKETYPE(depth, channels) }; | |
-}; | |
- | |
-template<> class DataType<double> | |
-{ | |
-public: | |
- typedef double value_type; | |
- typedef value_type work_type; | |
- typedef value_type channel_type; | |
- typedef value_type vec_type; | |
- enum { generic_type = 0, depth = DataDepth<channel_type>::value, channels = 1, | |
- fmt=DataDepth<channel_type>::fmt, | |
- type = CV_MAKETYPE(depth, channels) }; | |
-}; | |
- | |
-template<typename _Tp, int cn> class DataType<Vec<_Tp, cn> > | |
-{ | |
-public: | |
- typedef Vec<_Tp, cn> value_type; | |
- typedef Vec<typename DataType<_Tp>::work_type, cn> work_type; | |
- typedef _Tp channel_type; | |
- typedef value_type vec_type; | |
- enum { generic_type = 0, depth = DataDepth<channel_type>::value, channels = cn, | |
- fmt = ((channels-1)<<8) + DataDepth<channel_type>::fmt, | |
- type = CV_MAKETYPE(depth, channels) }; | |
-}; | |
- | |
-template<typename _Tp> class DataType<std::complex<_Tp> > | |
-{ | |
-public: | |
- typedef std::complex<_Tp> value_type; | |
- typedef value_type work_type; | |
- typedef _Tp channel_type; | |
- enum { generic_type = 0, depth = DataDepth<channel_type>::value, channels = 2, | |
- fmt = ((channels-1)<<8) + DataDepth<channel_type>::fmt, | |
- type = CV_MAKETYPE(depth, channels) }; | |
- typedef Vec<channel_type, channels> vec_type; | |
-}; | |
- | |
-template<typename _Tp> class DataType<Complex<_Tp> > | |
-{ | |
-public: | |
- typedef Complex<_Tp> value_type; | |
- typedef value_type work_type; | |
- typedef _Tp channel_type; | |
- enum { generic_type = 0, depth = DataDepth<channel_type>::value, channels = 2, | |
- fmt = ((channels-1)<<8) + DataDepth<channel_type>::fmt, | |
- type = CV_MAKETYPE(depth, channels) }; | |
- typedef Vec<channel_type, channels> vec_type; | |
-}; | |
- | |
-template<typename _Tp> class DataType<Point_<_Tp> > | |
-{ | |
-public: | |
- typedef Point_<_Tp> value_type; | |
- typedef Point_<typename DataType<_Tp>::work_type> work_type; | |
- typedef _Tp channel_type; | |
- enum { generic_type = 0, depth = DataDepth<channel_type>::value, channels = 2, | |
- fmt = ((channels-1)<<8) + DataDepth<channel_type>::fmt, | |
- type = CV_MAKETYPE(depth, channels) }; | |
- typedef Vec<channel_type, channels> vec_type; | |
-}; | |
- | |
-template<typename _Tp> class DataType<Point3_<_Tp> > | |
-{ | |
-public: | |
- typedef Point3_<_Tp> value_type; | |
- typedef Point3_<typename DataType<_Tp>::work_type> work_type; | |
- typedef _Tp channel_type; | |
- enum { generic_type = 0, depth = DataDepth<channel_type>::value, channels = 3, | |
- fmt = ((channels-1)<<8) + DataDepth<channel_type>::fmt, | |
- type = CV_MAKETYPE(depth, channels) }; | |
- typedef Vec<channel_type, channels> vec_type; | |
-}; | |
- | |
-template<typename _Tp> class DataType<Size_<_Tp> > | |
-{ | |
-public: | |
- typedef Size_<_Tp> value_type; | |
- typedef Size_<typename DataType<_Tp>::work_type> work_type; | |
- typedef _Tp channel_type; | |
- enum { generic_type = 0, depth = DataDepth<channel_type>::value, channels = 2, | |
- fmt = ((channels-1)<<8) + DataDepth<channel_type>::fmt, | |
- type = CV_MAKETYPE(depth, channels) }; | |
- typedef Vec<channel_type, channels> vec_type; | |
-}; | |
- | |
-template<typename _Tp> class DataType<Rect_<_Tp> > | |
-{ | |
-public: | |
- typedef Rect_<_Tp> value_type; | |
- typedef Rect_<typename DataType<_Tp>::work_type> work_type; | |
- typedef _Tp channel_type; | |
- enum { generic_type = 0, depth = DataDepth<channel_type>::value, channels = 4, | |
- fmt = ((channels-1)<<8) + DataDepth<channel_type>::fmt, | |
- type = CV_MAKETYPE(depth, channels) }; | |
- typedef Vec<channel_type, channels> vec_type; | |
-}; | |
- | |
-template<typename _Tp> class DataType<Scalar_<_Tp> > | |
-{ | |
-public: | |
- typedef Scalar_<_Tp> value_type; | |
- typedef Scalar_<typename DataType<_Tp>::work_type> work_type; | |
- typedef _Tp channel_type; | |
- enum { generic_type = 0, depth = DataDepth<channel_type>::value, channels = 4, | |
- fmt = ((channels-1)<<8) + DataDepth<channel_type>::fmt, | |
- type = CV_MAKETYPE(depth, channels) }; | |
- typedef Vec<channel_type, channels> vec_type; | |
-}; | |
- | |
-template<> class DataType<Range> | |
-{ | |
-public: | |
- typedef Range value_type; | |
- typedef value_type work_type; | |
- typedef int channel_type; | |
- enum { generic_type = 0, depth = DataDepth<channel_type>::value, channels = 2, | |
- fmt = ((channels-1)<<8) + DataDepth<channel_type>::fmt, | |
- type = CV_MAKETYPE(depth, channels) }; | |
- typedef Vec<channel_type, channels> vec_type; | |
-}; | |
- | |
-//////////////////// generic_type ref-counting pointer class for C/C++ objects //////////////////////// | |
- | |
-/*! | |
- Smart pointer to dynamically allocated objects. | |
- | |
- This is template pointer-wrapping class that stores the associated reference counter along with the | |
- object pointer. The class is similar to std::smart_ptr<> from the recent addons to the C++ standard, | |
- but is shorter to write :) and self-contained (i.e. does add any dependency on the compiler or an external library). | |
- | |
- Basically, you can use "Ptr<MyObjectType> ptr" (or faster "const Ptr<MyObjectType>& ptr" for read-only access) | |
- everywhere instead of "MyObjectType* ptr", where MyObjectType is some C structure or a C++ class. | |
- To make it all work, you need to specialize Ptr<>::delete_obj(), like: | |
- | |
- \code | |
- template<> void Ptr<MyObjectType>::delete_obj() { call_destructor_func(obj); } | |
- \endcode | |
- | |
- \note{if MyObjectType is a C++ class with a destructor, you do not need to specialize delete_obj(), | |
- since the default implementation calls "delete obj;"} | |
- | |
- \note{Another good property of the class is that the operations on the reference counter are atomic, | |
- i.e. it is safe to use the class in multi-threaded applications} | |
-*/ | |
-template<typename _Tp> class CV_EXPORTS Ptr | |
-{ | |
-public: | |
- //! empty constructor | |
- Ptr(); | |
- //! take ownership of the pointer. The associated reference counter is allocated and set to 1 | |
- Ptr(_Tp* _obj); | |
- //! calls release() | |
- ~Ptr(); | |
- //! copy constructor. Copies the members and calls addref() | |
- Ptr(const Ptr& ptr); | |
- //! copy operator. Calls ptr.addref() and release() before copying the members | |
- Ptr& operator = (const Ptr& ptr); | |
- //! increments the reference counter | |
- void addref(); | |
- //! decrements the reference counter. If it reaches 0, delete_obj() is called | |
- void release(); | |
- //! deletes the object. Override if needed | |
- void delete_obj(); | |
- //! returns true iff obj==NULL | |
- bool empty() const; | |
- | |
- //! cast pointer to another type | |
- template<typename _Tp2> Ptr<_Tp2> ptr(); | |
- template<typename _Tp2> const Ptr<_Tp2> ptr() const; | |
- | |
- //! helper operators making "Ptr<T> ptr" use very similar to "T* ptr". | |
- _Tp* operator -> (); | |
- const _Tp* operator -> () const; | |
- | |
- operator _Tp* (); | |
- operator const _Tp*() const; | |
- | |
- _Tp* obj; //< the object pointer. | |
- int* refcount; //< the associated reference counter | |
-}; | |
- | |
- | |
-//////////////////////// Input/Output Array Arguments ///////////////////////////////// | |
- | |
-/*! | |
- Proxy datatype for passing Mat's and vector<>'s as input parameters | |
- */ | |
-class CV_EXPORTS _InputArray | |
-{ | |
-public: | |
- enum { | |
- KIND_SHIFT = 16, | |
- FIXED_TYPE = 0x8000 << KIND_SHIFT, | |
- FIXED_SIZE = 0x4000 << KIND_SHIFT, | |
- KIND_MASK = ~(FIXED_TYPE|FIXED_SIZE) - (1 << KIND_SHIFT) + 1, | |
- | |
- NONE = 0 << KIND_SHIFT, | |
- MAT = 1 << KIND_SHIFT, | |
- MATX = 2 << KIND_SHIFT, | |
- STD_VECTOR = 3 << KIND_SHIFT, | |
- STD_VECTOR_VECTOR = 4 << KIND_SHIFT, | |
- STD_VECTOR_MAT = 5 << KIND_SHIFT, | |
- EXPR = 6 << KIND_SHIFT, | |
- OPENGL_BUFFER = 7 << KIND_SHIFT, | |
- OPENGL_TEXTURE = 8 << KIND_SHIFT, | |
- GPU_MAT = 9 << KIND_SHIFT | |
- }; | |
- _InputArray(); | |
- _InputArray(const Mat& m); | |
- _InputArray(const MatExpr& expr); | |
- template<typename _Tp> _InputArray(const _Tp* vec, int n); | |
- template<typename _Tp> _InputArray(const vector<_Tp>& vec); | |
- template<typename _Tp> _InputArray(const vector<vector<_Tp> >& vec); | |
- _InputArray(const vector<Mat>& vec); | |
- template<typename _Tp> _InputArray(const Mat_<_Tp>& m); | |
- template<typename _Tp, int m, int n> _InputArray(const Matx<_Tp, m, n>& matx); | |
- _InputArray(const Scalar& s); | |
- _InputArray(const double& val); | |
- _InputArray(const GlBuffer& buf); | |
- _InputArray(const GlTexture& tex); | |
- _InputArray(const gpu::GpuMat& d_mat); | |
- | |
- virtual Mat getMat(int i=-1) const; | |
- virtual void getMatVector(vector<Mat>& mv) const; | |
- virtual GlBuffer getGlBuffer() const; | |
- virtual GlTexture getGlTexture() const; | |
- virtual gpu::GpuMat getGpuMat() const; | |
- | |
- virtual int kind() const; | |
- virtual Size size(int i=-1) const; | |
- virtual size_t total(int i=-1) const; | |
- virtual int type(int i=-1) const; | |
- virtual int depth(int i=-1) const; | |
- virtual int channels(int i=-1) const; | |
- virtual bool empty() const; | |
- | |
- int flags; | |
- void* obj; | |
- Size sz; | |
-}; | |
- | |
- | |
-enum | |
-{ | |
- DEPTH_MASK_8U = 1 << CV_8U, | |
- DEPTH_MASK_8S = 1 << CV_8S, | |
- DEPTH_MASK_16U = 1 << CV_16U, | |
- DEPTH_MASK_16S = 1 << CV_16S, | |
- DEPTH_MASK_32S = 1 << CV_32S, | |
- DEPTH_MASK_32F = 1 << CV_32F, | |
- DEPTH_MASK_64F = 1 << CV_64F, | |
- DEPTH_MASK_ALL = (DEPTH_MASK_64F<<1)-1, | |
- DEPTH_MASK_ALL_BUT_8S = DEPTH_MASK_ALL & ~DEPTH_MASK_8S, | |
- DEPTH_MASK_FLT = DEPTH_MASK_32F + DEPTH_MASK_64F | |
-}; | |
- | |
- | |
-/*! | |
- Proxy datatype for passing Mat's and vector<>'s as input parameters | |
- */ | |
-class CV_EXPORTS _OutputArray : public _InputArray | |
-{ | |
-public: | |
- _OutputArray(); | |
- | |
- _OutputArray(Mat& m); | |
- template<typename _Tp> _OutputArray(vector<_Tp>& vec); | |
- template<typename _Tp> _OutputArray(vector<vector<_Tp> >& vec); | |
- _OutputArray(vector<Mat>& vec); | |
- template<typename _Tp> _OutputArray(Mat_<_Tp>& m); | |
- template<typename _Tp, int m, int n> _OutputArray(Matx<_Tp, m, n>& matx); | |
- template<typename _Tp> _OutputArray(_Tp* vec, int n); | |
- | |
- _OutputArray(const Mat& m); | |
- template<typename _Tp> _OutputArray(const vector<_Tp>& vec); | |
- template<typename _Tp> _OutputArray(const vector<vector<_Tp> >& vec); | |
- _OutputArray(const vector<Mat>& vec); | |
- template<typename _Tp> _OutputArray(const Mat_<_Tp>& m); | |
- template<typename _Tp, int m, int n> _OutputArray(const Matx<_Tp, m, n>& matx); | |
- template<typename _Tp> _OutputArray(const _Tp* vec, int n); | |
- | |
- virtual bool fixedSize() const; | |
- virtual bool fixedType() const; | |
- virtual bool needed() const; | |
- virtual Mat& getMatRef(int i=-1) const; | |
- virtual void create(Size sz, int type, int i=-1, bool allowTransposed=false, int fixedDepthMask=0) const; | |
- virtual void create(int rows, int cols, int type, int i=-1, bool allowTransposed=false, int fixedDepthMask=0) const; | |
- virtual void create(int dims, const int* size, int type, int i=-1, bool allowTransposed=false, int fixedDepthMask=0) const; | |
- virtual void release() const; | |
- virtual void clear() const; | |
-}; | |
- | |
-typedef const _InputArray& InputArray; | |
-typedef InputArray InputArrayOfArrays; | |
-typedef const _OutputArray& OutputArray; | |
-typedef OutputArray OutputArrayOfArrays; | |
-typedef OutputArray InputOutputArray; | |
-typedef OutputArray InputOutputArrayOfArrays; | |
- | |
-CV_EXPORTS OutputArray noArray(); | |
- | |
-/////////////////////////////////////// Mat /////////////////////////////////////////// | |
- | |
-enum { MAGIC_MASK=0xFFFF0000, TYPE_MASK=0x00000FFF, DEPTH_MASK=7 }; | |
- | |
-static inline size_t getElemSize(int type) { return CV_ELEM_SIZE(type); } | |
- | |
-/*! | |
- Custom array allocator | |
- | |
-*/ | |
-class CV_EXPORTS MatAllocator | |
-{ | |
-public: | |
- MatAllocator() {} | |
- virtual ~MatAllocator() {} | |
- virtual void allocate(int dims, const int* sizes, int type, int*& refcount, | |
- uchar*& datastart, uchar*& data, size_t* step) = 0; | |
- virtual void deallocate(int* refcount, uchar* datastart, uchar* data) = 0; | |
-}; | |
- | |
-/*! | |
- The n-dimensional matrix class. | |
- | |
- The class represents an n-dimensional dense numerical array that can act as | |
- a matrix, image, optical flow map, 3-focal tensor etc. | |
- It is very similar to CvMat and CvMatND types from earlier versions of OpenCV, | |
- and similarly to those types, the matrix can be multi-channel. It also fully supports ROI mechanism. | |
- | |
- There are many different ways to create cv::Mat object. Here are the some popular ones: | |
- <ul> | |
- <li> using cv::Mat::create(nrows, ncols, type) method or | |
- the similar constructor cv::Mat::Mat(nrows, ncols, type[, fill_value]) constructor. | |
- A new matrix of the specified size and specifed type will be allocated. | |
- "type" has the same meaning as in cvCreateMat function, | |
- e.g. CV_8UC1 means 8-bit single-channel matrix, CV_32FC2 means 2-channel (i.e. complex) | |
- floating-point matrix etc: | |
- | |
- \code | |
- // make 7x7 complex matrix filled with 1+3j. | |
- cv::Mat M(7,7,CV_32FC2,Scalar(1,3)); | |
- // and now turn M to 100x60 15-channel 8-bit matrix. | |
- // The old content will be deallocated | |
- M.create(100,60,CV_8UC(15)); | |
- \endcode | |
- | |
- As noted in the introduction of this chapter, Mat::create() | |
- will only allocate a new matrix when the current matrix dimensionality | |
- or type are different from the specified. | |
- | |
- <li> by using a copy constructor or assignment operator, where on the right side it can | |
- be a matrix or expression, see below. Again, as noted in the introduction, | |
- matrix assignment is O(1) operation because it only copies the header | |
- and increases the reference counter. cv::Mat::clone() method can be used to get a full | |
- (a.k.a. deep) copy of the matrix when you need it. | |
- | |
- <li> by constructing a header for a part of another matrix. It can be a single row, single column, | |
- several rows, several columns, rectangular region in the matrix (called a minor in algebra) or | |
- a diagonal. Such operations are also O(1), because the new header will reference the same data. | |
- You can actually modify a part of the matrix using this feature, e.g. | |
- | |
- \code | |
- // add 5-th row, multiplied by 3 to the 3rd row | |
- M.row(3) = M.row(3) + M.row(5)*3; | |
- | |
- // now copy 7-th column to the 1-st column | |
- // M.col(1) = M.col(7); // this will not work | |
- Mat M1 = M.col(1); | |
- M.col(7).copyTo(M1); | |
- | |
- // create new 320x240 image | |
- cv::Mat img(Size(320,240),CV_8UC3); | |
- // select a roi | |
- cv::Mat roi(img, Rect(10,10,100,100)); | |
- // fill the ROI with (0,255,0) (which is green in RGB space); | |
- // the original 320x240 image will be modified | |
- roi = Scalar(0,255,0); | |
- \endcode | |
- | |
- Thanks to the additional cv::Mat::datastart and cv::Mat::dataend members, it is possible to | |
- compute the relative sub-matrix position in the main "container" matrix using cv::Mat::locateROI(): | |
- | |
- \code | |
- Mat A = Mat::eye(10, 10, CV_32S); | |
- // extracts A columns, 1 (inclusive) to 3 (exclusive). | |
- Mat B = A(Range::all(), Range(1, 3)); | |
- // extracts B rows, 5 (inclusive) to 9 (exclusive). | |
- // that is, C ~ A(Range(5, 9), Range(1, 3)) | |
- Mat C = B(Range(5, 9), Range::all()); | |
- Size size; Point ofs; | |
- C.locateROI(size, ofs); | |
- // size will be (width=10,height=10) and the ofs will be (x=1, y=5) | |
- \endcode | |
- | |
- As in the case of whole matrices, if you need a deep copy, use cv::Mat::clone() method | |
- of the extracted sub-matrices. | |
- | |
- <li> by making a header for user-allocated-data. It can be useful for | |
- <ol> | |
- <li> processing "foreign" data using OpenCV (e.g. when you implement | |
- a DirectShow filter or a processing module for gstreamer etc.), e.g. | |
- | |
- \code | |
- void process_video_frame(const unsigned char* pixels, | |
- int width, int height, int step) | |
- { | |
- cv::Mat img(height, width, CV_8UC3, pixels, step); | |
- cv::GaussianBlur(img, img, cv::Size(7,7), 1.5, 1.5); | |
- } | |
- \endcode | |
- | |
- <li> for quick initialization of small matrices and/or super-fast element access | |
- | |
- \code | |
- double m[3][3] = {{a, b, c}, {d, e, f}, {g, h, i}}; | |
- cv::Mat M = cv::Mat(3, 3, CV_64F, m).inv(); | |
- \endcode | |
- </ol> | |
- | |
- partial yet very common cases of this "user-allocated data" case are conversions | |
- from CvMat and IplImage to cv::Mat. For this purpose there are special constructors | |
- taking pointers to CvMat or IplImage and the optional | |
- flag indicating whether to copy the data or not. | |
- | |
- Backward conversion from cv::Mat to CvMat or IplImage is provided via cast operators | |
- cv::Mat::operator CvMat() an cv::Mat::operator IplImage(). | |
- The operators do not copy the data. | |
- | |
- | |
- \code | |
- IplImage* img = cvLoadImage("greatwave.jpg", 1); | |
- Mat mtx(img); // convert IplImage* -> cv::Mat | |
- CvMat oldmat = mtx; // convert cv::Mat -> CvMat | |
- CV_Assert(oldmat.cols == img->width && oldmat.rows == img->height && | |
- oldmat.data.ptr == (uchar*)img->imageData && oldmat.step == img->widthStep); | |
- \endcode | |
- | |
- <li> by using MATLAB-style matrix initializers, cv::Mat::zeros(), cv::Mat::ones(), cv::Mat::eye(), e.g.: | |
- | |
- \code | |
- // create a double-precision identity martix and add it to M. | |
- M += Mat::eye(M.rows, M.cols, CV_64F); | |
- \endcode | |
- | |
- <li> by using comma-separated initializer: | |
- | |
- \code | |
- // create 3x3 double-precision identity matrix | |
- Mat M = (Mat_<double>(3,3) << 1, 0, 0, 0, 1, 0, 0, 0, 1); | |
- \endcode | |
- | |
- here we first call constructor of cv::Mat_ class (that we describe further) with the proper matrix, | |
- and then we just put "<<" operator followed by comma-separated values that can be constants, | |
- variables, expressions etc. Also, note the extra parentheses that are needed to avoid compiler errors. | |
- | |
- </ul> | |
- | |
- Once matrix is created, it will be automatically managed by using reference-counting mechanism | |
- (unless the matrix header is built on top of user-allocated data, | |
- in which case you should handle the data by yourself). | |
- The matrix data will be deallocated when no one points to it; | |
- if you want to release the data pointed by a matrix header before the matrix destructor is called, | |
- use cv::Mat::release(). | |
- | |
- The next important thing to learn about the matrix class is element access. Here is how the matrix is stored. | |
- The elements are stored in row-major order (row by row). The cv::Mat::data member points to the first element of the first row, | |
- cv::Mat::rows contains the number of matrix rows and cv::Mat::cols - the number of matrix columns. There is yet another member, | |
- cv::Mat::step that is used to actually compute address of a matrix element. cv::Mat::step is needed because the matrix can be | |
- a part of another matrix or because there can some padding space in the end of each row for a proper alignment. | |
- | |
- \image html roi.png | |
- | |
- Given these parameters, address of the matrix element M_{ij} is computed as following: | |
- | |
- addr(M_{ij})=M.data + M.step*i + j*M.elemSize() | |
- | |
- if you know the matrix element type, e.g. it is float, then you can use cv::Mat::at() method: | |
- | |
- addr(M_{ij})=&M.at<float>(i,j) | |
- | |
- (where & is used to convert the reference returned by cv::Mat::at() to a pointer). | |
- if you need to process a whole row of matrix, the most efficient way is to get | |
- the pointer to the row first, and then just use plain C operator []: | |
- | |
- \code | |
- // compute sum of positive matrix elements | |
- // (assuming that M is double-precision matrix) | |
- double sum=0; | |
- for(int i = 0; i < M.rows; i++) | |
- { | |
- const double* Mi = M.ptr<double>(i); | |
- for(int j = 0; j < M.cols; j++) | |
- sum += std::max(Mi[j], 0.); | |
- } | |
- \endcode | |
- | |
- Some operations, like the above one, do not actually depend on the matrix shape, | |
- they just process elements of a matrix one by one (or elements from multiple matrices | |
- that are sitting in the same place, e.g. matrix addition). Such operations are called | |
- element-wise and it makes sense to check whether all the input/output matrices are continuous, | |
- i.e. have no gaps in the end of each row, and if yes, process them as a single long row: | |
- | |
- \code | |
- // compute sum of positive matrix elements, optimized variant | |
- double sum=0; | |
- int cols = M.cols, rows = M.rows; | |
- if(M.isContinuous()) | |
- { | |
- cols *= rows; | |
- rows = 1; | |
- } | |
- for(int i = 0; i < rows; i++) | |
- { | |
- const double* Mi = M.ptr<double>(i); | |
- for(int j = 0; j < cols; j++) | |
- sum += std::max(Mi[j], 0.); | |
- } | |
- \endcode | |
- in the case of continuous matrix the outer loop body will be executed just once, | |
- so the overhead will be smaller, which will be especially noticeable in the case of small matrices. | |
- | |
- Finally, there are STL-style iterators that are smart enough to skip gaps between successive rows: | |
- \code | |
- // compute sum of positive matrix elements, iterator-based variant | |
- double sum=0; | |
- MatConstIterator_<double> it = M.begin<double>(), it_end = M.end<double>(); | |
- for(; it != it_end; ++it) | |
- sum += std::max(*it, 0.); | |
- \endcode | |
- | |
- The matrix iterators are random-access iterators, so they can be passed | |
- to any STL algorithm, including std::sort(). | |
-*/ | |
-class CV_EXPORTS Mat | |
-{ | |
-public: | |
- //! default constructor | |
- Mat(); | |
- //! constructs 2D matrix of the specified size and type | |
- // (_type is CV_8UC1, CV_64FC3, CV_32SC(12) etc.) | |
- Mat(int _rows, int _cols, int _type); | |
- Mat(Size _size, int _type); | |
- //! constucts 2D matrix and fills it with the specified value _s. | |
- Mat(int _rows, int _cols, int _type, const Scalar& _s); | |
- Mat(Size _size, int _type, const Scalar& _s); | |
- | |
- //! constructs n-dimensional matrix | |
- Mat(int _ndims, const int* _sizes, int _type); | |
- Mat(int _ndims, const int* _sizes, int _type, const Scalar& _s); | |
- | |
- //! copy constructor | |
- Mat(const Mat& m); | |
- //! constructor for matrix headers pointing to user-allocated data | |
- Mat(int _rows, int _cols, int _type, void* _data, size_t _step=AUTO_STEP); | |
- Mat(Size _size, int _type, void* _data, size_t _step=AUTO_STEP); | |
- Mat(int _ndims, const int* _sizes, int _type, void* _data, const size_t* _steps=0); | |
- | |
- //! creates a matrix header for a part of the bigger matrix | |
- Mat(const Mat& m, const Range& rowRange, const Range& colRange=Range::all()); | |
- Mat(const Mat& m, const Rect& roi); | |
- Mat(const Mat& m, const Range* ranges); | |
- //! converts old-style CvMat to the new matrix; the data is not copied by default | |
- Mat(const CvMat* m, bool copyData=false); | |
- //! converts old-style CvMatND to the new matrix; the data is not copied by default | |
- Mat(const CvMatND* m, bool copyData=false); | |
- //! converts old-style IplImage to the new matrix; the data is not copied by default | |
- Mat(const IplImage* img, bool copyData=false); | |
- //! builds matrix from std::vector with or without copying the data | |
- template<typename _Tp> explicit Mat(const vector<_Tp>& vec, bool copyData=false); | |
- //! builds matrix from cv::Vec; the data is copied by default | |
- template<typename _Tp, int n> explicit Mat(const Vec<_Tp, n>& vec, | |
- bool copyData=true); | |
- //! builds matrix from cv::Matx; the data is copied by default | |
- template<typename _Tp, int m, int n> explicit Mat(const Matx<_Tp, m, n>& mtx, | |
- bool copyData=true); | |
- //! builds matrix from a 2D point | |
- template<typename _Tp> explicit Mat(const Point_<_Tp>& pt, bool copyData=true); | |
- //! builds matrix from a 3D point | |
- template<typename _Tp> explicit Mat(const Point3_<_Tp>& pt, bool copyData=true); | |
- //! builds matrix from comma initializer | |
- template<typename _Tp> explicit Mat(const MatCommaInitializer_<_Tp>& commaInitializer); | |
- | |
- //! download data from GpuMat | |
- explicit Mat(const gpu::GpuMat& m); | |
- | |
- //! destructor - calls release() | |
- ~Mat(); | |
- //! assignment operators | |
- Mat& operator = (const Mat& m); | |
- Mat& operator = (const MatExpr& expr); | |
- | |
- //! returns a new matrix header for the specified row | |
- Mat row(int y) const; | |
- //! returns a new matrix header for the specified column | |
- Mat col(int x) const; | |
- //! ... for the specified row span | |
- Mat rowRange(int startrow, int endrow) const; | |
- Mat rowRange(const Range& r) const; | |
- //! ... for the specified column span | |
- Mat colRange(int startcol, int endcol) const; | |
- Mat colRange(const Range& r) const; | |
- //! ... for the specified diagonal | |
- // (d=0 - the main diagonal, | |
- // >0 - a diagonal from the lower half, | |
- // <0 - a diagonal from the upper half) | |
- Mat diag(int d=0) const; | |
- //! constructs a square diagonal matrix which main diagonal is vector "d" | |
- static Mat diag(const Mat& d); | |
- | |
- //! returns deep copy of the matrix, i.e. the data is copied | |
- Mat clone() const; | |
- //! copies the matrix content to "m". | |
- // It calls m.create(this->size(), this->type()). | |
- void copyTo( OutputArray m ) const; | |
- //! copies those matrix elements to "m" that are marked with non-zero mask elements. | |
- void copyTo( OutputArray m, InputArray mask ) const; | |
- //! converts matrix to another datatype with optional scalng. See cvConvertScale. | |
- void convertTo( OutputArray m, int rtype, double alpha=1, double beta=0 ) const; | |
- | |
- void assignTo( Mat& m, int type=-1 ) const; | |
- | |
- //! sets every matrix element to s | |
- Mat& operator = (const Scalar& s); | |
- //! sets some of the matrix elements to s, according to the mask | |
- Mat& setTo(InputArray value, InputArray mask=noArray()); | |
- //! creates alternative matrix header for the same data, with different | |
- // number of channels and/or different number of rows. see cvReshape. | |
- Mat reshape(int _cn, int _rows=0) const; | |
- Mat reshape(int _cn, int _newndims, const int* _newsz) const; | |
- | |
- //! matrix transposition by means of matrix expressions | |
- MatExpr t() const; | |
- //! matrix inversion by means of matrix expressions | |
- MatExpr inv(int method=DECOMP_LU) const; | |
- //! per-element matrix multiplication by means of matrix expressions | |
- MatExpr mul(InputArray m, double scale=1) const; | |
- | |
- //! computes cross-product of 2 3D vectors | |
- Mat cross(InputArray m) const; | |
- //! computes dot-product | |
- double dot(InputArray m) const; | |
- | |
- //! Matlab-style matrix initialization | |
- static MatExpr zeros(int rows, int cols, int type); | |
- static MatExpr zeros(Size size, int type); | |
- static MatExpr zeros(int ndims, const int* sz, int type); | |
- static MatExpr ones(int rows, int cols, int type); | |
- static MatExpr ones(Size size, int type); | |
- static MatExpr ones(int ndims, const int* sz, int type); | |
- static MatExpr eye(int rows, int cols, int type); | |
- static MatExpr eye(Size size, int type); | |
- | |
- //! allocates new matrix data unless the matrix already has specified size and type. | |
- // previous data is unreferenced if needed. | |
- void create(int _rows, int _cols, int _type); | |
- void create(Size _size, int _type); | |
- void create(int _ndims, const int* _sizes, int _type); | |
- | |
- //! increases the reference counter; use with care to avoid memleaks | |
- void addref(); | |
- //! decreases reference counter; | |
- // deallocates the data when reference counter reaches 0. | |
- void release(); | |
- | |
- //! deallocates the matrix data | |
- void deallocate(); | |
- //! internal use function; properly re-allocates _size, _step arrays | |
- void copySize(const Mat& m); | |
- | |
- //! reserves enough space to fit sz hyper-planes | |
- void reserve(size_t sz); | |
- //! resizes matrix to the specified number of hyper-planes | |
- void resize(size_t sz); | |
- //! resizes matrix to the specified number of hyper-planes; initializes the newly added elements | |
- void resize(size_t sz, const Scalar& s); | |
- //! internal function | |
- void push_back_(const void* elem); | |
- //! adds element to the end of 1d matrix (or possibly multiple elements when _Tp=Mat) | |
- template<typename _Tp> void push_back(const _Tp& elem); | |
- template<typename _Tp> void push_back(const Mat_<_Tp>& elem); | |
- void push_back(const Mat& m); | |
- //! removes several hyper-planes from bottom of the matrix | |
- void pop_back(size_t nelems=1); | |
- | |
- //! locates matrix header within a parent matrix. See below | |
- void locateROI( Size& wholeSize, Point& ofs ) const; | |
- //! moves/resizes the current matrix ROI inside the parent matrix. | |
- Mat& adjustROI( int dtop, int dbottom, int dleft, int dright ); | |
- //! extracts a rectangular sub-matrix | |
- // (this is a generalized form of row, rowRange etc.) | |
- Mat operator()( Range rowRange, Range colRange ) const; | |
- Mat operator()( const Rect& roi ) const; | |
- Mat operator()( const Range* ranges ) const; | |
- | |
- //! converts header to CvMat; no data is copied | |
- operator CvMat() const; | |
- //! converts header to CvMatND; no data is copied | |
- operator CvMatND() const; | |
- //! converts header to IplImage; no data is copied | |
- operator IplImage() const; | |
- | |
- template<typename _Tp> operator vector<_Tp>() const; | |
- template<typename _Tp, int n> operator Vec<_Tp, n>() const; | |
- template<typename _Tp, int m, int n> operator Matx<_Tp, m, n>() const; | |
- | |
- //! returns true iff the matrix data is continuous | |
- // (i.e. when there are no gaps between successive rows). | |
- // similar to CV_IS_MAT_CONT(cvmat->type) | |
- bool isContinuous() const; | |
- | |
- //! returns true if the matrix is a submatrix of another matrix | |
- bool isSubmatrix() const; | |
- | |
- //! returns element size in bytes, | |
- // similar to CV_ELEM_SIZE(cvmat->type) | |
- size_t elemSize() const; | |
- //! returns the size of element channel in bytes. | |
- size_t elemSize1() const; | |
- //! returns element type, similar to CV_MAT_TYPE(cvmat->type) | |
- int type() const; | |
- //! returns element type, similar to CV_MAT_DEPTH(cvmat->type) | |
- int depth() const; | |
- //! returns element type, similar to CV_MAT_CN(cvmat->type) | |
- int channels() const; | |
- //! returns step/elemSize1() | |
- size_t step1(int i=0) const; | |
- //! returns true if matrix data is NULL | |
- bool empty() const; | |
- //! returns the total number of matrix elements | |
- size_t total() const; | |
- | |
- //! returns N if the matrix is 1-channel (N x ptdim) or ptdim-channel (1 x N) or (N x 1); negative number otherwise | |
- int checkVector(int elemChannels, int depth=-1, bool requireContinuous=true) const; | |
- | |
- //! returns pointer to i0-th submatrix along the dimension #0 | |
- uchar* ptr(int i0=0); | |
- const uchar* ptr(int i0=0) const; | |
- | |
- //! returns pointer to (i0,i1) submatrix along the dimensions #0 and #1 | |
- uchar* ptr(int i0, int i1); | |
- const uchar* ptr(int i0, int i1) const; | |
- | |
- //! returns pointer to (i0,i1,i3) submatrix along the dimensions #0, #1, #2 | |
- uchar* ptr(int i0, int i1, int i2); | |
- const uchar* ptr(int i0, int i1, int i2) const; | |
- | |
- //! returns pointer to the matrix element | |
- uchar* ptr(const int* idx); | |
- //! returns read-only pointer to the matrix element | |
- const uchar* ptr(const int* idx) const; | |
- | |
- template<int n> uchar* ptr(const Vec<int, n>& idx); | |
- template<int n> const uchar* ptr(const Vec<int, n>& idx) const; | |
- | |
- //! template version of the above method | |
- template<typename _Tp> _Tp* ptr(int i0=0); | |
- template<typename _Tp> const _Tp* ptr(int i0=0) const; | |
- | |
- template<typename _Tp> _Tp* ptr(int i0, int i1); | |
- template<typename _Tp> const _Tp* ptr(int i0, int i1) const; | |
- | |
- template<typename _Tp> _Tp* ptr(int i0, int i1, int i2); | |
- template<typename _Tp> const _Tp* ptr(int i0, int i1, int i2) const; | |
- | |
- template<typename _Tp> _Tp* ptr(const int* idx); | |
- template<typename _Tp> const _Tp* ptr(const int* idx) const; | |
- | |
- template<typename _Tp, int n> _Tp* ptr(const Vec<int, n>& idx); | |
- template<typename _Tp, int n> const _Tp* ptr(const Vec<int, n>& idx) const; | |
- | |
- //! the same as above, with the pointer dereferencing | |
- template<typename _Tp> _Tp& at(int i0=0); | |
- template<typename _Tp> const _Tp& at(int i0=0) const; | |
- | |
- template<typename _Tp> _Tp& at(int i0, int i1); | |
- template<typename _Tp> const _Tp& at(int i0, int i1) const; | |
- | |
- template<typename _Tp> _Tp& at(int i0, int i1, int i2); | |
- template<typename _Tp> const _Tp& at(int i0, int i1, int i2) const; | |
- | |
- template<typename _Tp> _Tp& at(const int* idx); | |
- template<typename _Tp> const _Tp& at(const int* idx) const; | |
- | |
- template<typename _Tp, int n> _Tp& at(const Vec<int, n>& idx); | |
- template<typename _Tp, int n> const _Tp& at(const Vec<int, n>& idx) const; | |
- | |
- //! special versions for 2D arrays (especially convenient for referencing image pixels) | |
- template<typename _Tp> _Tp& at(Point pt); | |
- template<typename _Tp> const _Tp& at(Point pt) const; | |
- | |
- //! template methods for iteration over matrix elements. | |
- // the iterators take care of skipping gaps in the end of rows (if any) | |
- template<typename _Tp> MatIterator_<_Tp> begin(); | |
- template<typename _Tp> MatIterator_<_Tp> end(); | |
- template<typename _Tp> MatConstIterator_<_Tp> begin() const; | |
- template<typename _Tp> MatConstIterator_<_Tp> end() const; | |
- | |
- enum { MAGIC_VAL=0x42FF0000, AUTO_STEP=0, CONTINUOUS_FLAG=CV_MAT_CONT_FLAG, SUBMATRIX_FLAG=CV_SUBMAT_FLAG }; | |
- | |
- /*! includes several bit-fields: | |
- - the magic signature | |
- - continuity flag | |
- - depth | |
- - number of channels | |
- */ | |
- int flags; | |
- //! the matrix dimensionality, >= 2 | |
- int dims; | |
- //! the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions | |
- int rows, cols; | |
- //! pointer to the data | |
- uchar* data; | |
- | |
- //! pointer to the reference counter; | |
- // when matrix points to user-allocated data, the pointer is NULL | |
- int* refcount; | |
- | |
- //! helper fields used in locateROI and adjustROI | |
- uchar* datastart; | |
- uchar* dataend; | |
- uchar* datalimit; | |
- | |
- //! custom allocator | |
- MatAllocator* allocator; | |
- | |
- struct CV_EXPORTS MSize | |
- { | |
- MSize(int* _p); | |
- Size operator()() const; | |
- const int& operator[](int i) const; | |
- int& operator[](int i); | |
- operator const int*() const; | |
- bool operator == (const MSize& sz) const; | |
- bool operator != (const MSize& sz) const; | |
- | |
- int* p; | |
- }; | |
- | |
- struct CV_EXPORTS MStep | |
- { | |
- MStep(); | |
- MStep(size_t s); | |
- const size_t& operator[](int i) const; | |
- size_t& operator[](int i); | |
- operator size_t() const; | |
- MStep& operator = (size_t s); | |
- | |
- size_t* p; | |
- size_t buf[2]; | |
- protected: | |
- MStep& operator = (const MStep&); | |
- }; | |
- | |
- MSize size; | |
- MStep step; | |
- | |
-protected: | |
- void initEmpty(); | |
-}; | |
- | |
- | |
-/*! | |
- Random Number Generator | |
- | |
- The class implements RNG using Multiply-with-Carry algorithm | |
-*/ | |
-class CV_EXPORTS RNG | |
-{ | |
-public: | |
- enum { UNIFORM=0, NORMAL=1 }; | |
- | |
- RNG(); | |
- RNG(uint64 _state); | |
- //! updates the state and returns the next 32-bit unsigned integer random number | |
- unsigned next(); | |
- | |
- operator uchar(); | |
- operator schar(); | |
- operator ushort(); | |
- operator short(); | |
- operator unsigned(); | |
- //! returns a random integer sampled uniformly from [0, N). | |
- unsigned operator()(unsigned N); | |
- unsigned operator ()(); | |
- operator int(); | |
- operator float(); | |
- operator double(); | |
- //! returns uniformly distributed integer random number from [a,b) range | |
- int uniform(int a, int b); | |
- //! returns uniformly distributed floating-point random number from [a,b) range | |
- float uniform(float a, float b); | |
- //! returns uniformly distributed double-precision floating-point random number from [a,b) range | |
- double uniform(double a, double b); | |
- void fill( InputOutputArray mat, int distType, InputArray a, InputArray b, bool saturateRange=false ); | |
- //! returns Gaussian random variate with mean zero. | |
- double gaussian(double sigma); | |
- | |
- uint64 state; | |
-}; | |
- | |
- | |
-/*! | |
- Termination criteria in iterative algorithms | |
- */ | |
-class CV_EXPORTS TermCriteria | |
-{ | |
-public: | |
- enum | |
- { | |
- COUNT=1, //!< the maximum number of iterations or elements to compute | |
- MAX_ITER=COUNT, //!< ditto | |
- EPS=2 //!< the desired accuracy or change in parameters at which the iterative algorithm stops | |
- }; | |
- | |
- //! default constructor | |
- TermCriteria(); | |
- //! full constructor | |
- TermCriteria(int _type, int _maxCount, double _epsilon); | |
- //! conversion from CvTermCriteria | |
- TermCriteria(const CvTermCriteria& criteria); | |
- //! conversion from CvTermCriteria | |
- operator CvTermCriteria() const; | |
- | |
- int type; //!< the type of termination criteria: COUNT, EPS or COUNT + EPS | |
- int maxCount; // the maximum number of iterations/elements | |
- double epsilon; // the desired accuracy | |
-}; | |
- | |
- | |
-typedef void (*BinaryFunc)(const uchar* src1, size_t step1, | |
- const uchar* src2, size_t step2, | |
- uchar* dst, size_t step, Size sz, | |
- void*); | |
- | |
-CV_EXPORTS BinaryFunc getConvertFunc(int sdepth, int ddepth); | |
-CV_EXPORTS BinaryFunc getConvertScaleFunc(int sdepth, int ddepth); | |
-CV_EXPORTS BinaryFunc getCopyMaskFunc(size_t esz); | |
- | |
-//! swaps two matrices | |
-CV_EXPORTS void swap(Mat& a, Mat& b); | |
- | |
-//! converts array (CvMat or IplImage) to cv::Mat | |
-CV_EXPORTS Mat cvarrToMat(const CvArr* arr, bool copyData=false, | |
- bool allowND=true, int coiMode=0); | |
-//! extracts Channel of Interest from CvMat or IplImage and makes cv::Mat out of it. | |
-CV_EXPORTS void extractImageCOI(const CvArr* arr, OutputArray coiimg, int coi=-1); | |
-//! inserts single-channel cv::Mat into a multi-channel CvMat or IplImage | |
-CV_EXPORTS void insertImageCOI(InputArray coiimg, CvArr* arr, int coi=-1); | |
- | |
-//! adds one matrix to another (dst = src1 + src2) | |
-CV_EXPORTS_W void add(InputArray src1, InputArray src2, OutputArray dst, | |
- InputArray mask=noArray(), int dtype=-1); | |
-//! subtracts one matrix from another (dst = src1 - src2) | |
-CV_EXPORTS_W void subtract(InputArray src1, InputArray src2, OutputArray dst, | |
- InputArray mask=noArray(), int dtype=-1); | |
- | |
-//! computes element-wise weighted product of the two arrays (dst = scale*src1*src2) | |
-CV_EXPORTS_W void multiply(InputArray src1, InputArray src2, | |
- OutputArray dst, double scale=1, int dtype=-1); | |
- | |
-//! computes element-wise weighted quotient of the two arrays (dst = scale*src1/src2) | |
-CV_EXPORTS_W void divide(InputArray src1, InputArray src2, OutputArray dst, | |
- double scale=1, int dtype=-1); | |
- | |
-//! computes element-wise weighted reciprocal of an array (dst = scale/src2) | |
-CV_EXPORTS_W void divide(double scale, InputArray src2, | |
- OutputArray dst, int dtype=-1); | |
- | |
-//! adds scaled array to another one (dst = alpha*src1 + src2) | |
-CV_EXPORTS_W void scaleAdd(InputArray src1, double alpha, InputArray src2, OutputArray dst); | |
- | |
-//! computes weighted sum of two arrays (dst = alpha*src1 + beta*src2 + gamma) | |
-CV_EXPORTS_W void addWeighted(InputArray src1, double alpha, InputArray src2, | |
- double beta, double gamma, OutputArray dst, int dtype=-1); | |
- | |
-//! scales array elements, computes absolute values and converts the results to 8-bit unsigned integers: dst(i)=saturate_cast<uchar>abs(src(i)*alpha+beta) | |
-CV_EXPORTS_W void convertScaleAbs(InputArray src, OutputArray dst, | |
- double alpha=1, double beta=0); | |
-//! transforms array of numbers using a lookup table: dst(i)=lut(src(i)) | |
-CV_EXPORTS_W void LUT(InputArray src, InputArray lut, OutputArray dst, | |
- int interpolation=0); | |
- | |
-//! computes sum of array elements | |
-CV_EXPORTS_AS(sumElems) Scalar sum(InputArray src); | |
-//! computes the number of nonzero array elements | |
-CV_EXPORTS_W int countNonZero( InputArray src ); | |
-//! computes mean value of selected array elements | |
-CV_EXPORTS_W Scalar mean(InputArray src, InputArray mask=noArray()); | |
-//! computes mean value and standard deviation of all or selected array elements | |
-CV_EXPORTS_W void meanStdDev(InputArray src, OutputArray mean, OutputArray stddev, | |
- InputArray mask=noArray()); | |
-//! computes norm of the selected array part | |
-CV_EXPORTS_W double norm(InputArray src1, int normType=NORM_L2, InputArray mask=noArray()); | |
-//! computes norm of selected part of the difference between two arrays | |
-CV_EXPORTS_W double norm(InputArray src1, InputArray src2, | |
- int normType=NORM_L2, InputArray mask=noArray()); | |
- | |
-//! naive nearest neighbor finder | |
-CV_EXPORTS_W void batchDistance(InputArray src1, InputArray src2, | |
- OutputArray dist, int dtype, OutputArray nidx, | |
- int normType=NORM_L2, int K=0, | |
- InputArray mask=noArray(), int update=0, | |
- bool crosscheck=false); | |
- | |
-//! scales and shifts array elements so that either the specified norm (alpha) or the minimum (alpha) and maximum (beta) array values get the specified values | |
-CV_EXPORTS_W void normalize( InputArray src, OutputArray dst, double alpha=1, double beta=0, | |
- int norm_type=NORM_L2, int dtype=-1, InputArray mask=noArray()); | |
- | |
-//! finds global minimum and maximum array elements and returns their values and their locations | |
-CV_EXPORTS_W void minMaxLoc(InputArray src, CV_OUT double* minVal, | |
- CV_OUT double* maxVal=0, CV_OUT Point* minLoc=0, | |
- CV_OUT Point* maxLoc=0, InputArray mask=noArray()); | |
-CV_EXPORTS void minMaxIdx(InputArray src, double* minVal, double* maxVal, | |
- int* minIdx=0, int* maxIdx=0, InputArray mask=noArray()); | |
- | |
-//! transforms 2D matrix to 1D row or column vector by taking sum, minimum, maximum or mean value over all the rows | |
-CV_EXPORTS_W void reduce(InputArray src, OutputArray dst, int dim, int rtype, int dtype=-1); | |
- | |
-//! makes multi-channel array out of several single-channel arrays | |
-CV_EXPORTS void merge(const Mat* mv, size_t count, OutputArray dst); | |
-//! makes multi-channel array out of several single-channel arrays | |
-CV_EXPORTS_W void merge(const vector<Mat>& mv, OutputArray dst); | |
- | |
-//! copies each plane of a multi-channel array to a dedicated array | |
-CV_EXPORTS void split(const Mat& src, Mat* mvbegin); | |
-//! copies each plane of a multi-channel array to a dedicated array | |
-CV_EXPORTS_W void split(const Mat& m, CV_OUT vector<Mat>& mv); | |
- | |
-//! copies selected channels from the input arrays to the selected channels of the output arrays | |
-CV_EXPORTS void mixChannels(const Mat* src, size_t nsrcs, Mat* dst, size_t ndsts, | |
- const int* fromTo, size_t npairs); | |
-CV_EXPORTS void mixChannels(const vector<Mat>& src, vector<Mat>& dst, | |
- const int* fromTo, size_t npairs); | |
-CV_EXPORTS_W void mixChannels(InputArrayOfArrays src, InputArrayOfArrays dst, | |
- const vector<int>& fromTo); | |
- | |
-//! extracts a single channel from src (coi is 0-based index) | |
-CV_EXPORTS_W void extractChannel(InputArray src, OutputArray dst, int coi); | |
- | |
-//! inserts a single channel to dst (coi is 0-based index) | |
-CV_EXPORTS_W void insertChannel(InputArray src, InputOutputArray dst, int coi); | |
- | |
-//! reverses the order of the rows, columns or both in a matrix | |
-CV_EXPORTS_W void flip(InputArray src, OutputArray dst, int flipCode); | |
- | |
-//! replicates the input matrix the specified number of times in the horizontal and/or vertical direction | |
-CV_EXPORTS_W void repeat(InputArray src, int ny, int nx, OutputArray dst); | |
-CV_EXPORTS Mat repeat(const Mat& src, int ny, int nx); | |
- | |
-CV_EXPORTS void hconcat(const Mat* src, size_t nsrc, OutputArray dst); | |
-CV_EXPORTS void hconcat(InputArray src1, InputArray src2, OutputArray dst); | |
-CV_EXPORTS_W void hconcat(InputArrayOfArrays src, OutputArray dst); | |
- | |
-CV_EXPORTS void vconcat(const Mat* src, size_t nsrc, OutputArray dst); | |
-CV_EXPORTS void vconcat(InputArray src1, InputArray src2, OutputArray dst); | |
-CV_EXPORTS_W void vconcat(InputArrayOfArrays src, OutputArray dst); | |
- | |
-//! computes bitwise conjunction of the two arrays (dst = src1 & src2) | |
-CV_EXPORTS_W void bitwise_and(InputArray src1, InputArray src2, | |
- OutputArray dst, InputArray mask=noArray()); | |
-//! computes bitwise disjunction of the two arrays (dst = src1 | src2) | |
-CV_EXPORTS_W void bitwise_or(InputArray src1, InputArray src2, | |
- OutputArray dst, InputArray mask=noArray()); | |
-//! computes bitwise exclusive-or of the two arrays (dst = src1 ^ src2) | |
-CV_EXPORTS_W void bitwise_xor(InputArray src1, InputArray src2, | |
- OutputArray dst, InputArray mask=noArray()); | |
-//! inverts each bit of array (dst = ~src) | |
-CV_EXPORTS_W void bitwise_not(InputArray src, OutputArray dst, | |
- InputArray mask=noArray()); | |
-//! computes element-wise absolute difference of two arrays (dst = abs(src1 - src2)) | |
-CV_EXPORTS_W void absdiff(InputArray src1, InputArray src2, OutputArray dst); | |
-//! set mask elements for those array elements which are within the element-specific bounding box (dst = lowerb <= src && src < upperb) | |
-CV_EXPORTS_W void inRange(InputArray src, InputArray lowerb, | |
- InputArray upperb, OutputArray dst); | |
-//! compares elements of two arrays (dst = src1 <cmpop> src2) | |
-CV_EXPORTS_W void compare(InputArray src1, InputArray src2, OutputArray dst, int cmpop); | |
-//! computes per-element minimum of two arrays (dst = min(src1, src2)) | |
-CV_EXPORTS_W void min(InputArray src1, InputArray src2, OutputArray dst); | |
-//! computes per-element maximum of two arrays (dst = max(src1, src2)) | |
-CV_EXPORTS_W void max(InputArray src1, InputArray src2, OutputArray dst); | |
- | |
-//! computes per-element minimum of two arrays (dst = min(src1, src2)) | |
-CV_EXPORTS void min(const Mat& src1, const Mat& src2, Mat& dst); | |
-//! computes per-element minimum of array and scalar (dst = min(src1, src2)) | |
-CV_EXPORTS void min(const Mat& src1, double src2, Mat& dst); | |
-//! computes per-element maximum of two arrays (dst = max(src1, src2)) | |
-CV_EXPORTS void max(const Mat& src1, const Mat& src2, Mat& dst); | |
-//! computes per-element maximum of array and scalar (dst = max(src1, src2)) | |
-CV_EXPORTS void max(const Mat& src1, double src2, Mat& dst); | |
- | |
-//! computes square root of each matrix element (dst = src**0.5) | |
-CV_EXPORTS_W void sqrt(InputArray src, OutputArray dst); | |
-//! raises the input matrix elements to the specified power (b = a**power) | |
-CV_EXPORTS_W void pow(InputArray src, double power, OutputArray dst); | |
-//! computes exponent of each matrix element (dst = e**src) | |
-CV_EXPORTS_W void exp(InputArray src, OutputArray dst); | |
-//! computes natural logarithm of absolute value of each matrix element: dst = log(abs(src)) | |
-CV_EXPORTS_W void log(InputArray src, OutputArray dst); | |
-//! computes cube root of the argument | |
-CV_EXPORTS_W float cubeRoot(float val); | |
-//! computes the angle in degrees (0..360) of the vector (x,y) | |
-CV_EXPORTS_W float fastAtan2(float y, float x); | |
- | |
-CV_EXPORTS void exp(const float* src, float* dst, int n); | |
-CV_EXPORTS void log(const float* src, float* dst, int n); | |
-CV_EXPORTS void fastAtan2(const float* y, const float* x, float* dst, int n, bool angleInDegrees); | |
-CV_EXPORTS void magnitude(const float* x, const float* y, float* dst, int n); | |
- | |
-//! converts polar coordinates to Cartesian | |
-CV_EXPORTS_W void polarToCart(InputArray magnitude, InputArray angle, | |
- OutputArray x, OutputArray y, bool angleInDegrees=false); | |
-//! converts Cartesian coordinates to polar | |
-CV_EXPORTS_W void cartToPolar(InputArray x, InputArray y, | |
- OutputArray magnitude, OutputArray angle, | |
- bool angleInDegrees=false); | |
-//! computes angle (angle(i)) of each (x(i), y(i)) vector | |
-CV_EXPORTS_W void phase(InputArray x, InputArray y, OutputArray angle, | |
- bool angleInDegrees=false); | |
-//! computes magnitude (magnitude(i)) of each (x(i), y(i)) vector | |
-CV_EXPORTS_W void magnitude(InputArray x, InputArray y, OutputArray magnitude); | |
-//! checks that each matrix element is within the specified range. | |
-CV_EXPORTS_W bool checkRange(InputArray a, bool quiet=true, CV_OUT Point* pos=0, | |
- double minVal=-DBL_MAX, double maxVal=DBL_MAX); | |
-//! converts NaN's to the given number | |
-CV_EXPORTS_W void patchNaNs(InputOutputArray a, double val=0); | |
- | |
-//! implements generalized matrix product algorithm GEMM from BLAS | |
-CV_EXPORTS_W void gemm(InputArray src1, InputArray src2, double alpha, | |
- InputArray src3, double gamma, OutputArray dst, int flags=0); | |
-//! multiplies matrix by its transposition from the left or from the right | |
-CV_EXPORTS_W void mulTransposed( InputArray src, OutputArray dst, bool aTa, | |
- InputArray delta=noArray(), | |
- double scale=1, int dtype=-1 ); | |
-//! transposes the matrix | |
-CV_EXPORTS_W void transpose(InputArray src, OutputArray dst); | |
-//! performs affine transformation of each element of multi-channel input matrix | |
-CV_EXPORTS_W void transform(InputArray src, OutputArray dst, InputArray m ); | |
-//! performs perspective transformation of each element of multi-channel input matrix | |
-CV_EXPORTS_W void perspectiveTransform(InputArray src, OutputArray dst, InputArray m ); | |
- | |
-//! extends the symmetrical matrix from the lower half or from the upper half | |
-CV_EXPORTS_W void completeSymm(InputOutputArray mtx, bool lowerToUpper=false); | |
-//! initializes scaled identity matrix | |
-CV_EXPORTS_W void setIdentity(InputOutputArray mtx, const Scalar& s=Scalar(1)); | |
-//! computes determinant of a square matrix | |
-CV_EXPORTS_W double determinant(InputArray mtx); | |
-//! computes trace of a matrix | |
-CV_EXPORTS_W Scalar trace(InputArray mtx); | |
-//! computes inverse or pseudo-inverse matrix | |
-CV_EXPORTS_W double invert(InputArray src, OutputArray dst, int flags=DECOMP_LU); | |
-//! solves linear system or a least-square problem | |
-CV_EXPORTS_W bool solve(InputArray src1, InputArray src2, | |
- OutputArray dst, int flags=DECOMP_LU); | |
- | |
-enum | |
-{ | |
- SORT_EVERY_ROW=0, | |
- SORT_EVERY_COLUMN=1, | |
- SORT_ASCENDING=0, | |
- SORT_DESCENDING=16 | |
-}; | |
- | |
-//! sorts independently each matrix row or each matrix column | |
-CV_EXPORTS_W void sort(InputArray src, OutputArray dst, int flags); | |
-//! sorts independently each matrix row or each matrix column | |
-CV_EXPORTS_W void sortIdx(InputArray src, OutputArray dst, int flags); | |
-//! finds real roots of a cubic polynomial | |
-CV_EXPORTS_W int solveCubic(InputArray coeffs, OutputArray roots); | |
-//! finds real and complex roots of a polynomial | |
-CV_EXPORTS_W double solvePoly(InputArray coeffs, OutputArray roots, int maxIters=300); | |
-//! finds eigenvalues of a symmetric matrix | |
-CV_EXPORTS bool eigen(InputArray src, OutputArray eigenvalues, int lowindex=-1, | |
- int highindex=-1); | |
-//! finds eigenvalues and eigenvectors of a symmetric matrix | |
-CV_EXPORTS bool eigen(InputArray src, OutputArray eigenvalues, | |
- OutputArray eigenvectors, | |
- int lowindex=-1, int highindex=-1); | |
-CV_EXPORTS_W bool eigen(InputArray src, bool computeEigenvectors, | |
- OutputArray eigenvalues, OutputArray eigenvectors); | |
- | |
-enum | |
-{ | |
- COVAR_SCRAMBLED=0, | |
- COVAR_NORMAL=1, | |
- COVAR_USE_AVG=2, | |
- COVAR_SCALE=4, | |
- COVAR_ROWS=8, | |
- COVAR_COLS=16 | |
-}; | |
- | |
-//! computes covariation matrix of a set of samples | |
-CV_EXPORTS void calcCovarMatrix( const Mat* samples, int nsamples, Mat& covar, Mat& mean, | |
- int flags, int ctype=CV_64F); | |
-//! computes covariation matrix of a set of samples | |
-CV_EXPORTS_W void calcCovarMatrix( InputArray samples, OutputArray covar, | |
- OutputArray mean, int flags, int ctype=CV_64F); | |
- | |
-/*! | |
- Principal Component Analysis | |
- | |
- The class PCA is used to compute the special basis for a set of vectors. | |
- The basis will consist of eigenvectors of the covariance matrix computed | |
- from the input set of vectors. After PCA is performed, vectors can be transformed from | |
- the original high-dimensional space to the subspace formed by a few most | |
- prominent eigenvectors (called the principal components), | |
- corresponding to the largest eigenvalues of the covariation matrix. | |
- Thus the dimensionality of the vector and the correlation between the coordinates is reduced. | |
- | |
- The following sample is the function that takes two matrices. The first one stores the set | |
- of vectors (a row per vector) that is used to compute PCA, the second one stores another | |
- "test" set of vectors (a row per vector) that are first compressed with PCA, | |
- then reconstructed back and then the reconstruction error norm is computed and printed for each vector. | |
- | |
- \code | |
- using namespace cv; | |
- | |
- PCA compressPCA(const Mat& pcaset, int maxComponents, | |
- const Mat& testset, Mat& compressed) | |
- { | |
- PCA pca(pcaset, // pass the data | |
- Mat(), // we do not have a pre-computed mean vector, | |
- // so let the PCA engine to compute it | |
- CV_PCA_DATA_AS_ROW, // indicate that the vectors | |
- // are stored as matrix rows | |
- // (use CV_PCA_DATA_AS_COL if the vectors are | |
- // the matrix columns) | |
- maxComponents // specify, how many principal components to retain | |
- ); | |
- // if there is no test data, just return the computed basis, ready-to-use | |
- if( !testset.data ) | |
- return pca; | |
- CV_Assert( testset.cols == pcaset.cols ); | |
- | |
- compressed.create(testset.rows, maxComponents, testset.type()); | |
- | |
- Mat reconstructed; | |
- for( int i = 0; i < testset.rows; i++ ) | |
- { | |
- Mat vec = testset.row(i), coeffs = compressed.row(i), reconstructed; | |
- // compress the vector, the result will be stored | |
- // in the i-th row of the output matrix | |
- pca.project(vec, coeffs); | |
- // and then reconstruct it | |
- pca.backProject(coeffs, reconstructed); | |
- // and measure the error | |
- printf("%d. diff = %g\n", i, norm(vec, reconstructed, NORM_L2)); | |
- } | |
- return pca; | |
- } | |
- \endcode | |
-*/ | |
-class CV_EXPORTS PCA | |
-{ | |
-public: | |
- //! default constructor | |
- PCA(); | |
- //! the constructor that performs PCA | |
- PCA(InputArray data, InputArray mean, int flags, int maxComponents=0); | |
- //! operator that performs PCA. The previously stored data, if any, is released | |
- PCA& operator()(InputArray data, InputArray mean, int flags, int maxComponents=0); | |
- //! projects vector from the original space to the principal components subspace | |
- Mat project(InputArray vec) const; | |
- //! projects vector from the original space to the principal components subspace | |
- void project(InputArray vec, OutputArray result) const; | |
- //! reconstructs the original vector from the projection | |
- Mat backProject(InputArray vec) const; | |
- //! reconstructs the original vector from the projection | |
- void backProject(InputArray vec, OutputArray result) const; | |
- | |
- Mat eigenvectors; //!< eigenvectors of the covariation matrix | |
- Mat eigenvalues; //!< eigenvalues of the covariation matrix | |
- Mat mean; //!< mean value subtracted before the projection and added after the back projection | |
-}; | |
- | |
-CV_EXPORTS_W void PCACompute(InputArray data, CV_OUT InputOutputArray mean, | |
- OutputArray eigenvectors, int maxComponents=0); | |
- | |
-CV_EXPORTS_W void PCAProject(InputArray data, InputArray mean, | |
- InputArray eigenvectors, OutputArray result); | |
- | |
-CV_EXPORTS_W void PCABackProject(InputArray data, InputArray mean, | |
- InputArray eigenvectors, OutputArray result); | |
- | |
- | |
-/*! | |
- Singular Value Decomposition class | |
- | |
- The class is used to compute Singular Value Decomposition of a floating-point matrix and then | |
- use it to solve least-square problems, under-determined linear systems, invert matrices, | |
- compute condition numbers etc. | |
- | |
- For a bit faster operation you can pass flags=SVD::MODIFY_A|... to modify the decomposed matrix | |
- when it is not necessarily to preserve it. If you want to compute condition number of a matrix | |
- or absolute value of its determinant - you do not need SVD::u or SVD::vt, | |
- so you can pass flags=SVD::NO_UV|... . Another flag SVD::FULL_UV indicates that the full-size SVD::u and SVD::vt | |
- must be computed, which is not necessary most of the time. | |
-*/ | |
-class CV_EXPORTS SVD | |
-{ | |
-public: | |
- enum { MODIFY_A=1, NO_UV=2, FULL_UV=4 }; | |
- //! the default constructor | |
- SVD(); | |
- //! the constructor that performs SVD | |
- SVD( InputArray src, int flags=0 ); | |
- //! the operator that performs SVD. The previously allocated SVD::u, SVD::w are SVD::vt are released. | |
- SVD& operator ()( InputArray src, int flags=0 ); | |
- | |
- //! decomposes matrix and stores the results to user-provided matrices | |
- static void compute( InputArray src, OutputArray w, | |
- OutputArray u, OutputArray vt, int flags=0 ); | |
- //! computes singular values of a matrix | |
- static void compute( InputArray src, OutputArray w, int flags=0 ); | |
- //! performs back substitution | |
- static void backSubst( InputArray w, InputArray u, | |
- InputArray vt, InputArray rhs, | |
- OutputArray dst ); | |
- | |
- template<typename _Tp, int m, int n, int nm> static void compute( const Matx<_Tp, m, n>& a, | |
- Matx<_Tp, nm, 1>& w, Matx<_Tp, m, nm>& u, Matx<_Tp, n, nm>& vt ); | |
- template<typename _Tp, int m, int n, int nm> static void compute( const Matx<_Tp, m, n>& a, | |
- Matx<_Tp, nm, 1>& w ); | |
- template<typename _Tp, int m, int n, int nm, int nb> static void backSubst( const Matx<_Tp, nm, 1>& w, | |
- const Matx<_Tp, m, nm>& u, const Matx<_Tp, n, nm>& vt, const Matx<_Tp, m, nb>& rhs, Matx<_Tp, n, nb>& dst ); | |
- | |
- //! finds dst = arg min_{|dst|=1} |m*dst| | |
- static void solveZ( InputArray src, OutputArray dst ); | |
- //! performs back substitution, so that dst is the solution or pseudo-solution of m*dst = rhs, where m is the decomposed matrix | |
- void backSubst( InputArray rhs, OutputArray dst ) const; | |
- | |
- Mat u, w, vt; | |
-}; | |
- | |
-//! computes SVD of src | |
-CV_EXPORTS_W void SVDecomp( InputArray src, CV_OUT OutputArray w, | |
- CV_OUT OutputArray u, CV_OUT OutputArray vt, int flags=0 ); | |
- | |
-//! performs back substitution for the previously computed SVD | |
-CV_EXPORTS_W void SVBackSubst( InputArray w, InputArray u, InputArray vt, | |
- InputArray rhs, CV_OUT OutputArray dst ); | |
- | |
-//! computes Mahalanobis distance between two vectors: sqrt((v1-v2)'*icovar*(v1-v2)), where icovar is the inverse covariation matrix | |
-CV_EXPORTS_W double Mahalanobis(InputArray v1, InputArray v2, InputArray icovar); | |
-//! a synonym for Mahalanobis | |
-CV_EXPORTS double Mahalonobis(InputArray v1, InputArray v2, InputArray icovar); | |
- | |
-//! performs forward or inverse 1D or 2D Discrete Fourier Transformation | |
-CV_EXPORTS_W void dft(InputArray src, OutputArray dst, int flags=0, int nonzeroRows=0); | |
-//! performs inverse 1D or 2D Discrete Fourier Transformation | |
-CV_EXPORTS_W void idft(InputArray src, OutputArray dst, int flags=0, int nonzeroRows=0); | |
-//! performs forward or inverse 1D or 2D Discrete Cosine Transformation | |
-CV_EXPORTS_W void dct(InputArray src, OutputArray dst, int flags=0); | |
-//! performs inverse 1D or 2D Discrete Cosine Transformation | |
-CV_EXPORTS_W void idct(InputArray src, OutputArray dst, int flags=0); | |
-//! computes element-wise product of the two Fourier spectrums. The second spectrum can optionally be conjugated before the multiplication | |
-CV_EXPORTS_W void mulSpectrums(InputArray a, InputArray b, OutputArray c, | |
- int flags, bool conjB=false); | |
-//! computes the minimal vector size vecsize1 >= vecsize so that the dft() of the vector of length vecsize1 can be computed efficiently | |
-CV_EXPORTS_W int getOptimalDFTSize(int vecsize); | |
- | |
-/*! | |
- Various k-Means flags | |
-*/ | |
-enum | |
-{ | |
- KMEANS_RANDOM_CENTERS=0, // Chooses random centers for k-Means initialization | |
- KMEANS_PP_CENTERS=2, // Uses k-Means++ algorithm for initialization | |
- KMEANS_USE_INITIAL_LABELS=1 // Uses the user-provided labels for K-Means initialization | |
-}; | |
-//! clusters the input data using k-Means algorithm | |
-CV_EXPORTS_W double kmeans( InputArray data, int K, CV_OUT InputOutputArray bestLabels, | |
- TermCriteria criteria, int attempts, | |
- int flags, OutputArray centers=noArray() ); | |
- | |
-//! returns the thread-local Random number generator | |
-CV_EXPORTS RNG& theRNG(); | |
- | |
-//! returns the next unifomly-distributed random number of the specified type | |
-template<typename _Tp> static inline _Tp randu() { return (_Tp)theRNG(); } | |
- | |
-//! fills array with uniformly-distributed random numbers from the range [low, high) | |
-CV_EXPORTS_W void randu(InputOutputArray dst, InputArray low, InputArray high); | |
- | |
-//! fills array with normally-distributed random numbers with the specified mean and the standard deviation | |
-CV_EXPORTS_W void randn(InputOutputArray dst, InputArray mean, InputArray stddev); | |
- | |
-//! shuffles the input array elements | |
-CV_EXPORTS void randShuffle(InputOutputArray dst, double iterFactor=1., RNG* rng=0); | |
-CV_EXPORTS_AS(randShuffle) void randShuffle_(InputOutputArray dst, double iterFactor=1.); | |
- | |
-//! draws the line segment (pt1, pt2) in the image | |
-CV_EXPORTS_W void line(Mat& img, Point pt1, Point pt2, const Scalar& color, | |
- int thickness=1, int lineType=8, int shift=0); | |
- | |
-//! draws the rectangle outline or a solid rectangle with the opposite corners pt1 and pt2 in the image | |
-CV_EXPORTS_W void rectangle(Mat& img, Point pt1, Point pt2, | |
- const Scalar& color, int thickness=1, | |
- int lineType=8, int shift=0); | |
- | |
-//! draws the rectangle outline or a solid rectangle covering rec in the image | |
-CV_EXPORTS void rectangle(Mat& img, Rect rec, | |
- const Scalar& color, int thickness=1, | |
- int lineType=8, int shift=0); | |
- | |
-//! draws the circle outline or a solid circle in the image | |
-CV_EXPORTS_W void circle(Mat& img, Point center, int radius, | |
- const Scalar& color, int thickness=1, | |
- int lineType=8, int shift=0); | |
- | |
-//! draws an elliptic arc, ellipse sector or a rotated ellipse in the image | |
-CV_EXPORTS_W void ellipse(Mat& img, Point center, Size axes, | |
- double angle, double startAngle, double endAngle, | |
- const Scalar& color, int thickness=1, | |
- int lineType=8, int shift=0); | |
- | |
-//! draws a rotated ellipse in the image | |
-CV_EXPORTS_W void ellipse(Mat& img, const RotatedRect& box, const Scalar& color, | |
- int thickness=1, int lineType=8); | |
- | |
-//! draws a filled convex polygon in the image | |
-CV_EXPORTS void fillConvexPoly(Mat& img, const Point* pts, int npts, | |
- const Scalar& color, int lineType=8, | |
- int shift=0); | |
-CV_EXPORTS_W void fillConvexPoly(InputOutputArray img, InputArray points, | |
- const Scalar& color, int lineType=8, | |
- int shift=0); | |
- | |
-//! fills an area bounded by one or more polygons | |
-CV_EXPORTS void fillPoly(Mat& img, const Point** pts, | |
- const int* npts, int ncontours, | |
- const Scalar& color, int lineType=8, int shift=0, | |
- Point offset=Point() ); | |
- | |
-CV_EXPORTS_W void fillPoly(InputOutputArray img, InputArrayOfArrays pts, | |
- const Scalar& color, int lineType=8, int shift=0, | |
- Point offset=Point() ); | |
- | |
-//! draws one or more polygonal curves | |
-CV_EXPORTS void polylines(Mat& img, const Point** pts, const int* npts, | |
- int ncontours, bool isClosed, const Scalar& color, | |
- int thickness=1, int lineType=8, int shift=0 ); | |
- | |
-CV_EXPORTS_W void polylines(InputOutputArray img, InputArrayOfArrays pts, | |
- bool isClosed, const Scalar& color, | |
- int thickness=1, int lineType=8, int shift=0 ); | |
- | |
-//! clips the line segment by the rectangle Rect(0, 0, imgSize.width, imgSize.height) | |
-CV_EXPORTS bool clipLine(Size imgSize, CV_IN_OUT Point& pt1, CV_IN_OUT Point& pt2); | |
- | |
-//! clips the line segment by the rectangle imgRect | |
-CV_EXPORTS_W bool clipLine(Rect imgRect, CV_OUT CV_IN_OUT Point& pt1, CV_OUT CV_IN_OUT Point& pt2); | |
- | |
-/*! | |
- Line iterator class | |
- | |
- The class is used to iterate over all the pixels on the raster line | |
- segment connecting two specified points. | |
-*/ | |
-class CV_EXPORTS LineIterator | |
-{ | |
-public: | |
- //! intializes the iterator | |
- LineIterator( const Mat& img, Point pt1, Point pt2, | |
- int connectivity=8, bool leftToRight=false ); | |
- //! returns pointer to the current pixel | |
- uchar* operator *(); | |
- //! prefix increment operator (++it). shifts iterator to the next pixel | |
- LineIterator& operator ++(); | |
- //! postfix increment operator (it++). shifts iterator to the next pixel | |
- LineIterator operator ++(int); | |
- //! returns coordinates of the current pixel | |
- Point pos() const; | |
- | |
- uchar* ptr; | |
- const uchar* ptr0; | |
- int step, elemSize; | |
- int err, count; | |
- int minusDelta, plusDelta; | |
- int minusStep, plusStep; | |
-}; | |
- | |
-//! converts elliptic arc to a polygonal curve | |
-CV_EXPORTS_W void ellipse2Poly( Point center, Size axes, int angle, | |
- int arcStart, int arcEnd, int delta, | |
- CV_OUT vector<Point>& pts ); | |
- | |
-enum | |
-{ | |
- FONT_HERSHEY_SIMPLEX = 0, | |
- FONT_HERSHEY_PLAIN = 1, | |
- FONT_HERSHEY_DUPLEX = 2, | |
- FONT_HERSHEY_COMPLEX = 3, | |
- FONT_HERSHEY_TRIPLEX = 4, | |
- FONT_HERSHEY_COMPLEX_SMALL = 5, | |
- FONT_HERSHEY_SCRIPT_SIMPLEX = 6, | |
- FONT_HERSHEY_SCRIPT_COMPLEX = 7, | |
- FONT_ITALIC = 16 | |
-}; | |
- | |
-//! renders text string in the image | |
-CV_EXPORTS_W void putText( Mat& img, const string& text, Point org, | |
- int fontFace, double fontScale, Scalar color, | |
- int thickness=1, int lineType=8, | |
- bool bottomLeftOrigin=false ); | |
- | |
-//! returns bounding box of the text string | |
-CV_EXPORTS_W Size getTextSize(const string& text, int fontFace, | |
- double fontScale, int thickness, | |
- CV_OUT int* baseLine); | |
- | |
-///////////////////////////////// Mat_<_Tp> //////////////////////////////////// | |
- | |
-/*! | |
- Template matrix class derived from Mat | |
- | |
- The class Mat_ is a "thin" template wrapper on top of cv::Mat. It does not have any extra data fields, | |
- nor it or cv::Mat have any virtual methods and thus references or pointers to these two classes | |
- can be safely converted one to another. But do it with care, for example: | |
- | |
- \code | |
- // create 100x100 8-bit matrix | |
- Mat M(100,100,CV_8U); | |
- // this will compile fine. no any data conversion will be done. | |
- Mat_<float>& M1 = (Mat_<float>&)M; | |
- // the program will likely crash at the statement below | |
- M1(99,99) = 1.f; | |
- \endcode | |
- | |
- While cv::Mat is sufficient in most cases, cv::Mat_ can be more convenient if you use a lot of element | |
- access operations and if you know matrix type at compile time. | |
- Note that cv::Mat::at<_Tp>(int y, int x) and cv::Mat_<_Tp>::operator ()(int y, int x) do absolutely the | |
- same thing and run at the same speed, but the latter is certainly shorter: | |
- | |
- \code | |
- Mat_<double> M(20,20); | |
- for(int i = 0; i < M.rows; i++) | |
- for(int j = 0; j < M.cols; j++) | |
- M(i,j) = 1./(i+j+1); | |
- Mat E, V; | |
- eigen(M,E,V); | |
- cout << E.at<double>(0,0)/E.at<double>(M.rows-1,0); | |
- \endcode | |
- | |
- It is easy to use Mat_ for multi-channel images/matrices - just pass cv::Vec as cv::Mat_ template parameter: | |
- | |
- \code | |
- // allocate 320x240 color image and fill it with green (in RGB space) | |
- Mat_<Vec3b> img(240, 320, Vec3b(0,255,0)); | |
- // now draw a diagonal white line | |
- for(int i = 0; i < 100; i++) | |
- img(i,i)=Vec3b(255,255,255); | |
- // and now modify the 2nd (red) channel of each pixel | |
- for(int i = 0; i < img.rows; i++) | |
- for(int j = 0; j < img.cols; j++) | |
- img(i,j)[2] ^= (uchar)(i ^ j); // img(y,x)[c] accesses c-th channel of the pixel (x,y) | |
- \endcode | |
-*/ | |
-template<typename _Tp> class CV_EXPORTS Mat_ : public Mat | |
-{ | |
-public: | |
- typedef _Tp value_type; | |
- typedef typename DataType<_Tp>::channel_type channel_type; | |
- typedef MatIterator_<_Tp> iterator; | |
- typedef MatConstIterator_<_Tp> const_iterator; | |
- | |
- //! default constructor | |
- Mat_(); | |
- //! equivalent to Mat(_rows, _cols, DataType<_Tp>::type) | |
- Mat_(int _rows, int _cols); | |
- //! constructor that sets each matrix element to specified value | |
- Mat_(int _rows, int _cols, const _Tp& value); | |
- //! equivalent to Mat(_size, DataType<_Tp>::type) | |
- explicit Mat_(Size _size); | |
- //! constructor that sets each matrix element to specified value | |
- Mat_(Size _size, const _Tp& value); | |
- //! n-dim array constructor | |
- Mat_(int _ndims, const int* _sizes); | |
- //! n-dim array constructor that sets each matrix element to specified value | |
- Mat_(int _ndims, const int* _sizes, const _Tp& value); | |
- //! copy/conversion contructor. If m is of different type, it's converted | |
- Mat_(const Mat& m); | |
- //! copy constructor | |
- Mat_(const Mat_& m); | |
- //! constructs a matrix on top of user-allocated data. step is in bytes(!!!), regardless of the type | |
- Mat_(int _rows, int _cols, _Tp* _data, size_t _step=AUTO_STEP); | |
- //! constructs n-dim matrix on top of user-allocated data. steps are in bytes(!!!), regardless of the type | |
- Mat_(int _ndims, const int* _sizes, _Tp* _data, const size_t* _steps=0); | |
- //! selects a submatrix | |
- Mat_(const Mat_& m, const Range& rowRange, const Range& colRange=Range::all()); | |
- //! selects a submatrix | |
- Mat_(const Mat_& m, const Rect& roi); | |
- //! selects a submatrix, n-dim version | |
- Mat_(const Mat_& m, const Range* ranges); | |
- //! from a matrix expression | |
- explicit Mat_(const MatExpr& e); | |
- //! makes a matrix out of Vec, std::vector, Point_ or Point3_. The matrix will have a single column | |
- explicit Mat_(const vector<_Tp>& vec, bool copyData=false); | |
- template<int n> explicit Mat_(const Vec<typename DataType<_Tp>::channel_type, n>& vec, bool copyData=true); | |
- template<int m, int n> explicit Mat_(const Matx<typename DataType<_Tp>::channel_type, m, n>& mtx, bool copyData=true); | |
- explicit Mat_(const Point_<typename DataType<_Tp>::channel_type>& pt, bool copyData=true); | |
- explicit Mat_(const Point3_<typename DataType<_Tp>::channel_type>& pt, bool copyData=true); | |
- explicit Mat_(const MatCommaInitializer_<_Tp>& commaInitializer); | |
- | |
- Mat_& operator = (const Mat& m); | |
- Mat_& operator = (const Mat_& m); | |
- //! set all the elements to s. | |
- Mat_& operator = (const _Tp& s); | |
- //! assign a matrix expression | |
- Mat_& operator = (const MatExpr& e); | |
- | |
- //! iterators; they are smart enough to skip gaps in the end of rows | |
- iterator begin(); | |
- iterator end(); | |
- const_iterator begin() const; | |
- const_iterator end() const; | |
- | |
- //! equivalent to Mat::create(_rows, _cols, DataType<_Tp>::type) | |
- void create(int _rows, int _cols); | |
- //! equivalent to Mat::create(_size, DataType<_Tp>::type) | |
- void create(Size _size); | |
- //! equivalent to Mat::create(_ndims, _sizes, DatType<_Tp>::type) | |
- void create(int _ndims, const int* _sizes); | |
- //! cross-product | |
- Mat_ cross(const Mat_& m) const; | |
- //! data type conversion | |
- template<typename T2> operator Mat_<T2>() const; | |
- //! overridden forms of Mat::row() etc. | |
- Mat_ row(int y) const; | |
- Mat_ col(int x) const; | |
- Mat_ diag(int d=0) const; | |
- Mat_ clone() const; | |
- | |
- //! overridden forms of Mat::elemSize() etc. | |
- size_t elemSize() const; | |
- size_t elemSize1() const; | |
- int type() const; | |
- int depth() const; | |
- int channels() const; | |
- size_t step1(int i=0) const; | |
- //! returns step()/sizeof(_Tp) | |
- size_t stepT(int i=0) const; | |
- | |
- //! overridden forms of Mat::zeros() etc. Data type is omitted, of course | |
- static MatExpr zeros(int rows, int cols); | |
- static MatExpr zeros(Size size); | |
- static MatExpr zeros(int _ndims, const int* _sizes); | |
- static MatExpr ones(int rows, int cols); | |
- static MatExpr ones(Size size); | |
- static MatExpr ones(int _ndims, const int* _sizes); | |
- static MatExpr eye(int rows, int cols); | |
- static MatExpr eye(Size size); | |
- | |
- //! some more overriden methods | |
- Mat_& adjustROI( int dtop, int dbottom, int dleft, int dright ); | |
- Mat_ operator()( const Range& rowRange, const Range& colRange ) const; | |
- Mat_ operator()( const Rect& roi ) const; | |
- Mat_ operator()( const Range* ranges ) const; | |
- | |
- //! more convenient forms of row and element access operators | |
- _Tp* operator [](int y); | |
- const _Tp* operator [](int y) const; | |
- | |
- //! returns reference to the specified element | |
- _Tp& operator ()(const int* idx); | |
- //! returns read-only reference to the specified element | |
- const _Tp& operator ()(const int* idx) const; | |
- | |
- //! returns reference to the specified element | |
- template<int n> _Tp& operator ()(const Vec<int, n>& idx); | |
- //! returns read-only reference to the specified element | |
- template<int n> const _Tp& operator ()(const Vec<int, n>& idx) const; | |
- | |
- //! returns reference to the specified element (1D case) | |
- _Tp& operator ()(int idx0); | |
- //! returns read-only reference to the specified element (1D case) | |
- const _Tp& operator ()(int idx0) const; | |
- //! returns reference to the specified element (2D case) | |
- _Tp& operator ()(int idx0, int idx1); | |
- //! returns read-only reference to the specified element (2D case) | |
- const _Tp& operator ()(int idx0, int idx1) const; | |
- //! returns reference to the specified element (3D case) | |
- _Tp& operator ()(int idx0, int idx1, int idx2); | |
- //! returns read-only reference to the specified element (3D case) | |
- const _Tp& operator ()(int idx0, int idx1, int idx2) const; | |
- | |
- _Tp& operator ()(Point pt); | |
- const _Tp& operator ()(Point pt) const; | |
- | |
- //! conversion to vector. | |
- operator vector<_Tp>() const; | |
- //! conversion to Vec | |
- template<int n> operator Vec<typename DataType<_Tp>::channel_type, n>() const; | |
- //! conversion to Matx | |
- template<int m, int n> operator Matx<typename DataType<_Tp>::channel_type, m, n>() const; | |
-}; | |
- | |
-typedef Mat_<uchar> Mat1b; | |
-typedef Mat_<Vec2b> Mat2b; | |
-typedef Mat_<Vec3b> Mat3b; | |
-typedef Mat_<Vec4b> Mat4b; | |
- | |
-typedef Mat_<short> Mat1s; | |
-typedef Mat_<Vec2s> Mat2s; | |
-typedef Mat_<Vec3s> Mat3s; | |
-typedef Mat_<Vec4s> Mat4s; | |
- | |
-typedef Mat_<ushort> Mat1w; | |
-typedef Mat_<Vec2w> Mat2w; | |
-typedef Mat_<Vec3w> Mat3w; | |
-typedef Mat_<Vec4w> Mat4w; | |
- | |
-typedef Mat_<int> Mat1i; | |
-typedef Mat_<Vec2i> Mat2i; | |
-typedef Mat_<Vec3i> Mat3i; | |
-typedef Mat_<Vec4i> Mat4i; | |
- | |
-typedef Mat_<float> Mat1f; | |
-typedef Mat_<Vec2f> Mat2f; | |
-typedef Mat_<Vec3f> Mat3f; | |
-typedef Mat_<Vec4f> Mat4f; | |
- | |
-typedef Mat_<double> Mat1d; | |
-typedef Mat_<Vec2d> Mat2d; | |
-typedef Mat_<Vec3d> Mat3d; | |
-typedef Mat_<Vec4d> Mat4d; | |
- | |
-//////////// Iterators & Comma initializers ////////////////// | |
- | |
-class CV_EXPORTS MatConstIterator | |
-{ | |
-public: | |
- typedef uchar* value_type; | |
- typedef ptrdiff_t difference_type; | |
- typedef const uchar** pointer; | |
- typedef uchar* reference; | |
- typedef std::random_access_iterator_tag iterator_category; | |
- | |
- //! default constructor | |
- MatConstIterator(); | |
- //! constructor that sets the iterator to the beginning of the matrix | |
- MatConstIterator(const Mat* _m); | |
- //! constructor that sets the iterator to the specified element of the matrix | |
- MatConstIterator(const Mat* _m, int _row, int _col=0); | |
- //! constructor that sets the iterator to the specified element of the matrix | |
- MatConstIterator(const Mat* _m, Point _pt); | |
- //! constructor that sets the iterator to the specified element of the matrix | |
- MatConstIterator(const Mat* _m, const int* _idx); | |
- //! copy constructor | |
- MatConstIterator(const MatConstIterator& it); | |
- | |
- //! copy operator | |
- MatConstIterator& operator = (const MatConstIterator& it); | |
- //! returns the current matrix element | |
- uchar* operator *() const; | |
- //! returns the i-th matrix element, relative to the current | |
- uchar* operator [](ptrdiff_t i) const; | |
- | |
- //! shifts the iterator forward by the specified number of elements | |
- MatConstIterator& operator += (ptrdiff_t ofs); | |
- //! shifts the iterator backward by the specified number of elements | |
- MatConstIterator& operator -= (ptrdiff_t ofs); | |
- //! decrements the iterator | |
- MatConstIterator& operator --(); | |
- //! decrements the iterator | |
- MatConstIterator operator --(int); | |
- //! increments the iterator | |
- MatConstIterator& operator ++(); | |
- //! increments the iterator | |
- MatConstIterator operator ++(int); | |
- //! returns the current iterator position | |
- Point pos() const; | |
- //! returns the current iterator position | |
- void pos(int* _idx) const; | |
- ptrdiff_t lpos() const; | |
- void seek(ptrdiff_t ofs, bool relative=false); | |
- void seek(const int* _idx, bool relative=false); | |
- | |
- const Mat* m; | |
- size_t elemSize; | |
- uchar* ptr; | |
- uchar* sliceStart; | |
- uchar* sliceEnd; | |
-}; | |
- | |
-/*! | |
- Matrix read-only iterator | |
- | |
- */ | |
-template<typename _Tp> | |
-class CV_EXPORTS MatConstIterator_ : public MatConstIterator | |
-{ | |
-public: | |
- typedef _Tp value_type; | |
- typedef ptrdiff_t difference_type; | |
- typedef const _Tp* pointer; | |
- typedef const _Tp& reference; | |
- typedef std::random_access_iterator_tag iterator_category; | |
- | |
- //! default constructor | |
- MatConstIterator_(); | |
- //! constructor that sets the iterator to the beginning of the matrix | |
- MatConstIterator_(const Mat_<_Tp>* _m); | |
- //! constructor that sets the iterator to the specified element of the matrix | |
- MatConstIterator_(const Mat_<_Tp>* _m, int _row, int _col=0); | |
- //! constructor that sets the iterator to the specified element of the matrix | |
- MatConstIterator_(const Mat_<_Tp>* _m, Point _pt); | |
- //! constructor that sets the iterator to the specified element of the matrix | |
- MatConstIterator_(const Mat_<_Tp>* _m, const int* _idx); | |
- //! copy constructor | |
- MatConstIterator_(const MatConstIterator_& it); | |
- | |
- //! copy operator | |
- MatConstIterator_& operator = (const MatConstIterator_& it); | |
- //! returns the current matrix element | |
- _Tp operator *() const; | |
- //! returns the i-th matrix element, relative to the current | |
- _Tp operator [](ptrdiff_t i) const; | |
- | |
- //! shifts the iterator forward by the specified number of elements | |
- MatConstIterator_& operator += (ptrdiff_t ofs); | |
- //! shifts the iterator backward by the specified number of elements | |
- MatConstIterator_& operator -= (ptrdiff_t ofs); | |
- //! decrements the iterator | |
- MatConstIterator_& operator --(); | |
- //! decrements the iterator | |
- MatConstIterator_ operator --(int); | |
- //! increments the iterator | |
- MatConstIterator_& operator ++(); | |
- //! increments the iterator | |
- MatConstIterator_ operator ++(int); | |
- //! returns the current iterator position | |
- Point pos() const; | |
-}; | |
- | |
- | |
-/*! | |
- Matrix read-write iterator | |
- | |
-*/ | |
-template<typename _Tp> | |
-class CV_EXPORTS MatIterator_ : public MatConstIterator_<_Tp> | |
-{ | |
-public: | |
- typedef _Tp* pointer; | |
- typedef _Tp& reference; | |
- typedef std::random_access_iterator_tag iterator_category; | |
- | |
- //! the default constructor | |
- MatIterator_(); | |
- //! constructor that sets the iterator to the beginning of the matrix | |
- MatIterator_(Mat_<_Tp>* _m); | |
- //! constructor that sets the iterator to the specified element of the matrix | |
- MatIterator_(Mat_<_Tp>* _m, int _row, int _col=0); | |
- //! constructor that sets the iterator to the specified element of the matrix | |
- MatIterator_(const Mat_<_Tp>* _m, Point _pt); | |
- //! constructor that sets the iterator to the specified element of the matrix | |
- MatIterator_(const Mat_<_Tp>* _m, const int* _idx); | |
- //! copy constructor | |
- MatIterator_(const MatIterator_& it); | |
- //! copy operator | |
- MatIterator_& operator = (const MatIterator_<_Tp>& it ); | |
- | |
- //! returns the current matrix element | |
- _Tp& operator *() const; | |
- //! returns the i-th matrix element, relative to the current | |
- _Tp& operator [](ptrdiff_t i) const; | |
- | |
- //! shifts the iterator forward by the specified number of elements | |
- MatIterator_& operator += (ptrdiff_t ofs); | |
- //! shifts the iterator backward by the specified number of elements | |
- MatIterator_& operator -= (ptrdiff_t ofs); | |
- //! decrements the iterator | |
- MatIterator_& operator --(); | |
- //! decrements the iterator | |
- MatIterator_ operator --(int); | |
- //! increments the iterator | |
- MatIterator_& operator ++(); | |
- //! increments the iterator | |
- MatIterator_ operator ++(int); | |
-}; | |
- | |
-template<typename _Tp> class CV_EXPORTS MatOp_Iter_; | |
- | |
-/*! | |
- Comma-separated Matrix Initializer | |
- | |
- The class instances are usually not created explicitly. | |
- Instead, they are created on "matrix << firstValue" operator. | |
- | |
- The sample below initializes 2x2 rotation matrix: | |
- | |
- \code | |
- double angle = 30, a = cos(angle*CV_PI/180), b = sin(angle*CV_PI/180); | |
- Mat R = (Mat_<double>(2,2) << a, -b, b, a); | |
- \endcode | |
-*/ | |
-template<typename _Tp> class CV_EXPORTS MatCommaInitializer_ | |
-{ | |
-public: | |
- //! the constructor, created by "matrix << firstValue" operator, where matrix is cv::Mat | |
- MatCommaInitializer_(Mat_<_Tp>* _m); | |
- //! the operator that takes the next value and put it to the matrix | |
- template<typename T2> MatCommaInitializer_<_Tp>& operator , (T2 v); | |
- //! another form of conversion operator | |
- Mat_<_Tp> operator *() const; | |
- operator Mat_<_Tp>() const; | |
-protected: | |
- MatIterator_<_Tp> it; | |
-}; | |
- | |
- | |
-template<typename _Tp, int m, int n> class CV_EXPORTS MatxCommaInitializer | |
-{ | |
-public: | |
- MatxCommaInitializer(Matx<_Tp, m, n>* _mtx); | |
- template<typename T2> MatxCommaInitializer<_Tp, m, n>& operator , (T2 val); | |
- Matx<_Tp, m, n> operator *() const; | |
- | |
- Matx<_Tp, m, n>* dst; | |
- int idx; | |
-}; | |
- | |
-template<typename _Tp, int m> class CV_EXPORTS VecCommaInitializer : public MatxCommaInitializer<_Tp, m, 1> | |
-{ | |
-public: | |
- VecCommaInitializer(Vec<_Tp, m>* _vec); | |
- template<typename T2> VecCommaInitializer<_Tp, m>& operator , (T2 val); | |
- Vec<_Tp, m> operator *() const; | |
-}; | |
- | |
-/*! | |
- Automatically Allocated Buffer Class | |
- | |
- The class is used for temporary buffers in functions and methods. | |
- If a temporary buffer is usually small (a few K's of memory), | |
- but its size depends on the parameters, it makes sense to create a small | |
- fixed-size array on stack and use it if it's large enough. If the required buffer size | |
- is larger than the fixed size, another buffer of sufficient size is allocated dynamically | |
- and released after the processing. Therefore, in typical cases, when the buffer size is small, | |
- there is no overhead associated with malloc()/free(). | |
- At the same time, there is no limit on the size of processed data. | |
- | |
- This is what AutoBuffer does. The template takes 2 parameters - type of the buffer elements and | |
- the number of stack-allocated elements. Here is how the class is used: | |
- | |
- \code | |
- void my_func(const cv::Mat& m) | |
- { | |
- cv::AutoBuffer<float, 1000> buf; // create automatic buffer containing 1000 floats | |
- | |
- buf.allocate(m.rows); // if m.rows <= 1000, the pre-allocated buffer is used, | |
- // otherwise the buffer of "m.rows" floats will be allocated | |
- // dynamically and deallocated in cv::AutoBuffer destructor | |
- ... | |
- } | |
- \endcode | |
-*/ | |
-template<typename _Tp, size_t fixed_size=4096/sizeof(_Tp)+8> class CV_EXPORTS AutoBuffer | |
-{ | |
-public: | |
- typedef _Tp value_type; | |
- enum { buffer_padding = (int)((16 + sizeof(_Tp) - 1)/sizeof(_Tp)) }; | |
- | |
- //! the default contructor | |
- AutoBuffer(); | |
- //! constructor taking the real buffer size | |
- AutoBuffer(size_t _size); | |
- //! destructor. calls deallocate() | |
- ~AutoBuffer(); | |
- | |
- //! allocates the new buffer of size _size. if the _size is small enough, stack-allocated buffer is used | |
- void allocate(size_t _size); | |
- //! deallocates the buffer if it was dynamically allocated | |
- void deallocate(); | |
- //! returns pointer to the real buffer, stack-allocated or head-allocated | |
- operator _Tp* (); | |
- //! returns read-only pointer to the real buffer, stack-allocated or head-allocated | |
- operator const _Tp* () const; | |
- | |
-protected: | |
- //! pointer to the real buffer, can point to buf if the buffer is small enough | |
- _Tp* ptr; | |
- //! size of the real buffer | |
- size_t size; | |
- //! pre-allocated buffer | |
- _Tp buf[fixed_size+buffer_padding]; | |
-}; | |
- | |
-/////////////////////////// multi-dimensional dense matrix ////////////////////////// | |
- | |
-/*! | |
- n-Dimensional Dense Matrix Iterator Class. | |
- | |
- The class cv::NAryMatIterator is used for iterating over one or more n-dimensional dense arrays (cv::Mat's). | |
- | |
- The iterator is completely different from cv::Mat_ and cv::SparseMat_ iterators. | |
- It iterates through the slices (or planes), not the elements, where "slice" is a continuous part of the arrays. | |
- | |
- Here is the example on how the iterator can be used to normalize 3D histogram: | |
- | |
- \code | |
- void normalizeColorHist(Mat& hist) | |
- { | |
- #if 1 | |
- // intialize iterator (the style is different from STL). | |
- // after initialization the iterator will contain | |
- // the number of slices or planes | |
- // the iterator will go through | |
- Mat* arrays[] = { &hist, 0 }; | |
- Mat planes[1]; | |
- NAryMatIterator it(arrays, planes); | |
- double s = 0; | |
- // iterate through the matrix. on each iteration | |
- // it.planes[i] (of type Mat) will be set to the current plane of | |
- // i-th n-dim matrix passed to the iterator constructor. | |
- for(int p = 0; p < it.nplanes; p++, ++it) | |
- s += sum(it.planes[0])[0]; | |
- it = NAryMatIterator(hist); | |
- s = 1./s; | |
- for(int p = 0; p < it.nplanes; p++, ++it) | |
- it.planes[0] *= s; | |
- #elif 1 | |
- // this is a shorter implementation of the above | |
- // using built-in operations on Mat | |
- double s = sum(hist)[0]; | |
- hist.convertTo(hist, hist.type(), 1./s, 0); | |
- #else | |
- // and this is even shorter one | |
- // (assuming that the histogram elements are non-negative) | |
- normalize(hist, hist, 1, 0, NORM_L1); | |
- #endif | |
- } | |
- \endcode | |
- | |
- You can iterate through several matrices simultaneously as long as they have the same geometry | |
- (dimensionality and all the dimension sizes are the same), which is useful for binary | |
- and n-ary operations on such matrices. Just pass those matrices to cv::MatNDIterator. | |
- Then, during the iteration it.planes[0], it.planes[1], ... will | |
- be the slices of the corresponding matrices | |
-*/ | |
-class CV_EXPORTS NAryMatIterator | |
-{ | |
-public: | |
- //! the default constructor | |
- NAryMatIterator(); | |
- //! the full constructor taking arbitrary number of n-dim matrices | |
- NAryMatIterator(const Mat** arrays, uchar** ptrs, int narrays=-1); | |
- //! the full constructor taking arbitrary number of n-dim matrices | |
- NAryMatIterator(const Mat** arrays, Mat* planes, int narrays=-1); | |
- //! the separate iterator initialization method | |
- void init(const Mat** arrays, Mat* planes, uchar** ptrs, int narrays=-1); | |
- | |
- //! proceeds to the next plane of every iterated matrix | |
- NAryMatIterator& operator ++(); | |
- //! proceeds to the next plane of every iterated matrix (postfix increment operator) | |
- NAryMatIterator operator ++(int); | |
- | |
- //! the iterated arrays | |
- const Mat** arrays; | |
- //! the current planes | |
- Mat* planes; | |
- //! data pointers | |
- uchar** ptrs; | |
- //! the number of arrays | |
- int narrays; | |
- //! the number of hyper-planes that the iterator steps through | |
- size_t nplanes; | |
- //! the size of each segment (in elements) | |
- size_t size; | |
-protected: | |
- int iterdepth; | |
- size_t idx; | |
-}; | |
- | |
-//typedef NAryMatIterator NAryMatNDIterator; | |
- | |
-typedef void (*ConvertData)(const void* from, void* to, int cn); | |
-typedef void (*ConvertScaleData)(const void* from, void* to, int cn, double alpha, double beta); | |
- | |
-//! returns the function for converting pixels from one data type to another | |
-CV_EXPORTS ConvertData getConvertElem(int fromType, int toType); | |
-//! returns the function for converting pixels from one data type to another with the optional scaling | |
-CV_EXPORTS ConvertScaleData getConvertScaleElem(int fromType, int toType); | |
- | |
- | |
-/////////////////////////// multi-dimensional sparse matrix ////////////////////////// | |
- | |
-class SparseMatIterator; | |
-class SparseMatConstIterator; | |
-template<typename _Tp> class SparseMatIterator_; | |
-template<typename _Tp> class SparseMatConstIterator_; | |
- | |
-/*! | |
- Sparse matrix class. | |
- | |
- The class represents multi-dimensional sparse numerical arrays. Such a sparse array can store elements | |
- of any type that cv::Mat is able to store. "Sparse" means that only non-zero elements | |
- are stored (though, as a result of some operations on a sparse matrix, some of its stored elements | |
- can actually become 0. It's user responsibility to detect such elements and delete them using cv::SparseMat::erase(). | |
- The non-zero elements are stored in a hash table that grows when it's filled enough, | |
- so that the search time remains O(1) in average. Elements can be accessed using the following methods: | |
- | |
- <ol> | |
- <li>Query operations: cv::SparseMat::ptr() and the higher-level cv::SparseMat::ref(), | |
- cv::SparseMat::value() and cv::SparseMat::find, for example: | |
- \code | |
- const int dims = 5; | |
- int size[] = {10, 10, 10, 10, 10}; | |
- SparseMat sparse_mat(dims, size, CV_32F); | |
- for(int i = 0; i < 1000; i++) | |
- { | |
- int idx[dims]; | |
- for(int k = 0; k < dims; k++) | |
- idx[k] = rand()%sparse_mat.size(k); | |
- sparse_mat.ref<float>(idx) += 1.f; | |
- } | |
- \endcode | |
- | |
- <li>Sparse matrix iterators. Like cv::Mat iterators and unlike cv::Mat iterators, the sparse matrix iterators are STL-style, | |
- that is, the iteration is done as following: | |
- \code | |
- // prints elements of a sparse floating-point matrix and the sum of elements. | |
- SparseMatConstIterator_<float> | |
- it = sparse_mat.begin<float>(), | |
- it_end = sparse_mat.end<float>(); | |
- double s = 0; | |
- int dims = sparse_mat.dims(); | |
- for(; it != it_end; ++it) | |
- { | |
- // print element indices and the element value | |
- const Node* n = it.node(); | |
- printf("(") | |
- for(int i = 0; i < dims; i++) | |
- printf("%3d%c", n->idx[i], i < dims-1 ? ',' : ')'); | |
- printf(": %f\n", *it); | |
- s += *it; | |
- } | |
- printf("Element sum is %g\n", s); | |
- \endcode | |
- If you run this loop, you will notice that elements are enumerated | |
- in no any logical order (lexicographical etc.), | |
- they come in the same order as they stored in the hash table, i.e. semi-randomly. | |
- | |
- You may collect pointers to the nodes and sort them to get the proper ordering. | |
- Note, however, that pointers to the nodes may become invalid when you add more | |
- elements to the matrix; this is because of possible buffer reallocation. | |
- | |
- <li>A combination of the above 2 methods when you need to process 2 or more sparse | |
- matrices simultaneously, e.g. this is how you can compute unnormalized | |
- cross-correlation of the 2 floating-point sparse matrices: | |
- \code | |
- double crossCorr(const SparseMat& a, const SparseMat& b) | |
- { | |
- const SparseMat *_a = &a, *_b = &b; | |
- // if b contains less elements than a, | |
- // it's faster to iterate through b | |
- if(_a->nzcount() > _b->nzcount()) | |
- std::swap(_a, _b); | |
- SparseMatConstIterator_<float> it = _a->begin<float>(), | |
- it_end = _a->end<float>(); | |
- double ccorr = 0; | |
- for(; it != it_end; ++it) | |
- { | |
- // take the next element from the first matrix | |
- float avalue = *it; | |
- const Node* anode = it.node(); | |
- // and try to find element with the same index in the second matrix. | |
- // since the hash value depends only on the element index, | |
- // we reuse hashvalue stored in the node | |
- float bvalue = _b->value<float>(anode->idx,&anode->hashval); | |
- ccorr += avalue*bvalue; | |
- } | |
- return ccorr; | |
- } | |
- \endcode | |
- </ol> | |
-*/ | |
-class CV_EXPORTS SparseMat | |
-{ | |
-public: | |
- typedef SparseMatIterator iterator; | |
- typedef SparseMatConstIterator const_iterator; | |
- | |
- //! the sparse matrix header | |
- struct CV_EXPORTS Hdr | |
- { | |
- Hdr(int _dims, const int* _sizes, int _type); | |
- void clear(); | |
- int refcount; | |
- int dims; | |
- int valueOffset; | |
- size_t nodeSize; | |
- size_t nodeCount; | |
- size_t freeList; | |
- vector<uchar> pool; | |
- vector<size_t> hashtab; | |
- int size[CV_MAX_DIM]; | |
- }; | |
- | |
- //! sparse matrix node - element of a hash table | |
- struct CV_EXPORTS Node | |
- { | |
- //! hash value | |
- size_t hashval; | |
- //! index of the next node in the same hash table entry | |
- size_t next; | |
- //! index of the matrix element | |
- int idx[CV_MAX_DIM]; | |
- }; | |
- | |
- //! default constructor | |
- SparseMat(); | |
- //! creates matrix of the specified size and type | |
- SparseMat(int dims, const int* _sizes, int _type); | |
- //! copy constructor | |
- SparseMat(const SparseMat& m); | |
- //! converts dense 2d matrix to the sparse form | |
- /*! | |
- \param m the input matrix | |
- \param try1d if true and m is a single-column matrix (Nx1), | |
- then the sparse matrix will be 1-dimensional. | |
- */ | |
- explicit SparseMat(const Mat& m); | |
- //! converts old-style sparse matrix to the new-style. All the data is copied | |
- SparseMat(const CvSparseMat* m); | |
- //! the destructor | |
- ~SparseMat(); | |
- | |
- //! assignment operator. This is O(1) operation, i.e. no data is copied | |
- SparseMat& operator = (const SparseMat& m); | |
- //! equivalent to the corresponding constructor | |
- SparseMat& operator = (const Mat& m); | |
- | |
- //! creates full copy of the matrix | |
- SparseMat clone() const; | |
- | |
- //! copies all the data to the destination matrix. All the previous content of m is erased | |
- void copyTo( SparseMat& m ) const; | |
- //! converts sparse matrix to dense matrix. | |
- void copyTo( Mat& m ) const; | |
- //! multiplies all the matrix elements by the specified scale factor alpha and converts the results to the specified data type | |
- void convertTo( SparseMat& m, int rtype, double alpha=1 ) const; | |
- //! converts sparse matrix to dense n-dim matrix with optional type conversion and scaling. | |
- /*! | |
- \param rtype The output matrix data type. When it is =-1, the output array will have the same data type as (*this) | |
- \param alpha The scale factor | |
- \param beta The optional delta added to the scaled values before the conversion | |
- */ | |
- void convertTo( Mat& m, int rtype, double alpha=1, double beta=0 ) const; | |
- | |
- // not used now | |
- void assignTo( SparseMat& m, int type=-1 ) const; | |
- | |
- //! reallocates sparse matrix. | |
- /*! | |
- If the matrix already had the proper size and type, | |
- it is simply cleared with clear(), otherwise, | |
- the old matrix is released (using release()) and the new one is allocated. | |
- */ | |
- void create(int dims, const int* _sizes, int _type); | |
- //! sets all the sparse matrix elements to 0, which means clearing the hash table. | |
- void clear(); | |
- //! manually increments the reference counter to the header. | |
- void addref(); | |
- // decrements the header reference counter. When the counter reaches 0, the header and all the underlying data are deallocated. | |
- void release(); | |
- | |
- //! converts sparse matrix to the old-style representation; all the elements are copied. | |
- operator CvSparseMat*() const; | |
- //! returns the size of each element in bytes (not including the overhead - the space occupied by SparseMat::Node elements) | |
- size_t elemSize() const; | |
- //! returns elemSize()/channels() | |
- size_t elemSize1() const; | |
- | |
- //! returns type of sparse matrix elements | |
- int type() const; | |
- //! returns the depth of sparse matrix elements | |
- int depth() const; | |
- //! returns the number of channels | |
- int channels() const; | |
- | |
- //! returns the array of sizes, or NULL if the matrix is not allocated | |
- const int* size() const; | |
- //! returns the size of i-th matrix dimension (or 0) | |
- int size(int i) const; | |
- //! returns the matrix dimensionality | |
- int dims() const; | |
- //! returns the number of non-zero elements (=the number of hash table nodes) | |
- size_t nzcount() const; | |
- | |
- //! computes the element hash value (1D case) | |
- size_t hash(int i0) const; | |
- //! computes the element hash value (2D case) | |
- size_t hash(int i0, int i1) const; | |
- //! computes the element hash value (3D case) | |
- size_t hash(int i0, int i1, int i2) const; | |
- //! computes the element hash value (nD case) | |
- size_t hash(const int* idx) const; | |
- | |
- //@{ | |
- /*! | |
- specialized variants for 1D, 2D, 3D cases and the generic_type one for n-D case. | |
- | |
- return pointer to the matrix element. | |
- <ul> | |
- <li>if the element is there (it's non-zero), the pointer to it is returned | |
- <li>if it's not there and createMissing=false, NULL pointer is returned | |
- <li>if it's not there and createMissing=true, then the new element | |
- is created and initialized with 0. Pointer to it is returned | |
- <li>if the optional hashval pointer is not NULL, the element hash value is | |
- not computed, but *hashval is taken instead. | |
- </ul> | |
- */ | |
- //! returns pointer to the specified element (1D case) | |
- uchar* ptr(int i0, bool createMissing, size_t* hashval=0); | |
- //! returns pointer to the specified element (2D case) | |
- uchar* ptr(int i0, int i1, bool createMissing, size_t* hashval=0); | |
- //! returns pointer to the specified element (3D case) | |
- uchar* ptr(int i0, int i1, int i2, bool createMissing, size_t* hashval=0); | |
- //! returns pointer to the specified element (nD case) | |
- uchar* ptr(const int* idx, bool createMissing, size_t* hashval=0); | |
- //@} | |
- | |
- //@{ | |
- /*! | |
- return read-write reference to the specified sparse matrix element. | |
- | |
- ref<_Tp>(i0,...[,hashval]) is equivalent to *(_Tp*)ptr(i0,...,true[,hashval]). | |
- The methods always return a valid reference. | |
- If the element did not exist, it is created and initialiazed with 0. | |
- */ | |
- //! returns reference to the specified element (1D case) | |
- template<typename _Tp> _Tp& ref(int i0, size_t* hashval=0); | |
- //! returns reference to the specified element (2D case) | |
- template<typename _Tp> _Tp& ref(int i0, int i1, size_t* hashval=0); | |
- //! returns reference to the specified element (3D case) | |
- template<typename _Tp> _Tp& ref(int i0, int i1, int i2, size_t* hashval=0); | |
- //! returns reference to the specified element (nD case) | |
- template<typename _Tp> _Tp& ref(const int* idx, size_t* hashval=0); | |
- //@} | |
- | |
- //@{ | |
- /*! | |
- return value of the specified sparse matrix element. | |
- | |
- value<_Tp>(i0,...[,hashval]) is equivalent | |
- | |
- \code | |
- { const _Tp* p = find<_Tp>(i0,...[,hashval]); return p ? *p : _Tp(); } | |
- \endcode | |
- | |
- That is, if the element did not exist, the methods return 0. | |
- */ | |
- //! returns value of the specified element (1D case) | |
- template<typename _Tp> _Tp value(int i0, size_t* hashval=0) const; | |
- //! returns value of the specified element (2D case) | |
- template<typename _Tp> _Tp value(int i0, int i1, size_t* hashval=0) const; | |
- //! returns value of the specified element (3D case) | |
- template<typename _Tp> _Tp value(int i0, int i1, int i2, size_t* hashval=0) const; | |
- //! returns value of the specified element (nD case) | |
- template<typename _Tp> _Tp value(const int* idx, size_t* hashval=0) const; | |
- //@} | |
- | |
- //@{ | |
- /*! | |
- Return pointer to the specified sparse matrix element if it exists | |
- | |
- find<_Tp>(i0,...[,hashval]) is equivalent to (_const Tp*)ptr(i0,...false[,hashval]). | |
- | |
- If the specified element does not exist, the methods return NULL. | |
- */ | |
- //! returns pointer to the specified element (1D case) | |
- template<typename _Tp> const _Tp* find(int i0, size_t* hashval=0) const; | |
- //! returns pointer to the specified element (2D case) | |
- template<typename _Tp> const _Tp* find(int i0, int i1, size_t* hashval=0) const; | |
- //! returns pointer to the specified element (3D case) | |
- template<typename _Tp> const _Tp* find(int i0, int i1, int i2, size_t* hashval=0) const; | |
- //! returns pointer to the specified element (nD case) | |
- template<typename _Tp> const _Tp* find(const int* idx, size_t* hashval=0) const; | |
- | |
- //! erases the specified element (2D case) | |
- void erase(int i0, int i1, size_t* hashval=0); | |
- //! erases the specified element (3D case) | |
- void erase(int i0, int i1, int i2, size_t* hashval=0); | |
- //! erases the specified element (nD case) | |
- void erase(const int* idx, size_t* hashval=0); | |
- | |
- //@{ | |
- /*! | |
- return the sparse matrix iterator pointing to the first sparse matrix element | |
- */ | |
- //! returns the sparse matrix iterator at the matrix beginning | |
- SparseMatIterator begin(); | |
- //! returns the sparse matrix iterator at the matrix beginning | |
- template<typename _Tp> SparseMatIterator_<_Tp> begin(); | |
- //! returns the read-only sparse matrix iterator at the matrix beginning | |
- SparseMatConstIterator begin() const; | |
- //! returns the read-only sparse matrix iterator at the matrix beginning | |
- template<typename _Tp> SparseMatConstIterator_<_Tp> begin() const; | |
- //@} | |
- /*! | |
- return the sparse matrix iterator pointing to the element following the last sparse matrix element | |
- */ | |
- //! returns the sparse matrix iterator at the matrix end | |
- SparseMatIterator end(); | |
- //! returns the read-only sparse matrix iterator at the matrix end | |
- SparseMatConstIterator end() const; | |
- //! returns the typed sparse matrix iterator at the matrix end | |
- template<typename _Tp> SparseMatIterator_<_Tp> end(); | |
- //! returns the typed read-only sparse matrix iterator at the matrix end | |
- template<typename _Tp> SparseMatConstIterator_<_Tp> end() const; | |
- | |
- //! returns the value stored in the sparse martix node | |
- template<typename _Tp> _Tp& value(Node* n); | |
- //! returns the value stored in the sparse martix node | |
- template<typename _Tp> const _Tp& value(const Node* n) const; | |
- | |
- ////////////// some internal-use methods /////////////// | |
- Node* node(size_t nidx); | |
- const Node* node(size_t nidx) const; | |
- | |
- uchar* newNode(const int* idx, size_t hashval); | |
- void removeNode(size_t hidx, size_t nidx, size_t previdx); | |
- void resizeHashTab(size_t newsize); | |
- | |
- enum { MAGIC_VAL=0x42FD0000, MAX_DIM=CV_MAX_DIM, HASH_SCALE=0x5bd1e995, HASH_BIT=0x80000000 }; | |
- | |
- int flags; | |
- Hdr* hdr; | |
-}; | |
- | |
-//! finds global minimum and maximum sparse array elements and returns their values and their locations | |
-CV_EXPORTS void minMaxLoc(const SparseMat& a, double* minVal, | |
- double* maxVal, int* minIdx=0, int* maxIdx=0); | |
-//! computes norm of a sparse matrix | |
-CV_EXPORTS double norm( const SparseMat& src, int normType ); | |
-//! scales and shifts array elements so that either the specified norm (alpha) or the minimum (alpha) and maximum (beta) array values get the specified values | |
-CV_EXPORTS void normalize( const SparseMat& src, SparseMat& dst, double alpha, int normType ); | |
- | |
-/*! | |
- Read-Only Sparse Matrix Iterator. | |
- Here is how to use the iterator to compute the sum of floating-point sparse matrix elements: | |
- | |
- \code | |
- SparseMatConstIterator it = m.begin(), it_end = m.end(); | |
- double s = 0; | |
- CV_Assert( m.type() == CV_32F ); | |
- for( ; it != it_end; ++it ) | |
- s += it.value<float>(); | |
- \endcode | |
-*/ | |
-class CV_EXPORTS SparseMatConstIterator | |
-{ | |
-public: | |
- //! the default constructor | |
- SparseMatConstIterator(); | |
- //! the full constructor setting the iterator to the first sparse matrix element | |
- SparseMatConstIterator(const SparseMat* _m); | |
- //! the copy constructor | |
- SparseMatConstIterator(const SparseMatConstIterator& it); | |
- | |
- //! the assignment operator | |
- SparseMatConstIterator& operator = (const SparseMatConstIterator& it); | |
- | |
- //! template method returning the current matrix element | |
- template<typename _Tp> const _Tp& value() const; | |
- //! returns the current node of the sparse matrix. it.node->idx is the current element index | |
- const SparseMat::Node* node() const; | |
- | |
- //! moves iterator to the previous element | |
- SparseMatConstIterator& operator --(); | |
- //! moves iterator to the previous element | |
- SparseMatConstIterator operator --(int); | |
- //! moves iterator to the next element | |
- SparseMatConstIterator& operator ++(); | |
- //! moves iterator to the next element | |
- SparseMatConstIterator operator ++(int); | |
- | |
- //! moves iterator to the element after the last element | |
- void seekEnd(); | |
- | |
- const SparseMat* m; | |
- size_t hashidx; | |
- uchar* ptr; | |
-}; | |
- | |
-/*! | |
- Read-write Sparse Matrix Iterator | |
- | |
- The class is similar to cv::SparseMatConstIterator, | |
- but can be used for in-place modification of the matrix elements. | |
-*/ | |
-class CV_EXPORTS SparseMatIterator : public SparseMatConstIterator | |
-{ | |
-public: | |
- //! the default constructor | |
- SparseMatIterator(); | |
- //! the full constructor setting the iterator to the first sparse matrix element | |
- SparseMatIterator(SparseMat* _m); | |
- //! the full constructor setting the iterator to the specified sparse matrix element | |
- SparseMatIterator(SparseMat* _m, const int* idx); | |
- //! the copy constructor | |
- SparseMatIterator(const SparseMatIterator& it); | |
- | |
- //! the assignment operator | |
- SparseMatIterator& operator = (const SparseMatIterator& it); | |
- //! returns read-write reference to the current sparse matrix element | |
- template<typename _Tp> _Tp& value() const; | |
- //! returns pointer to the current sparse matrix node. it.node->idx is the index of the current element (do not modify it!) | |
- SparseMat::Node* node() const; | |
- | |
- //! moves iterator to the next element | |
- SparseMatIterator& operator ++(); | |
- //! moves iterator to the next element | |
- SparseMatIterator operator ++(int); | |
-}; | |
- | |
-/*! | |
- The Template Sparse Matrix class derived from cv::SparseMat | |
- | |
- The class provides slightly more convenient operations for accessing elements. | |
- | |
- \code | |
- SparseMat m; | |
- ... | |
- SparseMat_<int> m_ = (SparseMat_<int>&)m; | |
- m_.ref(1)++; // equivalent to m.ref<int>(1)++; | |
- m_.ref(2) += m_(3); // equivalent to m.ref<int>(2) += m.value<int>(3); | |
- \endcode | |
-*/ | |
-template<typename _Tp> class CV_EXPORTS SparseMat_ : public SparseMat | |
-{ | |
-public: | |
- typedef SparseMatIterator_<_Tp> iterator; | |
- typedef SparseMatConstIterator_<_Tp> const_iterator; | |
- | |
- //! the default constructor | |
- SparseMat_(); | |
- //! the full constructor equivelent to SparseMat(dims, _sizes, DataType<_Tp>::type) | |
- SparseMat_(int dims, const int* _sizes); | |
- //! the copy constructor. If DataType<_Tp>.type != m.type(), the m elements are converted | |
- SparseMat_(const SparseMat& m); | |
- //! the copy constructor. This is O(1) operation - no data is copied | |
- SparseMat_(const SparseMat_& m); | |
- //! converts dense matrix to the sparse form | |
- SparseMat_(const Mat& m); | |
- //! converts the old-style sparse matrix to the C++ class. All the elements are copied | |
- SparseMat_(const CvSparseMat* m); | |
- //! the assignment operator. If DataType<_Tp>.type != m.type(), the m elements are converted | |
- SparseMat_& operator = (const SparseMat& m); | |
- //! the assignment operator. This is O(1) operation - no data is copied | |
- SparseMat_& operator = (const SparseMat_& m); | |
- //! converts dense matrix to the sparse form | |
- SparseMat_& operator = (const Mat& m); | |
- | |
- //! makes full copy of the matrix. All the elements are duplicated | |
- SparseMat_ clone() const; | |
- //! equivalent to cv::SparseMat::create(dims, _sizes, DataType<_Tp>::type) | |
- void create(int dims, const int* _sizes); | |
- //! converts sparse matrix to the old-style CvSparseMat. All the elements are copied | |
- operator CvSparseMat*() const; | |
- | |
- //! returns type of the matrix elements | |
- int type() const; | |
- //! returns depth of the matrix elements | |
- int depth() const; | |
- //! returns the number of channels in each matrix element | |
- int channels() const; | |
- | |
- //! equivalent to SparseMat::ref<_Tp>(i0, hashval) | |
- _Tp& ref(int i0, size_t* hashval=0); | |
- //! equivalent to SparseMat::ref<_Tp>(i0, i1, hashval) | |
- _Tp& ref(int i0, int i1, size_t* hashval=0); | |
- //! equivalent to SparseMat::ref<_Tp>(i0, i1, i2, hashval) | |
- _Tp& ref(int i0, int i1, int i2, size_t* hashval=0); | |
- //! equivalent to SparseMat::ref<_Tp>(idx, hashval) | |
- _Tp& ref(const int* idx, size_t* hashval=0); | |
- | |
- //! equivalent to SparseMat::value<_Tp>(i0, hashval) | |
- _Tp operator()(int i0, size_t* hashval=0) const; | |
- //! equivalent to SparseMat::value<_Tp>(i0, i1, hashval) | |
- _Tp operator()(int i0, int i1, size_t* hashval=0) const; | |
- //! equivalent to SparseMat::value<_Tp>(i0, i1, i2, hashval) | |
- _Tp operator()(int i0, int i1, int i2, size_t* hashval=0) const; | |
- //! equivalent to SparseMat::value<_Tp>(idx, hashval) | |
- _Tp operator()(const int* idx, size_t* hashval=0) const; | |
- | |
- //! returns sparse matrix iterator pointing to the first sparse matrix element | |
- SparseMatIterator_<_Tp> begin(); | |
- //! returns read-only sparse matrix iterator pointing to the first sparse matrix element | |
- SparseMatConstIterator_<_Tp> begin() const; | |
- //! returns sparse matrix iterator pointing to the element following the last sparse matrix element | |
- SparseMatIterator_<_Tp> end(); | |
- //! returns read-only sparse matrix iterator pointing to the element following the last sparse matrix element | |
- SparseMatConstIterator_<_Tp> end() const; | |
-}; | |
- | |
- | |
-/*! | |
- Template Read-Only Sparse Matrix Iterator Class. | |
- | |
- This is the derived from SparseMatConstIterator class that | |
- introduces more convenient operator *() for accessing the current element. | |
-*/ | |
-template<typename _Tp> class CV_EXPORTS SparseMatConstIterator_ : public SparseMatConstIterator | |
-{ | |
-public: | |
- typedef std::forward_iterator_tag iterator_category; | |
- | |
- //! the default constructor | |
- SparseMatConstIterator_(); | |
- //! the full constructor setting the iterator to the first sparse matrix element | |
- SparseMatConstIterator_(const SparseMat_<_Tp>* _m); | |
- //! the copy constructor | |
- SparseMatConstIterator_(const SparseMatConstIterator_& it); | |
- | |
- //! the assignment operator | |
- SparseMatConstIterator_& operator = (const SparseMatConstIterator_& it); | |
- //! the element access operator | |
- const _Tp& operator *() const; | |
- | |
- //! moves iterator to the next element | |
- SparseMatConstIterator_& operator ++(); | |
- //! moves iterator to the next element | |
- SparseMatConstIterator_ operator ++(int); | |
-}; | |
- | |
-/*! | |
- Template Read-Write Sparse Matrix Iterator Class. | |
- | |
- This is the derived from cv::SparseMatConstIterator_ class that | |
- introduces more convenient operator *() for accessing the current element. | |
-*/ | |
-template<typename _Tp> class CV_EXPORTS SparseMatIterator_ : public SparseMatConstIterator_<_Tp> | |
-{ | |
-public: | |
- typedef std::forward_iterator_tag iterator_category; | |
- | |
- //! the default constructor | |
- SparseMatIterator_(); | |
- //! the full constructor setting the iterator to the first sparse matrix element | |
- SparseMatIterator_(SparseMat_<_Tp>* _m); | |
- //! the copy constructor | |
- SparseMatIterator_(const SparseMatIterator_& it); | |
- | |
- //! the assignment operator | |
- SparseMatIterator_& operator = (const SparseMatIterator_& it); | |
- //! returns the reference to the current element | |
- _Tp& operator *() const; | |
- | |
- //! moves the iterator to the next element | |
- SparseMatIterator_& operator ++(); | |
- //! moves the iterator to the next element | |
- SparseMatIterator_ operator ++(int); | |
-}; | |
- | |
-//////////////////// Fast Nearest-Neighbor Search Structure //////////////////// | |
- | |
-/*! | |
- Fast Nearest Neighbor Search Class. | |
- | |
- The class implements D. Lowe BBF (Best-Bin-First) algorithm for the last | |
- approximate (or accurate) nearest neighbor search in multi-dimensional spaces. | |
- | |
- First, a set of vectors is passed to KDTree::KDTree() constructor | |
- or KDTree::build() method, where it is reordered. | |
- | |
- Then arbitrary vectors can be passed to KDTree::findNearest() methods, which | |
- find the K nearest neighbors among the vectors from the initial set. | |
- The user can balance between the speed and accuracy of the search by varying Emax | |
- parameter, which is the number of leaves that the algorithm checks. | |
- The larger parameter values yield more accurate results at the expense of lower processing speed. | |
- | |
- \code | |
- KDTree T(points, false); | |
- const int K = 3, Emax = INT_MAX; | |
- int idx[K]; | |
- float dist[K]; | |
- T.findNearest(query_vec, K, Emax, idx, 0, dist); | |
- CV_Assert(dist[0] <= dist[1] && dist[1] <= dist[2]); | |
- \endcode | |
-*/ | |
-class CV_EXPORTS_W KDTree | |
-{ | |
-public: | |
- /*! | |
- The node of the search tree. | |
- */ | |
- struct Node | |
- { | |
- Node() : idx(-1), left(-1), right(-1), boundary(0.f) {} | |
- Node(int _idx, int _left, int _right, float _boundary) | |
- : idx(_idx), left(_left), right(_right), boundary(_boundary) {} | |
- //! split dimension; >=0 for nodes (dim), < 0 for leaves (index of the point) | |
- int idx; | |
- //! node indices of the left and the right branches | |
- int left, right; | |
- //! go to the left if query_vec[node.idx]<=node.boundary, otherwise go to the right | |
- float boundary; | |
- }; | |
- | |
- //! the default constructor | |
- CV_WRAP KDTree(); | |
- //! the full constructor that builds the search tree | |
- CV_WRAP KDTree(InputArray points, bool copyAndReorderPoints=false); | |
- //! the full constructor that builds the search tree | |
- CV_WRAP KDTree(InputArray points, InputArray _labels, | |
- bool copyAndReorderPoints=false); | |
- //! builds the search tree | |
- CV_WRAP void build(InputArray points, bool copyAndReorderPoints=false); | |
- //! builds the search tree | |
- CV_WRAP void build(InputArray points, InputArray labels, | |
- bool copyAndReorderPoints=false); | |
- //! finds the K nearest neighbors of "vec" while looking at Emax (at most) leaves | |
- CV_WRAP int findNearest(InputArray vec, int K, int Emax, | |
- OutputArray neighborsIdx, | |
- OutputArray neighbors=noArray(), | |
- OutputArray dist=noArray(), | |
- OutputArray labels=noArray()) const; | |
- //! finds all the points from the initial set that belong to the specified box | |
- CV_WRAP void findOrthoRange(InputArray minBounds, | |
- InputArray maxBounds, | |
- OutputArray neighborsIdx, | |
- OutputArray neighbors=noArray(), | |
- OutputArray labels=noArray()) const; | |
- //! returns vectors with the specified indices | |
- CV_WRAP void getPoints(InputArray idx, OutputArray pts, | |
- OutputArray labels=noArray()) const; | |
- //! return a vector with the specified index | |
- const float* getPoint(int ptidx, int* label=0) const; | |
- //! returns the search space dimensionality | |
- CV_WRAP int dims() const; | |
- | |
- vector<Node> nodes; //!< all the tree nodes | |
- CV_PROP Mat points; //!< all the points. It can be a reordered copy of the input vector set or the original vector set. | |
- CV_PROP vector<int> labels; //!< the parallel array of labels. | |
- CV_PROP int maxDepth; //!< maximum depth of the search tree. Do not modify it | |
- CV_PROP_RW int normType; //!< type of the distance (cv::NORM_L1 or cv::NORM_L2) used for search. Initially set to cv::NORM_L2, but you can modify it | |
-}; | |
- | |
-//////////////////////////////////////// XML & YAML I/O //////////////////////////////////// | |
- | |
-class CV_EXPORTS FileNode; | |
- | |
-/*! | |
- XML/YAML File Storage Class. | |
- | |
- The class describes an object associated with XML or YAML file. | |
- It can be used to store data to such a file or read and decode the data. | |
- | |
- The storage is organized as a tree of nested sequences (or lists) and mappings. | |
- Sequence is a heterogenious array, which elements are accessed by indices or sequentially using an iterator. | |
- Mapping is analogue of std::map or C structure, which elements are accessed by names. | |
- The most top level structure is a mapping. | |
- Leaves of the file storage tree are integers, floating-point numbers and text strings. | |
- | |
- For example, the following code: | |
- | |
- \code | |
- // open file storage for writing. Type of the file is determined from the extension | |
- FileStorage fs("test.yml", FileStorage::WRITE); | |
- fs << "test_int" << 5 << "test_real" << 3.1 << "test_string" << "ABCDEFGH"; | |
- fs << "test_mat" << Mat::eye(3,3,CV_32F); | |
- | |
- fs << "test_list" << "[" << 0.0000000000001 << 2 << CV_PI << -3435345 << "2-502 2-029 3egegeg" << | |
- "{:" << "month" << 12 << "day" << 31 << "year" << 1969 << "}" << "]"; | |
- fs << "test_map" << "{" << "x" << 1 << "y" << 2 << "width" << 100 << "height" << 200 << "lbp" << "[:"; | |
- | |
- const uchar arr[] = {0, 1, 1, 0, 1, 1, 0, 1}; | |
- fs.writeRaw("u", arr, (int)(sizeof(arr)/sizeof(arr[0]))); | |
- | |
- fs << "]" << "}"; | |
- \endcode | |
- | |
- will produce the following file: | |
- | |
- \verbatim | |
- %YAML:1.0 | |
- test_int: 5 | |
- test_real: 3.1000000000000001e+00 | |
- test_string: ABCDEFGH | |
- test_mat: !!opencv-matrix | |
- rows: 3 | |
- cols: 3 | |
- dt: f | |
- data: [ 1., 0., 0., 0., 1., 0., 0., 0., 1. ] | |
- test_list: | |
- - 1.0000000000000000e-13 | |
- - 2 | |
- - 3.1415926535897931e+00 | |
- - -3435345 | |
- - "2-502 2-029 3egegeg" | |
- - { month:12, day:31, year:1969 } | |
- test_map: | |
- x: 1 | |
- y: 2 | |
- width: 100 | |
- height: 200 | |
- lbp: [ 0, 1, 1, 0, 1, 1, 0, 1 ] | |
- \endverbatim | |
- | |
- and to read the file above, the following code can be used: | |
- | |
- \code | |
- // open file storage for reading. | |
- // Type of the file is determined from the content, not the extension | |
- FileStorage fs("test.yml", FileStorage::READ); | |
- int test_int = (int)fs["test_int"]; | |
- double test_real = (double)fs["test_real"]; | |
- string test_string = (string)fs["test_string"]; | |
- | |
- Mat M; | |
- fs["test_mat"] >> M; | |
- | |
- FileNode tl = fs["test_list"]; | |
- CV_Assert(tl.type() == FileNode::SEQ && tl.size() == 6); | |
- double tl0 = (double)tl[0]; | |
- int tl1 = (int)tl[1]; | |
- double tl2 = (double)tl[2]; | |
- int tl3 = (int)tl[3]; | |
- string tl4 = (string)tl[4]; | |
- CV_Assert(tl[5].type() == FileNode::MAP && tl[5].size() == 3); | |
- | |
- int month = (int)tl[5]["month"]; | |
- int day = (int)tl[5]["day"]; | |
- int year = (int)tl[5]["year"]; | |
- | |
- FileNode tm = fs["test_map"]; | |
- | |
- int x = (int)tm["x"]; | |
- int y = (int)tm["y"]; | |
- int width = (int)tm["width"]; | |
- int height = (int)tm["height"]; | |
- | |
- int lbp_val = 0; | |
- FileNodeIterator it = tm["lbp"].begin(); | |
- | |
- for(int k = 0; k < 8; k++, ++it) | |
- lbp_val |= ((int)*it) << k; | |
- \endcode | |
-*/ | |
-class CV_EXPORTS_W FileStorage | |
-{ | |
-public: | |
- //! file storage mode | |
- enum | |
- { | |
- READ=0, //! read mode | |
- WRITE=1, //! write mode | |
- APPEND=2 //! append mode | |
- }; | |
- enum | |
- { | |
- UNDEFINED=0, | |
- VALUE_EXPECTED=1, | |
- NAME_EXPECTED=2, | |
- INSIDE_MAP=4 | |
- }; | |
- //! the default constructor | |
- CV_WRAP FileStorage(); | |
- //! the full constructor that opens file storage for reading or writing | |
- CV_WRAP FileStorage(const string& filename, int flags, const string& encoding=string()); | |
- //! the constructor that takes pointer to the C FileStorage structure | |
- FileStorage(CvFileStorage* fs); | |
- //! the destructor. calls release() | |
- virtual ~FileStorage(); | |
- | |
- //! opens file storage for reading or writing. The previous storage is closed with release() | |
- CV_WRAP virtual bool open(const string& filename, int flags, const string& encoding=string()); | |
- //! returns true if the object is associated with currently opened file. | |
- CV_WRAP virtual bool isOpened() const; | |
- //! closes the file and releases all the memory buffers | |
- CV_WRAP virtual void release(); | |
- | |
- //! returns the first element of the top-level mapping | |
- CV_WRAP FileNode getFirstTopLevelNode() const; | |
- //! returns the top-level mapping. YAML supports multiple streams | |
- CV_WRAP FileNode root(int streamidx=0) const; | |
- //! returns the specified element of the top-level mapping | |
- FileNode operator[](const string& nodename) const; | |
- //! returns the specified element of the top-level mapping | |
- CV_WRAP FileNode operator[](const char* nodename) const; | |
- | |
- //! returns pointer to the underlying C FileStorage structure | |
- CvFileStorage* operator *() { return fs; } | |
- //! returns pointer to the underlying C FileStorage structure | |
- const CvFileStorage* operator *() const { return fs; } | |
- //! writes one or more numbers of the specified format to the currently written structure | |
- void writeRaw( const string& fmt, const uchar* vec, size_t len ); | |
- //! writes the registered C structure (CvMat, CvMatND, CvSeq). See cvWrite() | |
- void writeObj( const string& name, const void* obj ); | |
- | |
- //! returns the normalized object name for the specified file name | |
- static string getDefaultObjectName(const string& filename); | |
- | |
- Ptr<CvFileStorage> fs; //!< the underlying C FileStorage structure | |
- string elname; //!< the currently written element | |
- vector<char> structs; //!< the stack of written structures | |
- int state; //!< the writer state | |
-}; | |
- | |
-class CV_EXPORTS FileNodeIterator; | |
- | |
-/*! | |
- File Storage Node class | |
- | |
- The node is used to store each and every element of the file storage opened for reading - | |
- from the primitive objects, such as numbers and text strings, to the complex nodes: | |
- sequences, mappings and the registered objects. | |
- | |
- Note that file nodes are only used for navigating file storages opened for reading. | |
- When a file storage is opened for writing, no data is stored in memory after it is written. | |
-*/ | |
-class CV_EXPORTS_W_SIMPLE FileNode | |
-{ | |
-public: | |
- //! type of the file storage node | |
- enum | |
- { | |
- NONE=0, //!< empty node | |
- INT=1, //!< an integer | |
- REAL=2, //!< floating-point number | |
- FLOAT=REAL, //!< synonym or REAL | |
- STR=3, //!< text string in UTF-8 encoding | |
- STRING=STR, //!< synonym for STR | |
- REF=4, //!< integer of size size_t. Typically used for storing complex dynamic structures where some elements reference the others | |
- SEQ=5, //!< sequence | |
- MAP=6, //!< mapping | |
- TYPE_MASK=7, | |
- FLOW=8, //!< compact representation of a sequence or mapping. Used only by YAML writer | |
- USER=16, //!< a registered object (e.g. a matrix) | |
- EMPTY=32, //!< empty structure (sequence or mapping) | |
- NAMED=64 //!< the node has a name (i.e. it is element of a mapping) | |
- }; | |
- //! the default constructor | |
- CV_WRAP FileNode(); | |
- //! the full constructor wrapping CvFileNode structure. | |
- FileNode(const CvFileStorage* fs, const CvFileNode* node); | |
- //! the copy constructor | |
- FileNode(const FileNode& node); | |
- //! returns element of a mapping node | |
- FileNode operator[](const string& nodename) const; | |
- //! returns element of a mapping node | |
- CV_WRAP FileNode operator[](const char* nodename) const; | |
- //! returns element of a sequence node | |
- CV_WRAP FileNode operator[](int i) const; | |
- //! returns type of the node | |
- CV_WRAP int type() const; | |
- | |
- //! returns true if the node is empty | |
- CV_WRAP bool empty() const; | |
- //! returns true if the node is a "none" object | |
- CV_WRAP bool isNone() const; | |
- //! returns true if the node is a sequence | |
- CV_WRAP bool isSeq() const; | |
- //! returns true if the node is a mapping | |
- CV_WRAP bool isMap() const; | |
- //! returns true if the node is an integer | |
- CV_WRAP bool isInt() const; | |
- //! returns true if the node is a floating-point number | |
- CV_WRAP bool isReal() const; | |
- //! returns true if the node is a text string | |
- CV_WRAP bool isString() const; | |
- //! returns true if the node has a name | |
- CV_WRAP bool isNamed() const; | |
- //! returns the node name or an empty string if the node is nameless | |
- CV_WRAP string name() const; | |
- //! returns the number of elements in the node, if it is a sequence or mapping, or 1 otherwise. | |
- CV_WRAP size_t size() const; | |
- //! returns the node content as an integer. If the node stores floating-point number, it is rounded. | |
- operator int() const; | |
- //! returns the node content as float | |
- operator float() const; | |
- //! returns the node content as double | |
- operator double() const; | |
- //! returns the node content as text string | |
- operator string() const; | |
- | |
- //! returns pointer to the underlying file node | |
- CvFileNode* operator *(); | |
- //! returns pointer to the underlying file node | |
- const CvFileNode* operator* () const; | |
- | |
- //! returns iterator pointing to the first node element | |
- FileNodeIterator begin() const; | |
- //! returns iterator pointing to the element following the last node element | |
- FileNodeIterator end() const; | |
- | |
- //! reads node elements to the buffer with the specified format | |
- void readRaw( const string& fmt, uchar* vec, size_t len ) const; | |
- //! reads the registered object and returns pointer to it | |
- void* readObj() const; | |
- | |
- // do not use wrapper pointer classes for better efficiency | |
- const CvFileStorage* fs; | |
- const CvFileNode* node; | |
-}; | |
- | |
- | |
-/*! | |
- File Node Iterator | |
- | |
- The class is used for iterating sequences (usually) and mappings. | |
- */ | |
-class CV_EXPORTS FileNodeIterator | |
-{ | |
-public: | |
- //! the default constructor | |
- FileNodeIterator(); | |
- //! the full constructor set to the ofs-th element of the node | |
- FileNodeIterator(const CvFileStorage* fs, const CvFileNode* node, size_t ofs=0); | |
- //! the copy constructor | |
- FileNodeIterator(const FileNodeIterator& it); | |
- //! returns the currently observed element | |
- FileNode operator *() const; | |
- //! accesses the currently observed element methods | |
- FileNode operator ->() const; | |
- | |
- //! moves iterator to the next node | |
- FileNodeIterator& operator ++ (); | |
- //! moves iterator to the next node | |
- FileNodeIterator operator ++ (int); | |
- //! moves iterator to the previous node | |
- FileNodeIterator& operator -- (); | |
- //! moves iterator to the previous node | |
- FileNodeIterator operator -- (int); | |
- //! moves iterator forward by the specified offset (possibly negative) | |
- FileNodeIterator& operator += (int); | |
- //! moves iterator backward by the specified offset (possibly negative) | |
- FileNodeIterator& operator -= (int); | |
- | |
- //! reads the next maxCount elements (or less, if the sequence/mapping last element occurs earlier) to the buffer with the specified format | |
- FileNodeIterator& readRaw( const string& fmt, uchar* vec, | |
- size_t maxCount=(size_t)INT_MAX ); | |
- | |
- const CvFileStorage* fs; | |
- const CvFileNode* container; | |
- CvSeqReader reader; | |
- size_t remaining; | |
-}; | |
- | |
-////////////// convenient wrappers for operating old-style dynamic structures ////////////// | |
- | |
-template<typename _Tp> class SeqIterator; | |
- | |
-typedef Ptr<CvMemStorage> MemStorage; | |
- | |
-/*! | |
- Template Sequence Class derived from CvSeq | |
- | |
- The class provides more convenient access to sequence elements, | |
- STL-style operations and iterators. | |
- | |
- \note The class is targeted for simple data types, | |
- i.e. no constructors or destructors | |
- are called for the sequence elements. | |
-*/ | |
-template<typename _Tp> class CV_EXPORTS Seq | |
-{ | |
-public: | |
- typedef SeqIterator<_Tp> iterator; | |
- typedef SeqIterator<_Tp> const_iterator; | |
- | |
- //! the default constructor | |
- Seq(); | |
- //! the constructor for wrapping CvSeq structure. The real element type in CvSeq should match _Tp. | |
- Seq(const CvSeq* seq); | |
- //! creates the empty sequence that resides in the specified storage | |
- Seq(MemStorage& storage, int headerSize = sizeof(CvSeq)); | |
- //! returns read-write reference to the specified element | |
- _Tp& operator [](int idx); | |
- //! returns read-only reference to the specified element | |
- const _Tp& operator[](int idx) const; | |
- //! returns iterator pointing to the beginning of the sequence | |
- SeqIterator<_Tp> begin() const; | |
- //! returns iterator pointing to the element following the last sequence element | |
- SeqIterator<_Tp> end() const; | |
- //! returns the number of elements in the sequence | |
- size_t size() const; | |
- //! returns the type of sequence elements (CV_8UC1 ... CV_64FC(CV_CN_MAX) ...) | |
- int type() const; | |
- //! returns the depth of sequence elements (CV_8U ... CV_64F) | |
- int depth() const; | |
- //! returns the number of channels in each sequence element | |
- int channels() const; | |
- //! returns the size of each sequence element | |
- size_t elemSize() const; | |
- //! returns index of the specified sequence element | |
- size_t index(const _Tp& elem) const; | |
- //! appends the specified element to the end of the sequence | |
- void push_back(const _Tp& elem); | |
- //! appends the specified element to the front of the sequence | |
- void push_front(const _Tp& elem); | |
- //! appends zero or more elements to the end of the sequence | |
- void push_back(const _Tp* elems, size_t count); | |
- //! appends zero or more elements to the front of the sequence | |
- void push_front(const _Tp* elems, size_t count); | |
- //! inserts the specified element to the specified position | |
- void insert(int idx, const _Tp& elem); | |
- //! inserts zero or more elements to the specified position | |
- void insert(int idx, const _Tp* elems, size_t count); | |
- //! removes element at the specified position | |
- void remove(int idx); | |
- //! removes the specified subsequence | |
- void remove(const Range& r); | |
- | |
- //! returns reference to the first sequence element | |
- _Tp& front(); | |
- //! returns read-only reference to the first sequence element | |
- const _Tp& front() const; | |
- //! returns reference to the last sequence element | |
- _Tp& back(); | |
- //! returns read-only reference to the last sequence element | |
- const _Tp& back() const; | |
- //! returns true iff the sequence contains no elements | |
- bool empty() const; | |
- | |
- //! removes all the elements from the sequence | |
- void clear(); | |
- //! removes the first element from the sequence | |
- void pop_front(); | |
- //! removes the last element from the sequence | |
- void pop_back(); | |
- //! removes zero or more elements from the beginning of the sequence | |
- void pop_front(_Tp* elems, size_t count); | |
- //! removes zero or more elements from the end of the sequence | |
- void pop_back(_Tp* elems, size_t count); | |
- | |
- //! copies the whole sequence or the sequence slice to the specified vector | |
- void copyTo(vector<_Tp>& vec, const Range& range=Range::all()) const; | |
- //! returns the vector containing all the sequence elements | |
- operator vector<_Tp>() const; | |
- | |
- CvSeq* seq; | |
-}; | |
- | |
- | |
-/*! | |
- STL-style Sequence Iterator inherited from the CvSeqReader structure | |
-*/ | |
-template<typename _Tp> class CV_EXPORTS SeqIterator : public CvSeqReader | |
-{ | |
-public: | |
- //! the default constructor | |
- SeqIterator(); | |
- //! the constructor setting the iterator to the beginning or to the end of the sequence | |
- SeqIterator(const Seq<_Tp>& seq, bool seekEnd=false); | |
- //! positions the iterator within the sequence | |
- void seek(size_t pos); | |
- //! reports the current iterator position | |
- size_t tell() const; | |
- //! returns reference to the current sequence element | |
- _Tp& operator *(); | |
- //! returns read-only reference to the current sequence element | |
- const _Tp& operator *() const; | |
- //! moves iterator to the next sequence element | |
- SeqIterator& operator ++(); | |
- //! moves iterator to the next sequence element | |
- SeqIterator operator ++(int) const; | |
- //! moves iterator to the previous sequence element | |
- SeqIterator& operator --(); | |
- //! moves iterator to the previous sequence element | |
- SeqIterator operator --(int) const; | |
- | |
- //! moves iterator forward by the specified offset (possibly negative) | |
- SeqIterator& operator +=(int); | |
- //! moves iterator backward by the specified offset (possibly negative) | |
- SeqIterator& operator -=(int); | |
- | |
- // this is index of the current element module seq->total*2 | |
- // (to distinguish between 0 and seq->total) | |
- int index; | |
-}; | |
- | |
- | |
-class CV_EXPORTS Algorithm; | |
-class CV_EXPORTS AlgorithmInfo; | |
-struct CV_EXPORTS AlgorithmInfoData; | |
- | |
-template<typename _Tp> struct ParamType {}; | |
- | |
-/*! | |
- Base class for high-level OpenCV algorithms | |
-*/ | |
-class CV_EXPORTS_W Algorithm | |
-{ | |
-public: | |
- Algorithm(); | |
- virtual ~Algorithm(); | |
- string name() const; | |
- | |
- template<typename _Tp> typename ParamType<_Tp>::member_type get(const string& name) const; | |
- template<typename _Tp> typename ParamType<_Tp>::member_type get(const char* name) const; | |
- | |
- CV_WRAP int getInt(const string& name) const; | |
- CV_WRAP double getDouble(const string& name) const; | |
- CV_WRAP bool getBool(const string& name) const; | |
- CV_WRAP string getString(const string& name) const; | |
- CV_WRAP Mat getMat(const string& name) const; | |
- CV_WRAP vector<Mat> getMatVector(const string& name) const; | |
- CV_WRAP Ptr<Algorithm> getAlgorithm(const string& name) const; | |
- | |
- CV_WRAP_AS(setInt) void set(const string& name, int value); | |
- CV_WRAP_AS(setDouble) void set(const string& name, double value); | |
- CV_WRAP_AS(setBool) void set(const string& name, bool value); | |
- CV_WRAP_AS(setString) void set(const string& name, const string& value); | |
- CV_WRAP_AS(setMat) void set(const string& name, const Mat& value); | |
- CV_WRAP_AS(setMatVector) void set(const string& name, const vector<Mat>& value); | |
- CV_WRAP_AS(setAlgorithm) void set(const string& name, const Ptr<Algorithm>& value); | |
- | |
- void set(const char* name, int value); | |
- void set(const char* name, double value); | |
- void set(const char* name, bool value); | |
- void set(const char* name, const string& value); | |
- void set(const char* name, const Mat& value); | |
- void set(const char* name, const vector<Mat>& value); | |
- void set(const char* name, const Ptr<Algorithm>& value); | |
- | |
- CV_WRAP string paramHelp(const string& name) const; | |
- int paramType(const char* name) const; | |
- CV_WRAP int paramType(const string& name) const; | |
- CV_WRAP void getParams(CV_OUT vector<string>& names) const; | |
- | |
- | |
- virtual void write(FileStorage& fs) const; | |
- virtual void read(const FileNode& fn); | |
- | |
- typedef Algorithm* (*Constructor)(void); | |
- typedef int (Algorithm::*Getter)() const; | |
- typedef void (Algorithm::*Setter)(int); | |
- | |
- CV_WRAP static void getList(CV_OUT vector<string>& algorithms); | |
- CV_WRAP static Ptr<Algorithm> _create(const string& name); | |
- template<typename _Tp> static Ptr<_Tp> create(const string& name); | |
- | |
- virtual AlgorithmInfo* info() const /* TODO: make it = 0;*/ { return 0; } | |
-}; | |
- | |
- | |
-class CV_EXPORTS AlgorithmInfo | |
-{ | |
-public: | |
- friend class Algorithm; | |
- AlgorithmInfo(const string& name, Algorithm::Constructor create); | |
- ~AlgorithmInfo(); | |
- void get(const Algorithm* algo, const char* name, int argType, void* value) const; | |
- void addParam_(Algorithm& algo, const char* name, int argType, | |
- void* value, bool readOnly, | |
- Algorithm::Getter getter, Algorithm::Setter setter, | |
- const string& help=string()); | |
- string paramHelp(const char* name) const; | |
- int paramType(const char* name) const; | |
- void getParams(vector<string>& names) const; | |
- | |
- void write(const Algorithm* algo, FileStorage& fs) const; | |
- void read(Algorithm* algo, const FileNode& fn) const; | |
- string name() const; | |
- | |
- void addParam(Algorithm& algo, const char* name, | |
- int& value, bool readOnly=false, | |
- int (Algorithm::*getter)()=0, | |
- void (Algorithm::*setter)(int)=0, | |
- const string& help=string()); | |
- void addParam(Algorithm& algo, const char* name, | |
- bool& value, bool readOnly=false, | |
- int (Algorithm::*getter)()=0, | |
- void (Algorithm::*setter)(int)=0, | |
- const string& help=string()); | |
- void addParam(Algorithm& algo, const char* name, | |
- double& value, bool readOnly=false, | |
- double (Algorithm::*getter)()=0, | |
- void (Algorithm::*setter)(double)=0, | |
- const string& help=string()); | |
- void addParam(Algorithm& algo, const char* name, | |
- string& value, bool readOnly=false, | |
- string (Algorithm::*getter)()=0, | |
- void (Algorithm::*setter)(const string&)=0, | |
- const string& help=string()); | |
- void addParam(Algorithm& algo, const char* name, | |
- Mat& value, bool readOnly=false, | |
- Mat (Algorithm::*getter)()=0, | |
- void (Algorithm::*setter)(const Mat&)=0, | |
- const string& help=string()); | |
- void addParam(Algorithm& algo, const char* name, | |
- vector<Mat>& value, bool readOnly=false, | |
- vector<Mat> (Algorithm::*getter)()=0, | |
- void (Algorithm::*setter)(const vector<Mat>&)=0, | |
- const string& help=string()); | |
- void addParam(Algorithm& algo, const char* name, | |
- Ptr<Algorithm>& value, bool readOnly=false, | |
- Ptr<Algorithm> (Algorithm::*getter)()=0, | |
- void (Algorithm::*setter)(const Ptr<Algorithm>&)=0, | |
- const string& help=string()); | |
-protected: | |
- AlgorithmInfoData* data; | |
- void set(Algorithm* algo, const char* name, int argType, | |
- const void* value, bool force=false) const; | |
-}; | |
- | |
- | |
-struct CV_EXPORTS Param | |
-{ | |
- enum { INT=0, BOOLEAN=1, REAL=2, STRING=3, MAT=4, MAT_VECTOR=5, ALGORITHM=6 }; | |
- | |
- Param(); | |
- Param(int _type, bool _readonly, int _offset, | |
- Algorithm::Getter _getter=0, | |
- Algorithm::Setter _setter=0, | |
- const string& _help=string()); | |
- int type; | |
- int offset; | |
- bool readonly; | |
- Algorithm::Getter getter; | |
- Algorithm::Setter setter; | |
- string help; | |
-}; | |
- | |
-template<> struct ParamType<bool> | |
-{ | |
- typedef bool const_param_type; | |
- typedef bool member_type; | |
- | |
- enum { type = Param::BOOLEAN }; | |
-}; | |
- | |
-template<> struct ParamType<int> | |
-{ | |
- typedef int const_param_type; | |
- typedef int member_type; | |
- | |
- enum { type = Param::INT }; | |
-}; | |
- | |
-template<> struct ParamType<double> | |
-{ | |
- typedef double const_param_type; | |
- typedef double member_type; | |
- | |
- enum { type = Param::REAL }; | |
-}; | |
- | |
-template<> struct ParamType<string> | |
-{ | |
- typedef const string& const_param_type; | |
- typedef string member_type; | |
- | |
- enum { type = Param::STRING }; | |
-}; | |
- | |
-template<> struct ParamType<Mat> | |
-{ | |
- typedef const Mat& const_param_type; | |
- typedef Mat member_type; | |
- | |
- enum { type = Param::MAT }; | |
-}; | |
- | |
-template<> struct ParamType<vector<Mat> > | |
-{ | |
- typedef const vector<Mat>& const_param_type; | |
- typedef vector<Mat> member_type; | |
- | |
- enum { type = Param::MAT_VECTOR }; | |
-}; | |
- | |
-template<> struct ParamType<Algorithm> | |
-{ | |
- typedef const Ptr<Algorithm>& const_param_type; | |
- typedef Ptr<Algorithm> member_type; | |
- | |
- enum { type = Param::ALGORITHM }; | |
-}; | |
- | |
- | |
-/*! | |
-"\nThe CommandLineParser class is designed for command line arguments parsing\n" | |
- "Keys map: \n" | |
- "Before you start to work with CommandLineParser you have to create a map for keys.\n" | |
- " It will look like this\n" | |
- " const char* keys =\n" | |
- " {\n" | |
- " { s| string| 123asd |string parameter}\n" | |
- " { d| digit | 100 |digit parameter }\n" | |
- " { c|noCamera|false |without camera }\n" | |
- " { 1| |some text|help }\n" | |
- " { 2| |333 |another help }\n" | |
- " };\n" | |
- "Usage syntax: \n" | |
- " \"{\" - start of parameter string.\n" | |
- " \"}\" - end of parameter string\n" | |
- " \"|\" - separator between short name, full name, default value and help\n" | |
- "Supported syntax: \n" | |
- " --key1=arg1 <If a key with '--' must has an argument\n" | |
- " you have to assign it through '=' sign.> \n" | |
- "<If the key with '--' doesn't have any argument, it means that it is a bool key>\n" | |
- " -key2=arg2 <If a key with '-' must has an argument \n" | |
- " you have to assign it through '=' sign.> \n" | |
- "If the key with '-' doesn't have any argument, it means that it is a bool key\n" | |
- " key3 <This key can't has any parameter> \n" | |
- "Usage: \n" | |
- " Imagine that the input parameters are next:\n" | |
- " -s=string_value --digit=250 --noCamera lena.jpg 10000\n" | |
- " CommandLineParser parser(argc, argv, keys) - create a parser object\n" | |
- " parser.get<string>(\"s\" or \"string\") will return you first parameter value\n" | |
- " parser.get<string>(\"s\", false or \"string\", false) will return you first parameter value\n" | |
- " without spaces in end and begin\n" | |
- " parser.get<int>(\"d\" or \"digit\") will return you second parameter value.\n" | |
- " It also works with 'unsigned int', 'double', and 'float' types>\n" | |
- " parser.get<bool>(\"c\" or \"noCamera\") will return you true .\n" | |
- " If you enter this key in commandline>\n" | |
- " It return you false otherwise.\n" | |
- " parser.get<string>(\"1\") will return you the first argument without parameter (lena.jpg) \n" | |
- " parser.get<int>(\"2\") will return you the second argument without parameter (10000)\n" | |
- " It also works with 'unsigned int', 'double', and 'float' types \n" | |
-*/ | |
-class CV_EXPORTS CommandLineParser | |
-{ | |
- public: | |
- | |
- //! the default constructor | |
- CommandLineParser(int argc, const char* const argv[], const char* key_map); | |
- | |
- //! get parameter, you can choose: delete spaces in end and begin or not | |
- template<typename _Tp> | |
- _Tp get(const std::string& name, bool space_delete=true) | |
- { | |
- if (!has(name)) | |
- { | |
- return _Tp(); | |
- } | |
- std::string str = getString(name); | |
- return analyzeValue<_Tp>(str, space_delete); | |
- } | |
- | |
- //! print short name, full name, current value and help for all params | |
- void printParams(); | |
- | |
- protected: | |
- std::map<std::string, std::vector<std::string> > data; | |
- std::string getString(const std::string& name); | |
- | |
- bool has(const std::string& keys); | |
- | |
- template<typename _Tp> | |
- _Tp analyzeValue(const std::string& str, bool space_delete=false); | |
- | |
- template<typename _Tp> | |
- static _Tp getData(const std::string& str) | |
- { | |
- _Tp res; | |
- std::stringstream s1(str); | |
- s1 >> res; | |
- return res; | |
- } | |
- | |
- template<typename _Tp> | |
- _Tp fromStringNumber(const std::string& str);//the default conversion function for numbers | |
- | |
- }; | |
- | |
-template<> CV_EXPORTS | |
-bool CommandLineParser::get<bool>(const std::string& name, bool space_delete); | |
- | |
-template<> CV_EXPORTS | |
-std::string CommandLineParser::analyzeValue<std::string>(const std::string& str, bool space_delete); | |
- | |
-template<> CV_EXPORTS | |
-int CommandLineParser::analyzeValue<int>(const std::string& str, bool space_delete); | |
- | |
-template<> CV_EXPORTS | |
-unsigned int CommandLineParser::analyzeValue<unsigned int>(const std::string& str, bool space_delete); | |
- | |
-template<> CV_EXPORTS | |
-uint64 CommandLineParser::analyzeValue<uint64>(const std::string& str, bool space_delete); | |
- | |
-template<> CV_EXPORTS | |
-float CommandLineParser::analyzeValue<float>(const std::string& str, bool space_delete); | |
- | |
-template<> CV_EXPORTS | |
-double CommandLineParser::analyzeValue<double>(const std::string& str, bool space_delete); | |
- | |
-} | |
- | |
-#endif // __cplusplus | |
- | |
-#include "opencv2/core/operations.hpp" | |
-#include "opencv2/core/mat.hpp" | |
- | |
-#endif /*__OPENCV_CORE_HPP__*/ | |
diff --git a/card.io/src/main/jni/opencv2/core/core_c.h b/card.io/src/main/jni/opencv2/core/core_c.h | |
deleted file mode 100644 | |
index 6806821..0000000 | |
--- a/card.io/src/main/jni/opencv2/core/core_c.h | |
+++ /dev/null | |
@@ -1,1885 +0,0 @@ | |
-/*M/////////////////////////////////////////////////////////////////////////////////////// | |
-// | |
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. | |
-// | |
-// By downloading, copying, installing or using the software you agree to this license. | |
-// If you do not agree to this license, do not download, install, | |
-// copy or use the software. | |
-// | |
-// | |
-// License Agreement | |
-// For Open Source Computer Vision Library | |
-// | |
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. | |
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved. | |
-// Third party copyrights are property of their respective owners. | |
-// | |
-// Redistribution and use in source and binary forms, with or without modification, | |
-// are permitted provided that the following conditions are met: | |
-// | |
-// * Redistribution's of source code must retain the above copyright notice, | |
-// this list of conditions and the following disclaimer. | |
-// | |
-// * Redistribution's in binary form must reproduce the above copyright notice, | |
-// this list of conditions and the following disclaimer in the documentation | |
-// and/or other materials provided with the distribution. | |
-// | |
-// * The name of the copyright holders may not be used to endorse or promote products | |
-// derived from this software without specific prior written permission. | |
-// | |
-// This software is provided by the copyright holders and contributors "as is" and | |
-// any express or implied warranties, including, but not limited to, the implied | |
-// warranties of merchantability and fitness for a particular purpose are disclaimed. | |
-// In no event shall the Intel Corporation or contributors be liable for any direct, | |
-// indirect, incidental, special, exemplary, or consequential damages | |
-// (including, but not limited to, procurement of substitute goods or services; | |
-// loss of use, data, or profits; or business interruption) however caused | |
-// and on any theory of liability, whether in contract, strict liability, | |
-// or tort (including negligence or otherwise) arising in any way out of | |
-// the use of this software, even if advised of the possibility of such damage. | |
-// | |
-//M*/ | |
- | |
- | |
-#ifndef __OPENCV_CORE_C_H__ | |
-#define __OPENCV_CORE_C_H__ | |
- | |
-#include "opencv2/core/types_c.h" | |
- | |
-#ifdef __cplusplus | |
-extern "C" { | |
-#endif | |
- | |
-/****************************************************************************************\ | |
-* Array allocation, deallocation, initialization and access to elements * | |
-\****************************************************************************************/ | |
- | |
-/* <malloc> wrapper. | |
- If there is no enough memory, the function | |
- (as well as other OpenCV functions that call cvAlloc) | |
- raises an error. */ | |
-CVAPI(void*) cvAlloc( size_t size ); | |
- | |
-/* <free> wrapper. | |
- Here and further all the memory releasing functions | |
- (that all call cvFree) take double pointer in order to | |
- to clear pointer to the data after releasing it. | |
- Passing pointer to NULL pointer is Ok: nothing happens in this case | |
-*/ | |
-CVAPI(void) cvFree_( void* ptr ); | |
-#define cvFree(ptr) (cvFree_(*(ptr)), *(ptr)=0) | |
- | |
-/* Allocates and initializes IplImage header */ | |
-CVAPI(IplImage*) cvCreateImageHeader( CvSize size, int depth, int channels ); | |
- | |
-/* Inializes IplImage header */ | |
-CVAPI(IplImage*) cvInitImageHeader( IplImage* image, CvSize size, int depth, | |
- int channels, int origin CV_DEFAULT(0), | |
- int align CV_DEFAULT(4)); | |
- | |
-/* Creates IPL image (header and data) */ | |
-CVAPI(IplImage*) cvCreateImage( CvSize size, int depth, int channels ); | |
- | |
-/* Releases (i.e. deallocates) IPL image header */ | |
-CVAPI(void) cvReleaseImageHeader( IplImage** image ); | |
- | |
-/* Releases IPL image header and data */ | |
-CVAPI(void) cvReleaseImage( IplImage** image ); | |
- | |
-/* Creates a copy of IPL image (widthStep may differ) */ | |
-CVAPI(IplImage*) cvCloneImage( const IplImage* image ); | |
- | |
-/* Sets a Channel Of Interest (only a few functions support COI) - | |
- use cvCopy to extract the selected channel and/or put it back */ | |
-CVAPI(void) cvSetImageCOI( IplImage* image, int coi ); | |
- | |
-/* Retrieves image Channel Of Interest */ | |
-CVAPI(int) cvGetImageCOI( const IplImage* image ); | |
- | |
-/* Sets image ROI (region of interest) (COI is not changed) */ | |
-CVAPI(void) cvSetImageROI( IplImage* image, CvRect rect ); | |
- | |
-/* Resets image ROI and COI */ | |
-CVAPI(void) cvResetImageROI( IplImage* image ); | |
- | |
-/* Retrieves image ROI */ | |
-CVAPI(CvRect) cvGetImageROI( const IplImage* image ); | |
- | |
-/* Allocates and initalizes CvMat header */ | |
-CVAPI(CvMat*) cvCreateMatHeader( int rows, int cols, int type ); | |
- | |
-#define CV_AUTOSTEP 0x7fffffff | |
- | |
-/* Initializes CvMat header */ | |
-CVAPI(CvMat*) cvInitMatHeader( CvMat* mat, int rows, int cols, | |
- int type, void* data CV_DEFAULT(NULL), | |
- int step CV_DEFAULT(CV_AUTOSTEP) ); | |
- | |
-/* Allocates and initializes CvMat header and allocates data */ | |
-CVAPI(CvMat*) cvCreateMat( int rows, int cols, int type ); | |
- | |
-/* Releases CvMat header and deallocates matrix data | |
- (reference counting is used for data) */ | |
-CVAPI(void) cvReleaseMat( CvMat** mat ); | |
- | |
-/* Decrements CvMat data reference counter and deallocates the data if | |
- it reaches 0 */ | |
-CV_INLINE void cvDecRefData( CvArr* arr ) | |
-{ | |
- if( CV_IS_MAT( arr )) | |
- { | |
- CvMat* mat = (CvMat*)arr; | |
- mat->data.ptr = NULL; | |
- if( mat->refcount != NULL && --*mat->refcount == 0 ) | |
- cvFree( &mat->refcount ); | |
- mat->refcount = NULL; | |
- } | |
- else if( CV_IS_MATND( arr )) | |
- { | |
- CvMatND* mat = (CvMatND*)arr; | |
- mat->data.ptr = NULL; | |
- if( mat->refcount != NULL && --*mat->refcount == 0 ) | |
- cvFree( &mat->refcount ); | |
- mat->refcount = NULL; | |
- } | |
-} | |
- | |
-/* Increments CvMat data reference counter */ | |
-CV_INLINE int cvIncRefData( CvArr* arr ) | |
-{ | |
- int refcount = 0; | |
- if( CV_IS_MAT( arr )) | |
- { | |
- CvMat* mat = (CvMat*)arr; | |
- if( mat->refcount != NULL ) | |
- refcount = ++*mat->refcount; | |
- } | |
- else if( CV_IS_MATND( arr )) | |
- { | |
- CvMatND* mat = (CvMatND*)arr; | |
- if( mat->refcount != NULL ) | |
- refcount = ++*mat->refcount; | |
- } | |
- return refcount; | |
-} | |
- | |
- | |
-/* Creates an exact copy of the input matrix (except, may be, step value) */ | |
-CVAPI(CvMat*) cvCloneMat( const CvMat* mat ); | |
- | |
- | |
-/* Makes a new matrix from <rect> subrectangle of input array. | |
- No data is copied */ | |
-CVAPI(CvMat*) cvGetSubRect( const CvArr* arr, CvMat* submat, CvRect rect ); | |
-#define cvGetSubArr cvGetSubRect | |
- | |
-/* Selects row span of the input array: arr(start_row:delta_row:end_row,:) | |
- (end_row is not included into the span). */ | |
-CVAPI(CvMat*) cvGetRows( const CvArr* arr, CvMat* submat, | |
- int start_row, int end_row, | |
- int delta_row CV_DEFAULT(1)); | |
- | |
-CV_INLINE CvMat* cvGetRow( const CvArr* arr, CvMat* submat, int row ) | |
-{ | |
- return cvGetRows( arr, submat, row, row + 1, 1 ); | |
-} | |
- | |
- | |
-/* Selects column span of the input array: arr(:,start_col:end_col) | |
- (end_col is not included into the span) */ | |
-CVAPI(CvMat*) cvGetCols( const CvArr* arr, CvMat* submat, | |
- int start_col, int end_col ); | |
- | |
-CV_INLINE CvMat* cvGetCol( const CvArr* arr, CvMat* submat, int col ) | |
-{ | |
- return cvGetCols( arr, submat, col, col + 1 ); | |
-} | |
- | |
-/* Select a diagonal of the input array. | |
- (diag = 0 means the main diagonal, >0 means a diagonal above the main one, | |
- <0 - below the main one). | |
- The diagonal will be represented as a column (nx1 matrix). */ | |
-CVAPI(CvMat*) cvGetDiag( const CvArr* arr, CvMat* submat, | |
- int diag CV_DEFAULT(0)); | |
- | |
-/* low-level scalar <-> raw data conversion functions */ | |
-CVAPI(void) cvScalarToRawData( const CvScalar* scalar, void* data, int type, | |
- int extend_to_12 CV_DEFAULT(0) ); | |
- | |
-CVAPI(void) cvRawDataToScalar( const void* data, int type, CvScalar* scalar ); | |
- | |
-/* Allocates and initializes CvMatND header */ | |
-CVAPI(CvMatND*) cvCreateMatNDHeader( int dims, const int* sizes, int type ); | |
- | |
-/* Allocates and initializes CvMatND header and allocates data */ | |
-CVAPI(CvMatND*) cvCreateMatND( int dims, const int* sizes, int type ); | |
- | |
-/* Initializes preallocated CvMatND header */ | |
-CVAPI(CvMatND*) cvInitMatNDHeader( CvMatND* mat, int dims, const int* sizes, | |
- int type, void* data CV_DEFAULT(NULL) ); | |
- | |
-/* Releases CvMatND */ | |
-CV_INLINE void cvReleaseMatND( CvMatND** mat ) | |
-{ | |
- cvReleaseMat( (CvMat**)mat ); | |
-} | |
- | |
-/* Creates a copy of CvMatND (except, may be, steps) */ | |
-CVAPI(CvMatND*) cvCloneMatND( const CvMatND* mat ); | |
- | |
-/* Allocates and initializes CvSparseMat header and allocates data */ | |
-CVAPI(CvSparseMat*) cvCreateSparseMat( int dims, const int* sizes, int type ); | |
- | |
-/* Releases CvSparseMat */ | |
-CVAPI(void) cvReleaseSparseMat( CvSparseMat** mat ); | |
- | |
-/* Creates a copy of CvSparseMat (except, may be, zero items) */ | |
-CVAPI(CvSparseMat*) cvCloneSparseMat( const CvSparseMat* mat ); | |
- | |
-/* Initializes sparse array iterator | |
- (returns the first node or NULL if the array is empty) */ | |
-CVAPI(CvSparseNode*) cvInitSparseMatIterator( const CvSparseMat* mat, | |
- CvSparseMatIterator* mat_iterator ); | |
- | |
-// returns next sparse array node (or NULL if there is no more nodes) | |
-CV_INLINE CvSparseNode* cvGetNextSparseNode( CvSparseMatIterator* mat_iterator ) | |
-{ | |
- if( mat_iterator->node->next ) | |
- return mat_iterator->node = mat_iterator->node->next; | |
- else | |
- { | |
- int idx; | |
- for( idx = ++mat_iterator->curidx; idx < mat_iterator->mat->hashsize; idx++ ) | |
- { | |
- CvSparseNode* node = (CvSparseNode*)mat_iterator->mat->hashtable[idx]; | |
- if( node ) | |
- { | |
- mat_iterator->curidx = idx; | |
- return mat_iterator->node = node; | |
- } | |
- } | |
- return NULL; | |
- } | |
-} | |
- | |
-/**************** matrix iterator: used for n-ary operations on dense arrays *********/ | |
- | |
-#define CV_MAX_ARR 10 | |
- | |
-typedef struct CvNArrayIterator | |
-{ | |
- int count; /* number of arrays */ | |
- int dims; /* number of dimensions to iterate */ | |
- CvSize size; /* maximal common linear size: { width = size, height = 1 } */ | |
- uchar* ptr[CV_MAX_ARR]; /* pointers to the array slices */ | |
- int stack[CV_MAX_DIM]; /* for internal use */ | |
- CvMatND* hdr[CV_MAX_ARR]; /* pointers to the headers of the | |
- matrices that are processed */ | |
-} | |
-CvNArrayIterator; | |
- | |
-#define CV_NO_DEPTH_CHECK 1 | |
-#define CV_NO_CN_CHECK 2 | |
-#define CV_NO_SIZE_CHECK 4 | |
- | |
-/* initializes iterator that traverses through several arrays simulteneously | |
- (the function together with cvNextArraySlice is used for | |
- N-ari element-wise operations) */ | |
-CVAPI(int) cvInitNArrayIterator( int count, CvArr** arrs, | |
- const CvArr* mask, CvMatND* stubs, | |
- CvNArrayIterator* array_iterator, | |
- int flags CV_DEFAULT(0) ); | |
- | |
-/* returns zero value if iteration is finished, non-zero (slice length) otherwise */ | |
-CVAPI(int) cvNextNArraySlice( CvNArrayIterator* array_iterator ); | |
- | |
- | |
-/* Returns type of array elements: | |
- CV_8UC1 ... CV_64FC4 ... */ | |
-CVAPI(int) cvGetElemType( const CvArr* arr ); | |
- | |
-/* Retrieves number of an array dimensions and | |
- optionally sizes of the dimensions */ | |
-CVAPI(int) cvGetDims( const CvArr* arr, int* sizes CV_DEFAULT(NULL) ); | |
- | |
- | |
-/* Retrieves size of a particular array dimension. | |
- For 2d arrays cvGetDimSize(arr,0) returns number of rows (image height) | |
- and cvGetDimSize(arr,1) returns number of columns (image width) */ | |
-CVAPI(int) cvGetDimSize( const CvArr* arr, int index ); | |
- | |
- | |
-/* ptr = &arr(idx0,idx1,...). All indexes are zero-based, | |
- the major dimensions go first (e.g. (y,x) for 2D, (z,y,x) for 3D */ | |
-CVAPI(uchar*) cvPtr1D( const CvArr* arr, int idx0, int* type CV_DEFAULT(NULL)); | |
-CVAPI(uchar*) cvPtr2D( const CvArr* arr, int idx0, int idx1, int* type CV_DEFAULT(NULL) ); | |
-CVAPI(uchar*) cvPtr3D( const CvArr* arr, int idx0, int idx1, int idx2, | |
- int* type CV_DEFAULT(NULL)); | |
- | |
-/* For CvMat or IplImage number of indices should be 2 | |
- (row index (y) goes first, column index (x) goes next). | |
- For CvMatND or CvSparseMat number of infices should match number of <dims> and | |
- indices order should match the array dimension order. */ | |
-CVAPI(uchar*) cvPtrND( const CvArr* arr, const int* idx, int* type CV_DEFAULT(NULL), | |
- int create_node CV_DEFAULT(1), | |
- unsigned* precalc_hashval CV_DEFAULT(NULL)); | |
- | |
-/* value = arr(idx0,idx1,...) */ | |
-CVAPI(CvScalar) cvGet1D( const CvArr* arr, int idx0 ); | |
-CVAPI(CvScalar) cvGet2D( const CvArr* arr, int idx0, int idx1 ); | |
-CVAPI(CvScalar) cvGet3D( const CvArr* arr, int idx0, int idx1, int idx2 ); | |
-CVAPI(CvScalar) cvGetND( const CvArr* arr, const int* idx ); | |
- | |
-/* for 1-channel arrays */ | |
-CVAPI(double) cvGetReal1D( const CvArr* arr, int idx0 ); | |
-CVAPI(double) cvGetReal2D( const CvArr* arr, int idx0, int idx1 ); | |
-CVAPI(double) cvGetReal3D( const CvArr* arr, int idx0, int idx1, int idx2 ); | |
-CVAPI(double) cvGetRealND( const CvArr* arr, const int* idx ); | |
- | |
-/* arr(idx0,idx1,...) = value */ | |
-CVAPI(void) cvSet1D( CvArr* arr, int idx0, CvScalar value ); | |
-CVAPI(void) cvSet2D( CvArr* arr, int idx0, int idx1, CvScalar value ); | |
-CVAPI(void) cvSet3D( CvArr* arr, int idx0, int idx1, int idx2, CvScalar value ); | |
-CVAPI(void) cvSetND( CvArr* arr, const int* idx, CvScalar value ); | |
- | |
-/* for 1-channel arrays */ | |
-CVAPI(void) cvSetReal1D( CvArr* arr, int idx0, double value ); | |
-CVAPI(void) cvSetReal2D( CvArr* arr, int idx0, int idx1, double value ); | |
-CVAPI(void) cvSetReal3D( CvArr* arr, int idx0, | |
- int idx1, int idx2, double value ); | |
-CVAPI(void) cvSetRealND( CvArr* arr, const int* idx, double value ); | |
- | |
-/* clears element of ND dense array, | |
- in case of sparse arrays it deletes the specified node */ | |
-CVAPI(void) cvClearND( CvArr* arr, const int* idx ); | |
- | |
-/* Converts CvArr (IplImage or CvMat,...) to CvMat. | |
- If the last parameter is non-zero, function can | |
- convert multi(>2)-dimensional array to CvMat as long as | |
- the last array's dimension is continous. The resultant | |
- matrix will be have appropriate (a huge) number of rows */ | |
-CVAPI(CvMat*) cvGetMat( const CvArr* arr, CvMat* header, | |
- int* coi CV_DEFAULT(NULL), | |
- int allowND CV_DEFAULT(0)); | |
- | |
-/* Converts CvArr (IplImage or CvMat) to IplImage */ | |
-CVAPI(IplImage*) cvGetImage( const CvArr* arr, IplImage* image_header ); | |
- | |
- | |
-/* Changes a shape of multi-dimensional array. | |
- new_cn == 0 means that number of channels remains unchanged. | |
- new_dims == 0 means that number and sizes of dimensions remain the same | |
- (unless they need to be changed to set the new number of channels) | |
- if new_dims == 1, there is no need to specify new dimension sizes | |
- The resultant configuration should be achievable w/o data copying. | |
- If the resultant array is sparse, CvSparseMat header should be passed | |
- to the function else if the result is 1 or 2 dimensional, | |
- CvMat header should be passed to the function | |
- else CvMatND header should be passed */ | |
-CVAPI(CvArr*) cvReshapeMatND( const CvArr* arr, | |
- int sizeof_header, CvArr* header, | |
- int new_cn, int new_dims, int* new_sizes ); | |
- | |
-#define cvReshapeND( arr, header, new_cn, new_dims, new_sizes ) \ | |
- cvReshapeMatND( (arr), sizeof(*(header)), (header), \ | |
- (new_cn), (new_dims), (new_sizes)) | |
- | |
-CVAPI(CvMat*) cvReshape( const CvArr* arr, CvMat* header, | |
- int new_cn, int new_rows CV_DEFAULT(0) ); | |
- | |
-/* Repeats source 2d array several times in both horizontal and | |
- vertical direction to fill destination array */ | |
-CVAPI(void) cvRepeat( const CvArr* src, CvArr* dst ); | |
- | |
-/* Allocates array data */ | |
-CVAPI(void) cvCreateData( CvArr* arr ); | |
- | |
-/* Releases array data */ | |
-CVAPI(void) cvReleaseData( CvArr* arr ); | |
- | |
-/* Attaches user data to the array header. The step is reffered to | |
- the pre-last dimension. That is, all the planes of the array | |
- must be joint (w/o gaps) */ | |
-CVAPI(void) cvSetData( CvArr* arr, void* data, int step ); | |
- | |
-/* Retrieves raw data of CvMat, IplImage or CvMatND. | |
- In the latter case the function raises an error if | |
- the array can not be represented as a matrix */ | |
-CVAPI(void) cvGetRawData( const CvArr* arr, uchar** data, | |
- int* step CV_DEFAULT(NULL), | |
- CvSize* roi_size CV_DEFAULT(NULL)); | |
- | |
-/* Returns width and height of array in elements */ | |
-CVAPI(CvSize) cvGetSize( const CvArr* arr ); | |
- | |
-/* Copies source array to destination array */ | |
-CVAPI(void) cvCopy( const CvArr* src, CvArr* dst, | |
- const CvArr* mask CV_DEFAULT(NULL) ); | |
- | |
-/* Sets all or "masked" elements of input array | |
- to the same value*/ | |
-CVAPI(void) cvSet( CvArr* arr, CvScalar value, | |
- const CvArr* mask CV_DEFAULT(NULL) ); | |
- | |
-/* Clears all the array elements (sets them to 0) */ | |
-CVAPI(void) cvSetZero( CvArr* arr ); | |
-#define cvZero cvSetZero | |
- | |
- | |
-/* Splits a multi-channel array into the set of single-channel arrays or | |
- extracts particular [color] plane */ | |
-CVAPI(void) cvSplit( const CvArr* src, CvArr* dst0, CvArr* dst1, | |
- CvArr* dst2, CvArr* dst3 ); | |
- | |
-/* Merges a set of single-channel arrays into the single multi-channel array | |
- or inserts one particular [color] plane to the array */ | |
-CVAPI(void) cvMerge( const CvArr* src0, const CvArr* src1, | |
- const CvArr* src2, const CvArr* src3, | |
- CvArr* dst ); | |
- | |
-/* Copies several channels from input arrays to | |
- certain channels of output arrays */ | |
-CVAPI(void) cvMixChannels( const CvArr** src, int src_count, | |
- CvArr** dst, int dst_count, | |
- const int* from_to, int pair_count ); | |
- | |
-/* Performs linear transformation on every source array element: | |
- dst(x,y,c) = scale*src(x,y,c)+shift. | |
- Arbitrary combination of input and output array depths are allowed | |
- (number of channels must be the same), thus the function can be used | |
- for type conversion */ | |
-CVAPI(void) cvConvertScale( const CvArr* src, CvArr* dst, | |
- double scale CV_DEFAULT(1), | |
- double shift CV_DEFAULT(0) ); | |
-#define cvCvtScale cvConvertScale | |
-#define cvScale cvConvertScale | |
-#define cvConvert( src, dst ) cvConvertScale( (src), (dst), 1, 0 ) | |
- | |
- | |
-/* Performs linear transformation on every source array element, | |
- stores absolute value of the result: | |
- dst(x,y,c) = abs(scale*src(x,y,c)+shift). | |
- destination array must have 8u type. | |
- In other cases one may use cvConvertScale + cvAbsDiffS */ | |
-CVAPI(void) cvConvertScaleAbs( const CvArr* src, CvArr* dst, | |
- double scale CV_DEFAULT(1), | |
- double shift CV_DEFAULT(0) ); | |
-#define cvCvtScaleAbs cvConvertScaleAbs | |
- | |
- | |
-/* checks termination criteria validity and | |
- sets eps to default_eps (if it is not set), | |
- max_iter to default_max_iters (if it is not set) | |
-*/ | |
-CVAPI(CvTermCriteria) cvCheckTermCriteria( CvTermCriteria criteria, | |
- double default_eps, | |
- int default_max_iters ); | |
- | |
-/****************************************************************************************\ | |
-* Arithmetic, logic and comparison operations * | |
-\****************************************************************************************/ | |
- | |
-/* dst(mask) = src1(mask) + src2(mask) */ | |
-CVAPI(void) cvAdd( const CvArr* src1, const CvArr* src2, CvArr* dst, | |
- const CvArr* mask CV_DEFAULT(NULL)); | |
- | |
-/* dst(mask) = src(mask) + value */ | |
-CVAPI(void) cvAddS( const CvArr* src, CvScalar value, CvArr* dst, | |
- const CvArr* mask CV_DEFAULT(NULL)); | |
- | |
-/* dst(mask) = src1(mask) - src2(mask) */ | |
-CVAPI(void) cvSub( const CvArr* src1, const CvArr* src2, CvArr* dst, | |
- const CvArr* mask CV_DEFAULT(NULL)); | |
- | |
-/* dst(mask) = src(mask) - value = src(mask) + (-value) */ | |
-CV_INLINE void cvSubS( const CvArr* src, CvScalar value, CvArr* dst, | |
- const CvArr* mask CV_DEFAULT(NULL)) | |
-{ | |
- cvAddS( src, cvScalar( -value.val[0], -value.val[1], -value.val[2], -value.val[3]), | |
- dst, mask ); | |
-} | |
- | |
-/* dst(mask) = value - src(mask) */ | |
-CVAPI(void) cvSubRS( const CvArr* src, CvScalar value, CvArr* dst, | |
- const CvArr* mask CV_DEFAULT(NULL)); | |
- | |
-/* dst(idx) = src1(idx) * src2(idx) * scale | |
- (scaled element-wise multiplication of 2 arrays) */ | |
-CVAPI(void) cvMul( const CvArr* src1, const CvArr* src2, | |
- CvArr* dst, double scale CV_DEFAULT(1) ); | |
- | |
-/* element-wise division/inversion with scaling: | |
- dst(idx) = src1(idx) * scale / src2(idx) | |
- or dst(idx) = scale / src2(idx) if src1 == 0 */ | |
-CVAPI(void) cvDiv( const CvArr* src1, const CvArr* src2, | |
- CvArr* dst, double scale CV_DEFAULT(1)); | |
- | |
-/* dst = src1 * scale + src2 */ | |
-CVAPI(void) cvScaleAdd( const CvArr* src1, CvScalar scale, | |
- const CvArr* src2, CvArr* dst ); | |
-#define cvAXPY( A, real_scalar, B, C ) cvScaleAdd(A, cvRealScalar(real_scalar), B, C) | |
- | |
-/* dst = src1 * alpha + src2 * beta + gamma */ | |
-CVAPI(void) cvAddWeighted( const CvArr* src1, double alpha, | |
- const CvArr* src2, double beta, | |
- double gamma, CvArr* dst ); | |
- | |
-/* result = sum_i(src1(i) * src2(i)) (results for all channels are accumulated together) */ | |
-CVAPI(double) cvDotProduct( const CvArr* src1, const CvArr* src2 ); | |
- | |
-/* dst(idx) = src1(idx) & src2(idx) */ | |
-CVAPI(void) cvAnd( const CvArr* src1, const CvArr* src2, | |
- CvArr* dst, const CvArr* mask CV_DEFAULT(NULL)); | |
- | |
-/* dst(idx) = src(idx) & value */ | |
-CVAPI(void) cvAndS( const CvArr* src, CvScalar value, | |
- CvArr* dst, const CvArr* mask CV_DEFAULT(NULL)); | |
- | |
-/* dst(idx) = src1(idx) | src2(idx) */ | |
-CVAPI(void) cvOr( const CvArr* src1, const CvArr* src2, | |
- CvArr* dst, const CvArr* mask CV_DEFAULT(NULL)); | |
- | |
-/* dst(idx) = src(idx) | value */ | |
-CVAPI(void) cvOrS( const CvArr* src, CvScalar value, | |
- CvArr* dst, const CvArr* mask CV_DEFAULT(NULL)); | |
- | |
-/* dst(idx) = src1(idx) ^ src2(idx) */ | |
-CVAPI(void) cvXor( const CvArr* src1, const CvArr* src2, | |
- CvArr* dst, const CvArr* mask CV_DEFAULT(NULL)); | |
- | |
-/* dst(idx) = src(idx) ^ value */ | |
-CVAPI(void) cvXorS( const CvArr* src, CvScalar value, | |
- CvArr* dst, const CvArr* mask CV_DEFAULT(NULL)); | |
- | |
-/* dst(idx) = ~src(idx) */ | |
-CVAPI(void) cvNot( const CvArr* src, CvArr* dst ); | |
- | |
-/* dst(idx) = lower(idx) <= src(idx) < upper(idx) */ | |
-CVAPI(void) cvInRange( const CvArr* src, const CvArr* lower, | |
- const CvArr* upper, CvArr* dst ); | |
- | |
-/* dst(idx) = lower <= src(idx) < upper */ | |
-CVAPI(void) cvInRangeS( const CvArr* src, CvScalar lower, | |
- CvScalar upper, CvArr* dst ); | |
- | |
-#define CV_CMP_EQ 0 | |
-#define CV_CMP_GT 1 | |
-#define CV_CMP_GE 2 | |
-#define CV_CMP_LT 3 | |
-#define CV_CMP_LE 4 | |
-#define CV_CMP_NE 5 | |
- | |
-/* The comparison operation support single-channel arrays only. | |
- Destination image should be 8uC1 or 8sC1 */ | |
- | |
-/* dst(idx) = src1(idx) _cmp_op_ src2(idx) */ | |
-CVAPI(void) cvCmp( const CvArr* src1, const CvArr* src2, CvArr* dst, int cmp_op ); | |
- | |
-/* dst(idx) = src1(idx) _cmp_op_ value */ | |
-CVAPI(void) cvCmpS( const CvArr* src, double value, CvArr* dst, int cmp_op ); | |
- | |
-/* dst(idx) = min(src1(idx),src2(idx)) */ | |
-CVAPI(void) cvMin( const CvArr* src1, const CvArr* src2, CvArr* dst ); | |
- | |
-/* dst(idx) = max(src1(idx),src2(idx)) */ | |
-CVAPI(void) cvMax( const CvArr* src1, const CvArr* src2, CvArr* dst ); | |
- | |
-/* dst(idx) = min(src(idx),value) */ | |
-CVAPI(void) cvMinS( const CvArr* src, double value, CvArr* dst ); | |
- | |
-/* dst(idx) = max(src(idx),value) */ | |
-CVAPI(void) cvMaxS( const CvArr* src, double value, CvArr* dst ); | |
- | |
-/* dst(x,y,c) = abs(src1(x,y,c) - src2(x,y,c)) */ | |
-CVAPI(void) cvAbsDiff( const CvArr* src1, const CvArr* src2, CvArr* dst ); | |
- | |
-/* dst(x,y,c) = abs(src(x,y,c) - value(c)) */ | |
-CVAPI(void) cvAbsDiffS( const CvArr* src, CvArr* dst, CvScalar value ); | |
-#define cvAbs( src, dst ) cvAbsDiffS( (src), (dst), cvScalarAll(0)) | |
- | |
-/****************************************************************************************\ | |
-* Math operations * | |
-\****************************************************************************************/ | |
- | |
-/* Does cartesian->polar coordinates conversion. | |
- Either of output components (magnitude or angle) is optional */ | |
-CVAPI(void) cvCartToPolar( const CvArr* x, const CvArr* y, | |
- CvArr* magnitude, CvArr* angle CV_DEFAULT(NULL), | |
- int angle_in_degrees CV_DEFAULT(0)); | |
- | |
-/* Does polar->cartesian coordinates conversion. | |
- Either of output components (magnitude or angle) is optional. | |
- If magnitude is missing it is assumed to be all 1's */ | |
-CVAPI(void) cvPolarToCart( const CvArr* magnitude, const CvArr* angle, | |
- CvArr* x, CvArr* y, | |
- int angle_in_degrees CV_DEFAULT(0)); | |
- | |
-/* Does powering: dst(idx) = src(idx)^power */ | |
-CVAPI(void) cvPow( const CvArr* src, CvArr* dst, double power ); | |
- | |
-/* Does exponention: dst(idx) = exp(src(idx)). | |
- Overflow is not handled yet. Underflow is handled. | |
- Maximal relative error is ~7e-6 for single-precision input */ | |
-CVAPI(void) cvExp( const CvArr* src, CvArr* dst ); | |
- | |
-/* Calculates natural logarithms: dst(idx) = log(abs(src(idx))). | |
- Logarithm of 0 gives large negative number(~-700) | |
- Maximal relative error is ~3e-7 for single-precision output | |
-*/ | |
-CVAPI(void) cvLog( const CvArr* src, CvArr* dst ); | |
- | |
-/* Fast arctangent calculation */ | |
-CVAPI(float) cvFastArctan( float y, float x ); | |
- | |
-/* Fast cubic root calculation */ | |
-CVAPI(float) cvCbrt( float value ); | |
- | |
-/* Checks array values for NaNs, Infs or simply for too large numbers | |
- (if CV_CHECK_RANGE is set). If CV_CHECK_QUIET is set, | |
- no runtime errors is raised (function returns zero value in case of "bad" values). | |
- Otherwise cvError is called */ | |
-#define CV_CHECK_RANGE 1 | |
-#define CV_CHECK_QUIET 2 | |
-CVAPI(int) cvCheckArr( const CvArr* arr, int flags CV_DEFAULT(0), | |
- double min_val CV_DEFAULT(0), double max_val CV_DEFAULT(0)); | |
-#define cvCheckArray cvCheckArr | |
- | |
-#define CV_RAND_UNI 0 | |
-#define CV_RAND_NORMAL 1 | |
-CVAPI(void) cvRandArr( CvRNG* rng, CvArr* arr, int dist_type, | |
- CvScalar param1, CvScalar param2 ); | |
- | |
-CVAPI(void) cvRandShuffle( CvArr* mat, CvRNG* rng, | |
- double iter_factor CV_DEFAULT(1.)); | |
- | |
-#define CV_SORT_EVERY_ROW 0 | |
-#define CV_SORT_EVERY_COLUMN 1 | |
-#define CV_SORT_ASCENDING 0 | |
-#define CV_SORT_DESCENDING 16 | |
- | |
-CVAPI(void) cvSort( const CvArr* src, CvArr* dst CV_DEFAULT(NULL), | |
- CvArr* idxmat CV_DEFAULT(NULL), | |
- int flags CV_DEFAULT(0)); | |
- | |
-/* Finds real roots of a cubic equation */ | |
-CVAPI(int) cvSolveCubic( const CvMat* coeffs, CvMat* roots ); | |
- | |
-/* Finds all real and complex roots of a polynomial equation */ | |
-CVAPI(void) cvSolvePoly(const CvMat* coeffs, CvMat *roots2, | |
- int maxiter CV_DEFAULT(20), int fig CV_DEFAULT(100)); | |
- | |
-/****************************************************************************************\ | |
-* Matrix operations * | |
-\****************************************************************************************/ | |
- | |
-/* Calculates cross product of two 3d vectors */ | |
-CVAPI(void) cvCrossProduct( const CvArr* src1, const CvArr* src2, CvArr* dst ); | |
- | |
-/* Matrix transform: dst = A*B + C, C is optional */ | |
-#define cvMatMulAdd( src1, src2, src3, dst ) cvGEMM( (src1), (src2), 1., (src3), 1., (dst), 0 ) | |
-#define cvMatMul( src1, src2, dst ) cvMatMulAdd( (src1), (src2), NULL, (dst)) | |
- | |
-#define CV_GEMM_A_T 1 | |
-#define CV_GEMM_B_T 2 | |
-#define CV_GEMM_C_T 4 | |
-/* Extended matrix transform: | |
- dst = alpha*op(A)*op(B) + beta*op(C), where op(X) is X or X^T */ | |
-CVAPI(void) cvGEMM( const CvArr* src1, const CvArr* src2, double alpha, | |
- const CvArr* src3, double beta, CvArr* dst, | |
- int tABC CV_DEFAULT(0)); | |
-#define cvMatMulAddEx cvGEMM | |
- | |
-/* Transforms each element of source array and stores | |
- resultant vectors in destination array */ | |
-CVAPI(void) cvTransform( const CvArr* src, CvArr* dst, | |
- const CvMat* transmat, | |
- const CvMat* shiftvec CV_DEFAULT(NULL)); | |
-#define cvMatMulAddS cvTransform | |
- | |
-/* Does perspective transform on every element of input array */ | |
-CVAPI(void) cvPerspectiveTransform( const CvArr* src, CvArr* dst, | |
- const CvMat* mat ); | |
- | |
-/* Calculates (A-delta)*(A-delta)^T (order=0) or (A-delta)^T*(A-delta) (order=1) */ | |
-CVAPI(void) cvMulTransposed( const CvArr* src, CvArr* dst, int order, | |
- const CvArr* delta CV_DEFAULT(NULL), | |
- double scale CV_DEFAULT(1.) ); | |
- | |
-/* Tranposes matrix. Square matrices can be transposed in-place */ | |
-CVAPI(void) cvTranspose( const CvArr* src, CvArr* dst ); | |
-#define cvT cvTranspose | |
- | |
-/* Completes the symmetric matrix from the lower (LtoR=0) or from the upper (LtoR!=0) part */ | |
-CVAPI(void) cvCompleteSymm( CvMat* matrix, int LtoR CV_DEFAULT(0) ); | |
- | |
-/* Mirror array data around horizontal (flip=0), | |
- vertical (flip=1) or both(flip=-1) axises: | |
- cvFlip(src) flips images vertically and sequences horizontally (inplace) */ | |
-CVAPI(void) cvFlip( const CvArr* src, CvArr* dst CV_DEFAULT(NULL), | |
- int flip_mode CV_DEFAULT(0)); | |
-#define cvMirror cvFlip | |
- | |
- | |
-#define CV_SVD_MODIFY_A 1 | |
-#define CV_SVD_U_T 2 | |
-#define CV_SVD_V_T 4 | |
- | |
-/* Performs Singular Value Decomposition of a matrix */ | |
-CVAPI(void) cvSVD( CvArr* A, CvArr* W, CvArr* U CV_DEFAULT(NULL), | |
- CvArr* V CV_DEFAULT(NULL), int flags CV_DEFAULT(0)); | |
- | |
-/* Performs Singular Value Back Substitution (solves A*X = B): | |
- flags must be the same as in cvSVD */ | |
-CVAPI(void) cvSVBkSb( const CvArr* W, const CvArr* U, | |
- const CvArr* V, const CvArr* B, | |
- CvArr* X, int flags ); | |
- | |
-#define CV_LU 0 | |
-#define CV_SVD 1 | |
-#define CV_SVD_SYM 2 | |
-#define CV_CHOLESKY 3 | |
-#define CV_QR 4 | |
-#define CV_NORMAL 16 | |
- | |
-/* Inverts matrix */ | |
-CVAPI(double) cvInvert( const CvArr* src, CvArr* dst, | |
- int method CV_DEFAULT(CV_LU)); | |
-#define cvInv cvInvert | |
- | |
-/* Solves linear system (src1)*(dst) = (src2) | |
- (returns 0 if src1 is a singular and CV_LU method is used) */ | |
-CVAPI(int) cvSolve( const CvArr* src1, const CvArr* src2, CvArr* dst, | |
- int method CV_DEFAULT(CV_LU)); | |
- | |
-/* Calculates determinant of input matrix */ | |
-CVAPI(double) cvDet( const CvArr* mat ); | |
- | |
-/* Calculates trace of the matrix (sum of elements on the main diagonal) */ | |
-CVAPI(CvScalar) cvTrace( const CvArr* mat ); | |
- | |
-/* Finds eigen values and vectors of a symmetric matrix */ | |
-CVAPI(void) cvEigenVV( CvArr* mat, CvArr* evects, CvArr* evals, | |
- double eps CV_DEFAULT(0), | |
- int lowindex CV_DEFAULT(-1), | |
- int highindex CV_DEFAULT(-1)); | |
- | |
-///* Finds selected eigen values and vectors of a symmetric matrix */ | |
-//CVAPI(void) cvSelectedEigenVV( CvArr* mat, CvArr* evects, CvArr* evals, | |
-// int lowindex, int highindex ); | |
- | |
-/* Makes an identity matrix (mat_ij = i == j) */ | |
-CVAPI(void) cvSetIdentity( CvArr* mat, CvScalar value CV_DEFAULT(cvRealScalar(1)) ); | |
- | |
-/* Fills matrix with given range of numbers */ | |
-CVAPI(CvArr*) cvRange( CvArr* mat, double start, double end ); | |
- | |
-/* Calculates covariation matrix for a set of vectors */ | |
-/* transpose([v1-avg, v2-avg,...]) * [v1-avg,v2-avg,...] */ | |
-#define CV_COVAR_SCRAMBLED 0 | |
- | |
-/* [v1-avg, v2-avg,...] * transpose([v1-avg,v2-avg,...]) */ | |
-#define CV_COVAR_NORMAL 1 | |
- | |
-/* do not calc average (i.e. mean vector) - use the input vector instead | |
- (useful for calculating covariance matrix by parts) */ | |
-#define CV_COVAR_USE_AVG 2 | |
- | |
-/* scale the covariance matrix coefficients by number of the vectors */ | |
-#define CV_COVAR_SCALE 4 | |
- | |
-/* all the input vectors are stored in a single matrix, as its rows */ | |
-#define CV_COVAR_ROWS 8 | |
- | |
-/* all the input vectors are stored in a single matrix, as its columns */ | |
-#define CV_COVAR_COLS 16 | |
- | |
-CVAPI(void) cvCalcCovarMatrix( const CvArr** vects, int count, | |
- CvArr* cov_mat, CvArr* avg, int flags ); | |
- | |
-#define CV_PCA_DATA_AS_ROW 0 | |
-#define CV_PCA_DATA_AS_COL 1 | |
-#define CV_PCA_USE_AVG 2 | |
-CVAPI(void) cvCalcPCA( const CvArr* data, CvArr* mean, | |
- CvArr* eigenvals, CvArr* eigenvects, int flags ); | |
- | |
-CVAPI(void) cvProjectPCA( const CvArr* data, const CvArr* mean, | |
- const CvArr* eigenvects, CvArr* result ); | |
- | |
-CVAPI(void) cvBackProjectPCA( const CvArr* proj, const CvArr* mean, | |
- const CvArr* eigenvects, CvArr* result ); | |
- | |
-/* Calculates Mahalanobis(weighted) distance */ | |
-CVAPI(double) cvMahalanobis( const CvArr* vec1, const CvArr* vec2, const CvArr* mat ); | |
-#define cvMahalonobis cvMahalanobis | |
- | |
-/****************************************************************************************\ | |
-* Array Statistics * | |
-\****************************************************************************************/ | |
- | |
-/* Finds sum of array elements */ | |
-CVAPI(CvScalar) cvSum( const CvArr* arr ); | |
- | |
-/* Calculates number of non-zero pixels */ | |
-CVAPI(int) cvCountNonZero( const CvArr* arr ); | |
- | |
-/* Calculates mean value of array elements */ | |
-CVAPI(CvScalar) cvAvg( const CvArr* arr, const CvArr* mask CV_DEFAULT(NULL) ); | |
- | |
-/* Calculates mean and standard deviation of pixel values */ | |
-CVAPI(void) cvAvgSdv( const CvArr* arr, CvScalar* mean, CvScalar* std_dev, | |
- const CvArr* mask CV_DEFAULT(NULL) ); | |
- | |
-/* Finds global minimum, maximum and their positions */ | |
-CVAPI(void) cvMinMaxLoc( const CvArr* arr, double* min_val, double* max_val, | |
- CvPoint* min_loc CV_DEFAULT(NULL), | |
- CvPoint* max_loc CV_DEFAULT(NULL), | |
- const CvArr* mask CV_DEFAULT(NULL) ); | |
- | |
-/* types of array norm */ | |
-#define CV_C 1 | |
-#define CV_L1 2 | |
-#define CV_L2 4 | |
-#define CV_NORM_MASK 7 | |
-#define CV_RELATIVE 8 | |
-#define CV_DIFF 16 | |
-#define CV_MINMAX 32 | |
- | |
-#define CV_DIFF_C (CV_DIFF | CV_C) | |
-#define CV_DIFF_L1 (CV_DIFF | CV_L1) | |
-#define CV_DIFF_L2 (CV_DIFF | CV_L2) | |
-#define CV_RELATIVE_C (CV_RELATIVE | CV_C) | |
-#define CV_RELATIVE_L1 (CV_RELATIVE | CV_L1) | |
-#define CV_RELATIVE_L2 (CV_RELATIVE | CV_L2) | |
- | |
-/* Finds norm, difference norm or relative difference norm for an array (or two arrays) */ | |
-CVAPI(double) cvNorm( const CvArr* arr1, const CvArr* arr2 CV_DEFAULT(NULL), | |
- int norm_type CV_DEFAULT(CV_L2), | |
- const CvArr* mask CV_DEFAULT(NULL) ); | |
- | |
-CVAPI(void) cvNormalize( const CvArr* src, CvArr* dst, | |
- double a CV_DEFAULT(1.), double b CV_DEFAULT(0.), | |
- int norm_type CV_DEFAULT(CV_L2), | |
- const CvArr* mask CV_DEFAULT(NULL) ); | |
- | |
- | |
-#define CV_REDUCE_SUM 0 | |
-#define CV_REDUCE_AVG 1 | |
-#define CV_REDUCE_MAX 2 | |
-#define CV_REDUCE_MIN 3 | |
- | |
-CVAPI(void) cvReduce( const CvArr* src, CvArr* dst, int dim CV_DEFAULT(-1), | |
- int op CV_DEFAULT(CV_REDUCE_SUM) ); | |
- | |
-/****************************************************************************************\ | |
-* Discrete Linear Transforms and Related Functions * | |
-\****************************************************************************************/ | |
- | |
-#define CV_DXT_FORWARD 0 | |
-#define CV_DXT_INVERSE 1 | |
-#define CV_DXT_SCALE 2 /* divide result by size of array */ | |
-#define CV_DXT_INV_SCALE (CV_DXT_INVERSE + CV_DXT_SCALE) | |
-#define CV_DXT_INVERSE_SCALE CV_DXT_INV_SCALE | |
-#define CV_DXT_ROWS 4 /* transform each row individually */ | |
-#define CV_DXT_MUL_CONJ 8 /* conjugate the second argument of cvMulSpectrums */ | |
- | |
-/* Discrete Fourier Transform: | |
- complex->complex, | |
- real->ccs (forward), | |
- ccs->real (inverse) */ | |
-CVAPI(void) cvDFT( const CvArr* src, CvArr* dst, int flags, | |
- int nonzero_rows CV_DEFAULT(0) ); | |
-#define cvFFT cvDFT | |
- | |
-/* Multiply results of DFTs: DFT(X)*DFT(Y) or DFT(X)*conj(DFT(Y)) */ | |
-CVAPI(void) cvMulSpectrums( const CvArr* src1, const CvArr* src2, | |
- CvArr* dst, int flags ); | |
- | |
-/* Finds optimal DFT vector size >= size0 */ | |
-CVAPI(int) cvGetOptimalDFTSize( int size0 ); | |
- | |
-/* Discrete Cosine Transform */ | |
-CVAPI(void) cvDCT( const CvArr* src, CvArr* dst, int flags ); | |
- | |
-/****************************************************************************************\ | |
-* Dynamic data structures * | |
-\****************************************************************************************/ | |
- | |
-/* Calculates length of sequence slice (with support of negative indices). */ | |
-CVAPI(int) cvSliceLength( CvSlice slice, const CvSeq* seq ); | |
- | |
- | |
-/* Creates new memory storage. | |
- block_size == 0 means that default, | |
- somewhat optimal size, is used (currently, it is 64K) */ | |
-CVAPI(CvMemStorage*) cvCreateMemStorage( int block_size CV_DEFAULT(0)); | |
- | |
- | |
-/* Creates a memory storage that will borrow memory blocks from parent storage */ | |
-CVAPI(CvMemStorage*) cvCreateChildMemStorage( CvMemStorage* parent ); | |
- | |
- | |
-/* Releases memory storage. All the children of a parent must be released before | |
- the parent. A child storage returns all the blocks to parent when it is released */ | |
-CVAPI(void) cvReleaseMemStorage( CvMemStorage** storage ); | |
- | |
- | |
-/* Clears memory storage. This is the only way(!!!) (besides cvRestoreMemStoragePos) | |
- to reuse memory allocated for the storage - cvClearSeq,cvClearSet ... | |
- do not free any memory. | |
- A child storage returns all the blocks to the parent when it is cleared */ | |
-CVAPI(void) cvClearMemStorage( CvMemStorage* storage ); | |
- | |
-/* Remember a storage "free memory" position */ | |
-CVAPI(void) cvSaveMemStoragePos( const CvMemStorage* storage, CvMemStoragePos* pos ); | |
- | |
-/* Restore a storage "free memory" position */ | |
-CVAPI(void) cvRestoreMemStoragePos( CvMemStorage* storage, CvMemStoragePos* pos ); | |
- | |
-/* Allocates continuous buffer of the specified size in the storage */ | |
-CVAPI(void*) cvMemStorageAlloc( CvMemStorage* storage, size_t size ); | |
- | |
-/* Allocates string in memory storage */ | |
-CVAPI(CvString) cvMemStorageAllocString( CvMemStorage* storage, const char* ptr, | |
- int len CV_DEFAULT(-1) ); | |
- | |
-/* Creates new empty sequence that will reside in the specified storage */ | |
-CVAPI(CvSeq*) cvCreateSeq( int seq_flags, size_t header_size, | |
- size_t elem_size, CvMemStorage* storage ); | |
- | |
-/* Changes default size (granularity) of sequence blocks. | |
- The default size is ~1Kbyte */ | |
-CVAPI(void) cvSetSeqBlockSize( CvSeq* seq, int delta_elems ); | |
- | |
- | |
-/* Adds new element to the end of sequence. Returns pointer to the element */ | |
-CVAPI(schar*) cvSeqPush( CvSeq* seq, const void* element CV_DEFAULT(NULL)); | |
- | |
- | |
-/* Adds new element to the beginning of sequence. Returns pointer to it */ | |
-CVAPI(schar*) cvSeqPushFront( CvSeq* seq, const void* element CV_DEFAULT(NULL)); | |
- | |
- | |
-/* Removes the last element from sequence and optionally saves it */ | |
-CVAPI(void) cvSeqPop( CvSeq* seq, void* element CV_DEFAULT(NULL)); | |
- | |
- | |
-/* Removes the first element from sequence and optioanally saves it */ | |
-CVAPI(void) cvSeqPopFront( CvSeq* seq, void* element CV_DEFAULT(NULL)); | |
- | |
- | |
-#define CV_FRONT 1 | |
-#define CV_BACK 0 | |
-/* Adds several new elements to the end of sequence */ | |
-CVAPI(void) cvSeqPushMulti( CvSeq* seq, const void* elements, | |
- int count, int in_front CV_DEFAULT(0) ); | |
- | |
-/* Removes several elements from the end of sequence and optionally saves them */ | |
-CVAPI(void) cvSeqPopMulti( CvSeq* seq, void* elements, | |
- int count, int in_front CV_DEFAULT(0) ); | |
- | |
-/* Inserts a new element in the middle of sequence. | |
- cvSeqInsert(seq,0,elem) == cvSeqPushFront(seq,elem) */ | |
-CVAPI(schar*) cvSeqInsert( CvSeq* seq, int before_index, | |
- const void* element CV_DEFAULT(NULL)); | |
- | |
-/* Removes specified sequence element */ | |
-CVAPI(void) cvSeqRemove( CvSeq* seq, int index ); | |
- | |
- | |
-/* Removes all the elements from the sequence. The freed memory | |
- can be reused later only by the same sequence unless cvClearMemStorage | |
- or cvRestoreMemStoragePos is called */ | |
-CVAPI(void) cvClearSeq( CvSeq* seq ); | |
- | |
- | |
-/* Retrieves pointer to specified sequence element. | |
- Negative indices are supported and mean counting from the end | |
- (e.g -1 means the last sequence element) */ | |
-CVAPI(schar*) cvGetSeqElem( const CvSeq* seq, int index ); | |
- | |
-/* Calculates index of the specified sequence element. | |
- Returns -1 if element does not belong to the sequence */ | |
-CVAPI(int) cvSeqElemIdx( const CvSeq* seq, const void* element, | |
- CvSeqBlock** block CV_DEFAULT(NULL) ); | |
- | |
-/* Initializes sequence writer. The new elements will be added to the end of sequence */ | |
-CVAPI(void) cvStartAppendToSeq( CvSeq* seq, CvSeqWriter* writer ); | |
- | |
- | |
-/* Combination of cvCreateSeq and cvStartAppendToSeq */ | |
-CVAPI(void) cvStartWriteSeq( int seq_flags, int header_size, | |
- int elem_size, CvMemStorage* storage, | |
- CvSeqWriter* writer ); | |
- | |
-/* Closes sequence writer, updates sequence header and returns pointer | |
- to the resultant sequence | |
- (which may be useful if the sequence was created using cvStartWriteSeq)) | |
-*/ | |
-CVAPI(CvSeq*) cvEndWriteSeq( CvSeqWriter* writer ); | |
- | |
- | |
-/* Updates sequence header. May be useful to get access to some of previously | |
- written elements via cvGetSeqElem or sequence reader */ | |
-CVAPI(void) cvFlushSeqWriter( CvSeqWriter* writer ); | |
- | |
- | |
-/* Initializes sequence reader. | |
- The sequence can be read in forward or backward direction */ | |
-CVAPI(void) cvStartReadSeq( const CvSeq* seq, CvSeqReader* reader, | |
- int reverse CV_DEFAULT(0) ); | |
- | |
- | |
-/* Returns current sequence reader position (currently observed sequence element) */ | |
-CVAPI(int) cvGetSeqReaderPos( CvSeqReader* reader ); | |
- | |
- | |
-/* Changes sequence reader position. It may seek to an absolute or | |
- to relative to the current position */ | |
-CVAPI(void) cvSetSeqReaderPos( CvSeqReader* reader, int index, | |
- int is_relative CV_DEFAULT(0)); | |
- | |
-/* Copies sequence content to a continuous piece of memory */ | |
-CVAPI(void*) cvCvtSeqToArray( const CvSeq* seq, void* elements, | |
- CvSlice slice CV_DEFAULT(CV_WHOLE_SEQ) ); | |
- | |
-/* Creates sequence header for array. | |
- After that all the operations on sequences that do not alter the content | |
- can be applied to the resultant sequence */ | |
-CVAPI(CvSeq*) cvMakeSeqHeaderForArray( int seq_type, int header_size, | |
- int elem_size, void* elements, int total, | |
- CvSeq* seq, CvSeqBlock* block ); | |
- | |
-/* Extracts sequence slice (with or without copying sequence elements) */ | |
-CVAPI(CvSeq*) cvSeqSlice( const CvSeq* seq, CvSlice slice, | |
- CvMemStorage* storage CV_DEFAULT(NULL), | |
- int copy_data CV_DEFAULT(0)); | |
- | |
-CV_INLINE CvSeq* cvCloneSeq( const CvSeq* seq, CvMemStorage* storage CV_DEFAULT(NULL)) | |
-{ | |
- return cvSeqSlice( seq, CV_WHOLE_SEQ, storage, 1 ); | |
-} | |
- | |
-/* Removes sequence slice */ | |
-CVAPI(void) cvSeqRemoveSlice( CvSeq* seq, CvSlice slice ); | |
- | |
-/* Inserts a sequence or array into another sequence */ | |
-CVAPI(void) cvSeqInsertSlice( CvSeq* seq, int before_index, const CvArr* from_arr ); | |
- | |
-/* a < b ? -1 : a > b ? 1 : 0 */ | |
-typedef int (CV_CDECL* CvCmpFunc)(const void* a, const void* b, void* userdata ); | |
- | |
-/* Sorts sequence in-place given element comparison function */ | |
-CVAPI(void) cvSeqSort( CvSeq* seq, CvCmpFunc func, void* userdata CV_DEFAULT(NULL) ); | |
- | |
-/* Finds element in a [sorted] sequence */ | |
-CVAPI(schar*) cvSeqSearch( CvSeq* seq, const void* elem, CvCmpFunc func, | |
- int is_sorted, int* elem_idx, | |
- void* userdata CV_DEFAULT(NULL) ); | |
- | |
-/* Reverses order of sequence elements in-place */ | |
-CVAPI(void) cvSeqInvert( CvSeq* seq ); | |
- | |
-/* Splits sequence into one or more equivalence classes using the specified criteria */ | |
-CVAPI(int) cvSeqPartition( const CvSeq* seq, CvMemStorage* storage, | |
- CvSeq** labels, CvCmpFunc is_equal, void* userdata ); | |
- | |
-/************ Internal sequence functions ************/ | |
-CVAPI(void) cvChangeSeqBlock( void* reader, int direction ); | |
-CVAPI(void) cvCreateSeqBlock( CvSeqWriter* writer ); | |
- | |
- | |
-/* Creates a new set */ | |
-CVAPI(CvSet*) cvCreateSet( int set_flags, int header_size, | |
- int elem_size, CvMemStorage* storage ); | |
- | |
-/* Adds new element to the set and returns pointer to it */ | |
-CVAPI(int) cvSetAdd( CvSet* set_header, CvSetElem* elem CV_DEFAULT(NULL), | |
- CvSetElem** inserted_elem CV_DEFAULT(NULL) ); | |
- | |
-/* Fast variant of cvSetAdd */ | |
-CV_INLINE CvSetElem* cvSetNew( CvSet* set_header ) | |
-{ | |
- CvSetElem* elem = set_header->free_elems; | |
- if( elem ) | |
- { | |
- set_header->free_elems = elem->next_free; | |
- elem->flags = elem->flags & CV_SET_ELEM_IDX_MASK; | |
- set_header->active_count++; | |
- } | |
- else | |
- cvSetAdd( set_header, NULL, (CvSetElem**)&elem ); | |
- return elem; | |
-} | |
- | |
-/* Removes set element given its pointer */ | |
-CV_INLINE void cvSetRemoveByPtr( CvSet* set_header, void* elem ) | |
-{ | |
- CvSetElem* _elem = (CvSetElem*)elem; | |
- assert( _elem->flags >= 0 /*&& (elem->flags & CV_SET_ELEM_IDX_MASK) < set_header->total*/ ); | |
- _elem->next_free = set_header->free_elems; | |
- _elem->flags = (_elem->flags & CV_SET_ELEM_IDX_MASK) | CV_SET_ELEM_FREE_FLAG; | |
- set_header->free_elems = _elem; | |
- set_header->active_count--; | |
-} | |
- | |
-/* Removes element from the set by its index */ | |
-CVAPI(void) cvSetRemove( CvSet* set_header, int index ); | |
- | |
-/* Returns a set element by index. If the element doesn't belong to the set, | |
- NULL is returned */ | |
-CV_INLINE CvSetElem* cvGetSetElem( const CvSet* set_header, int index ) | |
-{ | |
- CvSetElem* elem = (CvSetElem*)cvGetSeqElem( (CvSeq*)set_header, index ); | |
- return elem && CV_IS_SET_ELEM( elem ) ? elem : 0; | |
-} | |
- | |
-/* Removes all the elements from the set */ | |
-CVAPI(void) cvClearSet( CvSet* set_header ); | |
- | |
-/* Creates new graph */ | |
-CVAPI(CvGraph*) cvCreateGraph( int graph_flags, int header_size, | |
- int vtx_size, int edge_size, | |
- CvMemStorage* storage ); | |
- | |
-/* Adds new vertex to the graph */ | |
-CVAPI(int) cvGraphAddVtx( CvGraph* graph, const CvGraphVtx* vtx CV_DEFAULT(NULL), | |
- CvGraphVtx** inserted_vtx CV_DEFAULT(NULL) ); | |
- | |
- | |
-/* Removes vertex from the graph together with all incident edges */ | |
-CVAPI(int) cvGraphRemoveVtx( CvGraph* graph, int index ); | |
-CVAPI(int) cvGraphRemoveVtxByPtr( CvGraph* graph, CvGraphVtx* vtx ); | |
- | |
- | |
-/* Link two vertices specifed by indices or pointers if they | |
- are not connected or return pointer to already existing edge | |
- connecting the vertices. | |
- Functions return 1 if a new edge was created, 0 otherwise */ | |
-CVAPI(int) cvGraphAddEdge( CvGraph* graph, | |
- int start_idx, int end_idx, | |
- const CvGraphEdge* edge CV_DEFAULT(NULL), | |
- CvGraphEdge** inserted_edge CV_DEFAULT(NULL) ); | |
- | |
-CVAPI(int) cvGraphAddEdgeByPtr( CvGraph* graph, | |
- CvGraphVtx* start_vtx, CvGraphVtx* end_vtx, | |
- const CvGraphEdge* edge CV_DEFAULT(NULL), | |
- CvGraphEdge** inserted_edge CV_DEFAULT(NULL) ); | |
- | |
-/* Remove edge connecting two vertices */ | |
-CVAPI(void) cvGraphRemoveEdge( CvGraph* graph, int start_idx, int end_idx ); | |
-CVAPI(void) cvGraphRemoveEdgeByPtr( CvGraph* graph, CvGraphVtx* start_vtx, | |
- CvGraphVtx* end_vtx ); | |
- | |
-/* Find edge connecting two vertices */ | |
-CVAPI(CvGraphEdge*) cvFindGraphEdge( const CvGraph* graph, int start_idx, int end_idx ); | |
-CVAPI(CvGraphEdge*) cvFindGraphEdgeByPtr( const CvGraph* graph, | |
- const CvGraphVtx* start_vtx, | |
- const CvGraphVtx* end_vtx ); | |
-#define cvGraphFindEdge cvFindGraphEdge | |
-#define cvGraphFindEdgeByPtr cvFindGraphEdgeByPtr | |
- | |
-/* Remove all vertices and edges from the graph */ | |
-CVAPI(void) cvClearGraph( CvGraph* graph ); | |
- | |
- | |
-/* Count number of edges incident to the vertex */ | |
-CVAPI(int) cvGraphVtxDegree( const CvGraph* graph, int vtx_idx ); | |
-CVAPI(int) cvGraphVtxDegreeByPtr( const CvGraph* graph, const CvGraphVtx* vtx ); | |
- | |
- | |
-/* Retrieves graph vertex by given index */ | |
-#define cvGetGraphVtx( graph, idx ) (CvGraphVtx*)cvGetSetElem((CvSet*)(graph), (idx)) | |
- | |
-/* Retrieves index of a graph vertex given its pointer */ | |
-#define cvGraphVtxIdx( graph, vtx ) ((vtx)->flags & CV_SET_ELEM_IDX_MASK) | |
- | |
-/* Retrieves index of a graph edge given its pointer */ | |
-#define cvGraphEdgeIdx( graph, edge ) ((edge)->flags & CV_SET_ELEM_IDX_MASK) | |
- | |
-#define cvGraphGetVtxCount( graph ) ((graph)->active_count) | |
-#define cvGraphGetEdgeCount( graph ) ((graph)->edges->active_count) | |
- | |
-#define CV_GRAPH_VERTEX 1 | |
-#define CV_GRAPH_TREE_EDGE 2 | |
-#define CV_GRAPH_BACK_EDGE 4 | |
-#define CV_GRAPH_FORWARD_EDGE 8 | |
-#define CV_GRAPH_CROSS_EDGE 16 | |
-#define CV_GRAPH_ANY_EDGE 30 | |
-#define CV_GRAPH_NEW_TREE 32 | |
-#define CV_GRAPH_BACKTRACKING 64 | |
-#define CV_GRAPH_OVER -1 | |
- | |
-#define CV_GRAPH_ALL_ITEMS -1 | |
- | |
-/* flags for graph vertices and edges */ | |
-#define CV_GRAPH_ITEM_VISITED_FLAG (1 << 30) | |
-#define CV_IS_GRAPH_VERTEX_VISITED(vtx) \ | |
- (((CvGraphVtx*)(vtx))->flags & CV_GRAPH_ITEM_VISITED_FLAG) | |
-#define CV_IS_GRAPH_EDGE_VISITED(edge) \ | |
- (((CvGraphEdge*)(edge))->flags & CV_GRAPH_ITEM_VISITED_FLAG) | |
-#define CV_GRAPH_SEARCH_TREE_NODE_FLAG (1 << 29) | |
-#define CV_GRAPH_FORWARD_EDGE_FLAG (1 << 28) | |
- | |
-typedef struct CvGraphScanner | |
-{ | |
- CvGraphVtx* vtx; /* current graph vertex (or current edge origin) */ | |
- CvGraphVtx* dst; /* current graph edge destination vertex */ | |
- CvGraphEdge* edge; /* current edge */ | |
- | |
- CvGraph* graph; /* the graph */ | |
- CvSeq* stack; /* the graph vertex stack */ | |
- int index; /* the lower bound of certainly visited vertices */ | |
- int mask; /* event mask */ | |
-} | |
-CvGraphScanner; | |
- | |
-/* Creates new graph scanner. */ | |
-CVAPI(CvGraphScanner*) cvCreateGraphScanner( CvGraph* graph, | |
- CvGraphVtx* vtx CV_DEFAULT(NULL), | |
- int mask CV_DEFAULT(CV_GRAPH_ALL_ITEMS)); | |
- | |
-/* Releases graph scanner. */ | |
-CVAPI(void) cvReleaseGraphScanner( CvGraphScanner** scanner ); | |
- | |
-/* Get next graph element */ | |
-CVAPI(int) cvNextGraphItem( CvGraphScanner* scanner ); | |
- | |
-/* Creates a copy of graph */ | |
-CVAPI(CvGraph*) cvCloneGraph( const CvGraph* graph, CvMemStorage* storage ); | |
- | |
-/****************************************************************************************\ | |
-* Drawing * | |
-\****************************************************************************************/ | |
- | |
-/****************************************************************************************\ | |
-* Drawing functions work with images/matrices of arbitrary type. * | |
-* For color images the channel order is BGR[A] * | |
-* Antialiasing is supported only for 8-bit image now. * | |
-* All the functions include parameter color that means rgb value (that may be * | |
-* constructed with CV_RGB macro) for color images and brightness * | |
-* for grayscale images. * | |
-* If a drawn figure is partially or completely outside of the image, it is clipped.* | |
-\****************************************************************************************/ | |
- | |
-#define CV_RGB( r, g, b ) cvScalar( (b), (g), (r), 0 ) | |
-#define CV_FILLED -1 | |
- | |
-#define CV_AA 16 | |
- | |
-/* Draws 4-connected, 8-connected or antialiased line segment connecting two points */ | |
-CVAPI(void) cvLine( CvArr* img, CvPoint pt1, CvPoint pt2, | |
- CvScalar color, int thickness CV_DEFAULT(1), | |
- int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) ); | |
- | |
-/* Draws a rectangle given two opposite corners of the rectangle (pt1 & pt2), | |
- if thickness<0 (e.g. thickness == CV_FILLED), the filled box is drawn */ | |
-CVAPI(void) cvRectangle( CvArr* img, CvPoint pt1, CvPoint pt2, | |
- CvScalar color, int thickness CV_DEFAULT(1), | |
- int line_type CV_DEFAULT(8), | |
- int shift CV_DEFAULT(0)); | |
- | |
-/* Draws a rectangle specified by a CvRect structure */ | |
-CVAPI(void) cvRectangleR( CvArr* img, CvRect r, | |
- CvScalar color, int thickness CV_DEFAULT(1), | |
- int line_type CV_DEFAULT(8), | |
- int shift CV_DEFAULT(0)); | |
- | |
- | |
-/* Draws a circle with specified center and radius. | |
- Thickness works in the same way as with cvRectangle */ | |
-CVAPI(void) cvCircle( CvArr* img, CvPoint center, int radius, | |
- CvScalar color, int thickness CV_DEFAULT(1), | |
- int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0)); | |
- | |
-/* Draws ellipse outline, filled ellipse, elliptic arc or filled elliptic sector, | |
- depending on <thickness>, <start_angle> and <end_angle> parameters. The resultant figure | |
- is rotated by <angle>. All the angles are in degrees */ | |
-CVAPI(void) cvEllipse( CvArr* img, CvPoint center, CvSize axes, | |
- double angle, double start_angle, double end_angle, | |
- CvScalar color, int thickness CV_DEFAULT(1), | |
- int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0)); | |
- | |
-CV_INLINE void cvEllipseBox( CvArr* img, CvBox2D box, CvScalar color, | |
- int thickness CV_DEFAULT(1), | |
- int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) ) | |
-{ | |
- CvSize axes; | |
- axes.width = cvRound(box.size.width*0.5); | |
- axes.height = cvRound(box.size.height*0.5); | |
- | |
- cvEllipse( img, cvPointFrom32f( box.center ), axes, box.angle, | |
- 0, 360, color, thickness, line_type, shift ); | |
-} | |
- | |
-/* Fills convex or monotonous polygon. */ | |
-CVAPI(void) cvFillConvexPoly( CvArr* img, const CvPoint* pts, int npts, CvScalar color, | |
- int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0)); | |
- | |
-/* Fills an area bounded by one or more arbitrary polygons */ | |
-CVAPI(void) cvFillPoly( CvArr* img, CvPoint** pts, const int* npts, | |
- int contours, CvScalar color, | |
- int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) ); | |
- | |
-/* Draws one or more polygonal curves */ | |
-CVAPI(void) cvPolyLine( CvArr* img, CvPoint** pts, const int* npts, int contours, | |
- int is_closed, CvScalar color, int thickness CV_DEFAULT(1), | |
- int line_type CV_DEFAULT(8), int shift CV_DEFAULT(0) ); | |
- | |
-#define cvDrawRect cvRectangle | |
-#define cvDrawLine cvLine | |
-#define cvDrawCircle cvCircle | |
-#define cvDrawEllipse cvEllipse | |
-#define cvDrawPolyLine cvPolyLine | |
- | |
-/* Clips the line segment connecting *pt1 and *pt2 | |
- by the rectangular window | |
- (0<=x<img_size.width, 0<=y<img_size.height). */ | |
-CVAPI(int) cvClipLine( CvSize img_size, CvPoint* pt1, CvPoint* pt2 ); | |
- | |
-/* Initializes line iterator. Initially, line_iterator->ptr will point | |
- to pt1 (or pt2, see left_to_right description) location in the image. | |
- Returns the number of pixels on the line between the ending points. */ | |
-CVAPI(int) cvInitLineIterator( const CvArr* image, CvPoint pt1, CvPoint pt2, | |
- CvLineIterator* line_iterator, | |
- int connectivity CV_DEFAULT(8), | |
- int left_to_right CV_DEFAULT(0)); | |
- | |
-/* Moves iterator to the next line point */ | |
-#define CV_NEXT_LINE_POINT( line_iterator ) \ | |
-{ \ | |
- int _line_iterator_mask = (line_iterator).err < 0 ? -1 : 0; \ | |
- (line_iterator).err += (line_iterator).minus_delta + \ | |
- ((line_iterator).plus_delta & _line_iterator_mask); \ | |
- (line_iterator).ptr += (line_iterator).minus_step + \ | |
- ((line_iterator).plus_step & _line_iterator_mask); \ | |
-} | |
- | |
- | |
-/* basic font types */ | |
-#define CV_FONT_HERSHEY_SIMPLEX 0 | |
-#define CV_FONT_HERSHEY_PLAIN 1 | |
-#define CV_FONT_HERSHEY_DUPLEX 2 | |
-#define CV_FONT_HERSHEY_COMPLEX 3 | |
-#define CV_FONT_HERSHEY_TRIPLEX 4 | |
-#define CV_FONT_HERSHEY_COMPLEX_SMALL 5 | |
-#define CV_FONT_HERSHEY_SCRIPT_SIMPLEX 6 | |
-#define CV_FONT_HERSHEY_SCRIPT_COMPLEX 7 | |
- | |
-/* font flags */ | |
-#define CV_FONT_ITALIC 16 | |
- | |
-#define CV_FONT_VECTOR0 CV_FONT_HERSHEY_SIMPLEX | |
- | |
- | |
-/* Font structure */ | |
-typedef struct CvFont | |
-{ | |
- const char* nameFont; //Qt:nameFont | |
- CvScalar color; //Qt:ColorFont -> cvScalar(blue_component, green_component, red\_component[, alpha_component]) | |
- int font_face; //Qt: bool italic /* =CV_FONT_* */ | |
- const int* ascii; /* font data and metrics */ | |
- const int* greek; | |
- const int* cyrillic; | |
- float hscale, vscale; | |
- float shear; /* slope coefficient: 0 - normal, >0 - italic */ | |
- int thickness; //Qt: weight /* letters thickness */ | |
- float dx; /* horizontal interval between letters */ | |
- int line_type; //Qt: PointSize | |
-} | |
-CvFont; | |
- | |
-/* Initializes font structure used further in cvPutText */ | |
-CVAPI(void) cvInitFont( CvFont* font, int font_face, | |
- double hscale, double vscale, | |
- double shear CV_DEFAULT(0), | |
- int thickness CV_DEFAULT(1), | |
- int line_type CV_DEFAULT(8)); | |
- | |
-CV_INLINE CvFont cvFont( double scale, int thickness CV_DEFAULT(1) ) | |
-{ | |
- CvFont font; | |
- cvInitFont( &font, CV_FONT_HERSHEY_PLAIN, scale, scale, 0, thickness, CV_AA ); | |
- return font; | |
-} | |
- | |
-/* Renders text stroke with specified font and color at specified location. | |
- CvFont should be initialized with cvInitFont */ | |
-CVAPI(void) cvPutText( CvArr* img, const char* text, CvPoint org, | |
- const CvFont* font, CvScalar color ); | |
- | |
-/* Calculates bounding box of text stroke (useful for alignment) */ | |
-CVAPI(void) cvGetTextSize( const char* text_string, const CvFont* font, | |
- CvSize* text_size, int* baseline ); | |
- | |
- | |
- | |
-/* Unpacks color value, if arrtype is CV_8UC?, <color> is treated as | |
- packed color value, otherwise the first channels (depending on arrtype) | |
- of destination scalar are set to the same value = <color> */ | |
-CVAPI(CvScalar) cvColorToScalar( double packed_color, int arrtype ); | |
- | |
-/* Returns the polygon points which make up the given ellipse. The ellipse is define by | |
- the box of size 'axes' rotated 'angle' around the 'center'. A partial sweep | |
- of the ellipse arc can be done by spcifying arc_start and arc_end to be something | |
- other than 0 and 360, respectively. The input array 'pts' must be large enough to | |
- hold the result. The total number of points stored into 'pts' is returned by this | |
- function. */ | |
-CVAPI(int) cvEllipse2Poly( CvPoint center, CvSize axes, | |
- int angle, int arc_start, int arc_end, CvPoint * pts, int delta ); | |
- | |
-/* Draws contour outlines or filled interiors on the image */ | |
-CVAPI(void) cvDrawContours( CvArr *img, CvSeq* contour, | |
- CvScalar external_color, CvScalar hole_color, | |
- int max_level, int thickness CV_DEFAULT(1), | |
- int line_type CV_DEFAULT(8), | |
- CvPoint offset CV_DEFAULT(cvPoint(0,0))); | |
- | |
-/* Does look-up transformation. Elements of the source array | |
- (that should be 8uC1 or 8sC1) are used as indexes in lutarr 256-element table */ | |
-CVAPI(void) cvLUT( const CvArr* src, CvArr* dst, const CvArr* lut ); | |
- | |
- | |
-/******************* Iteration through the sequence tree *****************/ | |
-typedef struct CvTreeNodeIterator | |
-{ | |
- const void* node; | |
- int level; | |
- int max_level; | |
-} | |
-CvTreeNodeIterator; | |
- | |
-CVAPI(void) cvInitTreeNodeIterator( CvTreeNodeIterator* tree_iterator, | |
- const void* first, int max_level ); | |
-CVAPI(void*) cvNextTreeNode( CvTreeNodeIterator* tree_iterator ); | |
-CVAPI(void*) cvPrevTreeNode( CvTreeNodeIterator* tree_iterator ); | |
- | |
-/* Inserts sequence into tree with specified "parent" sequence. | |
- If parent is equal to frame (e.g. the most external contour), | |
- then added contour will have null pointer to parent. */ | |
-CVAPI(void) cvInsertNodeIntoTree( void* node, void* parent, void* frame ); | |
- | |
-/* Removes contour from tree (together with the contour children). */ | |
-CVAPI(void) cvRemoveNodeFromTree( void* node, void* frame ); | |
- | |
-/* Gathers pointers to all the sequences, | |
- accessible from the <first>, to the single sequence */ | |
-CVAPI(CvSeq*) cvTreeToNodeSeq( const void* first, int header_size, | |
- CvMemStorage* storage ); | |
- | |
-/* The function implements the K-means algorithm for clustering an array of sample | |
- vectors in a specified number of classes */ | |
-#define CV_KMEANS_USE_INITIAL_LABELS 1 | |
-CVAPI(int) cvKMeans2( const CvArr* samples, int cluster_count, CvArr* labels, | |
- CvTermCriteria termcrit, int attempts CV_DEFAULT(1), | |
- CvRNG* rng CV_DEFAULT(0), int flags CV_DEFAULT(0), | |
- CvArr* _centers CV_DEFAULT(0), double* compactness CV_DEFAULT(0) ); | |
- | |
-/****************************************************************************************\ | |
-* System functions * | |
-\****************************************************************************************/ | |
- | |
-/* Add the function pointers table with associated information to the IPP primitives list */ | |
-CVAPI(int) cvRegisterModule( const CvModuleInfo* module_info ); | |
- | |
-/* Loads optimized functions from IPP, MKL etc. or switches back to pure C code */ | |
-CVAPI(int) cvUseOptimized( int on_off ); | |
- | |
-/* Retrieves information about the registered modules and loaded optimized plugins */ | |
-CVAPI(void) cvGetModuleInfo( const char* module_name, | |
- const char** version, | |
- const char** loaded_addon_plugins ); | |
- | |
-typedef void* (CV_CDECL *CvAllocFunc)(size_t size, void* userdata); | |
-typedef int (CV_CDECL *CvFreeFunc)(void* pptr, void* userdata); | |
- | |
-/* Set user-defined memory managment functions (substitutors for malloc and free) that | |
- will be called by cvAlloc, cvFree and higher-level functions (e.g. cvCreateImage) */ | |
-CVAPI(void) cvSetMemoryManager( CvAllocFunc alloc_func CV_DEFAULT(NULL), | |
- CvFreeFunc free_func CV_DEFAULT(NULL), | |
- void* userdata CV_DEFAULT(NULL)); | |
- | |
- | |
-typedef IplImage* (CV_STDCALL* Cv_iplCreateImageHeader) | |
- (int,int,int,char*,char*,int,int,int,int,int, | |
- IplROI*,IplImage*,void*,IplTileInfo*); | |
-typedef void (CV_STDCALL* Cv_iplAllocateImageData)(IplImage*,int,int); | |
-typedef void (CV_STDCALL* Cv_iplDeallocate)(IplImage*,int); | |
-typedef IplROI* (CV_STDCALL* Cv_iplCreateROI)(int,int,int,int,int); | |
-typedef IplImage* (CV_STDCALL* Cv_iplCloneImage)(const IplImage*); | |
- | |
-/* Makes OpenCV use IPL functions for IplImage allocation/deallocation */ | |
-CVAPI(void) cvSetIPLAllocators( Cv_iplCreateImageHeader create_header, | |
- Cv_iplAllocateImageData allocate_data, | |
- Cv_iplDeallocate deallocate, | |
- Cv_iplCreateROI create_roi, | |
- Cv_iplCloneImage clone_image ); | |
- | |
-#define CV_TURN_ON_IPL_COMPATIBILITY() \ | |
- cvSetIPLAllocators( iplCreateImageHeader, iplAllocateImage, \ | |
- iplDeallocate, iplCreateROI, iplCloneImage ) | |
- | |
-/****************************************************************************************\ | |
-* Data Persistence * | |
-\****************************************************************************************/ | |
- | |
-/********************************** High-level functions ********************************/ | |
- | |
-/* opens existing or creates new file storage */ | |
-CVAPI(CvFileStorage*) cvOpenFileStorage( const char* filename, CvMemStorage* memstorage, | |
- int flags, const char* encoding CV_DEFAULT(NULL) ); | |
- | |
-/* closes file storage and deallocates buffers */ | |
-CVAPI(void) cvReleaseFileStorage( CvFileStorage** fs ); | |
- | |
-/* returns attribute value or 0 (NULL) if there is no such attribute */ | |
-CVAPI(const char*) cvAttrValue( const CvAttrList* attr, const char* attr_name ); | |
- | |
-/* starts writing compound structure (map or sequence) */ | |
-CVAPI(void) cvStartWriteStruct( CvFileStorage* fs, const char* name, | |
- int struct_flags, const char* type_name CV_DEFAULT(NULL), | |
- CvAttrList attributes CV_DEFAULT(cvAttrList())); | |
- | |
-/* finishes writing compound structure */ | |
-CVAPI(void) cvEndWriteStruct( CvFileStorage* fs ); | |
- | |
-/* writes an integer */ | |
-CVAPI(void) cvWriteInt( CvFileStorage* fs, const char* name, int value ); | |
- | |
-/* writes a floating-point number */ | |
-CVAPI(void) cvWriteReal( CvFileStorage* fs, const char* name, double value ); | |
- | |
-/* writes a string */ | |
-CVAPI(void) cvWriteString( CvFileStorage* fs, const char* name, | |
- const char* str, int quote CV_DEFAULT(0) ); | |
- | |
-/* writes a comment */ | |
-CVAPI(void) cvWriteComment( CvFileStorage* fs, const char* comment, | |
- int eol_comment ); | |
- | |
-/* writes instance of a standard type (matrix, image, sequence, graph etc.) | |
- or user-defined type */ | |
-CVAPI(void) cvWrite( CvFileStorage* fs, const char* name, const void* ptr, | |
- CvAttrList attributes CV_DEFAULT(cvAttrList())); | |
- | |
-/* starts the next stream */ | |
-CVAPI(void) cvStartNextStream( CvFileStorage* fs ); | |
- | |
-/* helper function: writes multiple integer or floating-point numbers */ | |
-CVAPI(void) cvWriteRawData( CvFileStorage* fs, const void* src, | |
- int len, const char* dt ); | |
- | |
-/* returns the hash entry corresponding to the specified literal key string or 0 | |
- if there is no such a key in the storage */ | |
-CVAPI(CvStringHashNode*) cvGetHashedKey( CvFileStorage* fs, const char* name, | |
- int len CV_DEFAULT(-1), | |
- int create_missing CV_DEFAULT(0)); | |
- | |
-/* returns file node with the specified key within the specified map | |
- (collection of named nodes) */ | |
-CVAPI(CvFileNode*) cvGetRootFileNode( const CvFileStorage* fs, | |
- int stream_index CV_DEFAULT(0) ); | |
- | |
-/* returns file node with the specified key within the specified map | |
- (collection of named nodes) */ | |
-CVAPI(CvFileNode*) cvGetFileNode( CvFileStorage* fs, CvFileNode* map, | |
- const CvStringHashNode* key, | |
- int create_missing CV_DEFAULT(0) ); | |
- | |
-/* this is a slower version of cvGetFileNode that takes the key as a literal string */ | |
-CVAPI(CvFileNode*) cvGetFileNodeByName( const CvFileStorage* fs, | |
- const CvFileNode* map, | |
- const char* name ); | |
- | |
-CV_INLINE int cvReadInt( const CvFileNode* node, int default_value CV_DEFAULT(0) ) | |
-{ | |
- return !node ? default_value : | |
- CV_NODE_IS_INT(node->tag) ? node->data.i : | |
- CV_NODE_IS_REAL(node->tag) ? cvRound(node->data.f) : 0x7fffffff; | |
-} | |
- | |
- | |
-CV_INLINE int cvReadIntByName( const CvFileStorage* fs, const CvFileNode* map, | |
- const char* name, int default_value CV_DEFAULT(0) ) | |
-{ | |
- return cvReadInt( cvGetFileNodeByName( fs, map, name ), default_value ); | |
-} | |
- | |
- | |
-CV_INLINE double cvReadReal( const CvFileNode* node, double default_value CV_DEFAULT(0.) ) | |
-{ | |
- return !node ? default_value : | |
- CV_NODE_IS_INT(node->tag) ? (double)node->data.i : | |
- CV_NODE_IS_REAL(node->tag) ? node->data.f : 1e300; | |
-} | |
- | |
- | |
-CV_INLINE double cvReadRealByName( const CvFileStorage* fs, const CvFileNode* map, | |
- const char* name, double default_value CV_DEFAULT(0.) ) | |
-{ | |
- return cvReadReal( cvGetFileNodeByName( fs, map, name ), default_value ); | |
-} | |
- | |
- | |
-CV_INLINE const char* cvReadString( const CvFileNode* node, | |
- const char* default_value CV_DEFAULT(NULL) ) | |
-{ | |
- return !node ? default_value : CV_NODE_IS_STRING(node->tag) ? node->data.str.ptr : 0; | |
-} | |
- | |
- | |
-CV_INLINE const char* cvReadStringByName( const CvFileStorage* fs, const CvFileNode* map, | |
- const char* name, const char* default_value CV_DEFAULT(NULL) ) | |
-{ | |
- return cvReadString( cvGetFileNodeByName( fs, map, name ), default_value ); | |
-} | |
- | |
- | |
-/* decodes standard or user-defined object and returns it */ | |
-CVAPI(void*) cvRead( CvFileStorage* fs, CvFileNode* node, | |
- CvAttrList* attributes CV_DEFAULT(NULL)); | |
- | |
-/* decodes standard or user-defined object and returns it */ | |
-CV_INLINE void* cvReadByName( CvFileStorage* fs, const CvFileNode* map, | |
- const char* name, CvAttrList* attributes CV_DEFAULT(NULL) ) | |
-{ | |
- return cvRead( fs, cvGetFileNodeByName( fs, map, name ), attributes ); | |
-} | |
- | |
- | |
-/* starts reading data from sequence or scalar numeric node */ | |
-CVAPI(void) cvStartReadRawData( const CvFileStorage* fs, const CvFileNode* src, | |
- CvSeqReader* reader ); | |
- | |
-/* reads multiple numbers and stores them to array */ | |
-CVAPI(void) cvReadRawDataSlice( const CvFileStorage* fs, CvSeqReader* reader, | |
- int count, void* dst, const char* dt ); | |
- | |
-/* combination of two previous functions for easier reading of whole sequences */ | |
-CVAPI(void) cvReadRawData( const CvFileStorage* fs, const CvFileNode* src, | |
- void* dst, const char* dt ); | |
- | |
-/* writes a copy of file node to file storage */ | |
-CVAPI(void) cvWriteFileNode( CvFileStorage* fs, const char* new_node_name, | |
- const CvFileNode* node, int embed ); | |
- | |
-/* returns name of file node */ | |
-CVAPI(const char*) cvGetFileNodeName( const CvFileNode* node ); | |
- | |
-/*********************************** Adding own types ***********************************/ | |
- | |
-CVAPI(void) cvRegisterType( const CvTypeInfo* info ); | |
-CVAPI(void) cvUnregisterType( const char* type_name ); | |
-CVAPI(CvTypeInfo*) cvFirstType(void); | |
-CVAPI(CvTypeInfo*) cvFindType( const char* type_name ); | |
-CVAPI(CvTypeInfo*) cvTypeOf( const void* struct_ptr ); | |
- | |
-/* universal functions */ | |
-CVAPI(void) cvRelease( void** struct_ptr ); | |
-CVAPI(void*) cvClone( const void* struct_ptr ); | |
- | |
-/* simple API for reading/writing data */ | |
-CVAPI(void) cvSave( const char* filename, const void* struct_ptr, | |
- const char* name CV_DEFAULT(NULL), | |
- const char* comment CV_DEFAULT(NULL), | |
- CvAttrList attributes CV_DEFAULT(cvAttrList())); | |
-CVAPI(void*) cvLoad( const char* filename, | |
- CvMemStorage* memstorage CV_DEFAULT(NULL), | |
- const char* name CV_DEFAULT(NULL), | |
- const char** real_name CV_DEFAULT(NULL) ); | |
- | |
-/*********************************** Measuring Execution Time ***************************/ | |
- | |
-/* helper functions for RNG initialization and accurate time measurement: | |
- uses internal clock counter on x86 */ | |
-CVAPI(int64) cvGetTickCount( void ); | |
-CVAPI(double) cvGetTickFrequency( void ); | |
- | |
-/*********************************** CPU capabilities ***********************************/ | |
- | |
-#define CV_CPU_NONE 0 | |
-#define CV_CPU_MMX 1 | |
-#define CV_CPU_SSE 2 | |
-#define CV_CPU_SSE2 3 | |
-#define CV_CPU_SSE3 4 | |
-#define CV_CPU_SSSE3 5 | |
-#define CV_CPU_SSE4_1 6 | |
-#define CV_CPU_SSE4_2 7 | |
-#define CV_CPU_POPCNT 8 | |
-#define CV_CPU_AVX 10 | |
-#define CV_HARDWARE_MAX_FEATURE 255 | |
- | |
-CVAPI(int) cvCheckHardwareSupport(int feature); | |
- | |
-/*********************************** Multi-Threading ************************************/ | |
- | |
-/* retrieve/set the number of threads used in OpenMP implementations */ | |
-CVAPI(int) cvGetNumThreads( void ); | |
-CVAPI(void) cvSetNumThreads( int threads CV_DEFAULT(0) ); | |
-/* get index of the thread being executed */ | |
-CVAPI(int) cvGetThreadNum( void ); | |
- | |
- | |
-/********************************** Error Handling **************************************/ | |
- | |
-/* Get current OpenCV error status */ | |
-CVAPI(int) cvGetErrStatus( void ); | |
- | |
-/* Sets error status silently */ | |
-CVAPI(void) cvSetErrStatus( int status ); | |
- | |
-#define CV_ErrModeLeaf 0 /* Print error and exit program */ | |
-#define CV_ErrModeParent 1 /* Print error and continue */ | |
-#define CV_ErrModeSilent 2 /* Don't print and continue */ | |
- | |
-/* Retrives current error processing mode */ | |
-CVAPI(int) cvGetErrMode( void ); | |
- | |
-/* Sets error processing mode, returns previously used mode */ | |
-CVAPI(int) cvSetErrMode( int mode ); | |
- | |
-/* Sets error status and performs some additonal actions (displaying message box, | |
- writing message to stderr, terminating application etc.) | |
- depending on the current error mode */ | |
-CVAPI(void) cvError( int status, const char* func_name, | |
- const char* err_msg, const char* file_name, int line ); | |
- | |
-/* Retrieves textual description of the error given its code */ | |
-CVAPI(const char*) cvErrorStr( int status ); | |
- | |
-/* Retrieves detailed information about the last error occured */ | |
-CVAPI(int) cvGetErrInfo( const char** errcode_desc, const char** description, | |
- const char** filename, int* line ); | |
- | |
-/* Maps IPP error codes to the counterparts from OpenCV */ | |
-CVAPI(int) cvErrorFromIppStatus( int ipp_status ); | |
- | |
-typedef int (CV_CDECL *CvErrorCallback)( int status, const char* func_name, | |
- const char* err_msg, const char* file_name, int line, void* userdata ); | |
- | |
-/* Assigns a new error-handling function */ | |
-CVAPI(CvErrorCallback) cvRedirectError( CvErrorCallback error_handler, | |
- void* userdata CV_DEFAULT(NULL), | |
- void** prev_userdata CV_DEFAULT(NULL) ); | |
- | |
-/* | |
- Output to: | |
- cvNulDevReport - nothing | |
- cvStdErrReport - console(fprintf(stderr,...)) | |
- cvGuiBoxReport - MessageBox(WIN32) | |
- */ | |
-CVAPI(int) cvNulDevReport( int status, const char* func_name, const char* err_msg, | |
- const char* file_name, int line, void* userdata ); | |
- | |
-CVAPI(int) cvStdErrReport( int status, const char* func_name, const char* err_msg, | |
- const char* file_name, int line, void* userdata ); | |
- | |
-CVAPI(int) cvGuiBoxReport( int status, const char* func_name, const char* err_msg, | |
- const char* file_name, int line, void* userdata ); | |
- | |
-#define OPENCV_ERROR(status,func,context) \ | |
-cvError((status),(func),(context),__FILE__,__LINE__) | |
- | |
-#define OPENCV_ERRCHK(func,context) \ | |
-{if (cvGetErrStatus() >= 0) \ | |
-{OPENCV_ERROR(CV_StsBackTrace,(func),(context));}} | |
- | |
-#define OPENCV_ASSERT(expr,func,context) \ | |
-{if (! (expr)) \ | |
-{OPENCV_ERROR(CV_StsInternal,(func),(context));}} | |
- | |
-#define OPENCV_RSTERR() (cvSetErrStatus(CV_StsOk)) | |
- | |
-#define OPENCV_CALL( Func ) \ | |
-{ \ | |
-Func; \ | |
-} | |
- | |
- | |
-/* CV_FUNCNAME macro defines icvFuncName constant which is used by CV_ERROR macro */ | |
-#ifdef CV_NO_FUNC_NAMES | |
-#define CV_FUNCNAME( Name ) | |
-#define cvFuncName "" | |
-#else | |
-#define CV_FUNCNAME( Name ) \ | |
-static char cvFuncName[] = Name | |
-#endif | |
- | |
- | |
-/* | |
- CV_ERROR macro unconditionally raises error with passed code and message. | |
- After raising error, control will be transferred to the exit label. | |
- */ | |
-#define CV_ERROR( Code, Msg ) \ | |
-{ \ | |
- cvError( (Code), cvFuncName, Msg, __FILE__, __LINE__ ); \ | |
- __CV_EXIT__; \ | |
-} | |
- | |
-/* Simplified form of CV_ERROR */ | |
-#define CV_ERROR_FROM_CODE( code ) \ | |
- CV_ERROR( code, "" ) | |
- | |
-/* | |
- CV_CHECK macro checks error status after CV (or IPL) | |
- function call. If error detected, control will be transferred to the exit | |
- label. | |
- */ | |
-#define CV_CHECK() \ | |
-{ \ | |
- if( cvGetErrStatus() < 0 ) \ | |
- CV_ERROR( CV_StsBackTrace, "Inner function failed." ); \ | |
-} | |
- | |
- | |
-/* | |
- CV_CALL macro calls CV (or IPL) function, checks error status and | |
- signals a error if the function failed. Useful in "parent node" | |
- error procesing mode | |
- */ | |
-#define CV_CALL( Func ) \ | |
-{ \ | |
- Func; \ | |
- CV_CHECK(); \ | |
-} | |
- | |
- | |
-/* Runtime assertion macro */ | |
-#define CV_ASSERT( Condition ) \ | |
-{ \ | |
- if( !(Condition) ) \ | |
- CV_ERROR( CV_StsInternal, "Assertion: " #Condition " failed" ); \ | |
-} | |
- | |
-#define __CV_BEGIN__ { | |
-#define __CV_END__ goto exit; exit: ; } | |
-#define __CV_EXIT__ goto exit | |
- | |
-#ifdef __cplusplus | |
-} | |
- | |
-// classes for automatic module/RTTI data registration/unregistration | |
-struct CV_EXPORTS CvModule | |
-{ | |
- CvModule( CvModuleInfo* _info ); | |
- ~CvModule(); | |
- CvModuleInfo* info; | |
- | |
- static CvModuleInfo* first; | |
- static CvModuleInfo* last; | |
-}; | |
- | |
-struct CV_EXPORTS CvType | |
-{ | |
- CvType( const char* type_name, | |
- CvIsInstanceFunc is_instance, CvReleaseFunc release=0, | |
- CvReadFunc read=0, CvWriteFunc write=0, CvCloneFunc clone=0 ); | |
- ~CvType(); | |
- CvTypeInfo* info; | |
- | |
- static CvTypeInfo* first; | |
- static CvTypeInfo* last; | |
-}; | |
- | |
-#endif | |
- | |
-#endif | |
diff --git a/card.io/src/main/jni/opencv2/core/devmem2d.hpp b/card.io/src/main/jni/opencv2/core/devmem2d.hpp | |
deleted file mode 100644 | |
index 276aeb2..0000000 | |
--- a/card.io/src/main/jni/opencv2/core/devmem2d.hpp | |
+++ /dev/null | |
@@ -1,161 +0,0 @@ | |
-/*M/////////////////////////////////////////////////////////////////////////////////////// | |
-// | |
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. | |
-// | |
-// By downloading, copying, installing or using the software you agree to this license. | |
-// If you do not agree to this license, do not download, install, | |
-// copy or use the software. | |
-// | |
-// | |
-// License Agreement | |
-// For Open Source Computer Vision Library | |
-// | |
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. | |
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved. | |
-// Third party copyrights are property of their respective owners. | |
-// | |
-// Redistribution and use in source and binary forms, with or without modification, | |
-// are permitted provided that the following conditions are met: | |
-// | |
-// * Redistribution's of source code must retain the above copyright notice, | |
-// this list of conditions and the following disclaimer. | |
-// | |
-// * Redistribution's in binary form must reproduce the above copyright notice, | |
-// this list of conditions and the following disclaimer in the documentation | |
-// and/or other GpuMaterials provided with the distribution. | |
-// | |
-// * The name of the copyright holders may not be used to endorse or promote products | |
-// derived from this software without specific prior written permission. | |
-// | |
-// This software is provided by the copyright holders and contributors "as is" and | |
-// any express or implied warranties, including, but not limited to, the implied | |
-// warranties of merchantability and fitness for a particular purpose are disclaimed. | |
-// In no event shall the Intel Corporation or contributors be liable for any direct, | |
-// indirect, incidental, special, exemplary, or consequential damages | |
-// (including, but not limited to, procurement of substitute goods or services; | |
-// loss of use, data, or profits; or business interruption) however caused | |
-// and on any theory of liability, whether in contract, strict liability, | |
-// or tort (including negligence or otherwise) arising in any way out of | |
-// the use of this software, even if advised of the possibility of such damage. | |
-// | |
-//M*/ | |
- | |
-#ifndef __OPENCV_CORE_DevMem2D_HPP__ | |
-#define __OPENCV_CORE_DevMem2D_HPP__ | |
- | |
-#ifdef __cplusplus | |
- | |
-#ifdef __CUDACC__ | |
- #define __CV_GPU_HOST_DEVICE__ __host__ __device__ __forceinline__ | |
-#else | |
- #define __CV_GPU_HOST_DEVICE__ | |
-#endif | |
- | |
-namespace cv | |
-{ | |
- namespace gpu | |
- { | |
- // Simple lightweight structures that encapsulates information about an image on device. | |
- // It is intended to pass to nvcc-compiled code. GpuMat depends on headers that nvcc can't compile | |
- | |
- template <bool expr> struct StaticAssert; | |
- template <> struct StaticAssert<true> {static __CV_GPU_HOST_DEVICE__ void check(){}}; | |
- | |
- template<typename T> struct DevPtr | |
- { | |
- typedef T elem_type; | |
- typedef int index_type; | |
- | |
- enum { elem_size = sizeof(elem_type) }; | |
- | |
- T* data; | |
- | |
- __CV_GPU_HOST_DEVICE__ DevPtr() : data(0) {} | |
- __CV_GPU_HOST_DEVICE__ DevPtr(T* data_) : data(data_) {} | |
- | |
- __CV_GPU_HOST_DEVICE__ size_t elemSize() const { return elem_size; } | |
- __CV_GPU_HOST_DEVICE__ operator T*() { return data; } | |
- __CV_GPU_HOST_DEVICE__ operator const T*() const { return data; } | |
- }; | |
- | |
- template<typename T> struct PtrSz : public DevPtr<T> | |
- { | |
- __CV_GPU_HOST_DEVICE__ PtrSz() : size(0) {} | |
- __CV_GPU_HOST_DEVICE__ PtrSz(T* data_, size_t size_) : DevPtr<T>(data_), size(size_) {} | |
- | |
- size_t size; | |
- }; | |
- | |
- template<typename T> struct PtrStep : public DevPtr<T> | |
- { | |
- __CV_GPU_HOST_DEVICE__ PtrStep() : step(0) {} | |
- __CV_GPU_HOST_DEVICE__ PtrStep(T* data_, size_t step_) : DevPtr<T>(data_), step(step_) {} | |
- | |
- /** \brief stride between two consecutive rows in bytes. Step is stored always and everywhere in bytes!!! */ | |
- size_t step; | |
- | |
- __CV_GPU_HOST_DEVICE__ T* ptr(int y = 0) { return ( T*)( ( char*)DevPtr<T>::data + y * step); } | |
- __CV_GPU_HOST_DEVICE__ const T* ptr(int y = 0) const { return (const T*)( (const char*)DevPtr<T>::data + y * step); } | |
- | |
- __CV_GPU_HOST_DEVICE__ T& operator ()(int y, int x) { return ptr(y)[x]; } | |
- __CV_GPU_HOST_DEVICE__ const T& operator ()(int y, int x) const { return ptr(y)[x]; } | |
- }; | |
- | |
- template <typename T> struct PtrStepSz : public PtrStep<T> | |
- { | |
- __CV_GPU_HOST_DEVICE__ PtrStepSz() : cols(0), rows(0) {} | |
- __CV_GPU_HOST_DEVICE__ PtrStepSz(int rows_, int cols_, T* data_, size_t step_) | |
- : PtrStep<T>(data_, step_), cols(cols_), rows(rows_) {} | |
- | |
- int cols; | |
- int rows; | |
- }; | |
- | |
- template <typename T> struct DevMem2D_ : public PtrStepSz<T> | |
- { | |
- DevMem2D_() {} | |
- DevMem2D_(int rows_, int cols_, T* data_, size_t step_) : PtrStepSz<T>(rows_, cols_, data_, step_) {} | |
- | |
- template <typename U> | |
- explicit DevMem2D_(const DevMem2D_<U>& d) : PtrStepSz<T>(d.rows, d.cols, (T*)d.data, d.step) {} | |
- }; | |
- | |
- template<typename T> struct PtrElemStep_ : public PtrStep<T> | |
- { | |
- PtrElemStep_(const DevMem2D_<T>& mem) : PtrStep<T>(mem.data, mem.step) | |
- { | |
- StaticAssert<256 % sizeof(T) == 0>::check(); | |
- | |
- PtrStep<T>::step /= PtrStep<T>::elem_size; | |
- } | |
- __CV_GPU_HOST_DEVICE__ T* ptr(int y = 0) { return PtrStep<T>::data + y * PtrStep<T>::step; } | |
- __CV_GPU_HOST_DEVICE__ const T* ptr(int y = 0) const { return PtrStep<T>::data + y * PtrStep<T>::step; } | |
- | |
- __CV_GPU_HOST_DEVICE__ T& operator ()(int y, int x) { return ptr(y)[x]; } | |
- __CV_GPU_HOST_DEVICE__ const T& operator ()(int y, int x) const { return ptr(y)[x]; } | |
- }; | |
- | |
- template<typename T> struct PtrStep_ : public PtrStep<T> | |
- { | |
- PtrStep_() {} | |
- PtrStep_(const DevMem2D_<T>& mem) : PtrStep<T>(mem.data, mem.step) {} | |
- }; | |
- | |
- typedef DevMem2D_<unsigned char> DevMem2Db; | |
- typedef DevMem2Db DevMem2D; | |
- typedef DevMem2D_<float> DevMem2Df; | |
- typedef DevMem2D_<int> DevMem2Di; | |
- | |
- typedef PtrStep<unsigned char> PtrStepb; | |
- typedef PtrStep<float> PtrStepf; | |
- typedef PtrStep<int> PtrStepi; | |
- | |
- typedef PtrElemStep_<unsigned char> PtrElemStep; | |
- typedef PtrElemStep_<float> PtrElemStepf; | |
- typedef PtrElemStep_<int> PtrElemStepi; | |
- } | |
-} | |
- | |
-#endif // __cplusplus | |
- | |
-#endif /* __OPENCV_GPU_DevMem2D_HPP__ */ | |
diff --git a/card.io/src/main/jni/opencv2/core/eigen.hpp b/card.io/src/main/jni/opencv2/core/eigen.hpp | |
deleted file mode 100644 | |
index dbaa9fc..0000000 | |
--- a/card.io/src/main/jni/opencv2/core/eigen.hpp | |
+++ /dev/null | |
@@ -1,187 +0,0 @@ | |
-/*M/////////////////////////////////////////////////////////////////////////////////////// | |
-// | |
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. | |
-// | |
-// By downloading, copying, installing or using the software you agree to this license. | |
-// If you do not agree to this license, do not download, install, | |
-// copy or use the software. | |
-// | |
-// | |
-// License Agreement | |
-// For Open Source Computer Vision Library | |
-// | |
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. | |
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved. | |
-// Third party copyrights are property of their respective owners. | |
-// | |
-// Redistribution and use in source and binary forms, with or without modification, | |
-// are permitted provided that the following conditions are met: | |
-// | |
-// * Redistribution's of source code must retain the above copyright notice, | |
-// this list of conditions and the following disclaimer. | |
-// | |
-// * Redistribution's in binary form must reproduce the above copyright notice, | |
-// this list of conditions and the following disclaimer in the documentation | |
-// and/or other materials provided with the distribution. | |
-// | |
-// * The name of the copyright holders may not be used to endorse or promote products | |
-// derived from this software without specific prior written permission. | |
-// | |
-// This software is provided by the copyright holders and contributors "as is" and | |
-// any express or implied warranties, including, but not limited to, the implied | |
-// warranties of merchantability and fitness for a particular purpose are disclaimed. | |
-// In no event shall the Intel Corporation or contributors be liable for any direct, | |
-// indirect, incidental, special, exemplary, or consequential damages | |
-// (including, but not limited to, procurement of substitute goods or services; | |
-// loss of use, data, or profits; or business interruption) however caused | |
-// and on any theory of liability, whether in contract, strict liability, | |
-// or tort (including negligence or otherwise) arising in any way out of | |
-// the use of this software, even if advised of the possibility of such damage. | |
-// | |
-//M*/ | |
- | |
-#ifndef __OPENCV_CORE_EIGEN_HPP__ | |
-#define __OPENCV_CORE_EIGEN_HPP__ | |
- | |
-#ifdef __cplusplus | |
- | |
-#include "opencv2/core/core_c.h" | |
-#include "opencv2/core/core.hpp" | |
- | |
-namespace cv | |
-{ | |
- | |
-template<typename _Tp, int _rows, int _cols, int _options, int _maxRows, int _maxCols> | |
-void eigen2cv( const Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& src, Mat& dst ) | |
-{ | |
- if( !(src.Flags & Eigen::RowMajorBit) ) | |
- { | |
- Mat _src(src.cols(), src.rows(), DataType<_Tp>::type, | |
- (void*)src.data(), src.stride()*sizeof(_Tp)); | |
- transpose(_src, dst); | |
- } | |
- else | |
- { | |
- Mat _src(src.rows(), src.cols(), DataType<_Tp>::type, | |
- (void*)src.data(), src.stride()*sizeof(_Tp)); | |
- _src.copyTo(dst); | |
- } | |
-} | |
- | |
-template<typename _Tp, int _rows, int _cols, int _options, int _maxRows, int _maxCols> | |
-void cv2eigen( const Mat& src, | |
- Eigen::Matrix<_Tp, _rows, _cols, _options, _maxRows, _maxCols>& dst ) | |
-{ | |
- CV_DbgAssert(src.rows == _rows && src.cols == _cols); | |
- if( !(dst.Flags & Eigen::RowMajorBit) ) | |
- { | |
- Mat _dst(src.cols, src.rows, DataType<_Tp>::type, | |
- dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); | |
- if( src.type() == _dst.type() ) | |
- transpose(src, _dst); | |
- else if( src.cols == src.rows ) | |
- { | |
- src.convertTo(_dst, _dst.type()); | |
- transpose(_dst, _dst); | |
- } | |
- else | |
- Mat(src.t()).convertTo(_dst, _dst.type()); | |
- CV_DbgAssert(_dst.data == (uchar*)dst.data()); | |
- } | |
- else | |
- { | |
- Mat _dst(src.rows, src.cols, DataType<_Tp>::type, | |
- dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); | |
- src.convertTo(_dst, _dst.type()); | |
- CV_DbgAssert(_dst.data == (uchar*)dst.data()); | |
- } | |
-} | |
- | |
-template<typename _Tp> | |
-void cv2eigen( const Mat& src, | |
- Eigen::Matrix<_Tp, Eigen::Dynamic, Eigen::Dynamic>& dst ) | |
-{ | |
- dst.resize(src.rows, src.cols); | |
- if( !(dst.Flags & Eigen::RowMajorBit) ) | |
- { | |
- Mat _dst(src.cols, src.rows, DataType<_Tp>::type, | |
- dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); | |
- if( src.type() == _dst.type() ) | |
- transpose(src, _dst); | |
- else if( src.cols == src.rows ) | |
- { | |
- src.convertTo(_dst, _dst.type()); | |
- transpose(_dst, _dst); | |
- } | |
- else | |
- Mat(src.t()).convertTo(_dst, _dst.type()); | |
- CV_DbgAssert(_dst.data == (uchar*)dst.data()); | |
- } | |
- else | |
- { | |
- Mat _dst(src.rows, src.cols, DataType<_Tp>::type, | |
- dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); | |
- src.convertTo(_dst, _dst.type()); | |
- CV_DbgAssert(_dst.data == (uchar*)dst.data()); | |
- } | |
-} | |
- | |
- | |
-template<typename _Tp> | |
-void cv2eigen( const Mat& src, | |
- Eigen::Matrix<_Tp, Eigen::Dynamic, 1>& dst ) | |
-{ | |
- CV_Assert(src.cols == 1); | |
- dst.resize(src.rows); | |
- | |
- if( !(dst.Flags & Eigen::RowMajorBit) ) | |
- { | |
- Mat _dst(src.cols, src.rows, DataType<_Tp>::type, | |
- dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); | |
- if( src.type() == _dst.type() ) | |
- transpose(src, _dst); | |
- else | |
- Mat(src.t()).convertTo(_dst, _dst.type()); | |
- CV_DbgAssert(_dst.data == (uchar*)dst.data()); | |
- } | |
- else | |
- { | |
- Mat _dst(src.rows, src.cols, DataType<_Tp>::type, | |
- dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); | |
- src.convertTo(_dst, _dst.type()); | |
- CV_DbgAssert(_dst.data == (uchar*)dst.data()); | |
- } | |
-} | |
- | |
- | |
-template<typename _Tp> | |
-void cv2eigen( const Mat& src, | |
- Eigen::Matrix<_Tp, 1, Eigen::Dynamic>& dst ) | |
-{ | |
- CV_Assert(src.rows == 1); | |
- dst.resize(src.cols); | |
- if( !(dst.Flags & Eigen::RowMajorBit) ) | |
- { | |
- Mat _dst(src.cols, src.rows, DataType<_Tp>::type, | |
- dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); | |
- if( src.type() == _dst.type() ) | |
- transpose(src, _dst); | |
- else | |
- Mat(src.t()).convertTo(_dst, _dst.type()); | |
- CV_DbgAssert(_dst.data == (uchar*)dst.data()); | |
- } | |
- else | |
- { | |
- Mat _dst(src.rows, src.cols, DataType<_Tp>::type, | |
- dst.data(), (size_t)(dst.stride()*sizeof(_Tp))); | |
- src.convertTo(_dst, _dst.type()); | |
- CV_DbgAssert(_dst.data == (uchar*)dst.data()); | |
- } | |
-} | |
- | |
-} | |
- | |
-#endif | |
- | |
-#endif | |
- | |
diff --git a/card.io/src/main/jni/opencv2/core/gpumat.hpp b/card.io/src/main/jni/opencv2/core/gpumat.hpp | |
deleted file mode 100644 | |
index fda6990..0000000 | |
--- a/card.io/src/main/jni/opencv2/core/gpumat.hpp | |
+++ /dev/null | |
@@ -1,565 +0,0 @@ | |
-/*M/////////////////////////////////////////////////////////////////////////////////////// | |
-// | |
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. | |
-// | |
-// By downloading, copying, installing or using the software you agree to this license. | |
-// If you do not agree to this license, do not download, install, | |
-// copy or use the software. | |
-// | |
-// | |
-// License Agreement | |
-// For Open Source Computer Vision Library | |
-// | |
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. | |
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved. | |
-// Third party copyrights are property of their respective owners. | |
-// | |
-// Redistribution and use in source and binary forms, with or without modification, | |
-// are permitted provided that the following conditions are met: | |
-// | |
-// * Redistribution's of source code must retain the above copyright notice, | |
-// this list of conditions and the following disclaimer. | |
-// | |
-// * Redistribution's in binary form must reproduce the above copyright notice, | |
-// this list of conditions and the following disclaimer in the documentation | |
-// and/or other GpuMaterials provided with the distribution. | |
-// | |
-// * The name of the copyright holders may not be used to endorse or promote products | |
-// derived from this software without specific prior written permission. | |
-// | |
-// This software is provided by the copyright holders and contributors "as is" and | |
-// any express or implied warranties, including, but not limited to, the implied | |
-// warranties of merchantability and fitness for a particular purpose are disclaimed. | |
-// In no event shall the Intel Corporation or contributors be liable for any direct, | |
-// indirect, incidental, special, exemplary, or consequential damages | |
-// (including, but not limited to, procurement of substitute goods or services; | |
-// loss of use, data, or profits; or business interruption) however caused | |
-// and on any theory of liability, whether in contract, strict liability, | |
-// or tort (including negligence or otherwise) arising in any way out of | |
-// the use of this software, even if advised of the possibility of such damage. | |
-// | |
-//M*/ | |
- | |
-#ifndef __OPENCV_GPUMAT_HPP__ | |
-#define __OPENCV_GPUMAT_HPP__ | |
- | |
-#ifdef __cplusplus | |
- | |
-#include "opencv2/core/core.hpp" | |
-#include "opencv2/core/devmem2d.hpp" | |
- | |
-namespace cv { namespace gpu | |
-{ | |
- //////////////////////////////// Initialization & Info //////////////////////// | |
- | |
- //! This is the only function that do not throw exceptions if the library is compiled without Cuda. | |
- CV_EXPORTS int getCudaEnabledDeviceCount(); | |
- | |
- //! Functions below throw cv::Expception if the library is compiled without Cuda. | |
- | |
- CV_EXPORTS void setDevice(int device); | |
- CV_EXPORTS int getDevice(); | |
- | |
- //! Explicitly destroys and cleans up all resources associated with the current device in the current process. | |
- //! Any subsequent API call to this device will reinitialize the device. | |
- CV_EXPORTS void resetDevice(); | |
- | |
- enum FeatureSet | |
- { | |
- FEATURE_SET_COMPUTE_10 = 10, | |
- FEATURE_SET_COMPUTE_11 = 11, | |
- FEATURE_SET_COMPUTE_12 = 12, | |
- FEATURE_SET_COMPUTE_13 = 13, | |
- FEATURE_SET_COMPUTE_20 = 20, | |
- FEATURE_SET_COMPUTE_21 = 21, | |
- GLOBAL_ATOMICS = FEATURE_SET_COMPUTE_11, | |
- SHARED_ATOMICS = FEATURE_SET_COMPUTE_12, | |
- NATIVE_DOUBLE = FEATURE_SET_COMPUTE_13 | |
- }; | |
- | |
- // Gives information about what GPU archs this OpenCV GPU module was | |
- // compiled for | |
- class CV_EXPORTS TargetArchs | |
- { | |
- public: | |
- static bool builtWith(FeatureSet feature_set); | |
- static bool has(int major, int minor); | |
- static bool hasPtx(int major, int minor); | |
- static bool hasBin(int major, int minor); | |
- static bool hasEqualOrLessPtx(int major, int minor); | |
- static bool hasEqualOrGreater(int major, int minor); | |
- static bool hasEqualOrGreaterPtx(int major, int minor); | |
- static bool hasEqualOrGreaterBin(int major, int minor); | |
- private: | |
- TargetArchs(); | |
- }; | |
- | |
- // Gives information about the given GPU | |
- class CV_EXPORTS DeviceInfo | |
- { | |
- public: | |
- // Creates DeviceInfo object for the current GPU | |
- DeviceInfo() : device_id_(getDevice()) { query(); } | |
- | |
- // Creates DeviceInfo object for the given GPU | |
- DeviceInfo(int device_id) : device_id_(device_id) { query(); } | |
- | |
- std::string name() const { return name_; } | |
- | |
- // Return compute capability versions | |
- int majorVersion() const { return majorVersion_; } | |
- int minorVersion() const { return minorVersion_; } | |
- | |
- int multiProcessorCount() const { return multi_processor_count_; } | |
- | |
- size_t freeMemory() const; | |
- size_t totalMemory() const; | |
- | |
- // Checks whether device supports the given feature | |
- bool supports(FeatureSet feature_set) const; | |
- | |
- // Checks whether the GPU module can be run on the given device | |
- bool isCompatible() const; | |
- | |
- int deviceID() const { return device_id_; } | |
- | |
- private: | |
- void query(); | |
- void queryMemory(size_t& free_memory, size_t& total_memory) const; | |
- | |
- int device_id_; | |
- | |
- std::string name_; | |
- int multi_processor_count_; | |
- int majorVersion_; | |
- int minorVersion_; | |
- }; | |
- | |
- CV_EXPORTS void printCudaDeviceInfo(int device); | |
- CV_EXPORTS void printShortCudaDeviceInfo(int device); | |
- | |
- //////////////////////////////// GpuMat /////////////////////////////// | |
- | |
- //! Smart pointer for GPU memory with reference counting. Its interface is mostly similar with cv::Mat. | |
- class CV_EXPORTS GpuMat | |
- { | |
- public: | |
- //! default constructor | |
- GpuMat(); | |
- | |
- //! constructs GpuMatrix of the specified size and type (_type is CV_8UC1, CV_64FC3, CV_32SC(12) etc.) | |
- GpuMat(int rows, int cols, int type); | |
- GpuMat(Size size, int type); | |
- | |
- //! constucts GpuMatrix and fills it with the specified value _s. | |
- GpuMat(int rows, int cols, int type, Scalar s); | |
- GpuMat(Size size, int type, Scalar s); | |
- | |
- //! copy constructor | |
- GpuMat(const GpuMat& m); | |
- | |
- //! constructor for GpuMatrix headers pointing to user-allocated data | |
- GpuMat(int rows, int cols, int type, void* data, size_t step = Mat::AUTO_STEP); | |
- GpuMat(Size size, int type, void* data, size_t step = Mat::AUTO_STEP); | |
- | |
- //! creates a matrix header for a part of the bigger matrix | |
- GpuMat(const GpuMat& m, Range rowRange, Range colRange); | |
- GpuMat(const GpuMat& m, Rect roi); | |
- | |
- //! builds GpuMat from Mat. Perfom blocking upload to device. | |
- explicit GpuMat(const Mat& m); | |
- | |
- //! destructor - calls release() | |
- ~GpuMat(); | |
- | |
- //! assignment operators | |
- GpuMat& operator = (const GpuMat& m); | |
- | |
- //! pefroms blocking upload data to GpuMat. | |
- void upload(const Mat& m); | |
- | |
- //! downloads data from device to host memory. Blocking calls. | |
- void download(Mat& m) const; | |
- | |
- //! returns a new GpuMatrix header for the specified row | |
- GpuMat row(int y) const; | |
- //! returns a new GpuMatrix header for the specified column | |
- GpuMat col(int x) const; | |
- //! ... for the specified row span | |
- GpuMat rowRange(int startrow, int endrow) const; | |
- GpuMat rowRange(Range r) const; | |
- //! ... for the specified column span | |
- GpuMat colRange(int startcol, int endcol) const; | |
- GpuMat colRange(Range r) const; | |
- | |
- //! returns deep copy of the GpuMatrix, i.e. the data is copied | |
- GpuMat clone() const; | |
- //! copies the GpuMatrix content to "m". | |
- // It calls m.create(this->size(), this->type()). | |
- void copyTo(GpuMat& m) const; | |
- //! copies those GpuMatrix elements to "m" that are marked with non-zero mask elements. | |
- void copyTo(GpuMat& m, const GpuMat& mask) const; | |
- //! converts GpuMatrix to another datatype with optional scalng. See cvConvertScale. | |
- void convertTo(GpuMat& m, int rtype, double alpha = 1, double beta = 0) const; | |
- | |
- void assignTo(GpuMat& m, int type=-1) const; | |
- | |
- //! sets every GpuMatrix element to s | |
- GpuMat& operator = (Scalar s); | |
- //! sets some of the GpuMatrix elements to s, according to the mask | |
- GpuMat& setTo(Scalar s, const GpuMat& mask = GpuMat()); | |
- //! creates alternative GpuMatrix header for the same data, with different | |
- // number of channels and/or different number of rows. see cvReshape. | |
- GpuMat reshape(int cn, int rows = 0) const; | |
- | |
- //! allocates new GpuMatrix data unless the GpuMatrix already has specified size and type. | |
- // previous data is unreferenced if needed. | |
- void create(int rows, int cols, int type); | |
- void create(Size size, int type); | |
- //! decreases reference counter; | |
- // deallocate the data when reference counter reaches 0. | |
- void release(); | |
- | |
- //! swaps with other smart pointer | |
- void swap(GpuMat& mat); | |
- | |
- //! locates GpuMatrix header within a parent GpuMatrix. See below | |
- void locateROI(Size& wholeSize, Point& ofs) const; | |
- //! moves/resizes the current GpuMatrix ROI inside the parent GpuMatrix. | |
- GpuMat& adjustROI(int dtop, int dbottom, int dleft, int dright); | |
- //! extracts a rectangular sub-GpuMatrix | |
- // (this is a generalized form of row, rowRange etc.) | |
- GpuMat operator()(Range rowRange, Range colRange) const; | |
- GpuMat operator()(Rect roi) const; | |
- | |
- //! returns true iff the GpuMatrix data is continuous | |
- // (i.e. when there are no gaps between successive rows). | |
- // similar to CV_IS_GpuMat_CONT(cvGpuMat->type) | |
- bool isContinuous() const; | |
- //! returns element size in bytes, | |
- // similar to CV_ELEM_SIZE(cvMat->type) | |
- size_t elemSize() const; | |
- //! returns the size of element channel in bytes. | |
- size_t elemSize1() const; | |
- //! returns element type, similar to CV_MAT_TYPE(cvMat->type) | |
- int type() const; | |
- //! returns element type, similar to CV_MAT_DEPTH(cvMat->type) | |
- int depth() const; | |
- //! returns element type, similar to CV_MAT_CN(cvMat->type) | |
- int channels() const; | |
- //! returns step/elemSize1() | |
- size_t step1() const; | |
- //! returns GpuMatrix size: | |
- // width == number of columns, height == number of rows | |
- Size size() const; | |
- //! returns true if GpuMatrix data is NULL | |
- bool empty() const; | |
- | |
- //! returns pointer to y-th row | |
- uchar* ptr(int y = 0); | |
- const uchar* ptr(int y = 0) const; | |
- | |
- //! template version of the above method | |
- template<typename _Tp> _Tp* ptr(int y = 0); | |
- template<typename _Tp> const _Tp* ptr(int y = 0) const; | |
- | |
- template <typename _Tp> operator DevMem2D_<_Tp>() const; | |
- template <typename _Tp> operator PtrStep_<_Tp>() const; | |
- template <typename _Tp> operator PtrStep<_Tp>() const; | |
- | |
- /*! includes several bit-fields: | |
- - the magic signature | |
- - continuity flag | |
- - depth | |
- - number of channels | |
- */ | |
- int flags; | |
- | |
- //! the number of rows and columns | |
- int rows, cols; | |
- | |
- //! a distance between successive rows in bytes; includes the gap if any | |
- size_t step; | |
- | |
- //! pointer to the data | |
- uchar* data; | |
- | |
- //! pointer to the reference counter; | |
- // when GpuMatrix points to user-allocated data, the pointer is NULL | |
- int* refcount; | |
- | |
- //! helper fields used in locateROI and adjustROI | |
- uchar* datastart; | |
- uchar* dataend; | |
- }; | |
- | |
- //! Creates continuous GPU matrix | |
- CV_EXPORTS void createContinuous(int rows, int cols, int type, GpuMat& m); | |
- CV_EXPORTS GpuMat createContinuous(int rows, int cols, int type); | |
- CV_EXPORTS void createContinuous(Size size, int type, GpuMat& m); | |
- CV_EXPORTS GpuMat createContinuous(Size size, int type); | |
- | |
- //! Ensures that size of the given matrix is not less than (rows, cols) size | |
- //! and matrix type is match specified one too | |
- CV_EXPORTS void ensureSizeIsEnough(int rows, int cols, int type, GpuMat& m); | |
- CV_EXPORTS void ensureSizeIsEnough(Size size, int type, GpuMat& m); | |
- | |
- CV_EXPORTS GpuMat allocMatFromBuf(int rows, int cols, int type, GpuMat &mat); | |
- | |
- //////////////////////////////////////////////////////////////////////// | |
- // Error handling | |
- | |
- CV_EXPORTS void error(const char* error_string, const char* file, const int line, const char* func = ""); | |
- | |
- //////////////////////////////////////////////////////////////////////// | |
- //////////////////////////////////////////////////////////////////////// | |
- //////////////////////////////////////////////////////////////////////// | |
- | |
- inline GpuMat::GpuMat() | |
- : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0) | |
- { | |
- } | |
- | |
- inline GpuMat::GpuMat(int rows_, int cols_, int type_) | |
- : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0) | |
- { | |
- if (rows_ > 0 && cols_ > 0) | |
- create(rows_, cols_, type_); | |
- } | |
- | |
- inline GpuMat::GpuMat(Size size_, int type_) | |
- : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0) | |
- { | |
- if (size_.height > 0 && size_.width > 0) | |
- create(size_.height, size_.width, type_); | |
- } | |
- | |
- inline GpuMat::GpuMat(int rows_, int cols_, int type_, Scalar s_) | |
- : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0) | |
- { | |
- if (rows_ > 0 && cols_ > 0) | |
- { | |
- create(rows_, cols_, type_); | |
- setTo(s_); | |
- } | |
- } | |
- | |
- inline GpuMat::GpuMat(Size size_, int type_, Scalar s_) | |
- : flags(0), rows(0), cols(0), step(0), data(0), refcount(0), datastart(0), dataend(0) | |
- { | |
- if (size_.height > 0 && size_.width > 0) | |
- { | |
- create(size_.height, size_.width, type_); | |
- setTo(s_); | |
- } | |
- } | |
- | |
- inline GpuMat::~GpuMat() | |
- { | |
- release(); | |
- } | |
- | |
- inline GpuMat GpuMat::clone() const | |
- { | |
- GpuMat m; | |
- copyTo(m); | |
- return m; | |
- } | |
- | |
- inline void GpuMat::assignTo(GpuMat& m, int type) const | |
- { | |
- if (type < 0) | |
- m = *this; | |
- else | |
- convertTo(m, type); | |
- } | |
- | |
- inline size_t GpuMat::step1() const | |
- { | |
- return step / elemSize1(); | |
- } | |
- | |
- inline bool GpuMat::empty() const | |
- { | |
- return data == 0; | |
- } | |
- | |
- template<typename _Tp> inline _Tp* GpuMat::ptr(int y) | |
- { | |
- return (_Tp*)ptr(y); | |
- } | |
- | |
- template<typename _Tp> inline const _Tp* GpuMat::ptr(int y) const | |
- { | |
- return (const _Tp*)ptr(y); | |
- } | |
- | |
- inline void swap(GpuMat& a, GpuMat& b) | |
- { | |
- a.swap(b); | |
- } | |
- | |
- inline GpuMat GpuMat::row(int y) const | |
- { | |
- return GpuMat(*this, Range(y, y+1), Range::all()); | |
- } | |
- | |
- inline GpuMat GpuMat::col(int x) const | |
- { | |
- return GpuMat(*this, Range::all(), Range(x, x+1)); | |
- } | |
- | |
- inline GpuMat GpuMat::rowRange(int startrow, int endrow) const | |
- { | |
- return GpuMat(*this, Range(startrow, endrow), Range::all()); | |
- } | |
- | |
- inline GpuMat GpuMat::rowRange(Range r) const | |
- { | |
- return GpuMat(*this, r, Range::all()); | |
- } | |
- | |
- inline GpuMat GpuMat::colRange(int startcol, int endcol) const | |
- { | |
- return GpuMat(*this, Range::all(), Range(startcol, endcol)); | |
- } | |
- | |
- inline GpuMat GpuMat::colRange(Range r) const | |
- { | |
- return GpuMat(*this, Range::all(), r); | |
- } | |
- | |
- inline void GpuMat::create(Size size_, int type_) | |
- { | |
- create(size_.height, size_.width, type_); | |
- } | |
- | |
- inline GpuMat GpuMat::operator()(Range rowRange, Range colRange) const | |
- { | |
- return GpuMat(*this, rowRange, colRange); | |
- } | |
- | |
- inline GpuMat GpuMat::operator()(Rect roi) const | |
- { | |
- return GpuMat(*this, roi); | |
- } | |
- | |
- inline bool GpuMat::isContinuous() const | |
- { | |
- return (flags & Mat::CONTINUOUS_FLAG) != 0; | |
- } | |
- | |
- inline size_t GpuMat::elemSize() const | |
- { | |
- return CV_ELEM_SIZE(flags); | |
- } | |
- | |
- inline size_t GpuMat::elemSize1() const | |
- { | |
- return CV_ELEM_SIZE1(flags); | |
- } | |
- | |
- inline int GpuMat::type() const | |
- { | |
- return CV_MAT_TYPE(flags); | |
- } | |
- | |
- inline int GpuMat::depth() const | |
- { | |
- return CV_MAT_DEPTH(flags); | |
- } | |
- | |
- inline int GpuMat::channels() const | |
- { | |
- return CV_MAT_CN(flags); | |
- } | |
- | |
- inline Size GpuMat::size() const | |
- { | |
- return Size(cols, rows); | |
- } | |
- | |
- inline uchar* GpuMat::ptr(int y) | |
- { | |
- CV_DbgAssert((unsigned)y < (unsigned)rows); | |
- return data + step * y; | |
- } | |
- | |
- inline const uchar* GpuMat::ptr(int y) const | |
- { | |
- CV_DbgAssert((unsigned)y < (unsigned)rows); | |
- return data + step * y; | |
- } | |
- | |
- inline GpuMat& GpuMat::operator = (Scalar s) | |
- { | |
- setTo(s); | |
- return *this; | |
- } | |
- | |
- template <class T> inline GpuMat::operator DevMem2D_<T>() const | |
- { | |
- return DevMem2D_<T>(rows, cols, (T*)data, step); | |
- } | |
- | |
- template <class T> inline GpuMat::operator PtrStep_<T>() const | |
- { | |
- return PtrStep_<T>(static_cast< DevMem2D_<T> >(*this)); | |
- } | |
- | |
- template <class T> inline GpuMat::operator PtrStep<T>() const | |
- { | |
- return PtrStep<T>((T*)data, step); | |
- } | |
- | |
- inline GpuMat createContinuous(int rows, int cols, int type) | |
- { | |
- GpuMat m; | |
- createContinuous(rows, cols, type, m); | |
- return m; | |
- } | |
- | |
- inline void createContinuous(Size size, int type, GpuMat& m) | |
- { | |
- createContinuous(size.height, size.width, type, m); | |
- } | |
- | |
- inline GpuMat createContinuous(Size size, int type) | |
- { | |
- GpuMat m; | |
- createContinuous(size, type, m); | |
- return m; | |
- } | |
- | |
- inline void ensureSizeIsEnough(Size size, int type, GpuMat& m) | |
- { | |
- ensureSizeIsEnough(size.height, size.width, type, m); | |
- } | |
- | |
- inline void createContinuous(int rows, int cols, int type, GpuMat& m) | |
- { | |
- int area = rows * cols; | |
- if (!m.isContinuous() || m.type() != type || m.size().area() != area) | |
- ensureSizeIsEnough(1, area, type, m); | |
- m = m.reshape(0, rows); | |
- } | |
- | |
- inline void ensureSizeIsEnough(int rows, int cols, int type, GpuMat& m) | |
- { | |
- if (m.type() == type && m.rows >= rows && m.cols >= cols) | |
- m = m(Rect(0, 0, cols, rows)); | |
- else | |
- m.create(rows, cols, type); | |
- } | |
- | |
- inline GpuMat allocMatFromBuf(int rows, int cols, int type, GpuMat &mat) | |
- { | |
- if (!mat.empty() && mat.type() == type && mat.rows >= rows && mat.cols >= cols) | |
- return mat(Rect(0, 0, cols, rows)); | |
- return mat = GpuMat(rows, cols, type); | |
- } | |
-}} | |
- | |
-#endif // __cplusplus | |
- | |
-#endif // __OPENCV_GPUMAT_HPP__ | |
diff --git a/card.io/src/main/jni/opencv2/core/internal.hpp b/card.io/src/main/jni/opencv2/core/internal.hpp | |
deleted file mode 100644 | |
index 6e59af0..0000000 | |
--- a/card.io/src/main/jni/opencv2/core/internal.hpp | |
+++ /dev/null | |
@@ -1,736 +0,0 @@ | |
-/*M/////////////////////////////////////////////////////////////////////////////////////// | |
-// | |
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. | |
-// | |
-// By downloading, copying, installing or using the software you agree to this license. | |
-// If you do not agree to this license, do not download, install, | |
-// copy or use the software. | |
-// | |
-// | |
-// License Agreement | |
-// For Open Source Computer Vision Library | |
-// | |
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. | |
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved. | |
-// Third party copyrights are property of their respective owners. | |
-// | |
-// Redistribution and use in source and binary forms, with or without modification, | |
-// are permitted provided that the following conditions are met: | |
-// | |
-// * Redistribution's of source code must retain the above copyright notice, | |
-// this list of conditions and the following disclaimer. | |
-// | |
-// * Redistribution's in binary form must reproduce the above copyright notice, | |
-// this list of conditions and the following disclaimer in the documentation | |
-// and/or other materials provided with the distribution. | |
-// | |
-// * The name of the copyright holders may not be used to endorse or promote products | |
-// derived from this software without specific prior written permission. | |
-// | |
-// This software is provided by the copyright holders and contributors "as is" and | |
-// any express or implied warranties, including, but not limited to, the implied | |
-// warranties of merchantability and fitness for a particular purpose are disclaimed. | |
-// In no event shall the Intel Corporation or contributors be liable for any direct, | |
-// indirect, incidental, special, exemplary, or consequential damages | |
-// (including, but not limited to, procurement of substitute goods or services; | |
-// loss of use, data, or profits; or business interruption) however caused | |
-// and on any theory of liability, whether in contract, strict liability, | |
-// or tort (including negligence or otherwise) arising in any way out of | |
-// the use of this software, even if advised of the possibility of such damage. | |
-// | |
-//M*/ | |
- | |
-/* The header is for internal use and it is likely to change. | |
- It contains some macro definitions that are used in cxcore, cv, cvaux | |
- and, probably, other libraries. If you need some of this functionality, | |
- the safe way is to copy it into your code and rename the macros. | |
-*/ | |
-#ifndef __OPENCV_CORE_INTERNAL_HPP__ | |
-#define __OPENCV_CORE_INTERNAL_HPP__ | |
- | |
-#include <vector> | |
- | |
-#if defined WIN32 || defined _WIN32 | |
-# ifndef WIN32 | |
-# define WIN32 | |
-# endif | |
-# ifndef _WIN32 | |
-# define _WIN32 | |
-# endif | |
-#endif | |
- | |
-#if defined WIN32 || defined WINCE | |
-#include <windows.h> | |
-#undef small | |
-#undef min | |
-#undef max | |
-#else | |
-#include <pthread.h> | |
-#endif | |
- | |
-#ifdef __BORLANDC__ | |
-#ifndef WIN32 | |
- #define WIN32 | |
-#endif | |
-#ifndef _WIN32 | |
- #define _WIN32 | |
-#endif | |
- #define CV_DLL | |
- #undef _CV_ALWAYS_PROFILE_ | |
- #define _CV_ALWAYS_NO_PROFILE_ | |
-#endif | |
- | |
-#ifndef FALSE | |
-#define FALSE 0 | |
-#endif | |
-#ifndef TRUE | |
-#define TRUE 1 | |
-#endif | |
- | |
-#define __BEGIN__ __CV_BEGIN__ | |
-#define __END__ __CV_END__ | |
-#define EXIT __CV_EXIT__ | |
- | |
-#ifdef HAVE_IPP | |
-#include "ipp.h" | |
- | |
-CV_INLINE IppiSize ippiSize(int width, int height) | |
-{ | |
- IppiSize size = { width, height }; | |
- return size; | |
-} | |
-#endif | |
- | |
-#if defined __SSE2__ || _MSC_VER >= 1300 | |
-#include "emmintrin.h" | |
-#define CV_SSE 1 | |
-#define CV_SSE2 1 | |
-#if defined __SSE3__ || _MSC_VER >= 1500 | |
-#include "pmmintrin.h" | |
-#define CV_SSE3 1 | |
-#endif | |
-#if defined __SSSE3__ | |
-#include "tmmintrin.h" | |
-#define CV_SSSE3 1 | |
-#endif | |
-#else | |
-#define CV_SSE 0 | |
-#define CV_SSE2 0 | |
-#define CV_SSE3 0 | |
-#define CV_SSSE3 0 | |
-#endif | |
- | |
-#if defined ANDROID && defined __ARM_NEON__ && defined __GNUC__ | |
-#include "arm_neon.h" | |
-#define CV_NEON 1 | |
- | |
-#define CPU_HAS_NEON_FEATURE (true) | |
-//TODO: make real check using stuff from "cpu-features.h" | |
-//((bool)android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) | |
-#else | |
-#define CV_NEON 0 | |
-#define CPU_HAS_NEON_FEATURE (false) | |
-#endif | |
- | |
-#ifdef CV_ICC | |
-#define CV_ENABLE_UNROLLED 0 | |
-#else | |
-#define CV_ENABLE_UNROLLED 1 | |
-#endif | |
- | |
-#ifndef IPPI_CALL | |
-#define IPPI_CALL(func) CV_Assert((func) >= 0) | |
-#endif | |
- | |
-#ifdef HAVE_TBB | |
- #include "tbb/tbb_stddef.h" | |
- #if TBB_VERSION_MAJOR*100 + TBB_VERSION_MINOR >= 202 | |
- #include "tbb/tbb.h" | |
- #include "tbb/task.h" | |
- #undef min | |
- #undef max | |
- #else | |
- #undef HAVE_TBB | |
- #endif | |
-#endif | |
- | |
-#ifdef HAVE_EIGEN | |
- #include <Eigen/Core> | |
- #include "opencv2/core/eigen.hpp" | |
-#endif | |
- | |
-#ifdef __cplusplus | |
- | |
-#ifdef HAVE_TBB | |
- namespace cv | |
- { | |
- typedef tbb::blocked_range<int> BlockedRange; | |
- | |
- template<typename Body> static inline | |
- void parallel_for( const BlockedRange& range, const Body& body ) | |
- { | |
- tbb::parallel_for(range, body); | |
- } | |
- | |
- template<typename Iterator, typename Body> static inline | |
- void parallel_do( Iterator first, Iterator last, const Body& body ) | |
- { | |
- tbb::parallel_do(first, last, body); | |
- } | |
- | |
- typedef tbb::split Split; | |
- | |
- template<typename Body> static inline | |
- void parallel_reduce( const BlockedRange& range, Body& body ) | |
- { | |
- tbb::parallel_reduce(range, body); | |
- } | |
- | |
- typedef tbb::concurrent_vector<Rect> ConcurrentRectVector; | |
- typedef tbb::concurrent_vector<double> ConcurrentDoubleVector; | |
- } | |
-#else | |
- namespace cv | |
- { | |
- class BlockedRange | |
- { | |
- public: | |
- BlockedRange() : _begin(0), _end(0), _grainsize(0) {} | |
- BlockedRange(int b, int e, int g=1) : _begin(b), _end(e), _grainsize(g) {} | |
- int begin() const { return _begin; } | |
- int end() const { return _end; } | |
- int grainsize() const { return _grainsize; } | |
- | |
- protected: | |
- int _begin, _end, _grainsize; | |
- }; | |
- | |
- template<typename Body> static inline | |
- void parallel_for( const BlockedRange& range, const Body& body ) | |
- { | |
- body(range); | |
- } | |
- typedef std::vector<Rect> ConcurrentRectVector; | |
- typedef std::vector<double> ConcurrentDoubleVector; | |
- | |
- template<typename Iterator, typename Body> static inline | |
- void parallel_do( Iterator first, Iterator last, const Body& body ) | |
- { | |
- for( ; first != last; ++first ) | |
- body(*first); | |
- } | |
- | |
- class Split {}; | |
- | |
- template<typename Body> static inline | |
- void parallel_reduce( const BlockedRange& range, Body& body ) | |
- { | |
- body(range); | |
- } | |
- | |
- } | |
-#endif | |
-#endif | |
- | |
-/* maximal size of vector to run matrix operations on it inline (i.e. w/o ipp calls) */ | |
-#define CV_MAX_INLINE_MAT_OP_SIZE 10 | |
- | |
-/* maximal linear size of matrix to allocate it on stack. */ | |
-#define CV_MAX_LOCAL_MAT_SIZE 32 | |
- | |
-/* maximal size of local memory storage */ | |
-#define CV_MAX_LOCAL_SIZE \ | |
- (CV_MAX_LOCAL_MAT_SIZE*CV_MAX_LOCAL_MAT_SIZE*(int)sizeof(double)) | |
- | |
-/* default image row align (in bytes) */ | |
-#define CV_DEFAULT_IMAGE_ROW_ALIGN 4 | |
- | |
-/* matrices are continuous by default */ | |
-#define CV_DEFAULT_MAT_ROW_ALIGN 1 | |
- | |
-/* maximum size of dynamic memory buffer. | |
- cvAlloc reports an error if a larger block is requested. */ | |
-#define CV_MAX_ALLOC_SIZE (((size_t)1 << (sizeof(size_t)*8-2))) | |
- | |
-/* the alignment of all the allocated buffers */ | |
-#define CV_MALLOC_ALIGN 16 | |
- | |
-/* default alignment for dynamic data strucutures, resided in storages. */ | |
-#define CV_STRUCT_ALIGN ((int)sizeof(double)) | |
- | |
-/* default storage block size */ | |
-#define CV_STORAGE_BLOCK_SIZE ((1<<16) - 128) | |
- | |
-/* default memory block for sparse array elements */ | |
-#define CV_SPARSE_MAT_BLOCK (1<<12) | |
- | |
-/* initial hash table size */ | |
-#define CV_SPARSE_HASH_SIZE0 (1<<10) | |
- | |
-/* maximal average node_count/hash_size ratio beyond which hash table is resized */ | |
-#define CV_SPARSE_HASH_RATIO 3 | |
- | |
-/* max length of strings */ | |
-#define CV_MAX_STRLEN 1024 | |
- | |
-#if 0 /*def CV_CHECK_FOR_NANS*/ | |
- #define CV_CHECK_NANS( arr ) cvCheckArray((arr)) | |
-#else | |
- #define CV_CHECK_NANS( arr ) | |
-#endif | |
- | |
-/****************************************************************************************\ | |
-* Common declarations * | |
-\****************************************************************************************/ | |
- | |
-/* get alloca declaration */ | |
-#ifdef __GNUC__ | |
- #undef alloca | |
- #define alloca __builtin_alloca | |
- #define CV_HAVE_ALLOCA 1 | |
-#elif defined WIN32 || defined _WIN32 || \ | |
- defined WINCE || defined _MSC_VER || defined __BORLANDC__ | |
- #include <malloc.h> | |
- #define CV_HAVE_ALLOCA 1 | |
-#elif defined HAVE_ALLOCA_H | |
- #include <alloca.h> | |
- #define CV_HAVE_ALLOCA 1 | |
-#elif defined HAVE_ALLOCA | |
- #include <stdlib.h> | |
- #define CV_HAVE_ALLOCA 1 | |
-#else | |
- #undef CV_HAVE_ALLOCA | |
-#endif | |
- | |
-#ifdef __GNUC__ | |
-#define CV_DECL_ALIGNED(x) __attribute__ ((aligned (x))) | |
-#elif defined _MSC_VER | |
-#define CV_DECL_ALIGNED(x) __declspec(align(x)) | |
-#else | |
-#define CV_DECL_ALIGNED(x) | |
-#endif | |
- | |
-#if CV_HAVE_ALLOCA | |
-/* ! DO NOT make it an inline function */ | |
-#define cvStackAlloc(size) cvAlignPtr( alloca((size) + CV_MALLOC_ALIGN), CV_MALLOC_ALIGN ) | |
-#endif | |
- | |
-#ifndef CV_IMPL | |
-#define CV_IMPL CV_EXTERN_C | |
-#endif | |
- | |
-#define CV_DBG_BREAK() { volatile int* crashMe = 0; *crashMe = 0; } | |
- | |
-/* default step, set in case of continuous data | |
- to work around checks for valid step in some ipp functions */ | |
-#define CV_STUB_STEP (1 << 30) | |
- | |
-#define CV_SIZEOF_FLOAT ((int)sizeof(float)) | |
-#define CV_SIZEOF_SHORT ((int)sizeof(short)) | |
- | |
-#define CV_ORIGIN_TL 0 | |
-#define CV_ORIGIN_BL 1 | |
- | |
-/* IEEE754 constants and macros */ | |
-#define CV_POS_INF 0x7f800000 | |
-#define CV_NEG_INF 0x807fffff /* CV_TOGGLE_FLT(0xff800000) */ | |
-#define CV_1F 0x3f800000 | |
-#define CV_TOGGLE_FLT(x) ((x)^((int)(x) < 0 ? 0x7fffffff : 0)) | |
-#define CV_TOGGLE_DBL(x) \ | |
- ((x)^((int64)(x) < 0 ? CV_BIG_INT(0x7fffffffffffffff) : 0)) | |
- | |
-#define CV_NOP(a) (a) | |
-#define CV_ADD(a, b) ((a) + (b)) | |
-#define CV_SUB(a, b) ((a) - (b)) | |
-#define CV_MUL(a, b) ((a) * (b)) | |
-#define CV_AND(a, b) ((a) & (b)) | |
-#define CV_OR(a, b) ((a) | (b)) | |
-#define CV_XOR(a, b) ((a) ^ (b)) | |
-#define CV_ANDN(a, b) (~(a) & (b)) | |
-#define CV_ORN(a, b) (~(a) | (b)) | |
-#define CV_SQR(a) ((a) * (a)) | |
- | |
-#define CV_LT(a, b) ((a) < (b)) | |
-#define CV_LE(a, b) ((a) <= (b)) | |
-#define CV_EQ(a, b) ((a) == (b)) | |
-#define CV_NE(a, b) ((a) != (b)) | |
-#define CV_GT(a, b) ((a) > (b)) | |
-#define CV_GE(a, b) ((a) >= (b)) | |
- | |
-#define CV_NONZERO(a) ((a) != 0) | |
-#define CV_NONZERO_FLT(a) (((a)+(a)) != 0) | |
- | |
-/* general-purpose saturation macros */ | |
-#define CV_CAST_8U(t) (uchar)(!((t) & ~255) ? (t) : (t) > 0 ? 255 : 0) | |
-#define CV_CAST_8S(t) (schar)(!(((t)+128) & ~255) ? (t) : (t) > 0 ? 127 : -128) | |
-#define CV_CAST_16U(t) (ushort)(!((t) & ~65535) ? (t) : (t) > 0 ? 65535 : 0) | |
-#define CV_CAST_16S(t) (short)(!(((t)+32768) & ~65535) ? (t) : (t) > 0 ? 32767 : -32768) | |
-#define CV_CAST_32S(t) (int)(t) | |
-#define CV_CAST_64S(t) (int64)(t) | |
-#define CV_CAST_32F(t) (float)(t) | |
-#define CV_CAST_64F(t) (double)(t) | |
- | |
-#define CV_PASTE2(a,b) a##b | |
-#define CV_PASTE(a,b) CV_PASTE2(a,b) | |
- | |
-#define CV_EMPTY | |
-#define CV_MAKE_STR(a) #a | |
- | |
-#define CV_ZERO_OBJ(x) memset((x), 0, sizeof(*(x))) | |
- | |
-#define CV_DIM(static_array) ((int)(sizeof(static_array)/sizeof((static_array)[0]))) | |
- | |
-#define cvUnsupportedFormat "Unsupported format" | |
- | |
-CV_INLINE void* cvAlignPtr( const void* ptr, int align CV_DEFAULT(32) ) | |
-{ | |
- assert( (align & (align-1)) == 0 ); | |
- return (void*)( ((size_t)ptr + align - 1) & ~(size_t)(align-1) ); | |
-} | |
- | |
-CV_INLINE int cvAlign( int size, int align ) | |
-{ | |
- assert( (align & (align-1)) == 0 && size < INT_MAX ); | |
- return (size + align - 1) & -align; | |
-} | |
- | |
-CV_INLINE CvSize cvGetMatSize( const CvMat* mat ) | |
-{ | |
- CvSize size; | |
- size.width = mat->cols; | |
- size.height = mat->rows; | |
- return size; | |
-} | |
- | |
-#define CV_DESCALE(x,n) (((x) + (1 << ((n)-1))) >> (n)) | |
-#define CV_FLT_TO_FIX(x,n) cvRound((x)*(1<<(n))) | |
- | |
-/****************************************************************************************\ | |
- | |
- Generic implementation of QuickSort algorithm. | |
- ---------------------------------------------- | |
- Using this macro user can declare customized sort function that can be much faster | |
- than built-in qsort function because of lower overhead on elements | |
- comparison and exchange. The macro takes less_than (or LT) argument - a macro or function | |
- that takes 2 arguments returns non-zero if the first argument should be before the second | |
- one in the sorted sequence and zero otherwise. | |
- | |
- Example: | |
- | |
- Suppose that the task is to sort points by ascending of y coordinates and if | |
- y's are equal x's should ascend. | |
- | |
- The code is: | |
- ------------------------------------------------------------------------------ | |
- #define cmp_pts( pt1, pt2 ) \ | |
- ((pt1).y < (pt2).y || ((pt1).y < (pt2).y && (pt1).x < (pt2).x)) | |
- | |
- [static] CV_IMPLEMENT_QSORT( icvSortPoints, CvPoint, cmp_pts ) | |
- ------------------------------------------------------------------------------ | |
- | |
- After that the function "void icvSortPoints( CvPoint* array, size_t total, int aux );" | |
- is available to user. | |
- | |
- aux is an additional parameter, which can be used when comparing elements. | |
- The current implementation was derived from *BSD system qsort(): | |
- | |
- * Copyright (c) 1992, 1993 | |
- * The Regents of the University of California. All rights reserved. | |
- * | |
- * Redistribution and use in source and binary forms, with or without | |
- * modification, are permitted provided that the following conditions | |
- * are met: | |
- * 1. Redistributions of source code must retain the above copyright | |
- * notice, this list of conditions and the following disclaimer. | |
- * 2. Redistributions in binary form must reproduce the above copyright | |
- * notice, this list of conditions and the following disclaimer in the | |
- * documentation and/or other materials provided with the distribution. | |
- * 3. All advertising materials mentioning features or use of this software | |
- * must display the following acknowledgement: | |
- * This product includes software developed by the University of | |
- * California, Berkeley and its contributors. | |
- * 4. Neither the name of the University nor the names of its contributors | |
- * may be used to endorse or promote products derived from this software | |
- * without specific prior written permission. | |
- * | |
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
- * SUCH DAMAGE. | |
- | |
-\****************************************************************************************/ | |
- | |
-#define CV_IMPLEMENT_QSORT_EX( func_name, T, LT, user_data_type ) \ | |
-void func_name( T *array, size_t total, user_data_type aux ) \ | |
-{ \ | |
- int isort_thresh = 7; \ | |
- T t; \ | |
- int sp = 0; \ | |
- \ | |
- struct \ | |
- { \ | |
- T *lb; \ | |
- T *ub; \ | |
- } \ | |
- stack[48]; \ | |
- \ | |
- aux = aux; \ | |
- \ | |
- if( total <= 1 ) \ | |
- return; \ | |
- \ | |
- stack[0].lb = array; \ | |
- stack[0].ub = array + (total - 1); \ | |
- \ | |
- while( sp >= 0 ) \ | |
- { \ | |
- T* left = stack[sp].lb; \ | |
- T* right = stack[sp--].ub; \ | |
- \ | |
- for(;;) \ | |
- { \ | |
- int i, n = (int)(right - left) + 1, m; \ | |
- T* ptr; \ | |
- T* ptr2; \ | |
- \ | |
- if( n <= isort_thresh ) \ | |
- { \ | |
- insert_sort: \ | |
- for( ptr = left + 1; ptr <= right; ptr++ ) \ | |
- { \ | |
- for( ptr2 = ptr; ptr2 > left && LT(ptr2[0],ptr2[-1]); ptr2--) \ | |
- CV_SWAP( ptr2[0], ptr2[-1], t ); \ | |
- } \ | |
- break; \ | |
- } \ | |
- else \ | |
- { \ | |
- T* left0; \ | |
- T* left1; \ | |
- T* right0; \ | |
- T* right1; \ | |
- T* pivot; \ | |
- T* a; \ | |
- T* b; \ | |
- T* c; \ | |
- int swap_cnt = 0; \ | |
- \ | |
- left0 = left; \ | |
- right0 = right; \ | |
- pivot = left + (n/2); \ | |
- \ | |
- if( n > 40 ) \ | |
- { \ | |
- int d = n / 8; \ | |
- a = left, b = left + d, c = left + 2*d; \ | |
- left = LT(*a, *b) ? (LT(*b, *c) ? b : (LT(*a, *c) ? c : a)) \ | |
- : (LT(*c, *b) ? b : (LT(*a, *c) ? a : c)); \ | |
- \ | |
- a = pivot - d, b = pivot, c = pivot + d; \ | |
- pivot = LT(*a, *b) ? (LT(*b, *c) ? b : (LT(*a, *c) ? c : a)) \ | |
- : (LT(*c, *b) ? b : (LT(*a, *c) ? a : c)); \ | |
- \ | |
- a = right - 2*d, b = right - d, c = right; \ | |
- right = LT(*a, *b) ? (LT(*b, *c) ? b : (LT(*a, *c) ? c : a)) \ | |
- : (LT(*c, *b) ? b : (LT(*a, *c) ? a : c)); \ | |
- } \ | |
- \ | |
- a = left, b = pivot, c = right; \ | |
- pivot = LT(*a, *b) ? (LT(*b, *c) ? b : (LT(*a, *c) ? c : a)) \ | |
- : (LT(*c, *b) ? b : (LT(*a, *c) ? a : c)); \ | |
- if( pivot != left0 ) \ | |
- { \ | |
- CV_SWAP( *pivot, *left0, t ); \ | |
- pivot = left0; \ | |
- } \ | |
- left = left1 = left0 + 1; \ | |
- right = right1 = right0; \ | |
- \ | |
- for(;;) \ | |
- { \ | |
- while( left <= right && !LT(*pivot, *left) ) \ | |
- { \ | |
- if( !LT(*left, *pivot) ) \ | |
- { \ | |
- if( left > left1 ) \ | |
- CV_SWAP( *left1, *left, t ); \ | |
- swap_cnt = 1; \ | |
- left1++; \ | |
- } \ | |
- left++; \ | |
- } \ | |
- \ | |
- while( left <= right && !LT(*right, *pivot) ) \ | |
- { \ | |
- if( !LT(*pivot, *right) ) \ | |
- { \ | |
- if( right < right1 ) \ | |
- CV_SWAP( *right1, *right, t ); \ | |
- swap_cnt = 1; \ | |
- right1--; \ | |
- } \ | |
- right--; \ | |
- } \ | |
- \ | |
- if( left > right ) \ | |
- break; \ | |
- CV_SWAP( *left, *right, t ); \ | |
- swap_cnt = 1; \ | |
- left++; \ | |
- right--; \ | |
- } \ | |
- \ | |
- if( swap_cnt == 0 ) \ | |
- { \ | |
- left = left0, right = right0; \ | |
- goto insert_sort; \ | |
- } \ | |
- \ | |
- n = MIN( (int)(left1 - left0), (int)(left - left1) ); \ | |
- for( i = 0; i < n; i++ ) \ | |
- CV_SWAP( left0[i], left[i-n], t ); \ | |
- \ | |
- n = MIN( (int)(right0 - right1), (int)(right1 - right) ); \ | |
- for( i = 0; i < n; i++ ) \ | |
- CV_SWAP( left[i], right0[i-n+1], t ); \ | |
- n = (int)(left - left1); \ | |
- m = (int)(right1 - right); \ | |
- if( n > 1 ) \ | |
- { \ | |
- if( m > 1 ) \ | |
- { \ | |
- if( n > m ) \ | |
- { \ | |
- stack[++sp].lb = left0; \ | |
- stack[sp].ub = left0 + n - 1; \ | |
- left = right0 - m + 1, right = right0; \ | |
- } \ | |
- else \ | |
- { \ | |
- stack[++sp].lb = right0 - m + 1; \ | |
- stack[sp].ub = right0; \ | |
- left = left0, right = left0 + n - 1; \ | |
- } \ | |
- } \ | |
- else \ | |
- left = left0, right = left0 + n - 1; \ | |
- } \ | |
- else if( m > 1 ) \ | |
- left = right0 - m + 1, right = right0; \ | |
- else \ | |
- break; \ | |
- } \ | |
- } \ | |
- } \ | |
-} | |
- | |
-#define CV_IMPLEMENT_QSORT( func_name, T, cmp ) \ | |
- CV_IMPLEMENT_QSORT_EX( func_name, T, cmp, int ) | |
- | |
-/****************************************************************************************\ | |
-* Structures and macros for integration with IPP * | |
-\****************************************************************************************/ | |
- | |
-/* IPP-compatible return codes */ | |
-typedef enum CvStatus | |
-{ | |
- CV_BADMEMBLOCK_ERR = -113, | |
- CV_INPLACE_NOT_SUPPORTED_ERR= -112, | |
- CV_UNMATCHED_ROI_ERR = -111, | |
- CV_NOTFOUND_ERR = -110, | |
- CV_BADCONVERGENCE_ERR = -109, | |
- | |
- CV_BADDEPTH_ERR = -107, | |
- CV_BADROI_ERR = -106, | |
- CV_BADHEADER_ERR = -105, | |
- CV_UNMATCHED_FORMATS_ERR = -104, | |
- CV_UNSUPPORTED_COI_ERR = -103, | |
- CV_UNSUPPORTED_CHANNELS_ERR = -102, | |
- CV_UNSUPPORTED_DEPTH_ERR = -101, | |
- CV_UNSUPPORTED_FORMAT_ERR = -100, | |
- | |
- CV_BADARG_ERR = -49, //ipp comp | |
- CV_NOTDEFINED_ERR = -48, //ipp comp | |
- | |
- CV_BADCHANNELS_ERR = -47, //ipp comp | |
- CV_BADRANGE_ERR = -44, //ipp comp | |
- CV_BADSTEP_ERR = -29, //ipp comp | |
- | |
- CV_BADFLAG_ERR = -12, | |
- CV_DIV_BY_ZERO_ERR = -11, //ipp comp | |
- CV_BADCOEF_ERR = -10, | |
- | |
- CV_BADFACTOR_ERR = -7, | |
- CV_BADPOINT_ERR = -6, | |
- CV_BADSCALE_ERR = -4, | |
- CV_OUTOFMEM_ERR = -3, | |
- CV_NULLPTR_ERR = -2, | |
- CV_BADSIZE_ERR = -1, | |
- CV_NO_ERR = 0, | |
- CV_OK = CV_NO_ERR | |
-} | |
-CvStatus; | |
- | |
-#define CV_NOTHROW throw() | |
- | |
-typedef struct CvFuncTable | |
-{ | |
- void* fn_2d[CV_DEPTH_MAX]; | |
-} | |
-CvFuncTable; | |
- | |
-typedef struct CvBigFuncTable | |
-{ | |
- void* fn_2d[CV_DEPTH_MAX*4]; | |
-} | |
-CvBigFuncTable; | |
- | |
-#define CV_INIT_FUNC_TAB( tab, FUNCNAME, FLAG ) \ | |
- (tab).fn_2d[CV_8U] = (void*)FUNCNAME##_8u##FLAG; \ | |
- (tab).fn_2d[CV_8S] = 0; \ | |
- (tab).fn_2d[CV_16U] = (void*)FUNCNAME##_16u##FLAG; \ | |
- (tab).fn_2d[CV_16S] = (void*)FUNCNAME##_16s##FLAG; \ | |
- (tab).fn_2d[CV_32S] = (void*)FUNCNAME##_32s##FLAG; \ | |
- (tab).fn_2d[CV_32F] = (void*)FUNCNAME##_32f##FLAG; \ | |
- (tab).fn_2d[CV_64F] = (void*)FUNCNAME##_64f##FLAG | |
- | |
-//! OpenGL extension table | |
-class CV_EXPORTS CvOpenGlFuncTab | |
-{ | |
-public: | |
- virtual ~CvOpenGlFuncTab(); | |
- | |
- virtual void genBuffers(int n, unsigned int* buffers) const = 0; | |
- virtual void deleteBuffers(int n, const unsigned int* buffers) const = 0; | |
- | |
- virtual void bufferData(unsigned int target, ptrdiff_t size, const void* data, unsigned int usage) const = 0; | |
- virtual void bufferSubData(unsigned int target, ptrdiff_t offset, ptrdiff_t size, const void* data) const = 0; | |
- | |
- virtual void bindBuffer(unsigned int target, unsigned int buffer) const = 0; | |
- | |
- virtual void* mapBuffer(unsigned int target, unsigned int access) const = 0; | |
- virtual void unmapBuffer(unsigned int target) const = 0; | |
- | |
- virtual void generateBitmapFont(const std::string& family, int height, int weight, bool italic, bool underline, int start, int count, int base) const = 0; | |
- | |
- virtual bool isGlContextInitialized() const = 0; | |
-}; | |
- | |
-CV_EXPORTS void icvSetOpenGlFuncTab(const CvOpenGlFuncTab* tab); | |
- | |
-CV_EXPORTS bool icvCheckGlError(const char* file, const int line, const char* func = ""); | |
- | |
-#if defined(__GNUC__) | |
- #define CV_CheckGlError() CV_DbgAssert( (::icvCheckGlError(__FILE__, __LINE__, __func__)) ) | |
-#else | |
- #define CV_CheckGlError() CV_DbgAssert( (::icvCheckGlError(__FILE__, __LINE__)) ) | |
-#endif | |
- | |
-#endif | |
diff --git a/card.io/src/main/jni/opencv2/core/mat.hpp b/card.io/src/main/jni/opencv2/core/mat.hpp | |
deleted file mode 100644 | |
index d9ab8d7..0000000 | |
--- a/card.io/src/main/jni/opencv2/core/mat.hpp | |
+++ /dev/null | |
@@ -1,2584 +0,0 @@ | |
-/*M/////////////////////////////////////////////////////////////////////////////////////// | |
-// | |
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. | |
-// | |
-// By downloading, copying, installing or using the software you agree to this license. | |
-// If you do not agree to this license, do not download, install, | |
-// copy or use the software. | |
-// | |
-// | |
-// License Agreement | |
-// For Open Source Computer Vision Library | |
-// | |
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. | |
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved. | |
-// Third party copyrights are property of their respective owners. | |
-// | |
-// Redistribution and use in source and binary forms, with or without modification, | |
-// are permitted provided that the following conditions are met: | |
-// | |
-// * Redistribution's of source code must retain the above copyright notice, | |
-// this list of conditions and the following disclaimer. | |
-// | |
-// * Redistribution's in binary form must reproduce the above copyright notice, | |
-// this list of conditions and the following disclaimer in the documentation | |
-// and/or other materials provided with the distribution. | |
-// | |
-// * The name of the copyright holders may not be used to endorse or promote products | |
-// derived from this software without specific prior written permission. | |
-// | |
-// This software is provided by the copyright holders and contributors "as is" and | |
-// any express or implied warranties, including, but not limited to, the implied | |
-// warranties of merchantability and fitness for a particular purpose are disclaimed. | |
-// In no event shall the Intel Corporation or contributors be liable for any direct, | |
-// indirect, incidental, special, exemplary, or consequential damages | |
-// (including, but not limited to, procurement of substitute goods or services; | |
-// loss of use, data, or profits; or business interruption) however caused | |
-// and on any theory of liability, whether in contract, strict liability, | |
-// or tort (including negligence or otherwise) arising in any way out of | |
-// the use of this software, even if advised of the possibility of such damage. | |
-// | |
-//M*/ | |
- | |
-#ifndef __OPENCV_CORE_MATRIX_OPERATIONS_HPP__ | |
-#define __OPENCV_CORE_MATRIX_OPERATIONS_HPP__ | |
- | |
-#ifndef SKIP_INCLUDES | |
-#include <limits.h> | |
-#include <string.h> | |
-#endif // SKIP_INCLUDES | |
- | |
-#ifdef __cplusplus | |
- | |
-namespace cv | |
-{ | |
- | |
-//////////////////////////////// Mat //////////////////////////////// | |
- | |
-inline void Mat::initEmpty() | |
-{ | |
- flags = MAGIC_VAL; | |
- dims = rows = cols = 0; | |
- data = datastart = dataend = datalimit = 0; | |
- refcount = 0; | |
- allocator = 0; | |
-} | |
- | |
-inline Mat::Mat() : size(&rows) | |
-{ | |
- initEmpty(); | |
-} | |
- | |
-inline Mat::Mat(int _rows, int _cols, int _type) : size(&rows) | |
-{ | |
- initEmpty(); | |
- create(_rows, _cols, _type); | |
-} | |
- | |
-inline Mat::Mat(int _rows, int _cols, int _type, const Scalar& _s) : size(&rows) | |
-{ | |
- initEmpty(); | |
- create(_rows, _cols, _type); | |
- *this = _s; | |
-} | |
- | |
-inline Mat::Mat(Size _sz, int _type) : size(&rows) | |
-{ | |
- initEmpty(); | |
- create( _sz.height, _sz.width, _type ); | |
-} | |
- | |
-inline Mat::Mat(Size _sz, int _type, const Scalar& _s) : size(&rows) | |
-{ | |
- initEmpty(); | |
- create(_sz.height, _sz.width, _type); | |
- *this = _s; | |
-} | |
- | |
-inline Mat::Mat(int _dims, const int* _sz, int _type) : size(&rows) | |
-{ | |
- initEmpty(); | |
- create(_dims, _sz, _type); | |
-} | |
- | |
-inline Mat::Mat(int _dims, const int* _sz, int _type, const Scalar& _s) : size(&rows) | |
-{ | |
- initEmpty(); | |
- create(_dims, _sz, _type); | |
- *this = _s; | |
-} | |
- | |
-inline Mat::Mat(const Mat& m) | |
- : flags(m.flags), dims(m.dims), rows(m.rows), cols(m.cols), data(m.data), | |
- refcount(m.refcount), datastart(m.datastart), dataend(m.dataend), | |
- datalimit(m.datalimit), allocator(m.allocator), size(&rows) | |
-{ | |
- if( refcount ) | |
- CV_XADD(refcount, 1); | |
- if( m.dims <= 2 ) | |
- { | |
- step[0] = m.step[0]; step[1] = m.step[1]; | |
- } | |
- else | |
- { | |
- dims = 0; | |
- copySize(m); | |
- } | |
-} | |
- | |
-inline Mat::Mat(int _rows, int _cols, int _type, void* _data, size_t _step) | |
- : flags(MAGIC_VAL + (_type & TYPE_MASK)), dims(2), rows(_rows), cols(_cols), | |
- data((uchar*)_data), refcount(0), datastart((uchar*)_data), dataend(0), | |
- datalimit(0), allocator(0), size(&rows) | |
-{ | |
- size_t esz = CV_ELEM_SIZE(_type), minstep = cols*esz; | |
- if( _step == AUTO_STEP ) | |
- { | |
- _step = minstep; | |
- flags |= CONTINUOUS_FLAG; | |
- } | |
- else | |
- { | |
- if( rows == 1 ) _step = minstep; | |
- CV_DbgAssert( _step >= minstep ); | |
- flags |= _step == minstep ? CONTINUOUS_FLAG : 0; | |
- } | |
- step[0] = _step; step[1] = esz; | |
- datalimit = datastart + _step*rows; | |
- dataend = datalimit - _step + minstep; | |
-} | |
- | |
-inline Mat::Mat(Size _sz, int _type, void* _data, size_t _step) | |
- : flags(MAGIC_VAL + (_type & TYPE_MASK)), dims(2), rows(_sz.height), cols(_sz.width), | |
- data((uchar*)_data), refcount(0), datastart((uchar*)_data), dataend(0), | |
- datalimit(0), allocator(0), size(&rows) | |
-{ | |
- size_t esz = CV_ELEM_SIZE(_type), minstep = cols*esz; | |
- if( _step == AUTO_STEP ) | |
- { | |
- _step = minstep; | |
- flags |= CONTINUOUS_FLAG; | |
- } | |
- else | |
- { | |
- if( rows == 1 ) _step = minstep; | |
- CV_DbgAssert( _step >= minstep ); | |
- flags |= _step == minstep ? CONTINUOUS_FLAG : 0; | |
- } | |
- step[0] = _step; step[1] = esz; | |
- datalimit = datastart + _step*rows; | |
- dataend = datalimit - _step + minstep; | |
-} | |
- | |
- | |
-template<typename _Tp> inline Mat::Mat(const vector<_Tp>& vec, bool copyData) | |
- : flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG), | |
- dims(2), rows((int)vec.size()), cols(1), data(0), refcount(0), | |
- datastart(0), dataend(0), allocator(0), size(&rows) | |
-{ | |
- if(vec.empty()) | |
- return; | |
- if( !copyData ) | |
- { | |
- step[0] = step[1] = sizeof(_Tp); | |
- data = datastart = (uchar*)&vec[0]; | |
- datalimit = dataend = datastart + rows*step[0]; | |
- } | |
- else | |
- Mat((int)vec.size(), 1, DataType<_Tp>::type, (uchar*)&vec[0]).copyTo(*this); | |
-} | |
- | |
- | |
-template<typename _Tp, int n> inline Mat::Mat(const Vec<_Tp, n>& vec, bool copyData) | |
- : flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG), | |
- dims(2), rows(n), cols(1), data(0), refcount(0), | |
- datastart(0), dataend(0), allocator(0), size(&rows) | |
-{ | |
- if( !copyData ) | |
- { | |
- step[0] = step[1] = sizeof(_Tp); | |
- data = datastart = (uchar*)vec.val; | |
- datalimit = dataend = datastart + rows*step[0]; | |
- } | |
- else | |
- Mat(n, 1, DataType<_Tp>::type, (void*)vec.val).copyTo(*this); | |
-} | |
- | |
- | |
-template<typename _Tp, int m, int n> inline Mat::Mat(const Matx<_Tp,m,n>& M, bool copyData) | |
- : flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG), | |
- dims(2), rows(m), cols(n), data(0), refcount(0), | |
- datastart(0), dataend(0), allocator(0), size(&rows) | |
-{ | |
- if( !copyData ) | |
- { | |
- step[0] = cols*sizeof(_Tp); | |
- step[1] = sizeof(_Tp); | |
- data = datastart = (uchar*)M.val; | |
- datalimit = dataend = datastart + rows*step[0]; | |
- } | |
- else | |
- Mat(m, n, DataType<_Tp>::type, (uchar*)M.val).copyTo(*this); | |
-} | |
- | |
- | |
-template<typename _Tp> inline Mat::Mat(const Point_<_Tp>& pt, bool copyData) | |
- : flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG), | |
- dims(2), rows(2), cols(1), data(0), refcount(0), | |
- datastart(0), dataend(0), allocator(0), size(&rows) | |
-{ | |
- if( !copyData ) | |
- { | |
- step[0] = step[1] = sizeof(_Tp); | |
- data = datastart = (uchar*)&pt.x; | |
- datalimit = dataend = datastart + rows*step[0]; | |
- } | |
- else | |
- { | |
- create(2, 1, DataType<_Tp>::type); | |
- ((_Tp*)data)[0] = pt.x; | |
- ((_Tp*)data)[1] = pt.y; | |
- } | |
-} | |
- | |
- | |
-template<typename _Tp> inline Mat::Mat(const Point3_<_Tp>& pt, bool copyData) | |
- : flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG), | |
- dims(2), rows(3), cols(1), data(0), refcount(0), | |
- datastart(0), dataend(0), allocator(0), size(&rows) | |
-{ | |
- if( !copyData ) | |
- { | |
- step[0] = step[1] = sizeof(_Tp); | |
- data = datastart = (uchar*)&pt.x; | |
- datalimit = dataend = datastart + rows*step[0]; | |
- } | |
- else | |
- { | |
- create(3, 1, DataType<_Tp>::type); | |
- ((_Tp*)data)[0] = pt.x; | |
- ((_Tp*)data)[1] = pt.y; | |
- ((_Tp*)data)[2] = pt.z; | |
- } | |
-} | |
- | |
- | |
-template<typename _Tp> inline Mat::Mat(const MatCommaInitializer_<_Tp>& commaInitializer) | |
- : flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG), | |
- dims(0), rows(0), cols(0), data(0), refcount(0), | |
- datastart(0), dataend(0), allocator(0), size(&rows) | |
-{ | |
- *this = *commaInitializer; | |
-} | |
- | |
-inline Mat::~Mat() | |
-{ | |
- release(); | |
- if( step.p != step.buf ) | |
- fastFree(step.p); | |
-} | |
- | |
-inline Mat& Mat::operator = (const Mat& m) | |
-{ | |
- if( this != &m ) | |
- { | |
- if( m.refcount ) | |
- CV_XADD(m.refcount, 1); | |
- release(); | |
- flags = m.flags; | |
- if( dims <= 2 && m.dims <= 2 ) | |
- { | |
- dims = m.dims; | |
- rows = m.rows; | |
- cols = m.cols; | |
- step[0] = m.step[0]; | |
- step[1] = m.step[1]; | |
- } | |
- else | |
- copySize(m); | |
- data = m.data; | |
- datastart = m.datastart; | |
- dataend = m.dataend; | |
- datalimit = m.datalimit; | |
- refcount = m.refcount; | |
- allocator = m.allocator; | |
- } | |
- return *this; | |
-} | |
- | |
-inline Mat Mat::row(int y) const { return Mat(*this, Range(y, y+1), Range::all()); } | |
-inline Mat Mat::col(int x) const { return Mat(*this, Range::all(), Range(x, x+1)); } | |
-inline Mat Mat::rowRange(int startrow, int endrow) const | |
- { return Mat(*this, Range(startrow, endrow), Range::all()); } | |
-inline Mat Mat::rowRange(const Range& r) const | |
- { return Mat(*this, r, Range::all()); } | |
-inline Mat Mat::colRange(int startcol, int endcol) const | |
- { return Mat(*this, Range::all(), Range(startcol, endcol)); } | |
-inline Mat Mat::colRange(const Range& r) const | |
- { return Mat(*this, Range::all(), r); } | |
- | |
-inline Mat Mat::diag(const Mat& d) | |
-{ | |
- CV_Assert( d.cols == 1 || d.rows == 1 ); | |
- int len = d.rows + d.cols - 1; | |
- Mat m(len, len, d.type(), Scalar(0)), md = m.diag(); | |
- d.copyTo(md); | |
- return m; | |
-} | |
- | |
-inline Mat Mat::clone() const | |
-{ | |
- Mat m; | |
- copyTo(m); | |
- return m; | |
-} | |
- | |
-inline void Mat::assignTo( Mat& m, int type ) const | |
-{ | |
- if( type < 0 ) | |
- m = *this; | |
- else | |
- convertTo(m, type); | |
-} | |
- | |
-inline void Mat::create(int _rows, int _cols, int _type) | |
-{ | |
- _type &= TYPE_MASK; | |
- if( dims <= 2 && rows == _rows && cols == _cols && type() == _type && data ) | |
- return; | |
- int sz[] = {_rows, _cols}; | |
- create(2, sz, _type); | |
-} | |
- | |
-inline void Mat::create(Size _sz, int _type) | |
-{ | |
- create(_sz.height, _sz.width, _type); | |
-} | |
- | |
-inline void Mat::addref() | |
-{ if( refcount ) CV_XADD(refcount, 1); } | |
- | |
-inline void Mat::release() | |
-{ | |
- if( refcount && CV_XADD(refcount, -1) == 1 ) | |
- deallocate(); | |
- data = datastart = dataend = datalimit = 0; | |
- size.p[0] = 0; | |
- refcount = 0; | |
-} | |
- | |
-inline Mat Mat::operator()( Range rowRange, Range colRange ) const | |
-{ | |
- return Mat(*this, rowRange, colRange); | |
-} | |
- | |
-inline Mat Mat::operator()( const Rect& roi ) const | |
-{ return Mat(*this, roi); } | |
- | |
-inline Mat Mat::operator()(const Range* ranges) const | |
-{ | |
- return Mat(*this, ranges); | |
-} | |
- | |
-inline Mat::operator CvMat() const | |
-{ | |
- CV_DbgAssert(dims <= 2); | |
- CvMat m = cvMat(rows, dims == 1 ? 1 : cols, type(), data); | |
- m.step = (int)step[0]; | |
- m.type = (m.type & ~CONTINUOUS_FLAG) | (flags & CONTINUOUS_FLAG); | |
- return m; | |
-} | |
- | |
-inline bool Mat::isContinuous() const { return (flags & CONTINUOUS_FLAG) != 0; } | |
-inline bool Mat::isSubmatrix() const { return (flags & SUBMATRIX_FLAG) != 0; } | |
-inline size_t Mat::elemSize() const { return dims > 0 ? step.p[dims-1] : 0; } | |
-inline size_t Mat::elemSize1() const { return CV_ELEM_SIZE1(flags); } | |
-inline int Mat::type() const { return CV_MAT_TYPE(flags); } | |
-inline int Mat::depth() const { return CV_MAT_DEPTH(flags); } | |
-inline int Mat::channels() const { return CV_MAT_CN(flags); } | |
-inline size_t Mat::step1(int i) const { return step.p[i]/elemSize1(); } | |
-inline bool Mat::empty() const { return data == 0 || total() == 0; } | |
-inline size_t Mat::total() const | |
-{ | |
- if( dims <= 2 ) | |
- return rows*cols; | |
- size_t p = 1; | |
- for( int i = 0; i < dims; i++ ) | |
- p *= size[i]; | |
- return p; | |
-} | |
- | |
-inline uchar* Mat::ptr(int y) | |
-{ | |
- CV_DbgAssert( y == 0 || (data && dims >= 1 && (unsigned)y < (unsigned)size.p[0]) ); | |
- return data + step.p[0]*y; | |
-} | |
- | |
-inline const uchar* Mat::ptr(int y) const | |
-{ | |
- CV_DbgAssert( y == 0 || (data && dims >= 1 && (unsigned)y < (unsigned)size.p[0]) ); | |
- return data + step.p[0]*y; | |
-} | |
- | |
-template<typename _Tp> inline _Tp* Mat::ptr(int y) | |
-{ | |
- CV_DbgAssert( y == 0 || (data && dims >= 1 && (unsigned)y < (unsigned)size.p[0]) ); | |
- return (_Tp*)(data + step.p[0]*y); | |
-} | |
- | |
-template<typename _Tp> inline const _Tp* Mat::ptr(int y) const | |
-{ | |
- CV_DbgAssert( y == 0 || (data && dims >= 1 && data && (unsigned)y < (unsigned)size.p[0]) ); | |
- return (const _Tp*)(data + step.p[0]*y); | |
-} | |
- | |
- | |
-inline uchar* Mat::ptr(int i0, int i1) | |
-{ | |
- CV_DbgAssert( dims >= 2 && data && | |
- (unsigned)i0 < (unsigned)size.p[0] && | |
- (unsigned)i1 < (unsigned)size.p[1] ); | |
- return data + i0*step.p[0] + i1*step.p[1]; | |
-} | |
- | |
-inline const uchar* Mat::ptr(int i0, int i1) const | |
-{ | |
- CV_DbgAssert( dims >= 2 && data && | |
- (unsigned)i0 < (unsigned)size.p[0] && | |
- (unsigned)i1 < (unsigned)size.p[1] ); | |
- return data + i0*step.p[0] + i1*step.p[1]; | |
-} | |
- | |
-template<typename _Tp> inline _Tp* Mat::ptr(int i0, int i1) | |
-{ | |
- CV_DbgAssert( dims >= 2 && data && | |
- (unsigned)i0 < (unsigned)size.p[0] && | |
- (unsigned)i1 < (unsigned)size.p[1] ); | |
- return (_Tp*)(data + i0*step.p[0] + i1*step.p[1]); | |
-} | |
- | |
-template<typename _Tp> inline const _Tp* Mat::ptr(int i0, int i1) const | |
-{ | |
- CV_DbgAssert( dims >= 2 && data && | |
- (unsigned)i0 < (unsigned)size.p[0] && | |
- (unsigned)i1 < (unsigned)size.p[1] ); | |
- return (const _Tp*)(data + i0*step.p[0] + i1*step.p[1]); | |
-} | |
- | |
-inline uchar* Mat::ptr(int i0, int i1, int i2) | |
-{ | |
- CV_DbgAssert( dims >= 3 && data && | |
- (unsigned)i0 < (unsigned)size.p[0] && | |
- (unsigned)i1 < (unsigned)size.p[1] && | |
- (unsigned)i2 < (unsigned)size.p[2] ); | |
- return data + i0*step.p[0] + i1*step.p[1] + i2*step.p[2]; | |
-} | |
- | |
-inline const uchar* Mat::ptr(int i0, int i1, int i2) const | |
-{ | |
- CV_DbgAssert( dims >= 3 && data && | |
- (unsigned)i0 < (unsigned)size.p[0] && | |
- (unsigned)i1 < (unsigned)size.p[1] && | |
- (unsigned)i2 < (unsigned)size.p[2] ); | |
- return data + i0*step.p[0] + i1*step.p[1] + i2*step.p[2]; | |
-} | |
- | |
-template<typename _Tp> inline _Tp* Mat::ptr(int i0, int i1, int i2) | |
-{ | |
- CV_DbgAssert( dims >= 3 && data && | |
- (unsigned)i0 < (unsigned)size.p[0] && | |
- (unsigned)i1 < (unsigned)size.p[1] && | |
- (unsigned)i2 < (unsigned)size.p[2] ); | |
- return (_Tp*)(data + i0*step.p[0] + i1*step.p[1] + i2*step.p[2]); | |
-} | |
- | |
-template<typename _Tp> inline const _Tp* Mat::ptr(int i0, int i1, int i2) const | |
-{ | |
- CV_DbgAssert( dims >= 3 && data && | |
- (unsigned)i0 < (unsigned)size.p[0] && | |
- (unsigned)i1 < (unsigned)size.p[1] && | |
- (unsigned)i2 < (unsigned)size.p[2] ); | |
- return (const _Tp*)(data + i0*step.p[0] + i1*step.p[1] + i2*step.p[2]); | |
-} | |
- | |
-inline uchar* Mat::ptr(const int* idx) | |
-{ | |
- int i, d = dims; | |
- uchar* p = data; | |
- CV_DbgAssert( d >= 1 && p ); | |
- for( i = 0; i < d; i++ ) | |
- { | |
- CV_DbgAssert( (unsigned)idx[i] < (unsigned)size.p[i] ); | |
- p += idx[i]*step.p[i]; | |
- } | |
- return p; | |
-} | |
- | |
-inline const uchar* Mat::ptr(const int* idx) const | |
-{ | |
- int i, d = dims; | |
- uchar* p = data; | |
- CV_DbgAssert( d >= 1 && p ); | |
- for( i = 0; i < d; i++ ) | |
- { | |
- CV_DbgAssert( (unsigned)idx[i] < (unsigned)size.p[i] ); | |
- p += idx[i]*step.p[i]; | |
- } | |
- return p; | |
-} | |
- | |
-template<typename _Tp> inline _Tp& Mat::at(int i0, int i1) | |
-{ | |
- CV_DbgAssert( dims <= 2 && data && (unsigned)i0 < (unsigned)size.p[0] && | |
- (unsigned)(i1*DataType<_Tp>::channels) < (unsigned)(size.p[1]*channels()) && | |
- CV_ELEM_SIZE1(DataType<_Tp>::depth) == elemSize1()); | |
- return ((_Tp*)(data + step.p[0]*i0))[i1]; | |
-} | |
- | |
-template<typename _Tp> inline const _Tp& Mat::at(int i0, int i1) const | |
-{ | |
- CV_DbgAssert( dims <= 2 && data && (unsigned)i0 < (unsigned)size.p[0] && | |
- (unsigned)(i1*DataType<_Tp>::channels) < (unsigned)(size.p[1]*channels()) && | |
- CV_ELEM_SIZE1(DataType<_Tp>::depth) == elemSize1()); | |
- return ((const _Tp*)(data + step.p[0]*i0))[i1]; | |
-} | |
- | |
-template<typename _Tp> inline _Tp& Mat::at(Point pt) | |
-{ | |
- CV_DbgAssert( dims <= 2 && data && (unsigned)pt.y < (unsigned)size.p[0] && | |
- (unsigned)(pt.x*DataType<_Tp>::channels) < (unsigned)(size.p[1]*channels()) && | |
- CV_ELEM_SIZE1(DataType<_Tp>::depth) == elemSize1()); | |
- return ((_Tp*)(data + step.p[0]*pt.y))[pt.x]; | |
-} | |
- | |
-template<typename _Tp> inline const _Tp& Mat::at(Point pt) const | |
-{ | |
- CV_DbgAssert( dims <= 2 && data && (unsigned)pt.y < (unsigned)size.p[0] && | |
- (unsigned)(pt.x*DataType<_Tp>::channels) < (unsigned)(size.p[1]*channels()) && | |
- CV_ELEM_SIZE1(DataType<_Tp>::depth) == elemSize1()); | |
- return ((const _Tp*)(data + step.p[0]*pt.y))[pt.x]; | |
-} | |
- | |
-template<typename _Tp> inline _Tp& Mat::at(int i0) | |
-{ | |
- CV_DbgAssert( dims <= 2 && data && | |
- (unsigned)i0 < (unsigned)(size.p[0]*size.p[1]) && | |
- elemSize() == CV_ELEM_SIZE(DataType<_Tp>::type) ); | |
- if( isContinuous() || size.p[0] == 1 ) | |
- return ((_Tp*)data)[i0]; | |
- if( size.p[1] == 1 ) | |
- return *(_Tp*)(data + step.p[0]*i0); | |
- int i = i0/cols, j = i0 - i*cols; | |
- return ((_Tp*)(data + step.p[0]*i))[j]; | |
-} | |
- | |
-template<typename _Tp> inline const _Tp& Mat::at(int i0) const | |
-{ | |
- CV_DbgAssert( dims <= 2 && data && | |
- (unsigned)i0 < (unsigned)(size.p[0]*size.p[1]) && | |
- elemSize() == CV_ELEM_SIZE(DataType<_Tp>::type) ); | |
- if( isContinuous() || size.p[0] == 1 ) | |
- return ((const _Tp*)data)[i0]; | |
- if( size.p[1] == 1 ) | |
- return *(const _Tp*)(data + step.p[0]*i0); | |
- int i = i0/cols, j = i0 - i*cols; | |
- return ((const _Tp*)(data + step.p[0]*i))[j]; | |
-} | |
- | |
-template<typename _Tp> inline _Tp& Mat::at(int i0, int i1, int i2) | |
-{ | |
- CV_DbgAssert( elemSize() == CV_ELEM_SIZE(DataType<_Tp>::type) ); | |
- return *(_Tp*)ptr(i0, i1, i2); | |
-} | |
-template<typename _Tp> inline const _Tp& Mat::at(int i0, int i1, int i2) const | |
-{ | |
- CV_DbgAssert( elemSize() == CV_ELEM_SIZE(DataType<_Tp>::type) ); | |
- return *(const _Tp*)ptr(i0, i1, i2); | |
-} | |
-template<typename _Tp> inline _Tp& Mat::at(const int* idx) | |
-{ | |
- CV_DbgAssert( elemSize() == CV_ELEM_SIZE(DataType<_Tp>::type) ); | |
- return *(_Tp*)ptr(idx); | |
-} | |
-template<typename _Tp> inline const _Tp& Mat::at(const int* idx) const | |
-{ | |
- CV_DbgAssert( elemSize() == CV_ELEM_SIZE(DataType<_Tp>::type) ); | |
- return *(const _Tp*)ptr(idx); | |
-} | |
-template<typename _Tp, int n> _Tp& Mat::at(const Vec<int, n>& idx) | |
-{ | |
- CV_DbgAssert( elemSize() == CV_ELEM_SIZE(DataType<_Tp>::type) ); | |
- return *(_Tp*)ptr(idx.val); | |
-} | |
-template<typename _Tp, int n> inline const _Tp& Mat::at(const Vec<int, n>& idx) const | |
-{ | |
- CV_DbgAssert( elemSize() == CV_ELEM_SIZE(DataType<_Tp>::type) ); | |
- return *(const _Tp*)ptr(idx.val); | |
-} | |
- | |
- | |
-template<typename _Tp> inline MatConstIterator_<_Tp> Mat::begin() const | |
-{ | |
- CV_DbgAssert( elemSize() == sizeof(_Tp) ); | |
- return MatConstIterator_<_Tp>((const Mat_<_Tp>*)this); | |
-} | |
- | |
-template<typename _Tp> inline MatConstIterator_<_Tp> Mat::end() const | |
-{ | |
- CV_DbgAssert( elemSize() == sizeof(_Tp) ); | |
- MatConstIterator_<_Tp> it((const Mat_<_Tp>*)this); | |
- it += total(); | |
- return it; | |
-} | |
- | |
-template<typename _Tp> inline MatIterator_<_Tp> Mat::begin() | |
-{ | |
- CV_DbgAssert( elemSize() == sizeof(_Tp) ); | |
- return MatIterator_<_Tp>((Mat_<_Tp>*)this); | |
-} | |
- | |
-template<typename _Tp> inline MatIterator_<_Tp> Mat::end() | |
-{ | |
- CV_DbgAssert( elemSize() == sizeof(_Tp) ); | |
- MatIterator_<_Tp> it((Mat_<_Tp>*)this); | |
- it += total(); | |
- return it; | |
-} | |
- | |
-template<typename _Tp> inline Mat::operator vector<_Tp>() const | |
-{ | |
- vector<_Tp> v; | |
- copyTo(v); | |
- return v; | |
-} | |
- | |
-template<typename _Tp, int n> inline Mat::operator Vec<_Tp, n>() const | |
-{ | |
- CV_Assert( data && dims <= 2 && (rows == 1 || cols == 1) && | |
- rows + cols - 1 == n && channels() == 1 ); | |
- | |
- if( isContinuous() && type() == DataType<_Tp>::type ) | |
- return Vec<_Tp, n>((_Tp*)data); | |
- Vec<_Tp, n> v; Mat tmp(rows, cols, DataType<_Tp>::type, v.val); | |
- convertTo(tmp, tmp.type()); | |
- return v; | |
-} | |
- | |
-template<typename _Tp, int m, int n> inline Mat::operator Matx<_Tp, m, n>() const | |
-{ | |
- CV_Assert( data && dims <= 2 && rows == m && cols == n && channels() == 1 ); | |
- | |
- if( isContinuous() && type() == DataType<_Tp>::type ) | |
- return Matx<_Tp, m, n>((_Tp*)data); | |
- Matx<_Tp, m, n> mtx; Mat tmp(rows, cols, DataType<_Tp>::type, mtx.val); | |
- convertTo(tmp, tmp.type()); | |
- return mtx; | |
-} | |
- | |
- | |
-template<typename _Tp> inline void Mat::push_back(const _Tp& elem) | |
-{ | |
- if( !data ) | |
- { | |
- *this = Mat(1, 1, DataType<_Tp>::type, (void*)&elem).clone(); | |
- return; | |
- } | |
- CV_Assert(DataType<_Tp>::type == type() && cols == 1 | |
- /* && dims == 2 (cols == 1 implies dims == 2) */); | |
- uchar* tmp = dataend + step[0]; | |
- if( !isSubmatrix() && isContinuous() && tmp <= datalimit ) | |
- { | |
- *(_Tp*)(data + (size.p[0]++)*step.p[0]) = elem; | |
- dataend = tmp; | |
- } | |
- else | |
- push_back_(&elem); | |
-} | |
- | |
-template<typename _Tp> inline void Mat::push_back(const Mat_<_Tp>& m) | |
-{ | |
- push_back((const Mat&)m); | |
-} | |
- | |
-inline Mat::MSize::MSize(int* _p) : p(_p) {} | |
-inline Size Mat::MSize::operator()() const | |
-{ | |
- CV_DbgAssert(p[-1] <= 2); | |
- return Size(p[1], p[0]); | |
-} | |
-inline const int& Mat::MSize::operator[](int i) const { return p[i]; } | |
-inline int& Mat::MSize::operator[](int i) { return p[i]; } | |
-inline Mat::MSize::operator const int*() const { return p; } | |
- | |
-inline bool Mat::MSize::operator == (const MSize& sz) const | |
-{ | |
- int d = p[-1], dsz = sz.p[-1]; | |
- if( d != dsz ) | |
- return false; | |
- if( d == 2 ) | |
- return p[0] == sz.p[0] && p[1] == sz.p[1]; | |
- | |
- for( int i = 0; i < d; i++ ) | |
- if( p[i] != sz.p[i] ) | |
- return false; | |
- return true; | |
-} | |
- | |
-inline bool Mat::MSize::operator != (const MSize& sz) const | |
-{ | |
- return !(*this == sz); | |
-} | |
- | |
-inline Mat::MStep::MStep() { p = buf; p[0] = p[1] = 0; } | |
-inline Mat::MStep::MStep(size_t s) { p = buf; p[0] = s; p[1] = 0; } | |
-inline const size_t& Mat::MStep::operator[](int i) const { return p[i]; } | |
-inline size_t& Mat::MStep::operator[](int i) { return p[i]; } | |
-inline Mat::MStep::operator size_t() const | |
-{ | |
- CV_DbgAssert( p == buf ); | |
- return buf[0]; | |
-} | |
-inline Mat::MStep& Mat::MStep::operator = (size_t s) | |
-{ | |
- CV_DbgAssert( p == buf ); | |
- buf[0] = s; | |
- return *this; | |
-} | |
- | |
-static inline Mat cvarrToMatND(const CvArr* arr, bool copyData=false, int coiMode=0) | |
-{ | |
- return cvarrToMat(arr, copyData, true, coiMode); | |
-} | |
- | |
-///////////////////////////////////////////// SVD ////////////////////////////////////////////////////// | |
- | |
-inline SVD::SVD() {} | |
-inline SVD::SVD( InputArray m, int flags ) { operator ()(m, flags); } | |
-inline void SVD::solveZ( InputArray m, OutputArray _dst ) | |
-{ | |
- SVD svd(m); | |
- _dst.create(svd.vt.cols, 1, svd.vt.type()); | |
- Mat dst = _dst.getMat(); | |
- svd.vt.row(svd.vt.rows-1).reshape(1,svd.vt.cols).copyTo(dst); | |
-} | |
- | |
-template<typename _Tp, int m, int n, int nm> inline void | |
- SVD::compute( const Matx<_Tp, m, n>& a, Matx<_Tp, nm, 1>& w, Matx<_Tp, m, nm>& u, Matx<_Tp, n, nm>& vt ) | |
-{ | |
- assert( nm == MIN(m, n)); | |
- Mat _a(a, false), _u(u, false), _w(w, false), _vt(vt, false); | |
- SVD::compute(_a, _w, _u, _vt); | |
- CV_Assert(_w.data == (uchar*)&w.val[0] && _u.data == (uchar*)&u.val[0] && _vt.data == (uchar*)&vt.val[0]); | |
-} | |
- | |
-template<typename _Tp, int m, int n, int nm> inline void | |
-SVD::compute( const Matx<_Tp, m, n>& a, Matx<_Tp, nm, 1>& w ) | |
-{ | |
- assert( nm == MIN(m, n)); | |
- Mat _a(a, false), _w(w, false); | |
- SVD::compute(_a, _w); | |
- CV_Assert(_w.data == (uchar*)&w.val[0]); | |
-} | |
- | |
-template<typename _Tp, int m, int n, int nm, int nb> inline void | |
-SVD::backSubst( const Matx<_Tp, nm, 1>& w, const Matx<_Tp, m, nm>& u, | |
- const Matx<_Tp, n, nm>& vt, const Matx<_Tp, m, nb>& rhs, | |
- Matx<_Tp, n, nb>& dst ) | |
-{ | |
- assert( nm == MIN(m, n)); | |
- Mat _u(u, false), _w(w, false), _vt(vt, false), _rhs(rhs, false), _dst(dst, false); | |
- SVD::backSubst(_w, _u, _vt, _rhs, _dst); | |
- CV_Assert(_dst.data == (uchar*)&dst.val[0]); | |
-} | |
- | |
-///////////////////////////////// Mat_<_Tp> //////////////////////////////////// | |
- | |
-template<typename _Tp> inline Mat_<_Tp>::Mat_() | |
- : Mat() { flags = (flags & ~CV_MAT_TYPE_MASK) | DataType<_Tp>::type; } | |
- | |
-template<typename _Tp> inline Mat_<_Tp>::Mat_(int _rows, int _cols) | |
- : Mat(_rows, _cols, DataType<_Tp>::type) {} | |
- | |
-template<typename _Tp> inline Mat_<_Tp>::Mat_(int _rows, int _cols, const _Tp& value) | |
- : Mat(_rows, _cols, DataType<_Tp>::type) { *this = value; } | |
- | |
-template<typename _Tp> inline Mat_<_Tp>::Mat_(Size _sz) | |
- : Mat(_sz.height, _sz.width, DataType<_Tp>::type) {} | |
- | |
-template<typename _Tp> inline Mat_<_Tp>::Mat_(Size _sz, const _Tp& value) | |
- : Mat(_sz.height, _sz.width, DataType<_Tp>::type) { *this = value; } | |
- | |
-template<typename _Tp> inline Mat_<_Tp>::Mat_(int _dims, const int* _sz) | |
- : Mat(_dims, _sz, DataType<_Tp>::type) {} | |
- | |
-template<typename _Tp> inline Mat_<_Tp>::Mat_(int _dims, const int* _sz, const _Tp& _s) | |
- : Mat(_dims, _sz, DataType<_Tp>::type, Scalar(_s)) {} | |
- | |
-template<typename _Tp> inline Mat_<_Tp>::Mat_(const Mat_<_Tp>& m, const Range* ranges) | |
- : Mat(m, ranges) {} | |
- | |
-template<typename _Tp> inline Mat_<_Tp>::Mat_(const Mat& m) | |
- : Mat() { flags = (flags & ~CV_MAT_TYPE_MASK) | DataType<_Tp>::type; *this = m; } | |
- | |
-template<typename _Tp> inline Mat_<_Tp>::Mat_(const Mat_& m) | |
- : Mat(m) {} | |
- | |
-template<typename _Tp> inline Mat_<_Tp>::Mat_(int _rows, int _cols, _Tp* _data, size_t steps) | |
- : Mat(_rows, _cols, DataType<_Tp>::type, _data, steps) {} | |
- | |
-template<typename _Tp> inline Mat_<_Tp>::Mat_(const Mat_& m, const Range& rowRange, const Range& colRange) | |
- : Mat(m, rowRange, colRange) {} | |
- | |
-template<typename _Tp> inline Mat_<_Tp>::Mat_(const Mat_& m, const Rect& roi) | |
- : Mat(m, roi) {} | |
- | |
-template<typename _Tp> template<int n> inline | |
- Mat_<_Tp>::Mat_(const Vec<typename DataType<_Tp>::channel_type, n>& vec, bool copyData) | |
- : Mat(n/DataType<_Tp>::channels, 1, DataType<_Tp>::type, (void*)&vec) | |
-{ | |
- CV_Assert(n%DataType<_Tp>::channels == 0); | |
- if( copyData ) | |
- *this = clone(); | |
-} | |
- | |
-template<typename _Tp> template<int m, int n> inline | |
- Mat_<_Tp>::Mat_(const Matx<typename DataType<_Tp>::channel_type,m,n>& M, bool copyData) | |
- : Mat(m, n/DataType<_Tp>::channels, DataType<_Tp>::type, (void*)&M) | |
-{ | |
- CV_Assert(n % DataType<_Tp>::channels == 0); | |
- if( copyData ) | |
- *this = clone(); | |
-} | |
- | |
-template<typename _Tp> inline Mat_<_Tp>::Mat_(const Point_<typename DataType<_Tp>::channel_type>& pt, bool copyData) | |
- : Mat(2/DataType<_Tp>::channels, 1, DataType<_Tp>::type, (void*)&pt) | |
-{ | |
- CV_Assert(2 % DataType<_Tp>::channels == 0); | |
- if( copyData ) | |
- *this = clone(); | |
-} | |
- | |
-template<typename _Tp> inline Mat_<_Tp>::Mat_(const Point3_<typename DataType<_Tp>::channel_type>& pt, bool copyData) | |
- : Mat(3/DataType<_Tp>::channels, 1, DataType<_Tp>::type, (void*)&pt) | |
-{ | |
- CV_Assert(3 % DataType<_Tp>::channels == 0); | |
- if( copyData ) | |
- *this = clone(); | |
-} | |
- | |
-template<typename _Tp> inline Mat_<_Tp>::Mat_(const MatCommaInitializer_<_Tp>& commaInitializer) | |
- : Mat(commaInitializer) {} | |
- | |
-template<typename _Tp> inline Mat_<_Tp>::Mat_(const vector<_Tp>& vec, bool copyData) | |
- : Mat(vec, copyData) {} | |
- | |
-template<typename _Tp> inline Mat_<_Tp>& Mat_<_Tp>::operator = (const Mat& m) | |
-{ | |
- if( DataType<_Tp>::type == m.type() ) | |
- { | |
- Mat::operator = (m); | |
- return *this; | |
- } | |
- if( DataType<_Tp>::depth == m.depth() ) | |
- { | |
- return (*this = m.reshape(DataType<_Tp>::channels, m.dims, 0)); | |
- } | |
- CV_DbgAssert(DataType<_Tp>::channels == m.channels()); | |
- m.convertTo(*this, type()); | |
- return *this; | |
-} | |
- | |
-template<typename _Tp> inline Mat_<_Tp>& Mat_<_Tp>::operator = (const Mat_& m) | |
-{ | |
- Mat::operator=(m); | |
- return *this; | |
-} | |
- | |
-template<typename _Tp> inline Mat_<_Tp>& Mat_<_Tp>::operator = (const _Tp& s) | |
-{ | |
- typedef typename DataType<_Tp>::vec_type VT; | |
- Mat::operator=(Scalar((const VT&)s)); | |
- return *this; | |
-} | |
- | |
-template<typename _Tp> inline void Mat_<_Tp>::create(int _rows, int _cols) | |
-{ | |
- Mat::create(_rows, _cols, DataType<_Tp>::type); | |
-} | |
- | |
-template<typename _Tp> inline void Mat_<_Tp>::create(Size _sz) | |
-{ | |
- Mat::create(_sz, DataType<_Tp>::type); | |
-} | |
- | |
-template<typename _Tp> inline void Mat_<_Tp>::create(int _dims, const int* _sz) | |
-{ | |
- Mat::create(_dims, _sz, DataType<_Tp>::type); | |
-} | |
- | |
- | |
-template<typename _Tp> inline Mat_<_Tp> Mat_<_Tp>::cross(const Mat_& m) const | |
-{ return Mat_<_Tp>(Mat::cross(m)); } | |
- | |
-template<typename _Tp> template<typename T2> inline Mat_<_Tp>::operator Mat_<T2>() const | |
-{ return Mat_<T2>(*this); } | |
- | |
-template<typename _Tp> inline Mat_<_Tp> Mat_<_Tp>::row(int y) const | |
-{ return Mat_(*this, Range(y, y+1), Range::all()); } | |
-template<typename _Tp> inline Mat_<_Tp> Mat_<_Tp>::col(int x) const | |
-{ return Mat_(*this, Range::all(), Range(x, x+1)); } | |
-template<typename _Tp> inline Mat_<_Tp> Mat_<_Tp>::diag(int d) const | |
-{ return Mat_(Mat::diag(d)); } | |
-template<typename _Tp> inline Mat_<_Tp> Mat_<_Tp>::clone() const | |
-{ return Mat_(Mat::clone()); } | |
- | |
-template<typename _Tp> inline size_t Mat_<_Tp>::elemSize() const | |
-{ | |
- CV_DbgAssert( Mat::elemSize() == sizeof(_Tp) ); | |
- return sizeof(_Tp); | |
-} | |
- | |
-template<typename _Tp> inline size_t Mat_<_Tp>::elemSize1() const | |
-{ | |
- CV_DbgAssert( Mat::elemSize1() == sizeof(_Tp)/DataType<_Tp>::channels ); | |
- return sizeof(_Tp)/DataType<_Tp>::channels; | |
-} | |
-template<typename _Tp> inline int Mat_<_Tp>::type() const | |
-{ | |
- CV_DbgAssert( Mat::type() == DataType<_Tp>::type ); | |
- return DataType<_Tp>::type; | |
-} | |
-template<typename _Tp> inline int Mat_<_Tp>::depth() const | |
-{ | |
- CV_DbgAssert( Mat::depth() == DataType<_Tp>::depth ); | |
- return DataType<_Tp>::depth; | |
-} | |
-template<typename _Tp> inline int Mat_<_Tp>::channels() const | |
-{ | |
- CV_DbgAssert( Mat::channels() == DataType<_Tp>::channels ); | |
- return DataType<_Tp>::channels; | |
-} | |
-template<typename _Tp> inline size_t Mat_<_Tp>::stepT(int i) const { return step.p[i]/elemSize(); } | |
-template<typename _Tp> inline size_t Mat_<_Tp>::step1(int i) const { return step.p[i]/elemSize1(); } | |
- | |
-template<typename _Tp> inline Mat_<_Tp>& Mat_<_Tp>::adjustROI( int dtop, int dbottom, int dleft, int dright ) | |
-{ return (Mat_<_Tp>&)(Mat::adjustROI(dtop, dbottom, dleft, dright)); } | |
- | |
-template<typename _Tp> inline Mat_<_Tp> Mat_<_Tp>::operator()( const Range& rowRange, const Range& colRange ) const | |
-{ return Mat_<_Tp>(*this, rowRange, colRange); } | |
- | |
-template<typename _Tp> inline Mat_<_Tp> Mat_<_Tp>::operator()( const Rect& roi ) const | |
-{ return Mat_<_Tp>(*this, roi); } | |
- | |
-template<typename _Tp> inline Mat_<_Tp> Mat_<_Tp>::operator()( const Range* ranges ) const | |
-{ return Mat_<_Tp>(*this, ranges); } | |
- | |
-template<typename _Tp> inline _Tp* Mat_<_Tp>::operator [](int y) | |
-{ return (_Tp*)ptr(y); } | |
-template<typename _Tp> inline const _Tp* Mat_<_Tp>::operator [](int y) const | |
-{ return (const _Tp*)ptr(y); } | |
- | |
-template<typename _Tp> inline _Tp& Mat_<_Tp>::operator ()(int i0, int i1) | |
-{ | |
- CV_DbgAssert( dims <= 2 && data && | |
- (unsigned)i0 < (unsigned)size.p[0] && | |
- (unsigned)i1 < (unsigned)size.p[1] && | |
- type() == DataType<_Tp>::type ); | |
- return ((_Tp*)(data + step.p[0]*i0))[i1]; | |
-} | |
- | |
-template<typename _Tp> inline const _Tp& Mat_<_Tp>::operator ()(int i0, int i1) const | |
-{ | |
- CV_DbgAssert( dims <= 2 && data && | |
- (unsigned)i0 < (unsigned)size.p[0] && | |
- (unsigned)i1 < (unsigned)size.p[1] && | |
- type() == DataType<_Tp>::type ); | |
- return ((const _Tp*)(data + step.p[0]*i0))[i1]; | |
-} | |
- | |
-template<typename _Tp> inline _Tp& Mat_<_Tp>::operator ()(Point pt) | |
-{ | |
- CV_DbgAssert( dims <= 2 && data && | |
- (unsigned)pt.y < (unsigned)size.p[0] && | |
- (unsigned)pt.x < (unsigned)size.p[1] && | |
- type() == DataType<_Tp>::type ); | |
- return ((_Tp*)(data + step.p[0]*pt.y))[pt.x]; | |
-} | |
- | |
-template<typename _Tp> inline const _Tp& Mat_<_Tp>::operator ()(Point pt) const | |
-{ | |
- CV_DbgAssert( dims <= 2 && data && | |
- (unsigned)pt.y < (unsigned)size.p[0] && | |
- (unsigned)pt.x < (unsigned)size.p[1] && | |
- type() == DataType<_Tp>::type ); | |
- return ((const _Tp*)(data + step.p[0]*pt.y))[pt.x]; | |
-} | |
- | |
-template<typename _Tp> inline _Tp& Mat_<_Tp>::operator ()(const int* idx) | |
-{ | |
- return Mat::at<_Tp>(idx); | |
-} | |
- | |
-template<typename _Tp> inline const _Tp& Mat_<_Tp>::operator ()(const int* idx) const | |
-{ | |
- return Mat::at<_Tp>(idx); | |
-} | |
- | |
-template<typename _Tp> template<int n> inline _Tp& Mat_<_Tp>::operator ()(const Vec<int, n>& idx) | |
-{ | |
- return Mat::at<_Tp>(idx); | |
-} | |
- | |
-template<typename _Tp> template<int n> inline const _Tp& Mat_<_Tp>::operator ()(const Vec<int, n>& idx) const | |
-{ | |
- return Mat::at<_Tp>(idx); | |
-} | |
- | |
-template<typename _Tp> inline _Tp& Mat_<_Tp>::operator ()(int i0) | |
-{ | |
- return this->at<_Tp>(i0); | |
-} | |
- | |
-template<typename _Tp> inline const _Tp& Mat_<_Tp>::operator ()(int i0) const | |
-{ | |
- return this->at<_Tp>(i0); | |
-} | |
- | |
-template<typename _Tp> inline _Tp& Mat_<_Tp>::operator ()(int i0, int i1, int i2) | |
-{ | |
- return this->at<_Tp>(i0, i1, i2); | |
-} | |
- | |
-template<typename _Tp> inline const _Tp& Mat_<_Tp>::operator ()(int i0, int i1, int i2) const | |
-{ | |
- return this->at<_Tp>(i0, i1, i2); | |
-} | |
- | |
- | |
-template<typename _Tp> inline Mat_<_Tp>::operator vector<_Tp>() const | |
-{ | |
- vector<_Tp> v; | |
- copyTo(v); | |
- return v; | |
-} | |
- | |
-template<typename _Tp> template<int n> inline Mat_<_Tp>::operator Vec<typename DataType<_Tp>::channel_type, n>() const | |
-{ | |
- CV_Assert(n % DataType<_Tp>::channels == 0); | |
- return this->Mat::operator Vec<typename DataType<_Tp>::channel_type, n>(); | |
-} | |
- | |
-template<typename _Tp> template<int m, int n> inline Mat_<_Tp>::operator Matx<typename DataType<_Tp>::channel_type, m, n>() const | |
-{ | |
- CV_Assert(n % DataType<_Tp>::channels == 0); | |
- return this->Mat::operator Matx<typename DataType<_Tp>::channel_type, m, n>(); | |
-} | |
- | |
-template<typename T1, typename T2, typename Op> inline void | |
-process( const Mat_<T1>& m1, Mat_<T2>& m2, Op op ) | |
-{ | |
- int y, x, rows = m1.rows, cols = m1.cols; | |
- | |
- CV_DbgAssert( m1.size() == m2.size() ); | |
- | |
- for( y = 0; y < rows; y++ ) | |
- { | |
- const T1* src = m1[y]; | |
- T2* dst = m2[y]; | |
- | |
- for( x = 0; x < cols; x++ ) | |
- dst[x] = op(src[x]); | |
- } | |
-} | |
- | |
-template<typename T1, typename T2, typename T3, typename Op> inline void | |
-process( const Mat_<T1>& m1, const Mat_<T2>& m2, Mat_<T3>& m3, Op op ) | |
-{ | |
- int y, x, rows = m1.rows, cols = m1.cols; | |
- | |
- CV_DbgAssert( m1.size() == m2.size() ); | |
- | |
- for( y = 0; y < rows; y++ ) | |
- { | |
- const T1* src1 = m1[y]; | |
- const T2* src2 = m2[y]; | |
- T3* dst = m3[y]; | |
- | |
- for( x = 0; x < cols; x++ ) | |
- dst[x] = op( src1[x], src2[x] ); | |
- } | |
-} | |
- | |
- | |
-/////////////////////////////// Input/Output Arrays ///////////////////////////////// | |
- | |
-template<typename _Tp> inline _InputArray::_InputArray(const vector<_Tp>& vec) | |
- : flags(FIXED_TYPE + STD_VECTOR + DataType<_Tp>::type), obj((void*)&vec) {} | |
- | |
-template<typename _Tp> inline _InputArray::_InputArray(const vector<vector<_Tp> >& vec) | |
- : flags(FIXED_TYPE + STD_VECTOR_VECTOR + DataType<_Tp>::type), obj((void*)&vec) {} | |
- | |
-template<typename _Tp, int m, int n> inline _InputArray::_InputArray(const Matx<_Tp, m, n>& mtx) | |
- : flags(FIXED_TYPE + FIXED_SIZE + MATX + DataType<_Tp>::type), obj((void*)&mtx), sz(n, m) {} | |
- | |
-template<typename _Tp> inline _InputArray::_InputArray(const _Tp* vec, int n) | |
- : flags(FIXED_TYPE + FIXED_SIZE + MATX + DataType<_Tp>::type), obj((void*)vec), sz(n, 1) {} | |
- | |
-inline _InputArray::_InputArray(const Scalar& s) | |
- : flags(FIXED_TYPE + FIXED_SIZE + MATX + CV_64F), obj((void*)&s), sz(1, 4) {} | |
- | |
-template<typename _Tp> inline _InputArray::_InputArray(const Mat_<_Tp>& m) | |
- : flags(FIXED_TYPE + MAT + DataType<_Tp>::type), obj((void*)&m) {} | |
- | |
-template<typename _Tp> inline _OutputArray::_OutputArray(vector<_Tp>& vec) : _InputArray(vec) {} | |
-template<typename _Tp> inline _OutputArray::_OutputArray(vector<vector<_Tp> >& vec) : _InputArray(vec) {} | |
-template<typename _Tp> inline _OutputArray::_OutputArray(Mat_<_Tp>& m) : _InputArray(m) {} | |
-template<typename _Tp, int m, int n> inline _OutputArray::_OutputArray(Matx<_Tp, m, n>& mtx) : _InputArray(mtx) {} | |
-template<typename _Tp> inline _OutputArray::_OutputArray(_Tp* vec, int n) : _InputArray(vec, n) {} | |
- | |
- | |
-template<typename _Tp> inline _OutputArray::_OutputArray(const vector<_Tp>& vec) : _InputArray(vec) {flags |= FIXED_SIZE;} | |
-template<typename _Tp> inline _OutputArray::_OutputArray(const vector<vector<_Tp> >& vec) : _InputArray(vec) {flags |= FIXED_SIZE;} | |
-template<typename _Tp> inline _OutputArray::_OutputArray(const Mat_<_Tp>& m) : _InputArray(m) {flags |= FIXED_SIZE;} | |
-template<typename _Tp, int m, int n> inline _OutputArray::_OutputArray(const Matx<_Tp, m, n>& mtx) : _InputArray(mtx) {} | |
-template<typename _Tp> inline _OutputArray::_OutputArray(const _Tp* vec, int n) : _InputArray(vec, n) {} | |
- | |
-//////////////////////////////////// Matrix Expressions ///////////////////////////////////////// | |
- | |
-class CV_EXPORTS MatOp | |
-{ | |
-public: | |
- MatOp() {}; | |
- virtual ~MatOp() {}; | |
- | |
- virtual bool elementWise(const MatExpr& expr) const; | |
- virtual void assign(const MatExpr& expr, Mat& m, int type=-1) const = 0; | |
- virtual void roi(const MatExpr& expr, const Range& rowRange, | |
- const Range& colRange, MatExpr& res) const; | |
- virtual void diag(const MatExpr& expr, int d, MatExpr& res) const; | |
- virtual void augAssignAdd(const MatExpr& expr, Mat& m) const; | |
- virtual void augAssignSubtract(const MatExpr& expr, Mat& m) const; | |
- virtual void augAssignMultiply(const MatExpr& expr, Mat& m) const; | |
- virtual void augAssignDivide(const MatExpr& expr, Mat& m) const; | |
- virtual void augAssignAnd(const MatExpr& expr, Mat& m) const; | |
- virtual void augAssignOr(const MatExpr& expr, Mat& m) const; | |
- virtual void augAssignXor(const MatExpr& expr, Mat& m) const; | |
- | |
- virtual void add(const MatExpr& expr1, const MatExpr& expr2, MatExpr& res) const; | |
- virtual void add(const MatExpr& expr1, const Scalar& s, MatExpr& res) const; | |
- | |
- virtual void subtract(const MatExpr& expr1, const MatExpr& expr2, MatExpr& res) const; | |
- virtual void subtract(const Scalar& s, const MatExpr& expr, MatExpr& res) const; | |
- | |
- virtual void multiply(const MatExpr& expr1, const MatExpr& expr2, MatExpr& res, double scale=1) const; | |
- virtual void multiply(const MatExpr& expr1, double s, MatExpr& res) const; | |
- | |
- virtual void divide(const MatExpr& expr1, const MatExpr& expr2, MatExpr& res, double scale=1) const; | |
- virtual void divide(double s, const MatExpr& expr, MatExpr& res) const; | |
- | |
- virtual void abs(const MatExpr& expr, MatExpr& res) const; | |
- | |
- virtual void transpose(const MatExpr& expr, MatExpr& res) const; | |
- virtual void matmul(const MatExpr& expr1, const MatExpr& expr2, MatExpr& res) const; | |
- virtual void invert(const MatExpr& expr, int method, MatExpr& res) const; | |
- | |
- virtual Size size(const MatExpr& expr) const; | |
- virtual int type(const MatExpr& expr) const; | |
-}; | |
- | |
- | |
-class CV_EXPORTS MatExpr | |
-{ | |
-public: | |
- MatExpr() : op(0), flags(0), a(Mat()), b(Mat()), c(Mat()), alpha(0), beta(0), s(Scalar()) {} | |
- MatExpr(const MatOp* _op, int _flags, const Mat& _a=Mat(), const Mat& _b=Mat(), | |
- const Mat& _c=Mat(), double _alpha=1, double _beta=1, const Scalar& _s=Scalar()) | |
- : op(_op), flags(_flags), a(_a), b(_b), c(_c), alpha(_alpha), beta(_beta), s(_s) {} | |
- explicit MatExpr(const Mat& m); | |
- operator Mat() const | |
- { | |
- Mat m; | |
- op->assign(*this, m); | |
- return m; | |
- } | |
- | |
- template<typename _Tp> operator Mat_<_Tp>() const | |
- { | |
- Mat_<_Tp> m; | |
- op->assign(*this, m, DataType<_Tp>::type); | |
- return m; | |
- } | |
- | |
- MatExpr row(int y) const; | |
- MatExpr col(int x) const; | |
- MatExpr diag(int d=0) const; | |
- MatExpr operator()( const Range& rowRange, const Range& colRange ) const; | |
- MatExpr operator()( const Rect& roi ) const; | |
- | |
- Mat cross(const Mat& m) const; | |
- double dot(const Mat& m) const; | |
- | |
- MatExpr t() const; | |
- MatExpr inv(int method = DECOMP_LU) const; | |
- MatExpr mul(const MatExpr& e, double scale=1) const; | |
- MatExpr mul(const Mat& m, double scale=1) const; | |
- | |
- Size size() const; | |
- int type() const; | |
- | |
- const MatOp* op; | |
- int flags; | |
- | |
- Mat a, b, c; | |
- double alpha, beta; | |
- Scalar s; | |
-}; | |
- | |
- | |
-CV_EXPORTS MatExpr operator + (const Mat& a, const Mat& b); | |
-CV_EXPORTS MatExpr operator + (const Mat& a, const Scalar& s); | |
-CV_EXPORTS MatExpr operator + (const Scalar& s, const Mat& a); | |
-CV_EXPORTS MatExpr operator + (const MatExpr& e, const Mat& m); | |
-CV_EXPORTS MatExpr operator + (const Mat& m, const MatExpr& e); | |
-CV_EXPORTS MatExpr operator + (const MatExpr& e, const Scalar& s); | |
-CV_EXPORTS MatExpr operator + (const Scalar& s, const MatExpr& e); | |
-CV_EXPORTS MatExpr operator + (const MatExpr& e1, const MatExpr& e2); | |
- | |
-CV_EXPORTS MatExpr operator - (const Mat& a, const Mat& b); | |
-CV_EXPORTS MatExpr operator - (const Mat& a, const Scalar& s); | |
-CV_EXPORTS MatExpr operator - (const Scalar& s, const Mat& a); | |
-CV_EXPORTS MatExpr operator - (const MatExpr& e, const Mat& m); | |
-CV_EXPORTS MatExpr operator - (const Mat& m, const MatExpr& e); | |
-CV_EXPORTS MatExpr operator - (const MatExpr& e, const Scalar& s); | |
-CV_EXPORTS MatExpr operator - (const Scalar& s, const MatExpr& e); | |
-CV_EXPORTS MatExpr operator - (const MatExpr& e1, const MatExpr& e2); | |
- | |
-CV_EXPORTS MatExpr operator - (const Mat& m); | |
-CV_EXPORTS MatExpr operator - (const MatExpr& e); | |
- | |
-CV_EXPORTS MatExpr operator * (const Mat& a, const Mat& b); | |
-CV_EXPORTS MatExpr operator * (const Mat& a, double s); | |
-CV_EXPORTS MatExpr operator * (double s, const Mat& a); | |
-CV_EXPORTS MatExpr operator * (const MatExpr& e, const Mat& m); | |
-CV_EXPORTS MatExpr operator * (const Mat& m, const MatExpr& e); | |
-CV_EXPORTS MatExpr operator * (const MatExpr& e, double s); | |
-CV_EXPORTS MatExpr operator * (double s, const MatExpr& e); | |
-CV_EXPORTS MatExpr operator * (const MatExpr& e1, const MatExpr& e2); | |
- | |
-CV_EXPORTS MatExpr operator / (const Mat& a, const Mat& b); | |
-CV_EXPORTS MatExpr operator / (const Mat& a, double s); | |
-CV_EXPORTS MatExpr operator / (double s, const Mat& a); | |
-CV_EXPORTS MatExpr operator / (const MatExpr& e, const Mat& m); | |
-CV_EXPORTS MatExpr operator / (const Mat& m, const MatExpr& e); | |
-CV_EXPORTS MatExpr operator / (const MatExpr& e, double s); | |
-CV_EXPORTS MatExpr operator / (double s, const MatExpr& e); | |
-CV_EXPORTS MatExpr operator / (const MatExpr& e1, const MatExpr& e2); | |
- | |
-CV_EXPORTS MatExpr operator < (const Mat& a, const Mat& b); | |
-CV_EXPORTS MatExpr operator < (const Mat& a, double s); | |
-CV_EXPORTS MatExpr operator < (double s, const Mat& a); | |
- | |
-CV_EXPORTS MatExpr operator <= (const Mat& a, const Mat& b); | |
-CV_EXPORTS MatExpr operator <= (const Mat& a, double s); | |
-CV_EXPORTS MatExpr operator <= (double s, const Mat& a); | |
- | |
-CV_EXPORTS MatExpr operator == (const Mat& a, const Mat& b); | |
-CV_EXPORTS MatExpr operator == (const Mat& a, double s); | |
-CV_EXPORTS MatExpr operator == (double s, const Mat& a); | |
- | |
-CV_EXPORTS MatExpr operator != (const Mat& a, const Mat& b); | |
-CV_EXPORTS MatExpr operator != (const Mat& a, double s); | |
-CV_EXPORTS MatExpr operator != (double s, const Mat& a); | |
- | |
-CV_EXPORTS MatExpr operator >= (const Mat& a, const Mat& b); | |
-CV_EXPORTS MatExpr operator >= (const Mat& a, double s); | |
-CV_EXPORTS MatExpr operator >= (double s, const Mat& a); | |
- | |
-CV_EXPORTS MatExpr operator > (const Mat& a, const Mat& b); | |
-CV_EXPORTS MatExpr operator > (const Mat& a, double s); | |
-CV_EXPORTS MatExpr operator > (double s, const Mat& a); | |
- | |
-CV_EXPORTS MatExpr min(const Mat& a, const Mat& b); | |
-CV_EXPORTS MatExpr min(const Mat& a, double s); | |
-CV_EXPORTS MatExpr min(double s, const Mat& a); | |
- | |
-CV_EXPORTS MatExpr max(const Mat& a, const Mat& b); | |
-CV_EXPORTS MatExpr max(const Mat& a, double s); | |
-CV_EXPORTS MatExpr max(double s, const Mat& a); | |
- | |
-template<typename _Tp> static inline MatExpr min(const Mat_<_Tp>& a, const Mat_<_Tp>& b) | |
-{ | |
- return cv::min((const Mat&)a, (const Mat&)b); | |
-} | |
- | |
-template<typename _Tp> static inline MatExpr min(const Mat_<_Tp>& a, double s) | |
-{ | |
- return cv::min((const Mat&)a, s); | |
-} | |
- | |
-template<typename _Tp> static inline MatExpr min(double s, const Mat_<_Tp>& a) | |
-{ | |
- return cv::min((const Mat&)a, s); | |
-} | |
- | |
-template<typename _Tp> static inline MatExpr max(const Mat_<_Tp>& a, const Mat_<_Tp>& b) | |
-{ | |
- return cv::max((const Mat&)a, (const Mat&)b); | |
-} | |
- | |
-template<typename _Tp> static inline MatExpr max(const Mat_<_Tp>& a, double s) | |
-{ | |
- return cv::max((const Mat&)a, s); | |
-} | |
- | |
-template<typename _Tp> static inline MatExpr max(double s, const Mat_<_Tp>& a) | |
-{ | |
- return cv::max((const Mat&)a, s); | |
-} | |
- | |
-template<typename _Tp> static inline void min(const Mat_<_Tp>& a, const Mat_<_Tp>& b, Mat_<_Tp>& c) | |
-{ | |
- cv::min((const Mat&)a, (const Mat&)b, (Mat&)c); | |
-} | |
- | |
-template<typename _Tp> static inline void min(const Mat_<_Tp>& a, double s, Mat_<_Tp>& c) | |
-{ | |
- cv::min((const Mat&)a, s, (Mat&)c); | |
-} | |
- | |
-template<typename _Tp> static inline void min(double s, const Mat_<_Tp>& a, Mat_<_Tp>& c) | |
-{ | |
- cv::min((const Mat&)a, s, (Mat&)c); | |
-} | |
- | |
-template<typename _Tp> static inline void max(const Mat_<_Tp>& a, const Mat_<_Tp>& b, Mat_<_Tp>& c) | |
-{ | |
- cv::max((const Mat&)a, (const Mat&)b, (Mat&)c); | |
-} | |
- | |
-template<typename _Tp> static inline void max(const Mat_<_Tp>& a, double s, Mat_<_Tp>& c) | |
-{ | |
- cv::max((const Mat&)a, s, (Mat&)c); | |
-} | |
- | |
-template<typename _Tp> static inline void max(double s, const Mat_<_Tp>& a, Mat_<_Tp>& c) | |
-{ | |
- cv::max((const Mat&)a, s, (Mat&)c); | |
-} | |
- | |
- | |
-CV_EXPORTS MatExpr operator & (const Mat& a, const Mat& b); | |
-CV_EXPORTS MatExpr operator & (const Mat& a, const Scalar& s); | |
-CV_EXPORTS MatExpr operator & (const Scalar& s, const Mat& a); | |
- | |
-CV_EXPORTS MatExpr operator | (const Mat& a, const Mat& b); | |
-CV_EXPORTS MatExpr operator | (const Mat& a, const Scalar& s); | |
-CV_EXPORTS MatExpr operator | (const Scalar& s, const Mat& a); | |
- | |
-CV_EXPORTS MatExpr operator ^ (const Mat& a, const Mat& b); | |
-CV_EXPORTS MatExpr operator ^ (const Mat& a, const Scalar& s); | |
-CV_EXPORTS MatExpr operator ^ (const Scalar& s, const Mat& a); | |
- | |
-CV_EXPORTS MatExpr operator ~(const Mat& m); | |
- | |
-CV_EXPORTS MatExpr abs(const Mat& m); | |
-CV_EXPORTS MatExpr abs(const MatExpr& e); | |
- | |
-template<typename _Tp> static inline MatExpr abs(const Mat_<_Tp>& m) | |
-{ | |
- return cv::abs((const Mat&)m); | |
-} | |
- | |
-////////////////////////////// Augmenting algebraic operations ////////////////////////////////// | |
- | |
-inline Mat& Mat::operator = (const MatExpr& e) | |
-{ | |
- e.op->assign(e, *this); | |
- return *this; | |
-} | |
- | |
-template<typename _Tp> inline Mat_<_Tp>::Mat_(const MatExpr& e) | |
-{ | |
- e.op->assign(e, *this, DataType<_Tp>::type); | |
-} | |
- | |
-template<typename _Tp> Mat_<_Tp>& Mat_<_Tp>::operator = (const MatExpr& e) | |
-{ | |
- e.op->assign(e, *this, DataType<_Tp>::type); | |
- return *this; | |
-} | |
- | |
-static inline Mat& operator += (const Mat& a, const Mat& b) | |
-{ | |
- add(a, b, (Mat&)a); | |
- return (Mat&)a; | |
-} | |
- | |
-static inline Mat& operator += (const Mat& a, const Scalar& s) | |
-{ | |
- add(a, s, (Mat&)a); | |
- return (Mat&)a; | |
-} | |
- | |
-template<typename _Tp> static inline | |
-Mat_<_Tp>& operator += (const Mat_<_Tp>& a, const Mat_<_Tp>& b) | |
-{ | |
- add(a, b, (Mat&)a); | |
- return (Mat_<_Tp>&)a; | |
-} | |
- | |
-template<typename _Tp> static inline | |
-Mat_<_Tp>& operator += (const Mat_<_Tp>& a, const Scalar& s) | |
-{ | |
- add(a, s, (Mat&)a); | |
- return (Mat_<_Tp>&)a; | |
-} | |
- | |
-static inline Mat& operator += (const Mat& a, const MatExpr& b) | |
-{ | |
- b.op->augAssignAdd(b, (Mat&)a); | |
- return (Mat&)a; | |
-} | |
- | |
-template<typename _Tp> static inline | |
-Mat_<_Tp>& operator += (const Mat_<_Tp>& a, const MatExpr& b) | |
-{ | |
- b.op->augAssignAdd(b, (Mat&)a); | |
- return (Mat_<_Tp>&)a; | |
-} | |
- | |
-static inline Mat& operator -= (const Mat& a, const Mat& b) | |
-{ | |
- subtract(a, b, (Mat&)a); | |
- return (Mat&)a; | |
-} | |
- | |
-static inline Mat& operator -= (const Mat& a, const Scalar& s) | |
-{ | |
- subtract(a, s, (Mat&)a); | |
- return (Mat&)a; | |
-} | |
- | |
-template<typename _Tp> static inline | |
-Mat_<_Tp>& operator -= (const Mat_<_Tp>& a, const Mat_<_Tp>& b) | |
-{ | |
- subtract(a, b, (Mat&)a); | |
- return (Mat_<_Tp>&)a; | |
-} | |
- | |
-template<typename _Tp> static inline | |
-Mat_<_Tp>& operator -= (const Mat_<_Tp>& a, const Scalar& s) | |
-{ | |
- subtract(a, s, (Mat&)a); | |
- return (Mat_<_Tp>&)a; | |
-} | |
- | |
-static inline Mat& operator -= (const Mat& a, const MatExpr& b) | |
-{ | |
- b.op->augAssignSubtract(b, (Mat&)a); | |
- return (Mat&)a; | |
-} | |
- | |
-template<typename _Tp> static inline | |
-Mat_<_Tp>& operator -= (const Mat_<_Tp>& a, const MatExpr& b) | |
-{ | |
- b.op->augAssignSubtract(b, (Mat&)a); | |
- return (Mat_<_Tp>&)a; | |
-} | |
- | |
-static inline Mat& operator *= (const Mat& a, const Mat& b) | |
-{ | |
- gemm(a, b, 1, Mat(), 0, (Mat&)a, 0); | |
- return (Mat&)a; | |
-} | |
- | |
-static inline Mat& operator *= (const Mat& a, double s) | |
-{ | |
- a.convertTo((Mat&)a, -1, s); | |
- return (Mat&)a; | |
-} | |
- | |
-template<typename _Tp> static inline | |
-Mat_<_Tp>& operator *= (const Mat_<_Tp>& a, const Mat_<_Tp>& b) | |
-{ | |
- gemm(a, b, 1, Mat(), 0, (Mat&)a, 0); | |
- return (Mat_<_Tp>&)a; | |
-} | |
- | |
-template<typename _Tp> static inline | |
-Mat_<_Tp>& operator *= (const Mat_<_Tp>& a, double s) | |
-{ | |
- a.convertTo((Mat&)a, -1, s); | |
- return (Mat_<_Tp>&)a; | |
-} | |
- | |
-static inline Mat& operator *= (const Mat& a, const MatExpr& b) | |
-{ | |
- b.op->augAssignMultiply(b, (Mat&)a); | |
- return (Mat&)a; | |
-} | |
- | |
-template<typename _Tp> static inline | |
-Mat_<_Tp>& operator *= (const Mat_<_Tp>& a, const MatExpr& b) | |
-{ | |
- b.op->augAssignMultiply(b, (Mat&)a); | |
- return (Mat_<_Tp>&)a; | |
-} | |
- | |
-static inline Mat& operator /= (const Mat& a, const Mat& b) | |
-{ | |
- divide(a, b, (Mat&)a); | |
- return (Mat&)a; | |
-} | |
- | |
-static inline Mat& operator /= (const Mat& a, double s) | |
-{ | |
- a.convertTo((Mat&)a, -1, 1./s); | |
- return (Mat&)a; | |
-} | |
- | |
-template<typename _Tp> static inline | |
-Mat_<_Tp>& operator /= (const Mat_<_Tp>& a, const Mat_<_Tp>& b) | |
-{ | |
- divide(a, b, (Mat&)a); | |
- return (Mat_<_Tp>&)a; | |
-} | |
- | |
-template<typename _Tp> static inline | |
-Mat_<_Tp>& operator /= (const Mat_<_Tp>& a, double s) | |
-{ | |
- a.convertTo((Mat&)a, -1, 1./s); | |
- return (Mat_<_Tp>&)a; | |
-} | |
- | |
-static inline Mat& operator /= (const Mat& a, const MatExpr& b) | |
-{ | |
- b.op->augAssignDivide(b, (Mat&)a); | |
- return (Mat&)a; | |
-} | |
- | |
-template<typename _Tp> static inline | |
-Mat_<_Tp>& operator /= (const Mat_<_Tp>& a, const MatExpr& b) | |
-{ | |
- b.op->augAssignDivide(b, (Mat&)a); | |
- return (Mat_<_Tp>&)a; | |
-} | |
- | |
-////////////////////////////// Logical operations /////////////////////////////// | |
- | |
-static inline Mat& operator &= (const Mat& a, const Mat& b) | |
-{ | |
- bitwise_and(a, b, (Mat&)a); | |
- return (Mat&)a; | |
-} | |
- | |
-static inline Mat& operator &= (const Mat& a, const Scalar& s) | |
-{ | |
- bitwise_and(a, s, (Mat&)a); | |
- return (Mat&)a; | |
-} | |
- | |
-template<typename _Tp> static inline Mat_<_Tp>& | |
-operator &= (const Mat_<_Tp>& a, const Mat_<_Tp>& b) | |
-{ | |
- bitwise_and(a, b, (Mat&)a); | |
- return (Mat_<_Tp>&)a; | |
-} | |
- | |
-template<typename _Tp> static inline Mat_<_Tp>& | |
-operator &= (const Mat_<_Tp>& a, const Scalar& s) | |
-{ | |
- bitwise_and(a, s, (Mat&)a); | |
- return (Mat_<_Tp>&)a; | |
-} | |
- | |
-static inline Mat& operator |= (const Mat& a, const Mat& b) | |
-{ | |
- bitwise_or(a, b, (Mat&)a); | |
- return (Mat&)a; | |
-} | |
- | |
-static inline Mat& operator |= (const Mat& a, const Scalar& s) | |
-{ | |
- bitwise_or(a, s, (Mat&)a); | |
- return (Mat&)a; | |
-} | |
- | |
-template<typename _Tp> static inline Mat_<_Tp>& | |
-operator |= (const Mat_<_Tp>& a, const Mat_<_Tp>& b) | |
-{ | |
- bitwise_or(a, b, (Mat&)a); | |
- return (Mat_<_Tp>&)a; | |
-} | |
- | |
-template<typename _Tp> static inline Mat_<_Tp>& | |
-operator |= (const Mat_<_Tp>& a, const Scalar& s) | |
-{ | |
- bitwise_or(a, s, (Mat&)a); | |
- return (Mat_<_Tp>&)a; | |
-} | |
- | |
-static inline Mat& operator ^= (const Mat& a, const Mat& b) | |
-{ | |
- bitwise_xor(a, b, (Mat&)a); | |
- return (Mat&)a; | |
-} | |
- | |
-static inline Mat& operator ^= (const Mat& a, const Scalar& s) | |
-{ | |
- bitwise_xor(a, s, (Mat&)a); | |
- return (Mat&)a; | |
-} | |
- | |
-template<typename _Tp> static inline Mat_<_Tp>& | |
-operator ^= (const Mat_<_Tp>& a, const Mat_<_Tp>& b) | |
-{ | |
- bitwise_xor(a, b, (Mat&)a); | |
- return (Mat_<_Tp>&)a; | |
-} | |
- | |
-template<typename _Tp> static inline Mat_<_Tp>& | |
-operator ^= (const Mat_<_Tp>& a, const Scalar& s) | |
-{ | |
- bitwise_xor(a, s, (Mat&)a); | |
- return (Mat_<_Tp>&)a; | |
-} | |
- | |
-/////////////////////////////// Miscellaneous operations ////////////////////////////// | |
- | |
-template<typename _Tp> void split(const Mat& src, vector<Mat_<_Tp> >& mv) | |
-{ split(src, (vector<Mat>&)mv ); } | |
- | |
-////////////////////////////////////////////////////////////// | |
- | |
-template<typename _Tp> inline MatExpr Mat_<_Tp>::zeros(int rows, int cols) | |
-{ | |
- return Mat::zeros(rows, cols, DataType<_Tp>::type); | |
-} | |
- | |
-template<typename _Tp> inline MatExpr Mat_<_Tp>::zeros(Size sz) | |
-{ | |
- return Mat::zeros(sz, DataType<_Tp>::type); | |
-} | |
- | |
-template<typename _Tp> inline MatExpr Mat_<_Tp>::ones(int rows, int cols) | |
-{ | |
- return Mat::ones(rows, cols, DataType<_Tp>::type); | |
-} | |
- | |
-template<typename _Tp> inline MatExpr Mat_<_Tp>::ones(Size sz) | |
-{ | |
- return Mat::ones(sz, DataType<_Tp>::type); | |
-} | |
- | |
-template<typename _Tp> inline MatExpr Mat_<_Tp>::eye(int rows, int cols) | |
-{ | |
- return Mat::eye(rows, cols, DataType<_Tp>::type); | |
-} | |
- | |
-template<typename _Tp> inline MatExpr Mat_<_Tp>::eye(Size sz) | |
-{ | |
- return Mat::eye(sz, DataType<_Tp>::type); | |
-} | |
- | |
-//////////////////////////////// Iterators & Comma initializers ////////////////////////////////// | |
- | |
-inline MatConstIterator::MatConstIterator() | |
- : m(0), elemSize(0), ptr(0), sliceStart(0), sliceEnd(0) {} | |
- | |
-inline MatConstIterator::MatConstIterator(const Mat* _m) | |
- : m(_m), elemSize(_m->elemSize()), ptr(0), sliceStart(0), sliceEnd(0) | |
-{ | |
- if( m && m->isContinuous() ) | |
- { | |
- sliceStart = m->data; | |
- sliceEnd = sliceStart + m->total()*elemSize; | |
- } | |
- seek((const int*)0); | |
-} | |
- | |
-inline MatConstIterator::MatConstIterator(const Mat* _m, int _row, int _col) | |
- : m(_m), elemSize(_m->elemSize()), ptr(0), sliceStart(0), sliceEnd(0) | |
-{ | |
- CV_Assert(m && m->dims <= 2); | |
- if( m->isContinuous() ) | |
- { | |
- sliceStart = m->data; | |
- sliceEnd = sliceStart + m->total()*elemSize; | |
- } | |
- int idx[]={_row, _col}; | |
- seek(idx); | |
-} | |
- | |
-inline MatConstIterator::MatConstIterator(const Mat* _m, Point _pt) | |
- : m(_m), elemSize(_m->elemSize()), ptr(0), sliceStart(0), sliceEnd(0) | |
-{ | |
- CV_Assert(m && m->dims <= 2); | |
- if( m->isContinuous() ) | |
- { | |
- sliceStart = m->data; | |
- sliceEnd = sliceStart + m->total()*elemSize; | |
- } | |
- int idx[]={_pt.y, _pt.x}; | |
- seek(idx); | |
-} | |
- | |
-inline MatConstIterator::MatConstIterator(const MatConstIterator& it) | |
- : m(it.m), elemSize(it.elemSize), ptr(it.ptr), sliceStart(it.sliceStart), sliceEnd(it.sliceEnd) | |
-{} | |
- | |
-inline MatConstIterator& MatConstIterator::operator = (const MatConstIterator& it ) | |
-{ | |
- m = it.m; elemSize = it.elemSize; ptr = it.ptr; | |
- sliceStart = it.sliceStart; sliceEnd = it.sliceEnd; | |
- return *this; | |
-} | |
- | |
-inline uchar* MatConstIterator::operator *() const { return ptr; } | |
- | |
-inline MatConstIterator& MatConstIterator::operator += (ptrdiff_t ofs) | |
-{ | |
- if( !m || ofs == 0 ) | |
- return *this; | |
- ptrdiff_t ofsb = ofs*elemSize; | |
- ptr += ofsb; | |
- if( ptr < sliceStart || sliceEnd <= ptr ) | |
- { | |
- ptr -= ofsb; | |
- seek(ofs, true); | |
- } | |
- return *this; | |
-} | |
- | |
-inline MatConstIterator& MatConstIterator::operator -= (ptrdiff_t ofs) | |
-{ return (*this += -ofs); } | |
- | |
-inline MatConstIterator& MatConstIterator::operator --() | |
-{ | |
- if( m && (ptr -= elemSize) < sliceStart ) | |
- { | |
- ptr += elemSize; | |
- seek(-1, true); | |
- } | |
- return *this; | |
-} | |
- | |
-inline MatConstIterator MatConstIterator::operator --(int) | |
-{ | |
- MatConstIterator b = *this; | |
- *this += -1; | |
- return b; | |
-} | |
- | |
-inline MatConstIterator& MatConstIterator::operator ++() | |
-{ | |
- if( m && (ptr += elemSize) >= sliceEnd ) | |
- { | |
- ptr -= elemSize; | |
- seek(1, true); | |
- } | |
- return *this; | |
-} | |
- | |
-inline MatConstIterator MatConstIterator::operator ++(int) | |
-{ | |
- MatConstIterator b = *this; | |
- *this += 1; | |
- return b; | |
-} | |
- | |
-template<typename _Tp> inline MatConstIterator_<_Tp>::MatConstIterator_() {} | |
- | |
-template<typename _Tp> inline MatConstIterator_<_Tp>::MatConstIterator_(const Mat_<_Tp>* _m) | |
- : MatConstIterator(_m) {} | |
- | |
-template<typename _Tp> inline MatConstIterator_<_Tp>:: | |
- MatConstIterator_(const Mat_<_Tp>* _m, int _row, int _col) | |
- : MatConstIterator(_m, _row, _col) {} | |
- | |
-template<typename _Tp> inline MatConstIterator_<_Tp>:: | |
- MatConstIterator_(const Mat_<_Tp>* _m, Point _pt) | |
- : MatConstIterator(_m, _pt) {} | |
- | |
-template<typename _Tp> inline MatConstIterator_<_Tp>:: | |
- MatConstIterator_(const MatConstIterator_& it) | |
- : MatConstIterator(it) {} | |
- | |
-template<typename _Tp> inline MatConstIterator_<_Tp>& | |
- MatConstIterator_<_Tp>::operator = (const MatConstIterator_& it ) | |
-{ | |
- MatConstIterator::operator = (it); | |
- return *this; | |
-} | |
- | |
-template<typename _Tp> inline _Tp MatConstIterator_<_Tp>::operator *() const { return *(_Tp*)(this->ptr); } | |
- | |
-template<typename _Tp> inline MatConstIterator_<_Tp>& MatConstIterator_<_Tp>::operator += (ptrdiff_t ofs) | |
-{ | |
- MatConstIterator::operator += (ofs); | |
- return *this; | |
-} | |
- | |
-template<typename _Tp> inline MatConstIterator_<_Tp>& MatConstIterator_<_Tp>::operator -= (ptrdiff_t ofs) | |
-{ return (*this += -ofs); } | |
- | |
-template<typename _Tp> inline MatConstIterator_<_Tp>& MatConstIterator_<_Tp>::operator --() | |
-{ | |
- MatConstIterator::operator --(); | |
- return *this; | |
-} | |
- | |
-template<typename _Tp> inline MatConstIterator_<_Tp> MatConstIterator_<_Tp>::operator --(int) | |
-{ | |
- MatConstIterator_ b = *this; | |
- MatConstIterator::operator --(); | |
- return b; | |
-} | |
- | |
-template<typename _Tp> inline MatConstIterator_<_Tp>& MatConstIterator_<_Tp>::operator ++() | |
-{ | |
- MatConstIterator::operator ++(); | |
- return *this; | |
-} | |
- | |
-template<typename _Tp> inline MatConstIterator_<_Tp> MatConstIterator_<_Tp>::operator ++(int) | |
-{ | |
- MatConstIterator_ b = *this; | |
- MatConstIterator::operator ++(); | |
- return b; | |
-} | |
- | |
-template<typename _Tp> inline MatIterator_<_Tp>::MatIterator_() : MatConstIterator_<_Tp>() {} | |
- | |
-template<typename _Tp> inline MatIterator_<_Tp>::MatIterator_(Mat_<_Tp>* _m) | |
- : MatConstIterator_<_Tp>(_m) {} | |
- | |
-template<typename _Tp> inline MatIterator_<_Tp>::MatIterator_(Mat_<_Tp>* _m, int _row, int _col) | |
- : MatConstIterator_<_Tp>(_m, _row, _col) {} | |
- | |
-template<typename _Tp> inline MatIterator_<_Tp>::MatIterator_(const Mat_<_Tp>* _m, Point _pt) | |
- : MatConstIterator_<_Tp>(_m, _pt) {} | |
- | |
-template<typename _Tp> inline MatIterator_<_Tp>::MatIterator_(const Mat_<_Tp>* _m, const int* _idx) | |
- : MatConstIterator_<_Tp>(_m, _idx) {} | |
- | |
-template<typename _Tp> inline MatIterator_<_Tp>::MatIterator_(const MatIterator_& it) | |
- : MatConstIterator_<_Tp>(it) {} | |
- | |
-template<typename _Tp> inline MatIterator_<_Tp>& MatIterator_<_Tp>::operator = (const MatIterator_<_Tp>& it ) | |
-{ | |
- MatConstIterator::operator = (it); | |
- return *this; | |
-} | |
- | |
-template<typename _Tp> inline _Tp& MatIterator_<_Tp>::operator *() const { return *(_Tp*)(this->ptr); } | |
- | |
-template<typename _Tp> inline MatIterator_<_Tp>& MatIterator_<_Tp>::operator += (ptrdiff_t ofs) | |
-{ | |
- MatConstIterator::operator += (ofs); | |
- return *this; | |
-} | |
- | |
-template<typename _Tp> inline MatIterator_<_Tp>& MatIterator_<_Tp>::operator -= (ptrdiff_t ofs) | |
-{ | |
- MatConstIterator::operator += (-ofs); | |
- return *this; | |
-} | |
- | |
-template<typename _Tp> inline MatIterator_<_Tp>& MatIterator_<_Tp>::operator --() | |
-{ | |
- MatConstIterator::operator --(); | |
- return *this; | |
-} | |
- | |
-template<typename _Tp> inline MatIterator_<_Tp> MatIterator_<_Tp>::operator --(int) | |
-{ | |
- MatIterator_ b = *this; | |
- MatConstIterator::operator --(); | |
- return b; | |
-} | |
- | |
-template<typename _Tp> inline MatIterator_<_Tp>& MatIterator_<_Tp>::operator ++() | |
-{ | |
- MatConstIterator::operator ++(); | |
- return *this; | |
-} | |
- | |
-template<typename _Tp> inline MatIterator_<_Tp> MatIterator_<_Tp>::operator ++(int) | |
-{ | |
- MatIterator_ b = *this; | |
- MatConstIterator::operator ++(); | |
- return b; | |
-} | |
- | |
-template<typename _Tp> inline Point MatConstIterator_<_Tp>::pos() const | |
-{ | |
- if( !m ) | |
- return Point(); | |
- CV_DbgAssert( m->dims <= 2 ); | |
- if( m->isContinuous() ) | |
- { | |
- ptrdiff_t ofs = (const _Tp*)ptr - (const _Tp*)m->data; | |
- int y = (int)(ofs / m->cols), x = (int)(ofs - (ptrdiff_t)y*m->cols); | |
- return Point(x, y); | |
- } | |
- else | |
- { | |
- ptrdiff_t ofs = (uchar*)ptr - m->data; | |
- int y = (int)(ofs / m->step), x = (int)((ofs - y*m->step)/sizeof(_Tp)); | |
- return Point(x, y); | |
- } | |
-} | |
- | |
-static inline bool | |
-operator == (const MatConstIterator& a, const MatConstIterator& b) | |
-{ return a.m == b.m && a.ptr == b.ptr; } | |
- | |
-template<typename _Tp> static inline bool | |
-operator != (const MatConstIterator& a, const MatConstIterator& b) | |
-{ return !(a == b); } | |
- | |
-template<typename _Tp> static inline bool | |
-operator == (const MatConstIterator_<_Tp>& a, const MatConstIterator_<_Tp>& b) | |
-{ return a.m == b.m && a.ptr == b.ptr; } | |
- | |
-template<typename _Tp> static inline bool | |
-operator != (const MatConstIterator_<_Tp>& a, const MatConstIterator_<_Tp>& b) | |
-{ return a.m != b.m || a.ptr != b.ptr; } | |
- | |
-template<typename _Tp> static inline bool | |
-operator == (const MatIterator_<_Tp>& a, const MatIterator_<_Tp>& b) | |
-{ return a.m == b.m && a.ptr == b.ptr; } | |
- | |
-template<typename _Tp> static inline bool | |
-operator != (const MatIterator_<_Tp>& a, const MatIterator_<_Tp>& b) | |
-{ return a.m != b.m || a.ptr != b.ptr; } | |
- | |
-static inline bool | |
-operator < (const MatConstIterator& a, const MatConstIterator& b) | |
-{ return a.ptr < b.ptr; } | |
- | |
-static inline bool | |
-operator > (const MatConstIterator& a, const MatConstIterator& b) | |
-{ return a.ptr > b.ptr; } | |
- | |
-static inline bool | |
-operator <= (const MatConstIterator& a, const MatConstIterator& b) | |
-{ return a.ptr <= b.ptr; } | |
- | |
-static inline bool | |
-operator >= (const MatConstIterator& a, const MatConstIterator& b) | |
-{ return a.ptr >= b.ptr; } | |
- | |
-CV_EXPORTS ptrdiff_t operator - (const MatConstIterator& b, const MatConstIterator& a); | |
- | |
-static inline MatConstIterator operator + (const MatConstIterator& a, ptrdiff_t ofs) | |
-{ MatConstIterator b = a; return b += ofs; } | |
- | |
-static inline MatConstIterator operator + (ptrdiff_t ofs, const MatConstIterator& a) | |
-{ MatConstIterator b = a; return b += ofs; } | |
- | |
-static inline MatConstIterator operator - (const MatConstIterator& a, ptrdiff_t ofs) | |
-{ MatConstIterator b = a; return b += -ofs; } | |
- | |
-template<typename _Tp> static inline MatConstIterator_<_Tp> | |
-operator + (const MatConstIterator_<_Tp>& a, ptrdiff_t ofs) | |
-{ MatConstIterator t = (const MatConstIterator&)a + ofs; return (MatConstIterator_<_Tp>&)t; } | |
- | |
-template<typename _Tp> static inline MatConstIterator_<_Tp> | |
-operator + (ptrdiff_t ofs, const MatConstIterator_<_Tp>& a) | |
-{ MatConstIterator t = (const MatConstIterator&)a + ofs; return (MatConstIterator_<_Tp>&)t; } | |
- | |
-template<typename _Tp> static inline MatConstIterator_<_Tp> | |
-operator - (const MatConstIterator_<_Tp>& a, ptrdiff_t ofs) | |
-{ MatConstIterator t = (const MatConstIterator&)a - ofs; return (MatConstIterator_<_Tp>&)t; } | |
- | |
-inline uchar* MatConstIterator::operator [](ptrdiff_t i) const | |
-{ return *(*this + i); } | |
- | |
-template<typename _Tp> inline _Tp MatConstIterator_<_Tp>::operator [](ptrdiff_t i) const | |
-{ return *(_Tp*)MatConstIterator::operator [](i); } | |
- | |
-template<typename _Tp> static inline MatIterator_<_Tp> | |
-operator + (const MatIterator_<_Tp>& a, ptrdiff_t ofs) | |
-{ MatConstIterator t = (const MatConstIterator&)a + ofs; return (MatIterator_<_Tp>&)t; } | |
- | |
-template<typename _Tp> static inline MatIterator_<_Tp> | |
-operator + (ptrdiff_t ofs, const MatIterator_<_Tp>& a) | |
-{ MatConstIterator t = (const MatConstIterator&)a + ofs; return (MatIterator_<_Tp>&)t; } | |
- | |
-template<typename _Tp> static inline MatIterator_<_Tp> | |
-operator - (const MatIterator_<_Tp>& a, ptrdiff_t ofs) | |
-{ MatConstIterator t = (const MatConstIterator&)a - ofs; return (MatIterator_<_Tp>&)t; } | |
- | |
-template<typename _Tp> inline _Tp& MatIterator_<_Tp>::operator [](ptrdiff_t i) const | |
-{ return *(*this + i); } | |
- | |
-template<typename _Tp> inline MatConstIterator_<_Tp> Mat_<_Tp>::begin() const | |
-{ return Mat::begin<_Tp>(); } | |
- | |
-template<typename _Tp> inline MatConstIterator_<_Tp> Mat_<_Tp>::end() const | |
-{ return Mat::end<_Tp>(); } | |
- | |
-template<typename _Tp> inline MatIterator_<_Tp> Mat_<_Tp>::begin() | |
-{ return Mat::begin<_Tp>(); } | |
- | |
-template<typename _Tp> inline MatIterator_<_Tp> Mat_<_Tp>::end() | |
-{ return Mat::end<_Tp>(); } | |
- | |
-template<typename _Tp> inline MatCommaInitializer_<_Tp>::MatCommaInitializer_(Mat_<_Tp>* _m) : it(_m) {} | |
- | |
-template<typename _Tp> template<typename T2> inline MatCommaInitializer_<_Tp>& | |
-MatCommaInitializer_<_Tp>::operator , (T2 v) | |
-{ | |
- CV_DbgAssert( this->it < ((const Mat_<_Tp>*)this->it.m)->end() ); | |
- *this->it = _Tp(v); ++this->it; | |
- return *this; | |
-} | |
- | |
-template<typename _Tp> inline Mat_<_Tp> MatCommaInitializer_<_Tp>::operator *() const | |
-{ | |
- CV_DbgAssert( this->it == ((const Mat_<_Tp>*)this->it.m)->end() ); | |
- return Mat_<_Tp>(*this->it.m); | |
-} | |
- | |
-template<typename _Tp> inline MatCommaInitializer_<_Tp>::operator Mat_<_Tp>() const | |
-{ | |
- CV_DbgAssert( this->it == ((const Mat_<_Tp>*)this->it.m)->end() ); | |
- return Mat_<_Tp>(*this->it.m); | |
-} | |
- | |
-template<typename _Tp, typename T2> static inline MatCommaInitializer_<_Tp> | |
-operator << (const Mat_<_Tp>& m, T2 val) | |
-{ | |
- MatCommaInitializer_<_Tp> commaInitializer((Mat_<_Tp>*)&m); | |
- return (commaInitializer, val); | |
-} | |
- | |
-//////////////////////////////// SparseMat //////////////////////////////// | |
- | |
-inline SparseMat::SparseMat() | |
-: flags(MAGIC_VAL), hdr(0) | |
-{ | |
-} | |
- | |
-inline SparseMat::SparseMat(int _dims, const int* _sizes, int _type) | |
-: flags(MAGIC_VAL), hdr(0) | |
-{ | |
- create(_dims, _sizes, _type); | |
-} | |
- | |
-inline SparseMat::SparseMat(const SparseMat& m) | |
-: flags(m.flags), hdr(m.hdr) | |
-{ | |
- addref(); | |
-} | |
- | |
-inline SparseMat::~SparseMat() | |
-{ | |
- release(); | |
-} | |
- | |
-inline SparseMat& SparseMat::operator = (const SparseMat& m) | |
-{ | |
- if( this != &m ) | |
- { | |
- if( m.hdr ) | |
- CV_XADD(&m.hdr->refcount, 1); | |
- release(); | |
- flags = m.flags; | |
- hdr = m.hdr; | |
- } | |
- return *this; | |
-} | |
- | |
-inline SparseMat& SparseMat::operator = (const Mat& m) | |
-{ return (*this = SparseMat(m)); } | |
- | |
-inline SparseMat SparseMat::clone() const | |
-{ | |
- SparseMat temp; | |
- this->copyTo(temp); | |
- return temp; | |
-} | |
- | |
- | |
-inline void SparseMat::assignTo( SparseMat& m, int type ) const | |
-{ | |
- if( type < 0 ) | |
- m = *this; | |
- else | |
- convertTo(m, type); | |
-} | |
- | |
-inline void SparseMat::addref() | |
-{ if( hdr ) CV_XADD(&hdr->refcount, 1); } | |
- | |
-inline void SparseMat::release() | |
-{ | |
- if( hdr && CV_XADD(&hdr->refcount, -1) == 1 ) | |
- delete hdr; | |
- hdr = 0; | |
-} | |
- | |
-inline size_t SparseMat::elemSize() const | |
-{ return CV_ELEM_SIZE(flags); } | |
- | |
-inline size_t SparseMat::elemSize1() const | |
-{ return CV_ELEM_SIZE1(flags); } | |
- | |
-inline int SparseMat::type() const | |
-{ return CV_MAT_TYPE(flags); } | |
- | |
-inline int SparseMat::depth() const | |
-{ return CV_MAT_DEPTH(flags); } | |
- | |
-inline int SparseMat::channels() const | |
-{ return CV_MAT_CN(flags); } | |
- | |
-inline const int* SparseMat::size() const | |
-{ | |
- return hdr ? hdr->size : 0; | |
-} | |
- | |
-inline int SparseMat::size(int i) const | |
-{ | |
- if( hdr ) | |
- { | |
- CV_DbgAssert((unsigned)i < (unsigned)hdr->dims); | |
- return hdr->size[i]; | |
- } | |
- return 0; | |
-} | |
- | |
-inline int SparseMat::dims() const | |
-{ | |
- return hdr ? hdr->dims : 0; | |
-} | |
- | |
-inline size_t SparseMat::nzcount() const | |
-{ | |
- return hdr ? hdr->nodeCount : 0; | |
-} | |
- | |
-inline size_t SparseMat::hash(int i0) const | |
-{ | |
- return (size_t)i0; | |
-} | |
- | |
-inline size_t SparseMat::hash(int i0, int i1) const | |
-{ | |
- return (size_t)(unsigned)i0*HASH_SCALE + (unsigned)i1; | |
-} | |
- | |
-inline size_t SparseMat::hash(int i0, int i1, int i2) const | |
-{ | |
- return ((size_t)(unsigned)i0*HASH_SCALE + (unsigned)i1)*HASH_SCALE + (unsigned)i2; | |
-} | |
- | |
-inline size_t SparseMat::hash(const int* idx) const | |
-{ | |
- size_t h = (unsigned)idx[0]; | |
- if( !hdr ) | |
- return 0; | |
- int i, d = hdr->dims; | |
- for( i = 1; i < d; i++ ) | |
- h = h*HASH_SCALE + (unsigned)idx[i]; | |
- return h; | |
-} | |
- | |
-template<typename _Tp> inline _Tp& SparseMat::ref(int i0, size_t* hashval) | |
-{ return *(_Tp*)((SparseMat*)this)->ptr(i0, true, hashval); } | |
- | |
-template<typename _Tp> inline _Tp& SparseMat::ref(int i0, int i1, size_t* hashval) | |
-{ return *(_Tp*)((SparseMat*)this)->ptr(i0, i1, true, hashval); } | |
- | |
-template<typename _Tp> inline _Tp& SparseMat::ref(int i0, int i1, int i2, size_t* hashval) | |
-{ return *(_Tp*)((SparseMat*)this)->ptr(i0, i1, i2, true, hashval); } | |
- | |
-template<typename _Tp> inline _Tp& SparseMat::ref(const int* idx, size_t* hashval) | |
-{ return *(_Tp*)((SparseMat*)this)->ptr(idx, true, hashval); } | |
- | |
-template<typename _Tp> inline _Tp SparseMat::value(int i0, size_t* hashval) const | |
-{ | |
- const _Tp* p = (const _Tp*)((SparseMat*)this)->ptr(i0, false, hashval); | |
- return p ? *p : _Tp(); | |
-} | |
- | |
-template<typename _Tp> inline _Tp SparseMat::value(int i0, int i1, size_t* hashval) const | |
-{ | |
- const _Tp* p = (const _Tp*)((SparseMat*)this)->ptr(i0, i1, false, hashval); | |
- return p ? *p : _Tp(); | |
-} | |
- | |
-template<typename _Tp> inline _Tp SparseMat::value(int i0, int i1, int i2, size_t* hashval) const | |
-{ | |
- const _Tp* p = (const _Tp*)((SparseMat*)this)->ptr(i0, i1, i2, false, hashval); | |
- return p ? *p : _Tp(); | |
-} | |
- | |
-template<typename _Tp> inline _Tp SparseMat::value(const int* idx, size_t* hashval) const | |
-{ | |
- const _Tp* p = (const _Tp*)((SparseMat*)this)->ptr(idx, false, hashval); | |
- return p ? *p : _Tp(); | |
-} | |
- | |
-template<typename _Tp> inline const _Tp* SparseMat::find(int i0, size_t* hashval) const | |
-{ return (const _Tp*)((SparseMat*)this)->ptr(i0, false, hashval); } | |
- | |
-template<typename _Tp> inline const _Tp* SparseMat::find(int i0, int i1, size_t* hashval) const | |
-{ return (const _Tp*)((SparseMat*)this)->ptr(i0, i1, false, hashval); } | |
- | |
-template<typename _Tp> inline const _Tp* SparseMat::find(int i0, int i1, int i2, size_t* hashval) const | |
-{ return (const _Tp*)((SparseMat*)this)->ptr(i0, i1, i2, false, hashval); } | |
- | |
-template<typename _Tp> inline const _Tp* SparseMat::find(const int* idx, size_t* hashval) const | |
-{ return (const _Tp*)((SparseMat*)this)->ptr(idx, false, hashval); } | |
- | |
-template<typename _Tp> inline _Tp& SparseMat::value(Node* n) | |
-{ return *(_Tp*)((uchar*)n + hdr->valueOffset); } | |
- | |
-template<typename _Tp> inline const _Tp& SparseMat::value(const Node* n) const | |
-{ return *(const _Tp*)((const uchar*)n + hdr->valueOffset); } | |
- | |
-inline SparseMat::Node* SparseMat::node(size_t nidx) | |
-{ return (Node*)&hdr->pool[nidx]; } | |
- | |
-inline const SparseMat::Node* SparseMat::node(size_t nidx) const | |
-{ return (const Node*)&hdr->pool[nidx]; } | |
- | |
-inline SparseMatIterator SparseMat::begin() | |
-{ return SparseMatIterator(this); } | |
- | |
-inline SparseMatConstIterator SparseMat::begin() const | |
-{ return SparseMatConstIterator(this); } | |
- | |
-inline SparseMatIterator SparseMat::end() | |
-{ SparseMatIterator it(this); it.seekEnd(); return it; } | |
- | |
-inline SparseMatConstIterator SparseMat::end() const | |
-{ SparseMatConstIterator it(this); it.seekEnd(); return it; } | |
- | |
-template<typename _Tp> inline SparseMatIterator_<_Tp> SparseMat::begin() | |
-{ return SparseMatIterator_<_Tp>(this); } | |
- | |
-template<typename _Tp> inline SparseMatConstIterator_<_Tp> SparseMat::begin() const | |
-{ return SparseMatConstIterator_<_Tp>(this); } | |
- | |
-template<typename _Tp> inline SparseMatIterator_<_Tp> SparseMat::end() | |
-{ SparseMatIterator_<_Tp> it(this); it.seekEnd(); return it; } | |
- | |
-template<typename _Tp> inline SparseMatConstIterator_<_Tp> SparseMat::end() const | |
-{ SparseMatConstIterator_<_Tp> it(this); it.seekEnd(); return it; } | |
- | |
- | |
-inline SparseMatConstIterator::SparseMatConstIterator() | |
-: m(0), hashidx(0), ptr(0) | |
-{ | |
-} | |
- | |
-inline SparseMatConstIterator::SparseMatConstIterator(const SparseMatConstIterator& it) | |
-: m(it.m), hashidx(it.hashidx), ptr(it.ptr) | |
-{ | |
-} | |
- | |
-static inline bool operator == (const SparseMatConstIterator& it1, const SparseMatConstIterator& it2) | |
-{ return it1.m == it2.m && it1.ptr == it2.ptr; } | |
- | |
-static inline bool operator != (const SparseMatConstIterator& it1, const SparseMatConstIterator& it2) | |
-{ return !(it1 == it2); } | |
- | |
- | |
-inline SparseMatConstIterator& SparseMatConstIterator::operator = (const SparseMatConstIterator& it) | |
-{ | |
- if( this != &it ) | |
- { | |
- m = it.m; | |
- hashidx = it.hashidx; | |
- ptr = it.ptr; | |
- } | |
- return *this; | |
-} | |
- | |
-template<typename _Tp> inline const _Tp& SparseMatConstIterator::value() const | |
-{ return *(_Tp*)ptr; } | |
- | |
-inline const SparseMat::Node* SparseMatConstIterator::node() const | |
-{ | |
- return ptr && m && m->hdr ? | |
- (const SparseMat::Node*)(ptr - m->hdr->valueOffset) : 0; | |
-} | |
- | |
-inline SparseMatConstIterator SparseMatConstIterator::operator ++(int) | |
-{ | |
- SparseMatConstIterator it = *this; | |
- ++*this; | |
- return it; | |
-} | |
- | |
- | |
-inline void SparseMatConstIterator::seekEnd() | |
-{ | |
- if( m && m->hdr ) | |
- { | |
- hashidx = m->hdr->hashtab.size(); | |
- ptr = 0; | |
- } | |
-} | |
- | |
-inline SparseMatIterator::SparseMatIterator() | |
-{} | |
- | |
-inline SparseMatIterator::SparseMatIterator(SparseMat* _m) | |
-: SparseMatConstIterator(_m) | |
-{} | |
- | |
-inline SparseMatIterator::SparseMatIterator(const SparseMatIterator& it) | |
-: SparseMatConstIterator(it) | |
-{ | |
-} | |
- | |
-inline SparseMatIterator& SparseMatIterator::operator = (const SparseMatIterator& it) | |
-{ | |
- (SparseMatConstIterator&)*this = it; | |
- return *this; | |
-} | |
- | |
-template<typename _Tp> inline _Tp& SparseMatIterator::value() const | |
-{ return *(_Tp*)ptr; } | |
- | |
-inline SparseMat::Node* SparseMatIterator::node() const | |
-{ | |
- return (SparseMat::Node*)SparseMatConstIterator::node(); | |
-} | |
- | |
-inline SparseMatIterator& SparseMatIterator::operator ++() | |
-{ | |
- SparseMatConstIterator::operator ++(); | |
- return *this; | |
-} | |
- | |
-inline SparseMatIterator SparseMatIterator::operator ++(int) | |
-{ | |
- SparseMatIterator it = *this; | |
- ++*this; | |
- return it; | |
-} | |
- | |
- | |
-template<typename _Tp> inline SparseMat_<_Tp>::SparseMat_() | |
-{ flags = MAGIC_VAL | DataType<_Tp>::type; } | |
- | |
-template<typename _Tp> inline SparseMat_<_Tp>::SparseMat_(int _dims, const int* _sizes) | |
-: SparseMat(_dims, _sizes, DataType<_Tp>::type) | |
-{} | |
- | |
-template<typename _Tp> inline SparseMat_<_Tp>::SparseMat_(const SparseMat& m) | |
-{ | |
- if( m.type() == DataType<_Tp>::type ) | |
- *this = (const SparseMat_<_Tp>&)m; | |
- else | |
- m.convertTo(this, DataType<_Tp>::type); | |
-} | |
- | |
-template<typename _Tp> inline SparseMat_<_Tp>::SparseMat_(const SparseMat_<_Tp>& m) | |
-{ | |
- this->flags = m.flags; | |
- this->hdr = m.hdr; | |
- if( this->hdr ) | |
- CV_XADD(&this->hdr->refcount, 1); | |
-} | |
- | |
-template<typename _Tp> inline SparseMat_<_Tp>::SparseMat_(const Mat& m) | |
-{ | |
- SparseMat sm(m); | |
- *this = sm; | |
-} | |
- | |
-template<typename _Tp> inline SparseMat_<_Tp>::SparseMat_(const CvSparseMat* m) | |
-{ | |
- SparseMat sm(m); | |
- *this = sm; | |
-} | |
- | |
-template<typename _Tp> inline SparseMat_<_Tp>& | |
-SparseMat_<_Tp>::operator = (const SparseMat_<_Tp>& m) | |
-{ | |
- if( this != &m ) | |
- { | |
- if( m.hdr ) CV_XADD(&m.hdr->refcount, 1); | |
- release(); | |
- flags = m.flags; | |
- hdr = m.hdr; | |
- } | |
- return *this; | |
-} | |
- | |
-template<typename _Tp> inline SparseMat_<_Tp>& | |
-SparseMat_<_Tp>::operator = (const SparseMat& m) | |
-{ | |
- if( m.type() == DataType<_Tp>::type ) | |
- return (*this = (const SparseMat_<_Tp>&)m); | |
- m.convertTo(*this, DataType<_Tp>::type); | |
- return *this; | |
-} | |
- | |
-template<typename _Tp> inline SparseMat_<_Tp>& | |
-SparseMat_<_Tp>::operator = (const Mat& m) | |
-{ return (*this = SparseMat(m)); } | |
- | |
-template<typename _Tp> inline SparseMat_<_Tp> | |
-SparseMat_<_Tp>::clone() const | |
-{ | |
- SparseMat_<_Tp> m; | |
- this->copyTo(m); | |
- return m; | |
-} | |
- | |
-template<typename _Tp> inline void | |
-SparseMat_<_Tp>::create(int _dims, const int* _sizes) | |
-{ | |
- SparseMat::create(_dims, _sizes, DataType<_Tp>::type); | |
-} | |
- | |
-template<typename _Tp> inline | |
-SparseMat_<_Tp>::operator CvSparseMat*() const | |
-{ | |
- return SparseMat::operator CvSparseMat*(); | |
-} | |
- | |
-template<typename _Tp> inline int SparseMat_<_Tp>::type() const | |
-{ return DataType<_Tp>::type; } | |
- | |
-template<typename _Tp> inline int SparseMat_<_Tp>::depth() const | |
-{ return DataType<_Tp>::depth; } | |
- | |
-template<typename _Tp> inline int SparseMat_<_Tp>::channels() const | |
-{ return DataType<_Tp>::channels; } | |
- | |
-template<typename _Tp> inline _Tp& | |
-SparseMat_<_Tp>::ref(int i0, size_t* hashval) | |
-{ return SparseMat::ref<_Tp>(i0, hashval); } | |
- | |
-template<typename _Tp> inline _Tp | |
-SparseMat_<_Tp>::operator()(int i0, size_t* hashval) const | |
-{ return SparseMat::value<_Tp>(i0, hashval); } | |
- | |
-template<typename _Tp> inline _Tp& | |
-SparseMat_<_Tp>::ref(int i0, int i1, size_t* hashval) | |
-{ return SparseMat::ref<_Tp>(i0, i1, hashval); } | |
- | |
-template<typename _Tp> inline _Tp | |
-SparseMat_<_Tp>::operator()(int i0, int i1, size_t* hashval) const | |
-{ return SparseMat::value<_Tp>(i0, i1, hashval); } | |
- | |
-template<typename _Tp> inline _Tp& | |
-SparseMat_<_Tp>::ref(int i0, int i1, int i2, size_t* hashval) | |
-{ return SparseMat::ref<_Tp>(i0, i1, i2, hashval); } | |
- | |
-template<typename _Tp> inline _Tp | |
-SparseMat_<_Tp>::operator()(int i0, int i1, int i2, size_t* hashval) const | |
-{ return SparseMat::value<_Tp>(i0, i1, i2, hashval); } | |
- | |
-template<typename _Tp> inline _Tp& | |
-SparseMat_<_Tp>::ref(const int* idx, size_t* hashval) | |
-{ return SparseMat::ref<_Tp>(idx, hashval); } | |
- | |
-template<typename _Tp> inline _Tp | |
-SparseMat_<_Tp>::operator()(const int* idx, size_t* hashval) const | |
-{ return SparseMat::value<_Tp>(idx, hashval); } | |
- | |
-template<typename _Tp> inline SparseMatIterator_<_Tp> SparseMat_<_Tp>::begin() | |
-{ return SparseMatIterator_<_Tp>(this); } | |
- | |
-template<typename _Tp> inline SparseMatConstIterator_<_Tp> SparseMat_<_Tp>::begin() const | |
-{ return SparseMatConstIterator_<_Tp>(this); } | |
- | |
-template<typename _Tp> inline SparseMatIterator_<_Tp> SparseMat_<_Tp>::end() | |
-{ SparseMatIterator_<_Tp> it(this); it.seekEnd(); return it; } | |
- | |
-template<typename _Tp> inline SparseMatConstIterator_<_Tp> SparseMat_<_Tp>::end() const | |
-{ SparseMatConstIterator_<_Tp> it(this); it.seekEnd(); return it; } | |
- | |
-template<typename _Tp> inline | |
-SparseMatConstIterator_<_Tp>::SparseMatConstIterator_() | |
-{} | |
- | |
-template<typename _Tp> inline | |
-SparseMatConstIterator_<_Tp>::SparseMatConstIterator_(const SparseMat_<_Tp>* _m) | |
-: SparseMatConstIterator(_m) | |
-{} | |
- | |
-template<typename _Tp> inline | |
-SparseMatConstIterator_<_Tp>::SparseMatConstIterator_(const SparseMatConstIterator_<_Tp>& it) | |
-: SparseMatConstIterator(it) | |
-{} | |
- | |
-template<typename _Tp> inline SparseMatConstIterator_<_Tp>& | |
-SparseMatConstIterator_<_Tp>::operator = (const SparseMatConstIterator_<_Tp>& it) | |
-{ return reinterpret_cast<SparseMatConstIterator_<_Tp>&> | |
- (*reinterpret_cast<SparseMatConstIterator*>(this) = | |
- reinterpret_cast<const SparseMatConstIterator&>(it)); } | |
- | |
-template<typename _Tp> inline const _Tp& | |
-SparseMatConstIterator_<_Tp>::operator *() const | |
-{ return *(const _Tp*)this->ptr; } | |
- | |
-template<typename _Tp> inline SparseMatConstIterator_<_Tp>& | |
-SparseMatConstIterator_<_Tp>::operator ++() | |
-{ | |
- SparseMatConstIterator::operator ++(); | |
- return *this; | |
-} | |
- | |
-template<typename _Tp> inline SparseMatConstIterator_<_Tp> | |
-SparseMatConstIterator_<_Tp>::operator ++(int) | |
-{ | |
- SparseMatConstIterator it = *this; | |
- SparseMatConstIterator::operator ++(); | |
- return it; | |
-} | |
- | |
-template<typename _Tp> inline | |
-SparseMatIterator_<_Tp>::SparseMatIterator_() | |
-{} | |
- | |
-template<typename _Tp> inline | |
-SparseMatIterator_<_Tp>::SparseMatIterator_(SparseMat_<_Tp>* _m) | |
-: SparseMatConstIterator_<_Tp>(_m) | |
-{} | |
- | |
-template<typename _Tp> inline | |
-SparseMatIterator_<_Tp>::SparseMatIterator_(const SparseMatIterator_<_Tp>& it) | |
-: SparseMatConstIterator_<_Tp>(it) | |
-{} | |
- | |
-template<typename _Tp> inline SparseMatIterator_<_Tp>& | |
-SparseMatIterator_<_Tp>::operator = (const SparseMatIterator_<_Tp>& it) | |
-{ return reinterpret_cast<SparseMatIterator_<_Tp>&> | |
- (*reinterpret_cast<SparseMatConstIterator*>(this) = | |
- reinterpret_cast<const SparseMatConstIterator&>(it)); } | |
- | |
-template<typename _Tp> inline _Tp& | |
-SparseMatIterator_<_Tp>::operator *() const | |
-{ return *(_Tp*)this->ptr; } | |
- | |
-template<typename _Tp> inline SparseMatIterator_<_Tp>& | |
-SparseMatIterator_<_Tp>::operator ++() | |
-{ | |
- SparseMatConstIterator::operator ++(); | |
- return *this; | |
-} | |
- | |
-template<typename _Tp> inline SparseMatIterator_<_Tp> | |
-SparseMatIterator_<_Tp>::operator ++(int) | |
-{ | |
- SparseMatIterator it = *this; | |
- SparseMatConstIterator::operator ++(); | |
- return it; | |
-} | |
- | |
-} | |
- | |
-#endif | |
-#endif | |
diff --git a/card.io/src/main/jni/opencv2/core/opengl_interop.hpp b/card.io/src/main/jni/opencv2/core/opengl_interop.hpp | |
deleted file mode 100644 | |
index 338466b..0000000 | |
--- a/card.io/src/main/jni/opencv2/core/opengl_interop.hpp | |
+++ /dev/null | |
@@ -1,330 +0,0 @@ | |
-/*M/////////////////////////////////////////////////////////////////////////////////////// | |
-// | |
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. | |
-// | |
-// By downloading, copying, installing or using the software you agree to this license. | |
-// If you do not agree to this license, do not download, install, | |
-// copy or use the software. | |
-// | |
-// | |
-// License Agreement | |
-// For Open Source Computer Vision Library | |
-// | |
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. | |
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved. | |
-// Third party copyrights are property of their respective owners. | |
-// | |
-// Redistribution and use in source and binary forms, with or without modification, | |
-// are permitted provided that the following conditions are met: | |
-// | |
-// * Redistribution's of source code must retain the above copyright notice, | |
-// this list of conditions and the following disclaimer. | |
-// | |
-// * Redistribution's in binary form must reproduce the above copyright notice, | |
-// this list of conditions and the following disclaimer in the documentation | |
-// and/or other GpuMaterials provided with the distribution. | |
-// | |
-// * The name of the copyright holders may not be used to endorse or promote products | |
-// derived from this software without specific prior written permission. | |
-// | |
-// This software is provided by the copyright holders and contributors "as is" and | |
-// any express or implied warranties, including, but not limited to, the implied | |
-// warranties of merchantability and fitness for a particular purpose are disclaimed. | |
-// In no event shall the Intel Corporation or contributors be liable for any direct, | |
-// indirect, incidental, special, exemplary, or consequential damages | |
-// (including, but not limited to, procurement of substitute goods or services; | |
-// loss of use, data, or profits; or business interruption) however caused | |
-// and on any theory of liability, whether in contract, strict liability, | |
-// or tort (including negligence or otherwise) arising in any way out of | |
-// the use of this software, even if advised of the possibility of such damage. | |
-// | |
-//M*/ | |
- | |
-#ifndef __OPENCV_OPENGL_INTEROP_HPP__ | |
-#define __OPENCV_OPENGL_INTEROP_HPP__ | |
- | |
-#ifdef __cplusplus | |
- | |
-#include "opencv2/core/core.hpp" | |
- | |
-namespace cv | |
-{ | |
- //! Smart pointer for OpenGL buffer memory with reference counting. | |
- class CV_EXPORTS GlBuffer | |
- { | |
- public: | |
- enum Usage | |
- { | |
- ARRAY_BUFFER = 0x8892, // buffer will use for OpenGL arrays (vertices, colors, normals, etc) | |
- TEXTURE_BUFFER = 0x88EC // buffer will ise for OpenGL textures | |
- }; | |
- | |
- //! create empty buffer | |
- explicit GlBuffer(Usage usage); | |
- | |
- //! create buffer | |
- GlBuffer(int rows, int cols, int type, Usage usage); | |
- GlBuffer(Size size, int type, Usage usage); | |
- | |
- //! copy from host/device memory | |
- GlBuffer(InputArray mat, Usage usage); | |
- | |
- void create(int rows, int cols, int type, Usage usage); | |
- inline void create(Size size, int type, Usage usage) { create(size.height, size.width, type, usage); } | |
- inline void create(int rows, int cols, int type) { create(rows, cols, type, usage()); } | |
- inline void create(Size size, int type) { create(size.height, size.width, type, usage()); } | |
- | |
- void release(); | |
- | |
- //! copy from host/device memory | |
- void copyFrom(InputArray mat); | |
- | |
- void bind() const; | |
- void unbind() const; | |
- | |
- //! map to host memory | |
- Mat mapHost(); | |
- void unmapHost(); | |
- | |
- //! map to device memory | |
- gpu::GpuMat mapDevice(); | |
- void unmapDevice(); | |
- | |
- inline int rows() const { return rows_; } | |
- inline int cols() const { return cols_; } | |
- inline Size size() const { return Size(cols_, rows_); } | |
- inline bool empty() const { return rows_ == 0 || cols_ == 0; } | |
- | |
- inline int type() const { return type_; } | |
- inline int depth() const { return CV_MAT_DEPTH(type_); } | |
- inline int channels() const { return CV_MAT_CN(type_); } | |
- inline int elemSize() const { return CV_ELEM_SIZE(type_); } | |
- inline int elemSize1() const { return CV_ELEM_SIZE1(type_); } | |
- | |
- inline Usage usage() const { return usage_; } | |
- | |
- class Impl; | |
- private: | |
- int rows_; | |
- int cols_; | |
- int type_; | |
- Usage usage_; | |
- | |
- Ptr<Impl> impl_; | |
- }; | |
- | |
- template <> CV_EXPORTS void Ptr<GlBuffer::Impl>::delete_obj(); | |
- | |
- //! Smart pointer for OpenGL 2d texture memory with reference counting. | |
- class CV_EXPORTS GlTexture | |
- { | |
- public: | |
- //! create empty texture | |
- GlTexture(); | |
- | |
- //! create texture | |
- GlTexture(int rows, int cols, int type); | |
- GlTexture(Size size, int type); | |
- | |
- //! copy from host/device memory | |
- explicit GlTexture(InputArray mat, bool bgra = true); | |
- | |
- void create(int rows, int cols, int type); | |
- inline void create(Size size, int type) { create(size.height, size.width, type); } | |
- void release(); | |
- | |
- //! copy from host/device memory | |
- void copyFrom(InputArray mat, bool bgra = true); | |
- | |
- void bind() const; | |
- void unbind() const; | |
- | |
- inline int rows() const { return rows_; } | |
- inline int cols() const { return cols_; } | |
- inline Size size() const { return Size(cols_, rows_); } | |
- inline bool empty() const { return rows_ == 0 || cols_ == 0; } | |
- | |
- inline int type() const { return type_; } | |
- inline int depth() const { return CV_MAT_DEPTH(type_); } | |
- inline int channels() const { return CV_MAT_CN(type_); } | |
- inline int elemSize() const { return CV_ELEM_SIZE(type_); } | |
- inline int elemSize1() const { return CV_ELEM_SIZE1(type_); } | |
- | |
- class Impl; | |
- private: | |
- int rows_; | |
- int cols_; | |
- int type_; | |
- | |
- Ptr<Impl> impl_; | |
- GlBuffer buf_; | |
- }; | |
- | |
- template <> CV_EXPORTS void Ptr<GlTexture::Impl>::delete_obj(); | |
- | |
- //! OpenGL Arrays | |
- class CV_EXPORTS GlArrays | |
- { | |
- public: | |
- inline GlArrays() | |
- : vertex_(GlBuffer::ARRAY_BUFFER), color_(GlBuffer::ARRAY_BUFFER), bgra_(true), normal_(GlBuffer::ARRAY_BUFFER), texCoord_(GlBuffer::ARRAY_BUFFER) | |
- { | |
- } | |
- | |
- void setVertexArray(InputArray vertex); | |
- inline void resetVertexArray() { vertex_.release(); } | |
- | |
- void setColorArray(InputArray color, bool bgra = true); | |
- inline void resetColorArray() { color_.release(); } | |
- | |
- void setNormalArray(InputArray normal); | |
- inline void resetNormalArray() { normal_.release(); } | |
- | |
- void setTexCoordArray(InputArray texCoord); | |
- inline void resetTexCoordArray() { texCoord_.release(); } | |
- | |
- void bind() const; | |
- void unbind() const; | |
- | |
- inline int rows() const { return vertex_.rows(); } | |
- inline int cols() const { return vertex_.cols(); } | |
- inline Size size() const { return vertex_.size(); } | |
- inline bool empty() const { return vertex_.empty(); } | |
- | |
- private: | |
- GlBuffer vertex_; | |
- GlBuffer color_; | |
- bool bgra_; | |
- GlBuffer normal_; | |
- GlBuffer texCoord_; | |
- }; | |
- | |
- //! OpenGL Font | |
- class CV_EXPORTS GlFont | |
- { | |
- public: | |
- enum Weight | |
- { | |
- WEIGHT_LIGHT = 300, | |
- WEIGHT_NORMAL = 400, | |
- WEIGHT_SEMIBOLD = 600, | |
- WEIGHT_BOLD = 700, | |
- WEIGHT_BLACK = 900 | |
- }; | |
- | |
- enum Style | |
- { | |
- STYLE_NORMAL = 0, | |
- STYLE_ITALIC = 1, | |
- STYLE_UNDERLINE = 2 | |
- }; | |
- | |
- static Ptr<GlFont> get(const std::string& family, int height = 12, Weight weight = WEIGHT_NORMAL, Style style = STYLE_NORMAL); | |
- | |
- void draw(const char* str, int len) const; | |
- | |
- inline const std::string& family() const { return family_; } | |
- inline int height() const { return height_; } | |
- inline Weight weight() const { return weight_; } | |
- inline Style style() const { return style_; } | |
- | |
- private: | |
- GlFont(const std::string& family, int height, Weight weight, Style style); | |
- | |
- std::string family_; | |
- int height_; | |
- Weight weight_; | |
- Style style_; | |
- | |
- unsigned int base_; | |
- | |
- GlFont(const GlFont&); | |
- GlFont& operator =(const GlFont&); | |
- }; | |
- | |
- //! render functions | |
- | |
- //! render texture rectangle in window | |
- CV_EXPORTS void render(const GlTexture& tex, | |
- Rect_<double> wndRect = Rect_<double>(0.0, 0.0, 1.0, 1.0), | |
- Rect_<double> texRect = Rect_<double>(0.0, 0.0, 1.0, 1.0)); | |
- | |
- //! render mode | |
- namespace RenderMode { | |
- enum { | |
- POINTS = 0x0000, | |
- LINES = 0x0001, | |
- LINE_LOOP = 0x0002, | |
- LINE_STRIP = 0x0003, | |
- TRIANGLES = 0x0004, | |
- TRIANGLE_STRIP = 0x0005, | |
- TRIANGLE_FAN = 0x0006, | |
- QUADS = 0x0007, | |
- QUAD_STRIP = 0x0008, | |
- POLYGON = 0x0009 | |
- }; | |
- } | |
- | |
- //! render OpenGL arrays | |
- CV_EXPORTS void render(const GlArrays& arr, int mode = RenderMode::POINTS, Scalar color = Scalar::all(255)); | |
- | |
- CV_EXPORTS void render(const std::string& str, const Ptr<GlFont>& font, Scalar color, Point2d pos); | |
- | |
- //! OpenGL camera | |
- class CV_EXPORTS GlCamera | |
- { | |
- public: | |
- GlCamera(); | |
- | |
- void lookAt(Point3d eye, Point3d center, Point3d up); | |
- void setCameraPos(Point3d pos, double yaw, double pitch, double roll); | |
- | |
- void setScale(Point3d scale); | |
- | |
- void setProjectionMatrix(const Mat& projectionMatrix, bool transpose = true); | |
- void setPerspectiveProjection(double fov, double aspect, double zNear, double zFar); | |
- void setOrthoProjection(double left, double right, double bottom, double top, double zNear, double zFar); | |
- | |
- void setupProjectionMatrix() const; | |
- void setupModelViewMatrix() const; | |
- | |
- private: | |
- Point3d eye_; | |
- Point3d center_; | |
- Point3d up_; | |
- | |
- Point3d pos_; | |
- double yaw_; | |
- double pitch_; | |
- double roll_; | |
- | |
- bool useLookAtParams_; | |
- | |
- Point3d scale_; | |
- | |
- Mat projectionMatrix_; | |
- | |
- double fov_; | |
- double aspect_; | |
- | |
- double left_; | |
- double right_; | |
- double bottom_; | |
- double top_; | |
- | |
- double zNear_; | |
- double zFar_; | |
- | |
- bool perspectiveProjection_; | |
- }; | |
- | |
- namespace gpu | |
- { | |
- //! set a CUDA device to use OpenGL interoperability | |
- CV_EXPORTS void setGlDevice(int device = 0); | |
- } | |
-} // namespace cv | |
- | |
-#endif // __cplusplus | |
- | |
-#endif // __OPENCV_OPENGL_INTEROP_HPP__ | |
diff --git a/card.io/src/main/jni/opencv2/core/operations.hpp b/card.io/src/main/jni/opencv2/core/operations.hpp | |
deleted file mode 100644 | |
index 1d8d42f..0000000 | |
--- a/card.io/src/main/jni/opencv2/core/operations.hpp | |
+++ /dev/null | |
@@ -1,3862 +0,0 @@ | |
-/*M/////////////////////////////////////////////////////////////////////////////////////// | |
-// | |
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. | |
-// | |
-// By downloading, copying, installing or using the software you agree to this license. | |
-// If you do not agree to this license, do not download, install, | |
-// copy or use the software. | |
-// | |
-// | |
-// License Agreement | |
-// For Open Source Computer Vision Library | |
-// | |
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. | |
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved. | |
-// Third party copyrights are property of their respective owners. | |
-// | |
-// Redistribution and use in source and binary forms, with or without modification, | |
-// are permitted provided that the following conditions are met: | |
-// | |
-// * Redistribution's of source code must retain the above copyright notice, | |
-// this list of conditions and the following disclaimer. | |
-// | |
-// * Redistribution's in binary form must reproduce the above copyright notice, | |
-// this list of conditions and the following disclaimer in the documentation | |
-// and/or other materials provided with the distribution. | |
-// | |
-// * The name of the copyright holders may not be used to endorse or promote products | |
-// derived from this software without specific prior written permission. | |
-// | |
-// This software is provided by the copyright holders and contributors "as is" and | |
-// any express or implied warranties, including, but not limited to, the implied | |
-// warranties of merchantability and fitness for a particular purpose are disclaimed. | |
-// In no event shall the Intel Corporation or contributors be liable for any direct, | |
-// indirect, incidental, special, exemplary, or consequential damages | |
-// (including, but not limited to, procurement of substitute goods or services; | |
-// loss of use, data, or profits; or business interruption) however caused | |
-// and on any theory of liability, whether in contract, strict liability, | |
-// or tort (including negligence or otherwise) arising in any way out of | |
-// the use of this software, even if advised of the possibility of such damage. | |
-// | |
-//M*/ | |
- | |
-#ifndef __OPENCV_CORE_OPERATIONS_HPP__ | |
-#define __OPENCV_CORE_OPERATIONS_HPP__ | |
- | |
-#ifndef SKIP_INCLUDES | |
- #include <string.h> | |
- #include <limits.h> | |
-#endif // SKIP_INCLUDES | |
- | |
- | |
-#ifdef __cplusplus | |
- | |
-/////// exchange-add operation for atomic operations on reference counters /////// | |
-#if defined __INTEL_COMPILER && !(defined WIN32 || defined _WIN32) // atomic increment on the linux version of the Intel(tm) compiler | |
- #define CV_XADD(addr,delta) _InterlockedExchangeAdd(const_cast<void*>(reinterpret_cast<volatile void*>(addr)), delta) | |
-#elif defined __GNUC__ | |
- | |
- #if __GNUC__*10 + __GNUC_MINOR__ >= 42 | |
- | |
- #if !defined WIN32 && (defined __i486__ || defined __i586__ || \ | |
- defined __i686__ || defined __MMX__ || defined __SSE__ || defined __ppc__) | |
- #define CV_XADD __sync_fetch_and_add | |
- #else | |
- #include <ext/atomicity.h> | |
- #define CV_XADD __gnu_cxx::__exchange_and_add | |
- #endif | |
- | |
- #else | |
- #include <bits/atomicity.h> | |
- #if __GNUC__*10 + __GNUC_MINOR__ >= 34 | |
- #define CV_XADD __gnu_cxx::__exchange_and_add | |
- #else | |
- #define CV_XADD __exchange_and_add | |
- #endif | |
- #endif | |
- | |
-#elif defined WIN32 || defined _WIN32 | |
- #define WIN32_MEAN_AND_LEAN | |
- #ifndef _WIN32_WINNT // This is needed for the declaration of TryEnterCriticalSection in winbase.h with Visual Studio 2005 (and older?) | |
- #define _WIN32_WINNT 0x0400 // http://msdn.microsoft.com/en-us/library/ms686857(VS.85).aspx | |
- #endif | |
- #include <windows.h> | |
- #undef min | |
- #undef max | |
- #undef abs | |
- #define CV_XADD(addr,delta) InterlockedExchangeAdd((long volatile*)(addr), (delta)) | |
- | |
-#else | |
- static inline int CV_XADD(int* addr, int delta) | |
- { int tmp = *addr; *addr += delta; return tmp; } | |
-#endif | |
- | |
-#include <limits> | |
- | |
-namespace cv | |
-{ | |
- | |
-using std::cos; | |
-using std::sin; | |
-using std::max; | |
-using std::min; | |
-using std::exp; | |
-using std::log; | |
-using std::pow; | |
-using std::sqrt; | |
- | |
- | |
-/////////////// saturate_cast (used in image & signal processing) /////////////////// | |
- | |
-template<typename _Tp> static inline _Tp saturate_cast(uchar v) { return _Tp(v); } | |
-template<typename _Tp> static inline _Tp saturate_cast(schar v) { return _Tp(v); } | |
-template<typename _Tp> static inline _Tp saturate_cast(ushort v) { return _Tp(v); } | |
-template<typename _Tp> static inline _Tp saturate_cast(short v) { return _Tp(v); } | |
-template<typename _Tp> static inline _Tp saturate_cast(unsigned v) { return _Tp(v); } | |
-template<typename _Tp> static inline _Tp saturate_cast(int v) { return _Tp(v); } | |
-template<typename _Tp> static inline _Tp saturate_cast(float v) { return _Tp(v); } | |
-template<typename _Tp> static inline _Tp saturate_cast(double v) { return _Tp(v); } | |
- | |
-template<> inline uchar saturate_cast<uchar>(schar v) | |
-{ return (uchar)std::max((int)v, 0); } | |
-template<> inline uchar saturate_cast<uchar>(ushort v) | |
-{ return (uchar)std::min((unsigned)v, (unsigned)UCHAR_MAX); } | |
-template<> inline uchar saturate_cast<uchar>(int v) | |
-{ return (uchar)((unsigned)v <= UCHAR_MAX ? v : v > 0 ? UCHAR_MAX : 0); } | |
-template<> inline uchar saturate_cast<uchar>(short v) | |
-{ return saturate_cast<uchar>((int)v); } | |
-template<> inline uchar saturate_cast<uchar>(unsigned v) | |
-{ return (uchar)std::min(v, (unsigned)UCHAR_MAX); } | |
-template<> inline uchar saturate_cast<uchar>(float v) | |
-{ int iv = cvRound(v); return saturate_cast<uchar>(iv); } | |
-template<> inline uchar saturate_cast<uchar>(double v) | |
-{ int iv = cvRound(v); return saturate_cast<uchar>(iv); } | |
- | |
-template<> inline schar saturate_cast<schar>(uchar v) | |
-{ return (schar)std::min((int)v, SCHAR_MAX); } | |
-template<> inline schar saturate_cast<schar>(ushort v) | |
-{ return (schar)std::min((unsigned)v, (unsigned)SCHAR_MAX); } | |
-template<> inline schar saturate_cast<schar>(int v) | |
-{ | |
- return (schar)((unsigned)(v-SCHAR_MIN) <= (unsigned)UCHAR_MAX ? | |
- v : v > 0 ? SCHAR_MAX : SCHAR_MIN); | |
-} | |
-template<> inline schar saturate_cast<schar>(short v) | |
-{ return saturate_cast<schar>((int)v); } | |
-template<> inline schar saturate_cast<schar>(unsigned v) | |
-{ return (schar)std::min(v, (unsigned)SCHAR_MAX); } | |
- | |
-template<> inline schar saturate_cast<schar>(float v) | |
-{ int iv = cvRound(v); return saturate_cast<schar>(iv); } | |
-template<> inline schar saturate_cast<schar>(double v) | |
-{ int iv = cvRound(v); return saturate_cast<schar>(iv); } | |
- | |
-template<> inline ushort saturate_cast<ushort>(schar v) | |
-{ return (ushort)std::max((int)v, 0); } | |
-template<> inline ushort saturate_cast<ushort>(short v) | |
-{ return (ushort)std::max((int)v, 0); } | |
-template<> inline ushort saturate_cast<ushort>(int v) | |
-{ return (ushort)((unsigned)v <= (unsigned)USHRT_MAX ? v : v > 0 ? USHRT_MAX : 0); } | |
-template<> inline ushort saturate_cast<ushort>(unsigned v) | |
-{ return (ushort)std::min(v, (unsigned)USHRT_MAX); } | |
-template<> inline ushort saturate_cast<ushort>(float v) | |
-{ int iv = cvRound(v); return saturate_cast<ushort>(iv); } | |
-template<> inline ushort saturate_cast<ushort>(double v) | |
-{ int iv = cvRound(v); return saturate_cast<ushort>(iv); } | |
- | |
-template<> inline short saturate_cast<short>(ushort v) | |
-{ return (short)std::min((int)v, SHRT_MAX); } | |
-template<> inline short saturate_cast<short>(int v) | |
-{ | |
- return (short)((unsigned)(v - SHRT_MIN) <= (unsigned)USHRT_MAX ? | |
- v : v > 0 ? SHRT_MAX : SHRT_MIN); | |
-} | |
-template<> inline short saturate_cast<short>(unsigned v) | |
-{ return (short)std::min(v, (unsigned)SHRT_MAX); } | |
-template<> inline short saturate_cast<short>(float v) | |
-{ int iv = cvRound(v); return saturate_cast<short>(iv); } | |
-template<> inline short saturate_cast<short>(double v) | |
-{ int iv = cvRound(v); return saturate_cast<short>(iv); } | |
- | |
-template<> inline int saturate_cast<int>(float v) { return cvRound(v); } | |
-template<> inline int saturate_cast<int>(double v) { return cvRound(v); } | |
- | |
-// we intentionally do not clip negative numbers, to make -1 become 0xffffffff etc. | |
-template<> inline unsigned saturate_cast<unsigned>(float v){ return cvRound(v); } | |
-template<> inline unsigned saturate_cast<unsigned>(double v) { return cvRound(v); } | |
- | |
-inline int fast_abs(uchar v) { return v; } | |
-inline int fast_abs(schar v) { return std::abs((int)v); } | |
-inline int fast_abs(ushort v) { return v; } | |
-inline int fast_abs(short v) { return std::abs((int)v); } | |
-inline int fast_abs(int v) { return std::abs(v); } | |
-inline float fast_abs(float v) { return std::abs(v); } | |
-inline double fast_abs(double v) { return std::abs(v); } | |
- | |
-//////////////////////////////// Matx ///////////////////////////////// | |
- | |
- | |
-template<typename _Tp, int m, int n> inline Matx<_Tp, m, n>::Matx() | |
-{ | |
- for(int i = 0; i < channels; i++) val[i] = _Tp(0); | |
-} | |
- | |
-template<typename _Tp, int m, int n> inline Matx<_Tp, m, n>::Matx(_Tp v0) | |
-{ | |
- val[0] = v0; | |
- for(int i = 1; i < channels; i++) val[i] = _Tp(0); | |
-} | |
- | |
-template<typename _Tp, int m, int n> inline Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1) | |
-{ | |
- assert(channels >= 2); | |
- val[0] = v0; val[1] = v1; | |
- for(int i = 2; i < channels; i++) val[i] = _Tp(0); | |
-} | |
- | |
-template<typename _Tp, int m, int n> inline Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2) | |
-{ | |
- assert(channels >= 3); | |
- val[0] = v0; val[1] = v1; val[2] = v2; | |
- for(int i = 3; i < channels; i++) val[i] = _Tp(0); | |
-} | |
- | |
-template<typename _Tp, int m, int n> inline Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3) | |
-{ | |
- assert(channels >= 4); | |
- val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3; | |
- for(int i = 4; i < channels; i++) val[i] = _Tp(0); | |
-} | |
- | |
-template<typename _Tp, int m, int n> inline Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4) | |
-{ | |
- assert(channels >= 5); | |
- val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3; val[4] = v4; | |
- for(int i = 5; i < channels; i++) val[i] = _Tp(0); | |
-} | |
- | |
-template<typename _Tp, int m, int n> inline Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, | |
- _Tp v4, _Tp v5) | |
-{ | |
- assert(channels >= 6); | |
- val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3; | |
- val[4] = v4; val[5] = v5; | |
- for(int i = 6; i < channels; i++) val[i] = _Tp(0); | |
-} | |
- | |
-template<typename _Tp, int m, int n> inline Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, | |
- _Tp v4, _Tp v5, _Tp v6) | |
-{ | |
- assert(channels >= 7); | |
- val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3; | |
- val[4] = v4; val[5] = v5; val[6] = v6; | |
- for(int i = 7; i < channels; i++) val[i] = _Tp(0); | |
-} | |
- | |
-template<typename _Tp, int m, int n> inline Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, | |
- _Tp v4, _Tp v5, _Tp v6, _Tp v7) | |
-{ | |
- assert(channels >= 8); | |
- val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3; | |
- val[4] = v4; val[5] = v5; val[6] = v6; val[7] = v7; | |
- for(int i = 8; i < channels; i++) val[i] = _Tp(0); | |
-} | |
- | |
-template<typename _Tp, int m, int n> inline Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, | |
- _Tp v4, _Tp v5, _Tp v6, _Tp v7, | |
- _Tp v8) | |
-{ | |
- assert(channels >= 9); | |
- val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3; | |
- val[4] = v4; val[5] = v5; val[6] = v6; val[7] = v7; | |
- val[8] = v8; | |
- for(int i = 9; i < channels; i++) val[i] = _Tp(0); | |
-} | |
- | |
-template<typename _Tp, int m, int n> inline Matx<_Tp, m, n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, | |
- _Tp v4, _Tp v5, _Tp v6, _Tp v7, | |
- _Tp v8, _Tp v9) | |
-{ | |
- assert(channels >= 10); | |
- val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3; | |
- val[4] = v4; val[5] = v5; val[6] = v6; val[7] = v7; | |
- val[8] = v8; val[9] = v9; | |
- for(int i = 10; i < channels; i++) val[i] = _Tp(0); | |
-} | |
- | |
- | |
-template<typename _Tp, int m, int n> | |
-inline Matx<_Tp,m,n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, | |
- _Tp v4, _Tp v5, _Tp v6, _Tp v7, | |
- _Tp v8, _Tp v9, _Tp v10, _Tp v11) | |
-{ | |
- assert(channels == 12); | |
- val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3; | |
- val[4] = v4; val[5] = v5; val[6] = v6; val[7] = v7; | |
- val[8] = v8; val[9] = v9; val[10] = v10; val[11] = v11; | |
-} | |
- | |
-template<typename _Tp, int m, int n> | |
-inline Matx<_Tp,m,n>::Matx(_Tp v0, _Tp v1, _Tp v2, _Tp v3, | |
- _Tp v4, _Tp v5, _Tp v6, _Tp v7, | |
- _Tp v8, _Tp v9, _Tp v10, _Tp v11, | |
- _Tp v12, _Tp v13, _Tp v14, _Tp v15) | |
-{ | |
- assert(channels == 16); | |
- val[0] = v0; val[1] = v1; val[2] = v2; val[3] = v3; | |
- val[4] = v4; val[5] = v5; val[6] = v6; val[7] = v7; | |
- val[8] = v8; val[9] = v9; val[10] = v10; val[11] = v11; | |
- val[12] = v12; val[13] = v13; val[14] = v14; val[15] = v15; | |
-} | |
- | |
-template<typename _Tp, int m, int n> inline Matx<_Tp, m, n>::Matx(const _Tp* values) | |
-{ | |
- for( int i = 0; i < channels; i++ ) val[i] = values[i]; | |
-} | |
- | |
-template<typename _Tp, int m, int n> inline Matx<_Tp, m, n> Matx<_Tp, m, n>::all(_Tp alpha) | |
-{ | |
- Matx<_Tp, m, n> M; | |
- for( int i = 0; i < m*n; i++ ) M.val[i] = alpha; | |
- return M; | |
-} | |
- | |
-template<typename _Tp, int m, int n> inline | |
-Matx<_Tp,m,n> Matx<_Tp,m,n>::zeros() | |
-{ | |
- return all(0); | |
-} | |
- | |
-template<typename _Tp, int m, int n> inline | |
-Matx<_Tp,m,n> Matx<_Tp,m,n>::ones() | |
-{ | |
- return all(1); | |
-} | |
- | |
-template<typename _Tp, int m, int n> inline | |
-Matx<_Tp,m,n> Matx<_Tp,m,n>::eye() | |
-{ | |
- Matx<_Tp,m,n> M; | |
- for(int i = 0; i < MIN(m,n); i++) | |
- M(i,i) = 1; | |
- return M; | |
-} | |
- | |
-template<typename _Tp, int m, int n> inline _Tp Matx<_Tp, m, n>::dot(const Matx<_Tp, m, n>& M) const | |
-{ | |
- _Tp s = 0; | |
- for( int i = 0; i < m*n; i++ ) s += val[i]*M.val[i]; | |
- return s; | |
-} | |
- | |
- | |
-template<typename _Tp, int m, int n> inline double Matx<_Tp, m, n>::ddot(const Matx<_Tp, m, n>& M) const | |
-{ | |
- double s = 0; | |
- for( int i = 0; i < m*n; i++ ) s += (double)val[i]*M.val[i]; | |
- return s; | |
-} | |
- | |
- | |
- | |
-template<typename _Tp, int m, int n> inline | |
-Matx<_Tp,m,n> Matx<_Tp,m,n>::diag(const typename Matx<_Tp,m,n>::diag_type& d) | |
-{ | |
- Matx<_Tp,m,n> M; | |
- for(int i = 0; i < MIN(m,n); i++) | |
- M(i,i) = d(i, 0); | |
- return M; | |
-} | |
- | |
-template<typename _Tp, int m, int n> inline | |
-Matx<_Tp,m,n> Matx<_Tp,m,n>::randu(_Tp a, _Tp b) | |
-{ | |
- Matx<_Tp,m,n> M; | |
- Mat matM(M, false); | |
- cv::randu(matM, Scalar(a), Scalar(b)); | |
- return M; | |
-} | |
- | |
-template<typename _Tp, int m, int n> inline | |
-Matx<_Tp,m,n> Matx<_Tp,m,n>::randn(_Tp a, _Tp b) | |
-{ | |
- Matx<_Tp,m,n> M; | |
- Mat matM(M, false); | |
- cv::randn(matM, Scalar(a), Scalar(b)); | |
- return M; | |
-} | |
- | |
-template<typename _Tp, int m, int n> template<typename T2> | |
-inline Matx<_Tp, m, n>::operator Matx<T2, m, n>() const | |
-{ | |
- Matx<T2, m, n> M; | |
- for( int i = 0; i < m*n; i++ ) M.val[i] = saturate_cast<T2>(val[i]); | |
- return M; | |
-} | |
- | |
- | |
-template<typename _Tp, int m, int n> template<int m1, int n1> inline | |
-Matx<_Tp, m1, n1> Matx<_Tp, m, n>::reshape() const | |
-{ | |
- CV_DbgAssert(m1*n1 == m*n); | |
- return (const Matx<_Tp, m1, n1>&)*this; | |
-} | |
- | |
- | |
-template<typename _Tp, int m, int n> | |
-template<int m1, int n1> inline | |
-Matx<_Tp, m1, n1> Matx<_Tp, m, n>::get_minor(int i, int j) const | |
-{ | |
- CV_DbgAssert(0 <= i && i+m1 <= m && 0 <= j && j+n1 <= n); | |
- Matx<_Tp, m1, n1> s; | |
- for( int di = 0; di < m1; di++ ) | |
- for( int dj = 0; dj < n1; dj++ ) | |
- s(di, dj) = (*this)(i+di, j+dj); | |
- return s; | |
-} | |
- | |
- | |
-template<typename _Tp, int m, int n> inline | |
-Matx<_Tp, 1, n> Matx<_Tp, m, n>::row(int i) const | |
-{ | |
- CV_DbgAssert((unsigned)i < (unsigned)m); | |
- return Matx<_Tp, 1, n>(&val[i*n]); | |
-} | |
- | |
- | |
-template<typename _Tp, int m, int n> inline | |
-Matx<_Tp, m, 1> Matx<_Tp, m, n>::col(int j) const | |
-{ | |
- CV_DbgAssert((unsigned)j < (unsigned)n); | |
- Matx<_Tp, m, 1> v; | |
- for( int i = 0; i < m; i++ ) | |
- v.val[i] = val[i*n + j]; | |
- return v; | |
-} | |
- | |
- | |
-template<typename _Tp, int m, int n> inline | |
-typename Matx<_Tp, m, n>::diag_type Matx<_Tp, m, n>::diag() const | |
-{ | |
- diag_type d; | |
- for( int i = 0; i < MIN(m, n); i++ ) | |
- d.val[i] = val[i*n + i]; | |
- return d; | |
-} | |
- | |
- | |
-template<typename _Tp, int m, int n> inline | |
-const _Tp& Matx<_Tp, m, n>::operator ()(int i, int j) const | |
-{ | |
- CV_DbgAssert( (unsigned)i < (unsigned)m && (unsigned)j < (unsigned)n ); | |
- return this->val[i*n + j]; | |
-} | |
- | |
- | |
-template<typename _Tp, int m, int n> inline | |
-_Tp& Matx<_Tp, m, n>::operator ()(int i, int j) | |
-{ | |
- CV_DbgAssert( (unsigned)i < (unsigned)m && (unsigned)j < (unsigned)n ); | |
- return val[i*n + j]; | |
-} | |
- | |
- | |
-template<typename _Tp, int m, int n> inline | |
-const _Tp& Matx<_Tp, m, n>::operator ()(int i) const | |
-{ | |
- CV_DbgAssert( (m == 1 || n == 1) && (unsigned)i < (unsigned)(m+n-1) ); | |
- return val[i]; | |
-} | |
- | |
- | |
-template<typename _Tp, int m, int n> inline | |
-_Tp& Matx<_Tp, m, n>::operator ()(int i) | |
-{ | |
- CV_DbgAssert( (m == 1 || n == 1) && (unsigned)i < (unsigned)(m+n-1) ); | |
- return val[i]; | |
-} | |
- | |
- | |
-template<typename _Tp1, typename _Tp2, int m, int n> static inline | |
-Matx<_Tp1, m, n>& operator += (Matx<_Tp1, m, n>& a, const Matx<_Tp2, m, n>& b) | |
-{ | |
- for( int i = 0; i < m*n; i++ ) | |
- a.val[i] = saturate_cast<_Tp1>(a.val[i] + b.val[i]); | |
- return a; | |
-} | |
- | |
- | |
-template<typename _Tp1, typename _Tp2, int m, int n> static inline | |
-Matx<_Tp1, m, n>& operator -= (Matx<_Tp1, m, n>& a, const Matx<_Tp2, m, n>& b) | |
-{ | |
- for( int i = 0; i < m*n; i++ ) | |
- a.val[i] = saturate_cast<_Tp1>(a.val[i] - b.val[i]); | |
- return a; | |
-} | |
- | |
- | |
-template<typename _Tp, int m, int n> inline | |
-Matx<_Tp,m,n>::Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_AddOp) | |
-{ | |
- for( int i = 0; i < m*n; i++ ) | |
- val[i] = saturate_cast<_Tp>(a.val[i] + b.val[i]); | |
-} | |
- | |
- | |
-template<typename _Tp, int m, int n> inline | |
-Matx<_Tp,m,n>::Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_SubOp) | |
-{ | |
- for( int i = 0; i < m*n; i++ ) | |
- val[i] = saturate_cast<_Tp>(a.val[i] - b.val[i]); | |
-} | |
- | |
- | |
-template<typename _Tp, int m, int n> template<typename _T2> inline | |
-Matx<_Tp,m,n>::Matx(const Matx<_Tp, m, n>& a, _T2 alpha, Matx_ScaleOp) | |
-{ | |
- for( int i = 0; i < m*n; i++ ) | |
- val[i] = saturate_cast<_Tp>(a.val[i] * alpha); | |
-} | |
- | |
- | |
-template<typename _Tp, int m, int n> inline | |
-Matx<_Tp,m,n>::Matx(const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b, Matx_MulOp) | |
-{ | |
- for( int i = 0; i < m*n; i++ ) | |
- val[i] = saturate_cast<_Tp>(a.val[i] * b.val[i]); | |
-} | |
- | |
- | |
-template<typename _Tp, int m, int n> template<int l> inline | |
-Matx<_Tp,m,n>::Matx(const Matx<_Tp, m, l>& a, const Matx<_Tp, l, n>& b, Matx_MatMulOp) | |
-{ | |
- for( int i = 0; i < m; i++ ) | |
- for( int j = 0; j < n; j++ ) | |
- { | |
- _Tp s = 0; | |
- for( int k = 0; k < l; k++ ) | |
- s += a(i, k) * b(k, j); | |
- val[i*n + j] = s; | |
- } | |
-} | |
- | |
- | |
-template<typename _Tp, int m, int n> inline | |
-Matx<_Tp,m,n>::Matx(const Matx<_Tp, n, m>& a, Matx_TOp) | |
-{ | |
- for( int i = 0; i < m; i++ ) | |
- for( int j = 0; j < n; j++ ) | |
- val[i*n + j] = a(j, i); | |
-} | |
- | |
- | |
-template<typename _Tp, int m, int n> static inline | |
-Matx<_Tp, m, n> operator + (const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b) | |
-{ | |
- return Matx<_Tp, m, n>(a, b, Matx_AddOp()); | |
-} | |
- | |
- | |
-template<typename _Tp, int m, int n> static inline | |
-Matx<_Tp, m, n> operator - (const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b) | |
-{ | |
- return Matx<_Tp, m, n>(a, b, Matx_SubOp()); | |
-} | |
- | |
- | |
-template<typename _Tp, int m, int n> static inline | |
-Matx<_Tp, m, n>& operator *= (Matx<_Tp, m, n>& a, int alpha) | |
-{ | |
- for( int i = 0; i < m*n; i++ ) | |
- a.val[i] = saturate_cast<_Tp>(a.val[i] * alpha); | |
- return a; | |
-} | |
- | |
-template<typename _Tp, int m, int n> static inline | |
-Matx<_Tp, m, n>& operator *= (Matx<_Tp, m, n>& a, float alpha) | |
-{ | |
- for( int i = 0; i < m*n; i++ ) | |
- a.val[i] = saturate_cast<_Tp>(a.val[i] * alpha); | |
- return a; | |
-} | |
- | |
-template<typename _Tp, int m, int n> static inline | |
-Matx<_Tp, m, n>& operator *= (Matx<_Tp, m, n>& a, double alpha) | |
-{ | |
- for( int i = 0; i < m*n; i++ ) | |
- a.val[i] = saturate_cast<_Tp>(a.val[i] * alpha); | |
- return a; | |
-} | |
- | |
-template<typename _Tp, int m, int n> static inline | |
-Matx<_Tp, m, n> operator * (const Matx<_Tp, m, n>& a, int alpha) | |
-{ | |
- return Matx<_Tp, m, n>(a, alpha, Matx_ScaleOp()); | |
-} | |
- | |
-template<typename _Tp, int m, int n> static inline | |
-Matx<_Tp, m, n> operator * (const Matx<_Tp, m, n>& a, float alpha) | |
-{ | |
- return Matx<_Tp, m, n>(a, alpha, Matx_ScaleOp()); | |
-} | |
- | |
-template<typename _Tp, int m, int n> static inline | |
-Matx<_Tp, m, n> operator * (const Matx<_Tp, m, n>& a, double alpha) | |
-{ | |
- return Matx<_Tp, m, n>(a, alpha, Matx_ScaleOp()); | |
-} | |
- | |
-template<typename _Tp, int m, int n> static inline | |
-Matx<_Tp, m, n> operator * (int alpha, const Matx<_Tp, m, n>& a) | |
-{ | |
- return Matx<_Tp, m, n>(a, alpha, Matx_ScaleOp()); | |
-} | |
- | |
-template<typename _Tp, int m, int n> static inline | |
-Matx<_Tp, m, n> operator * (float alpha, const Matx<_Tp, m, n>& a) | |
-{ | |
- return Matx<_Tp, m, n>(a, alpha, Matx_ScaleOp()); | |
-} | |
- | |
-template<typename _Tp, int m, int n> static inline | |
-Matx<_Tp, m, n> operator * (double alpha, const Matx<_Tp, m, n>& a) | |
-{ | |
- return Matx<_Tp, m, n>(a, alpha, Matx_ScaleOp()); | |
-} | |
- | |
-template<typename _Tp, int m, int n> static inline | |
-Matx<_Tp, m, n> operator - (const Matx<_Tp, m, n>& a) | |
-{ | |
- return Matx<_Tp, m, n>(a, -1, Matx_ScaleOp()); | |
-} | |
- | |
- | |
-template<typename _Tp, int m, int n, int l> static inline | |
-Matx<_Tp, m, n> operator * (const Matx<_Tp, m, l>& a, const Matx<_Tp, l, n>& b) | |
-{ | |
- return Matx<_Tp, m, n>(a, b, Matx_MatMulOp()); | |
-} | |
- | |
- | |
-template<typename _Tp, int m, int n> static inline | |
-Vec<_Tp, m> operator * (const Matx<_Tp, m, n>& a, const Vec<_Tp, n>& b) | |
-{ | |
- Matx<_Tp, m, 1> c(a, b, Matx_MatMulOp()); | |
- return reinterpret_cast<const Vec<_Tp, m>&>(c); | |
-} | |
- | |
- | |
-template<typename _Tp> static inline | |
-Point_<_Tp> operator * (const Matx<_Tp, 2, 2>& a, const Point_<_Tp>& b) | |
-{ | |
- Matx<_Tp, 2, 1> tmp = a*Vec<_Tp,2>(b.x, b.y); | |
- return Point_<_Tp>(tmp.val[0], tmp.val[1]); | |
-} | |
- | |
- | |
-template<typename _Tp> static inline | |
-Point3_<_Tp> operator * (const Matx<_Tp, 3, 3>& a, const Point3_<_Tp>& b) | |
-{ | |
- Matx<_Tp, 3, 1> tmp = a*Vec<_Tp,3>(b.x, b.y, b.z); | |
- return Point3_<_Tp>(tmp.val[0], tmp.val[1], tmp.val[2]); | |
-} | |
- | |
- | |
-template<typename _Tp> static inline | |
-Point3_<_Tp> operator * (const Matx<_Tp, 3, 3>& a, const Point_<_Tp>& b) | |
-{ | |
- Matx<_Tp, 3, 1> tmp = a*Vec<_Tp,3>(b.x, b.y, 1); | |
- return Point3_<_Tp>(tmp.val[0], tmp.val[1], tmp.val[2]); | |
-} | |
- | |
- | |
-template<typename _Tp> static inline | |
-Matx<_Tp, 4, 1> operator * (const Matx<_Tp, 4, 4>& a, const Point3_<_Tp>& b) | |
-{ | |
- return a*Matx<_Tp, 4, 1>(b.x, b.y, b.z, 1); | |
-} | |
- | |
- | |
-template<typename _Tp> static inline | |
-Scalar operator * (const Matx<_Tp, 4, 4>& a, const Scalar& b) | |
-{ | |
- Matx<double, 4, 1> c(Matx<double, 4, 4>(a), b, Matx_MatMulOp()); | |
- return reinterpret_cast<const Scalar&>(c); | |
-} | |
- | |
- | |
-static inline | |
-Scalar operator * (const Matx<double, 4, 4>& a, const Scalar& b) | |
-{ | |
- Matx<double, 4, 1> c(a, b, Matx_MatMulOp()); | |
- return reinterpret_cast<const Scalar&>(c); | |
-} | |
- | |
- | |
-template<typename _Tp, int m, int n> inline | |
-Matx<_Tp, m, n> Matx<_Tp, m, n>::mul(const Matx<_Tp, m, n>& a) const | |
-{ | |
- return Matx<_Tp, m, n>(*this, a, Matx_MulOp()); | |
-} | |
- | |
- | |
-CV_EXPORTS int LU(float* A, size_t astep, int m, float* b, size_t bstep, int n); | |
-CV_EXPORTS int LU(double* A, size_t astep, int m, double* b, size_t bstep, int n); | |
-CV_EXPORTS bool Cholesky(float* A, size_t astep, int m, float* b, size_t bstep, int n); | |
-CV_EXPORTS bool Cholesky(double* A, size_t astep, int m, double* b, size_t bstep, int n); | |
- | |
- | |
-template<typename _Tp, int m> struct CV_EXPORTS Matx_DetOp | |
-{ | |
- double operator ()(const Matx<_Tp, m, m>& a) const | |
- { | |
- Matx<_Tp, m, m> temp = a; | |
- double p = LU(temp.val, m, m, 0, 0, 0); | |
- if( p == 0 ) | |
- return p; | |
- for( int i = 0; i < m; i++ ) | |
- p *= temp(i, i); | |
- return p; | |
- } | |
-}; | |
- | |
- | |
-template<typename _Tp> struct CV_EXPORTS Matx_DetOp<_Tp, 1> | |
-{ | |
- double operator ()(const Matx<_Tp, 1, 1>& a) const | |
- { | |
- return a(0,0); | |
- } | |
-}; | |
- | |
- | |
-template<typename _Tp> struct CV_EXPORTS Matx_DetOp<_Tp, 2> | |
-{ | |
- double operator ()(const Matx<_Tp, 2, 2>& a) const | |
- { | |
- return a(0,0)*a(1,1) - a(0,1)*a(1,0); | |
- } | |
-}; | |
- | |
- | |
-template<typename _Tp> struct CV_EXPORTS Matx_DetOp<_Tp, 3> | |
-{ | |
- double operator ()(const Matx<_Tp, 3, 3>& a) const | |
- { | |
- return a(0,0)*(a(1,1)*a(2,2) - a(2,1)*a(1,2)) - | |
- a(0,1)*(a(1,0)*a(2,2) - a(2,0)*a(1,2)) + | |
- a(0,2)*(a(1,0)*a(2,1) - a(2,0)*a(1,1)); | |
- } | |
-}; | |
- | |
-template<typename _Tp, int m> static inline | |
-double determinant(const Matx<_Tp, m, m>& a) | |
-{ | |
- return Matx_DetOp<_Tp, m>()(a); | |
-} | |
- | |
- | |
-template<typename _Tp, int m, int n> static inline | |
-double trace(const Matx<_Tp, m, n>& a) | |
-{ | |
- _Tp s = 0; | |
- for( int i = 0; i < std::min(m, n); i++ ) | |
- s += a(i,i); | |
- return s; | |
-} | |
- | |
- | |
-template<typename _Tp, int m, int n> inline | |
-Matx<_Tp, n, m> Matx<_Tp, m, n>::t() const | |
-{ | |
- return Matx<_Tp, n, m>(*this, Matx_TOp()); | |
-} | |
- | |
- | |
-template<typename _Tp, int m> struct CV_EXPORTS Matx_FastInvOp | |
-{ | |
- bool operator()(const Matx<_Tp, m, m>& a, Matx<_Tp, m, m>& b, int method) const | |
- { | |
- Matx<_Tp, m, m> temp = a; | |
- | |
- // assume that b is all 0's on input => make it a unity matrix | |
- for( int i = 0; i < m; i++ ) | |
- b(i, i) = (_Tp)1; | |
- | |
- if( method == DECOMP_CHOLESKY ) | |
- return Cholesky(temp.val, m*sizeof(_Tp), m, b.val, m*sizeof(_Tp), m); | |
- | |
- return LU(temp.val, m*sizeof(_Tp), m, b.val, m*sizeof(_Tp), m) != 0; | |
- } | |
-}; | |
- | |
- | |
-template<typename _Tp> struct CV_EXPORTS Matx_FastInvOp<_Tp, 2> | |
-{ | |
- bool operator()(const Matx<_Tp, 2, 2>& a, Matx<_Tp, 2, 2>& b, int) const | |
- { | |
- _Tp d = determinant(a); | |
- if( d == 0 ) | |
- return false; | |
- d = 1/d; | |
- b(1,1) = a(0,0)*d; | |
- b(0,0) = a(1,1)*d; | |
- b(0,1) = -a(0,1)*d; | |
- b(1,0) = -a(1,0)*d; | |
- return true; | |
- } | |
-}; | |
- | |
- | |
-template<typename _Tp> struct CV_EXPORTS Matx_FastInvOp<_Tp, 3> | |
-{ | |
- bool operator()(const Matx<_Tp, 3, 3>& a, Matx<_Tp, 3, 3>& b, int) const | |
- { | |
- _Tp d = (_Tp)determinant(a); | |
- if( d == 0 ) | |
- return false; | |
- d = 1/d; | |
- b(0,0) = (a(1,1) * a(2,2) - a(1,2) * a(2,1)) * d; | |
- b(0,1) = (a(0,2) * a(2,1) - a(0,1) * a(2,2)) * d; | |
- b(0,2) = (a(0,1) * a(1,2) - a(0,2) * a(1,1)) * d; | |
- | |
- b(1,0) = (a(1,2) * a(2,0) - a(1,0) * a(2,2)) * d; | |
- b(1,1) = (a(0,0) * a(2,2) - a(0,2) * a(2,0)) * d; | |
- b(1,2) = (a(0,2) * a(1,0) - a(0,0) * a(1,2)) * d; | |
- | |
- b(2,0) = (a(1,0) * a(2,1) - a(1,1) * a(2,0)) * d; | |
- b(2,1) = (a(0,1) * a(2,0) - a(0,0) * a(2,1)) * d; | |
- b(2,2) = (a(0,0) * a(1,1) - a(0,1) * a(1,0)) * d; | |
- return true; | |
- } | |
-}; | |
- | |
- | |
-template<typename _Tp, int m, int n> inline | |
-Matx<_Tp, n, m> Matx<_Tp, m, n>::inv(int method) const | |
-{ | |
- Matx<_Tp, n, m> b; | |
- bool ok; | |
- if( method == DECOMP_LU || method == DECOMP_CHOLESKY ) | |
- ok = Matx_FastInvOp<_Tp, m>()(*this, b, method); | |
- else | |
- { | |
- Mat A(*this, false), B(b, false); | |
- ok = (invert(A, B, method) != 0); | |
- } | |
- return ok ? b : Matx<_Tp, n, m>::zeros(); | |
-} | |
- | |
- | |
-template<typename _Tp, int m, int n> struct CV_EXPORTS Matx_FastSolveOp | |
-{ | |
- bool operator()(const Matx<_Tp, m, m>& a, const Matx<_Tp, m, n>& b, | |
- Matx<_Tp, m, n>& x, int method) const | |
- { | |
- Matx<_Tp, m, m> temp = a; | |
- x = b; | |
- if( method == DECOMP_CHOLESKY ) | |
- return Cholesky(temp.val, m*sizeof(_Tp), m, x.val, n*sizeof(_Tp), n); | |
- | |
- return LU(temp.val, m*sizeof(_Tp), m, x.val, n*sizeof(_Tp), n) != 0; | |
- } | |
-}; | |
- | |
- | |
-template<typename _Tp> struct CV_EXPORTS Matx_FastSolveOp<_Tp, 2, 1> | |
-{ | |
- bool operator()(const Matx<_Tp, 2, 2>& a, const Matx<_Tp, 2, 1>& b, | |
- Matx<_Tp, 2, 1>& x, int method) const | |
- { | |
- _Tp d = determinant(a); | |
- if( d == 0 ) | |
- return false; | |
- d = 1/d; | |
- x(0) = (b(0)*a(1,1) - b(1)*a(0,1))*d; | |
- x(1) = (b(1)*a(0,0) - b(0)*a(1,0))*d; | |
- return true; | |
- } | |
-}; | |
- | |
- | |
-template<typename _Tp> struct CV_EXPORTS Matx_FastSolveOp<_Tp, 3, 1> | |
-{ | |
- bool operator()(const Matx<_Tp, 3, 3>& a, const Matx<_Tp, 3, 1>& b, | |
- Matx<_Tp, 3, 1>& x, int) const | |
- { | |
- _Tp d = (_Tp)determinant(a); | |
- if( d == 0 ) | |
- return false; | |
- d = 1/d; | |
- x(0) = d*(b(0)*(a(1,1)*a(2,2) - a(1,2)*a(2,1)) - | |
- a(0,1)*(b(1)*a(2,2) - a(1,2)*b(2)) + | |
- a(0,2)*(b(1)*a(2,1) - a(1,1)*b(2))); | |
- | |
- x(1) = d*(a(0,0)*(b(1)*a(2,2) - a(1,2)*b(2)) - | |
- b(0)*(a(1,0)*a(2,2) - a(1,2)*a(2,0)) + | |
- a(0,2)*(a(1,0)*b(2) - b(1)*a(2,0))); | |
- | |
- x(2) = d*(a(0,0)*(a(1,1)*b(2) - b(1)*a(2,1)) - | |
- a(0,1)*(a(1,0)*b(2) - b(1)*a(2,0)) + | |
- b(0)*(a(1,0)*a(2,1) - a(1,1)*a(2,0))); | |
- return true; | |
- } | |
-}; | |
- | |
- | |
-template<typename _Tp, int m, int n> template<int l> inline | |
-Matx<_Tp, n, l> Matx<_Tp, m, n>::solve(const Matx<_Tp, m, l>& rhs, int method) const | |
-{ | |
- Matx<_Tp, n, l> x; | |
- bool ok; | |
- if( method == DECOMP_LU || method == DECOMP_CHOLESKY ) | |
- ok = Matx_FastSolveOp<_Tp, m, l>()(*this, rhs, x, method); | |
- else | |
- { | |
- Mat A(*this, false), B(rhs, false), X(x, false); | |
- ok = cv::solve(A, B, X, method); | |
- } | |
- | |
- return ok ? x : Matx<_Tp, n, l>::zeros(); | |
-} | |
- | |
-template<typename _Tp, int m, int n> inline | |
-Vec<_Tp, n> Matx<_Tp, m, n>::solve(const Vec<_Tp, m>& rhs, int method) const | |
-{ | |
- Matx<_Tp, n, 1> x = solve(reinterpret_cast<const Matx<_Tp, m, 1>&>(rhs), method); | |
- return reinterpret_cast<Vec<_Tp, n>&>(x); | |
-} | |
- | |
-template<typename _Tp, typename _AccTp> static inline | |
-_AccTp normL2Sqr(const _Tp* a, int n) | |
-{ | |
- _AccTp s = 0; | |
- int i=0; | |
- #if CV_ENABLE_UNROLLED | |
- for( ; i <= n - 4; i += 4 ) | |
- { | |
- _AccTp v0 = a[i], v1 = a[i+1], v2 = a[i+2], v3 = a[i+3]; | |
- s += v0*v0 + v1*v1 + v2*v2 + v3*v3; | |
- } | |
-#endif | |
- for( ; i < n; i++ ) | |
- { | |
- _AccTp v = a[i]; | |
- s += v*v; | |
- } | |
- return s; | |
-} | |
- | |
- | |
-template<typename _Tp, typename _AccTp> static inline | |
-_AccTp normL1(const _Tp* a, int n) | |
-{ | |
- _AccTp s = 0; | |
- int i = 0; | |
-#if CV_ENABLE_UNROLLED | |
- for(; i <= n - 4; i += 4 ) | |
- { | |
- s += (_AccTp)fast_abs(a[i]) + (_AccTp)fast_abs(a[i+1]) + | |
- (_AccTp)fast_abs(a[i+2]) + (_AccTp)fast_abs(a[i+3]); | |
- } | |
-#endif | |
- for( ; i < n; i++ ) | |
- s += fast_abs(a[i]); | |
- return s; | |
-} | |
- | |
- | |
-template<typename _Tp, typename _AccTp> static inline | |
-_AccTp normInf(const _Tp* a, int n) | |
-{ | |
- _AccTp s = 0; | |
- for( int i = 0; i < n; i++ ) | |
- s = std::max(s, (_AccTp)fast_abs(a[i])); | |
- return s; | |
-} | |
- | |
- | |
-template<typename _Tp, typename _AccTp> static inline | |
-_AccTp normL2Sqr(const _Tp* a, const _Tp* b, int n) | |
-{ | |
- _AccTp s = 0; | |
- int i= 0; | |
-#if CV_ENABLE_UNROLLED | |
- for(; i <= n - 4; i += 4 ) | |
- { | |
- _AccTp v0 = a[i] - b[i], v1 = a[i+1] - b[i+1], v2 = a[i+2] - b[i+2], v3 = a[i+3] - b[i+3]; | |
- s += v0*v0 + v1*v1 + v2*v2 + v3*v3; | |
- } | |
-#endif | |
- for( ; i < n; i++ ) | |
- { | |
- _AccTp v = (_AccTp)(a[i] - b[i]); | |
- s += v*v; | |
- } | |
- return s; | |
-} | |
- | |
-CV_EXPORTS float normL2Sqr_(const float* a, const float* b, int n); | |
-CV_EXPORTS float normL1_(const float* a, const float* b, int n); | |
-CV_EXPORTS int normL1_(const uchar* a, const uchar* b, int n); | |
-CV_EXPORTS int normHamming(const uchar* a, const uchar* b, int n); | |
-CV_EXPORTS int normHamming(const uchar* a, const uchar* b, int n, int cellSize); | |
- | |
-template<> inline float normL2Sqr(const float* a, const float* b, int n) | |
-{ | |
- if( n >= 8 ) | |
- return normL2Sqr_(a, b, n); | |
- float s = 0; | |
- for( int i = 0; i < n; i++ ) | |
- { | |
- float v = a[i] - b[i]; | |
- s += v*v; | |
- } | |
- return s; | |
-} | |
- | |
- | |
-template<typename _Tp, typename _AccTp> static inline | |
-_AccTp normL1(const _Tp* a, const _Tp* b, int n) | |
-{ | |
- _AccTp s = 0; | |
- int i= 0; | |
-#if CV_ENABLE_UNROLLED | |
- for(; i <= n - 4; i += 4 ) | |
- { | |
- _AccTp v0 = a[i] - b[i], v1 = a[i+1] - b[i+1], v2 = a[i+2] - b[i+2], v3 = a[i+3] - b[i+3]; | |
- s += std::abs(v0) + std::abs(v1) + std::abs(v2) + std::abs(v3); | |
- } | |
-#endif | |
- for( ; i < n; i++ ) | |
- { | |
- _AccTp v = (_AccTp)(a[i] - b[i]); | |
- s += std::abs(v); | |
- } | |
- return s; | |
-} | |
- | |
-template<> inline float normL1(const float* a, const float* b, int n) | |
-{ | |
- if( n >= 8 ) | |
- return normL1_(a, b, n); | |
- float s = 0; | |
- for( int i = 0; i < n; i++ ) | |
- { | |
- float v = a[i] - b[i]; | |
- s += std::abs(v); | |
- } | |
- return s; | |
-} | |
- | |
-template<> inline int normL1(const uchar* a, const uchar* b, int n) | |
-{ | |
- return normL1_(a, b, n); | |
-} | |
- | |
-template<typename _Tp, typename _AccTp> static inline | |
-_AccTp normInf(const _Tp* a, const _Tp* b, int n) | |
-{ | |
- _AccTp s = 0; | |
- for( int i = 0; i < n; i++ ) | |
- { | |
- _AccTp v0 = a[i] - b[i]; | |
- s = std::max(s, std::abs(v0)); | |
- } | |
- return s; | |
-} | |
- | |
- | |
-template<typename _Tp, int m, int n> static inline | |
-double norm(const Matx<_Tp, m, n>& M) | |
-{ | |
- return std::sqrt(normL2Sqr<_Tp, double>(M.val, m*n)); | |
-} | |
- | |
- | |
-template<typename _Tp, int m, int n> static inline | |
-double norm(const Matx<_Tp, m, n>& M, int normType) | |
-{ | |
- return normType == NORM_INF ? (double)normInf<_Tp, DataType<_Tp>::work_type>(M.val, m*n) : | |
- normType == NORM_L1 ? (double)normL1<_Tp, DataType<_Tp>::work_type>(M.val, m*n) : | |
- std::sqrt((double)normL2Sqr<_Tp, DataType<_Tp>::work_type>(M.val, m*n)); | |
-} | |
- | |
- | |
-template<typename _Tp, int m, int n> static inline | |
-bool operator == (const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b) | |
-{ | |
- for( int i = 0; i < m*n; i++ ) | |
- if( a.val[i] != b.val[i] ) return false; | |
- return true; | |
-} | |
- | |
-template<typename _Tp, int m, int n> static inline | |
-bool operator != (const Matx<_Tp, m, n>& a, const Matx<_Tp, m, n>& b) | |
-{ | |
- return !(a == b); | |
-} | |
- | |
- | |
-template<typename _Tp, typename _T2, int m, int n> static inline | |
-MatxCommaInitializer<_Tp, m, n> operator << (const Matx<_Tp, m, n>& mtx, _T2 val) | |
-{ | |
- MatxCommaInitializer<_Tp, m, n> commaInitializer((Matx<_Tp, m, n>*)&mtx); | |
- return (commaInitializer, val); | |
-} | |
- | |
-template<typename _Tp, int m, int n> inline | |
-MatxCommaInitializer<_Tp, m, n>::MatxCommaInitializer(Matx<_Tp, m, n>* _mtx) | |
- : dst(_mtx), idx(0) | |
-{} | |
- | |
-template<typename _Tp, int m, int n> template<typename _T2> inline | |
-MatxCommaInitializer<_Tp, m, n>& MatxCommaInitializer<_Tp, m, n>::operator , (_T2 value) | |
-{ | |
- CV_DbgAssert( idx < m*n ); | |
- dst->val[idx++] = saturate_cast<_Tp>(value); | |
- return *this; | |
-} | |
- | |
-template<typename _Tp, int m, int n> inline | |
-Matx<_Tp, m, n> MatxCommaInitializer<_Tp, m, n>::operator *() const | |
-{ | |
- CV_DbgAssert( idx == n*m ); | |
- return *dst; | |
-} | |
- | |
-/////////////////////////// short vector (Vec) ///////////////////////////// | |
- | |
-template<typename _Tp, int cn> inline Vec<_Tp, cn>::Vec() | |
-{} | |
- | |
-template<typename _Tp, int cn> inline Vec<_Tp, cn>::Vec(_Tp v0) | |
- : Matx<_Tp, cn, 1>(v0) | |
-{} | |
- | |
-template<typename _Tp, int cn> inline Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1) | |
- : Matx<_Tp, cn, 1>(v0, v1) | |
-{} | |
- | |
-template<typename _Tp, int cn> inline Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1, _Tp v2) | |
- : Matx<_Tp, cn, 1>(v0, v1, v2) | |
-{} | |
- | |
-template<typename _Tp, int cn> inline Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3) | |
- : Matx<_Tp, cn, 1>(v0, v1, v2, v3) | |
-{} | |
- | |
-template<typename _Tp, int cn> inline Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4) | |
- : Matx<_Tp, cn, 1>(v0, v1, v2, v3, v4) | |
-{} | |
- | |
-template<typename _Tp, int cn> inline Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, _Tp v4, _Tp v5) | |
- : Matx<_Tp, cn, 1>(v0, v1, v2, v3, v4, v5) | |
-{} | |
- | |
-template<typename _Tp, int cn> inline Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, | |
- _Tp v4, _Tp v5, _Tp v6) | |
- : Matx<_Tp, cn, 1>(v0, v1, v2, v3, v4, v5, v6) | |
-{} | |
- | |
-template<typename _Tp, int cn> inline Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, | |
- _Tp v4, _Tp v5, _Tp v6, _Tp v7) | |
- : Matx<_Tp, cn, 1>(v0, v1, v2, v3, v4, v5, v6, v7) | |
-{} | |
- | |
-template<typename _Tp, int cn> inline Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, | |
- _Tp v4, _Tp v5, _Tp v6, _Tp v7, | |
- _Tp v8) | |
- : Matx<_Tp, cn, 1>(v0, v1, v2, v3, v4, v5, v6, v7, v8) | |
-{} | |
- | |
-template<typename _Tp, int cn> inline Vec<_Tp, cn>::Vec(_Tp v0, _Tp v1, _Tp v2, _Tp v3, | |
- _Tp v4, _Tp v5, _Tp v6, _Tp v7, | |
- _Tp v8, _Tp v9) | |
- : Matx<_Tp, cn, 1>(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) | |
-{} | |
- | |
-template<typename _Tp, int cn> inline Vec<_Tp, cn>::Vec(const _Tp* values) | |
- : Matx<_Tp, cn, 1>(values) | |
-{} | |
- | |
- | |
-template<typename _Tp, int cn> inline Vec<_Tp, cn>::Vec(const Vec<_Tp, cn>& m) | |
- : Matx<_Tp, cn, 1>(m.val) | |
-{} | |
- | |
-template<typename _Tp, int cn> inline | |
-Vec<_Tp, cn>::Vec(const Matx<_Tp, cn, 1>& a, const Matx<_Tp, cn, 1>& b, Matx_AddOp op) | |
-: Matx<_Tp, cn, 1>(a, b, op) | |
-{} | |
- | |
-template<typename _Tp, int cn> inline | |
-Vec<_Tp, cn>::Vec(const Matx<_Tp, cn, 1>& a, const Matx<_Tp, cn, 1>& b, Matx_SubOp op) | |
-: Matx<_Tp, cn, 1>(a, b, op) | |
-{} | |
- | |
-template<typename _Tp, int cn> template<typename _T2> inline | |
-Vec<_Tp, cn>::Vec(const Matx<_Tp, cn, 1>& a, _T2 alpha, Matx_ScaleOp op) | |
-: Matx<_Tp, cn, 1>(a, alpha, op) | |
-{} | |
- | |
-template<typename _Tp, int cn> inline Vec<_Tp, cn> Vec<_Tp, cn>::all(_Tp alpha) | |
-{ | |
- Vec v; | |
- for( int i = 0; i < cn; i++ ) v.val[i] = alpha; | |
- return v; | |
-} | |
- | |
-template<typename _Tp, int cn> inline Vec<_Tp, cn> Vec<_Tp, cn>::mul(const Vec<_Tp, cn>& v) const | |
-{ | |
- Vec<_Tp, cn> w; | |
- for( int i = 0; i < cn; i++ ) w.val[i] = saturate_cast<_Tp>(this->val[i]*v.val[i]); | |
- return w; | |
-} | |
- | |
-template<typename _Tp> Vec<_Tp, 2> conjugate(const Vec<_Tp, 2>& v) | |
-{ | |
- return Vec<_Tp, 2>(v[0], -v[1]); | |
-} | |
- | |
-template<typename _Tp> Vec<_Tp, 4> conjugate(const Vec<_Tp, 4>& v) | |
-{ | |
- return Vec<_Tp, 4>(v[0], -v[1], -v[2], -v[3]); | |
-} | |
- | |
-template<> inline Vec<float, 2> Vec<float, 2>::conj() const | |
-{ | |
- return conjugate(*this); | |
-} | |
- | |
-template<> inline Vec<double, 2> Vec<double, 2>::conj() const | |
-{ | |
- return conjugate(*this); | |
-} | |
- | |
-template<> inline Vec<float, 4> Vec<float, 4>::conj() const | |
-{ | |
- return conjugate(*this); | |
-} | |
- | |
-template<> inline Vec<double, 4> Vec<double, 4>::conj() const | |
-{ | |
- return conjugate(*this); | |
-} | |
- | |
-template<typename _Tp, int cn> inline Vec<_Tp, cn> Vec<_Tp, cn>::cross(const Vec<_Tp, cn>& v) const | |
-{ | |
- CV_Error(CV_StsError, "for arbitrary-size vector there is no cross-product defined"); | |
- return Vec<_Tp, cn>(); | |
-} | |
- | |
-template<typename _Tp, int cn> template<typename T2> | |
-inline Vec<_Tp, cn>::operator Vec<T2, cn>() const | |
-{ | |
- Vec<T2, cn> v; | |
- for( int i = 0; i < cn; i++ ) v.val[i] = saturate_cast<T2>(this->val[i]); | |
- return v; | |
-} | |
- | |
-template<typename _Tp, int cn> inline Vec<_Tp, cn>::operator CvScalar() const | |
-{ | |
- CvScalar s = {{0,0,0,0}}; | |
- int i; | |
- for( i = 0; i < std::min(cn, 4); i++ ) s.val[i] = this->val[i]; | |
- for( ; i < 4; i++ ) s.val[i] = 0; | |
- return s; | |
-} | |
- | |
-template<typename _Tp, int cn> inline const _Tp& Vec<_Tp, cn>::operator [](int i) const | |
-{ | |
- CV_DbgAssert( (unsigned)i < (unsigned)cn ); | |
- return this->val[i]; | |
-} | |
- | |
-template<typename _Tp, int cn> inline _Tp& Vec<_Tp, cn>::operator [](int i) | |
-{ | |
- CV_DbgAssert( (unsigned)i < (unsigned)cn ); | |
- return this->val[i]; | |
-} | |
- | |
-template<typename _Tp, int cn> inline const _Tp& Vec<_Tp, cn>::operator ()(int i) const | |
-{ | |
- CV_DbgAssert( (unsigned)i < (unsigned)cn ); | |
- return this->val[i]; | |
-} | |
- | |
-template<typename _Tp, int cn> inline _Tp& Vec<_Tp, cn>::operator ()(int i) | |
-{ | |
- CV_DbgAssert( (unsigned)i < (unsigned)cn ); | |
- return this->val[i]; | |
-} | |
- | |
-template<typename _Tp1, typename _Tp2, int cn> static inline Vec<_Tp1, cn>& | |
-operator += (Vec<_Tp1, cn>& a, const Vec<_Tp2, cn>& b) | |
-{ | |
- for( int i = 0; i < cn; i++ ) | |
- a.val[i] = saturate_cast<_Tp1>(a.val[i] + b.val[i]); | |
- return a; | |
-} | |
- | |
-template<typename _Tp1, typename _Tp2, int cn> static inline Vec<_Tp1, cn>& | |
-operator -= (Vec<_Tp1, cn>& a, const Vec<_Tp2, cn>& b) | |
-{ | |
- for( int i = 0; i < cn; i++ ) | |
- a.val[i] = saturate_cast<_Tp1>(a.val[i] - b.val[i]); | |
- return a; | |
-} | |
- | |
-template<typename _Tp, int cn> static inline Vec<_Tp, cn> | |
-operator + (const Vec<_Tp, cn>& a, const Vec<_Tp, cn>& b) | |
-{ | |
- return Vec<_Tp, cn>(a, b, Matx_AddOp()); | |
-} | |
- | |
-template<typename _Tp, int cn> static inline Vec<_Tp, cn> | |
-operator - (const Vec<_Tp, cn>& a, const Vec<_Tp, cn>& b) | |
-{ | |
- return Vec<_Tp, cn>(a, b, Matx_SubOp()); | |
-} | |
- | |
-template<typename _Tp, int cn> static inline | |
-Vec<_Tp, cn>& operator *= (Vec<_Tp, cn>& a, int alpha) | |
-{ | |
- for( int i = 0; i < cn; i++ ) | |
- a[i] = saturate_cast<_Tp>(a[i]*alpha); | |
- return a; | |
-} | |
- | |
-template<typename _Tp, int cn> static inline | |
-Vec<_Tp, cn>& operator *= (Vec<_Tp, cn>& a, float alpha) | |
-{ | |
- for( int i = 0; i < cn; i++ ) | |
- a[i] = saturate_cast<_Tp>(a[i]*alpha); | |
- return a; | |
-} | |
- | |
-template<typename _Tp, int cn> static inline | |
-Vec<_Tp, cn>& operator *= (Vec<_Tp, cn>& a, double alpha) | |
-{ | |
- for( int i = 0; i < cn; i++ ) | |
- a[i] = saturate_cast<_Tp>(a[i]*alpha); | |
- return a; | |
-} | |
- | |
-template<typename _Tp, int cn> static inline | |
-Vec<_Tp, cn>& operator /= (Vec<_Tp, cn>& a, int alpha) | |
-{ | |
- double ialpha = 1./alpha; | |
- for( int i = 0; i < cn; i++ ) | |
- a[i] = saturate_cast<_Tp>(a[i]*ialpha); | |
- return a; | |
-} | |
- | |
-template<typename _Tp, int cn> static inline | |
-Vec<_Tp, cn>& operator /= (Vec<_Tp, cn>& a, float alpha) | |
-{ | |
- float ialpha = 1.f/alpha; | |
- for( int i = 0; i < cn; i++ ) | |
- a[i] = saturate_cast<_Tp>(a[i]*ialpha); | |
- return a; | |
-} | |
- | |
-template<typename _Tp, int cn> static inline | |
-Vec<_Tp, cn>& operator /= (Vec<_Tp, cn>& a, double alpha) | |
-{ | |
- double ialpha = 1./alpha; | |
- for( int i = 0; i < cn; i++ ) | |
- a[i] = saturate_cast<_Tp>(a[i]*ialpha); | |
- return a; | |
-} | |
- | |
-template<typename _Tp, int cn> static inline Vec<_Tp, cn> | |
-operator * (const Vec<_Tp, cn>& a, int alpha) | |
-{ | |
- return Vec<_Tp, cn>(a, alpha, Matx_ScaleOp()); | |
-} | |
- | |
-template<typename _Tp, int cn> static inline Vec<_Tp, cn> | |
-operator * (int alpha, const Vec<_Tp, cn>& a) | |
-{ | |
- return Vec<_Tp, cn>(a, alpha, Matx_ScaleOp()); | |
-} | |
- | |
-template<typename _Tp, int cn> static inline Vec<_Tp, cn> | |
-operator * (const Vec<_Tp, cn>& a, float alpha) | |
-{ | |
- return Vec<_Tp, cn>(a, alpha, Matx_ScaleOp()); | |
-} | |
- | |
-template<typename _Tp, int cn> static inline Vec<_Tp, cn> | |
-operator * (float alpha, const Vec<_Tp, cn>& a) | |
-{ | |
- return Vec<_Tp, cn>(a, alpha, Matx_ScaleOp()); | |
-} | |
- | |
-template<typename _Tp, int cn> static inline Vec<_Tp, cn> | |
-operator * (const Vec<_Tp, cn>& a, double alpha) | |
-{ | |
- return Vec<_Tp, cn>(a, alpha, Matx_ScaleOp()); | |
-} | |
- | |
-template<typename _Tp, int cn> static inline Vec<_Tp, cn> | |
-operator * (double alpha, const Vec<_Tp, cn>& a) | |
-{ | |
- return Vec<_Tp, cn>(a, alpha, Matx_ScaleOp()); | |
-} | |
- | |
-template<typename _Tp, int cn> static inline Vec<_Tp, cn> | |
-operator / (const Vec<_Tp, cn>& a, int alpha) | |
-{ | |
- return Vec<_Tp, cn>(a, 1./alpha, Matx_ScaleOp()); | |
-} | |
- | |
-template<typename _Tp, int cn> static inline Vec<_Tp, cn> | |
-operator / (const Vec<_Tp, cn>& a, float alpha) | |
-{ | |
- return Vec<_Tp, cn>(a, 1.f/alpha, Matx_ScaleOp()); | |
-} | |
- | |
-template<typename _Tp, int cn> static inline Vec<_Tp, cn> | |
-operator / (const Vec<_Tp, cn>& a, double alpha) | |
-{ | |
- return Vec<_Tp, cn>(a, 1./alpha, Matx_ScaleOp()); | |
-} | |
- | |
-template<typename _Tp, int cn> static inline Vec<_Tp, cn> | |
-operator - (const Vec<_Tp, cn>& a) | |
-{ | |
- Vec<_Tp,cn> t; | |
- for( int i = 0; i < cn; i++ ) t.val[i] = saturate_cast<_Tp>(-a.val[i]); | |
- return t; | |
-} | |
- | |
-template<typename _Tp> inline Vec<_Tp, 4> operator * (const Vec<_Tp, 4>& v1, const Vec<_Tp, 4>& v2) | |
-{ | |
- return Vec<_Tp, 4>(saturate_cast<_Tp>(v1[0]*v2[0] - v1[1]*v2[1] - v1[2]*v2[2] - v1[3]*v2[3]), | |
- saturate_cast<_Tp>(v1[0]*v2[1] + v1[1]*v2[0] + v1[2]*v2[3] - v1[3]*v2[2]), | |
- saturate_cast<_Tp>(v1[0]*v2[2] - v1[1]*v2[3] + v1[2]*v2[0] + v1[3]*v2[1]), | |
- saturate_cast<_Tp>(v1[0]*v2[3] + v1[1]*v2[2] - v1[2]*v2[1] + v1[3]*v2[0])); | |
-} | |
- | |
-template<typename _Tp> inline Vec<_Tp, 4>& operator *= (Vec<_Tp, 4>& v1, const Vec<_Tp, 4>& v2) | |
-{ | |
- v1 = v1 * v2; | |
- return v1; | |
-} | |
- | |
-template<> inline Vec<float, 3> Vec<float, 3>::cross(const Vec<float, 3>& v) const | |
-{ | |
- return Vec<float,3>(val[1]*v.val[2] - val[2]*v.val[1], | |
- val[2]*v.val[0] - val[0]*v.val[2], | |
- val[0]*v.val[1] - val[1]*v.val[0]); | |
-} | |
- | |
-template<> inline Vec<double, 3> Vec<double, 3>::cross(const Vec<double, 3>& v) const | |
-{ | |
- return Vec<double,3>(val[1]*v.val[2] - val[2]*v.val[1], | |
- val[2]*v.val[0] - val[0]*v.val[2], | |
- val[0]*v.val[1] - val[1]*v.val[0]); | |
-} | |
- | |
-template<typename _Tp, int cn> inline Vec<_Tp, cn> normalize(const Vec<_Tp, cn>& v) | |
-{ | |
- double nv = norm(v); | |
- return v * (nv ? 1./nv : 0.); | |
-} | |
- | |
-template<typename _Tp, typename _T2, int cn> static inline | |
-VecCommaInitializer<_Tp, cn> operator << (const Vec<_Tp, cn>& vec, _T2 val) | |
-{ | |
- VecCommaInitializer<_Tp, cn> commaInitializer((Vec<_Tp, cn>*)&vec); | |
- return (commaInitializer, val); | |
-} | |
- | |
-template<typename _Tp, int cn> inline | |
-VecCommaInitializer<_Tp, cn>::VecCommaInitializer(Vec<_Tp, cn>* _vec) | |
- : MatxCommaInitializer<_Tp, cn, 1>(_vec) | |
-{} | |
- | |
-template<typename _Tp, int cn> template<typename _T2> inline | |
-VecCommaInitializer<_Tp, cn>& VecCommaInitializer<_Tp, cn>::operator , (_T2 value) | |
-{ | |
- CV_DbgAssert( this->idx < cn ); | |
- this->dst->val[this->idx++] = saturate_cast<_Tp>(value); | |
- return *this; | |
-} | |
- | |
-template<typename _Tp, int cn> inline | |
-Vec<_Tp, cn> VecCommaInitializer<_Tp, cn>::operator *() const | |
-{ | |
- CV_DbgAssert( this->idx == cn ); | |
- return *this->dst; | |
-} | |
- | |
-//////////////////////////////// Complex ////////////////////////////// | |
- | |
-template<typename _Tp> inline Complex<_Tp>::Complex() : re(0), im(0) {} | |
-template<typename _Tp> inline Complex<_Tp>::Complex( _Tp _re, _Tp _im ) : re(_re), im(_im) {} | |
-template<typename _Tp> template<typename T2> inline Complex<_Tp>::operator Complex<T2>() const | |
-{ return Complex<T2>(saturate_cast<T2>(re), saturate_cast<T2>(im)); } | |
-template<typename _Tp> inline Complex<_Tp> Complex<_Tp>::conj() const | |
-{ return Complex<_Tp>(re, -im); } | |
- | |
-template<typename _Tp> static inline | |
-bool operator == (const Complex<_Tp>& a, const Complex<_Tp>& b) | |
-{ return a.re == b.re && a.im == b.im; } | |
- | |
-template<typename _Tp> static inline | |
-bool operator != (const Complex<_Tp>& a, const Complex<_Tp>& b) | |
-{ return a.re != b.re || a.im != b.im; } | |
- | |
-template<typename _Tp> static inline | |
-Complex<_Tp> operator + (const Complex<_Tp>& a, const Complex<_Tp>& b) | |
-{ return Complex<_Tp>( a.re + b.re, a.im + b.im ); } | |
- | |
-template<typename _Tp> static inline | |
-Complex<_Tp>& operator += (Complex<_Tp>& a, const Complex<_Tp>& b) | |
-{ a.re += b.re; a.im += b.im; return a; } | |
- | |
-template<typename _Tp> static inline | |
-Complex<_Tp> operator - (const Complex<_Tp>& a, const Complex<_Tp>& b) | |
-{ return Complex<_Tp>( a.re - b.re, a.im - b.im ); } | |
- | |
-template<typename _Tp> static inline | |
-Complex<_Tp>& operator -= (Complex<_Tp>& a, const Complex<_Tp>& b) | |
-{ a.re -= b.re; a.im -= b.im; return a; } | |
- | |
-template<typename _Tp> static inline | |
-Complex<_Tp> operator - (const Complex<_Tp>& a) | |
-{ return Complex<_Tp>(-a.re, -a.im); } | |
- | |
-template<typename _Tp> static inline | |
-Complex<_Tp> operator * (const Complex<_Tp>& a, const Complex<_Tp>& b) | |
-{ return Complex<_Tp>( a.re*b.re - a.im*b.im, a.re*b.im + a.im*b.re ); } | |
- | |
-template<typename _Tp> static inline | |
-Complex<_Tp> operator * (const Complex<_Tp>& a, _Tp b) | |
-{ return Complex<_Tp>( a.re*b, a.im*b ); } | |
- | |
-template<typename _Tp> static inline | |
-Complex<_Tp> operator * (_Tp b, const Complex<_Tp>& a) | |
-{ return Complex<_Tp>( a.re*b, a.im*b ); } | |
- | |
-template<typename _Tp> static inline | |
-Complex<_Tp> operator + (const Complex<_Tp>& a, _Tp b) | |
-{ return Complex<_Tp>( a.re + b, a.im ); } | |
- | |
-template<typename _Tp> static inline | |
-Complex<_Tp> operator - (const Complex<_Tp>& a, _Tp b) | |
-{ return Complex<_Tp>( a.re - b, a.im ); } | |
- | |
-template<typename _Tp> static inline | |
-Complex<_Tp> operator + (_Tp b, const Complex<_Tp>& a) | |
-{ return Complex<_Tp>( a.re + b, a.im ); } | |
- | |
-template<typename _Tp> static inline | |
-Complex<_Tp> operator - (_Tp b, const Complex<_Tp>& a) | |
-{ return Complex<_Tp>( b - a.re, -a.im ); } | |
- | |
-template<typename _Tp> static inline | |
-Complex<_Tp>& operator += (Complex<_Tp>& a, _Tp b) | |
-{ a.re += b; return a; } | |
- | |
-template<typename _Tp> static inline | |
-Complex<_Tp>& operator -= (Complex<_Tp>& a, _Tp b) | |
-{ a.re -= b; return a; } | |
- | |
-template<typename _Tp> static inline | |
-Complex<_Tp>& operator *= (Complex<_Tp>& a, _Tp b) | |
-{ a.re *= b; a.im *= b; return a; } | |
- | |
-template<typename _Tp> static inline | |
-double abs(const Complex<_Tp>& a) | |
-{ return std::sqrt( (double)a.re*a.re + (double)a.im*a.im); } | |
- | |
-template<typename _Tp> static inline | |
-Complex<_Tp> operator / (const Complex<_Tp>& a, const Complex<_Tp>& b) | |
-{ | |
- double t = 1./((double)b.re*b.re + (double)b.im*b.im); | |
- return Complex<_Tp>( (_Tp)((a.re*b.re + a.im*b.im)*t), | |
- (_Tp)((-a.re*b.im + a.im*b.re)*t) ); | |
-} | |
- | |
-template<typename _Tp> static inline | |
-Complex<_Tp>& operator /= (Complex<_Tp>& a, const Complex<_Tp>& b) | |
-{ | |
- return (a = a / b); | |
-} | |
- | |
-template<typename _Tp> static inline | |
-Complex<_Tp> operator / (const Complex<_Tp>& a, _Tp b) | |
-{ | |
- _Tp t = (_Tp)1/b; | |
- return Complex<_Tp>( a.re*t, a.im*t ); | |
-} | |
- | |
-template<typename _Tp> static inline | |
-Complex<_Tp> operator / (_Tp b, const Complex<_Tp>& a) | |
-{ | |
- return Complex<_Tp>(b)/a; | |
-} | |
- | |
-template<typename _Tp> static inline | |
-Complex<_Tp> operator /= (const Complex<_Tp>& a, _Tp b) | |
-{ | |
- _Tp t = (_Tp)1/b; | |
- a.re *= t; a.im *= t; return a; | |
-} | |
- | |
-//////////////////////////////// 2D Point //////////////////////////////// | |
- | |
-template<typename _Tp> inline Point_<_Tp>::Point_() : x(0), y(0) {} | |
-template<typename _Tp> inline Point_<_Tp>::Point_(_Tp _x, _Tp _y) : x(_x), y(_y) {} | |
-template<typename _Tp> inline Point_<_Tp>::Point_(const Point_& pt) : x(pt.x), y(pt.y) {} | |
-template<typename _Tp> inline Point_<_Tp>::Point_(const CvPoint& pt) : x((_Tp)pt.x), y((_Tp)pt.y) {} | |
-template<typename _Tp> inline Point_<_Tp>::Point_(const CvPoint2D32f& pt) | |
- : x(saturate_cast<_Tp>(pt.x)), y(saturate_cast<_Tp>(pt.y)) {} | |
-template<typename _Tp> inline Point_<_Tp>::Point_(const Size_<_Tp>& sz) : x(sz.width), y(sz.height) {} | |
-template<typename _Tp> inline Point_<_Tp>::Point_(const Vec<_Tp,2>& v) : x(v[0]), y(v[1]) {} | |
-template<typename _Tp> inline Point_<_Tp>& Point_<_Tp>::operator = (const Point_& pt) | |
-{ x = pt.x; y = pt.y; return *this; } | |
- | |
-template<typename _Tp> template<typename _Tp2> inline Point_<_Tp>::operator Point_<_Tp2>() const | |
-{ return Point_<_Tp2>(saturate_cast<_Tp2>(x), saturate_cast<_Tp2>(y)); } | |
-template<typename _Tp> inline Point_<_Tp>::operator CvPoint() const | |
-{ return cvPoint(saturate_cast<int>(x), saturate_cast<int>(y)); } | |
-template<typename _Tp> inline Point_<_Tp>::operator CvPoint2D32f() const | |
-{ return cvPoint2D32f((float)x, (float)y); } | |
-template<typename _Tp> inline Point_<_Tp>::operator Vec<_Tp, 2>() const | |
-{ return Vec<_Tp, 2>(x, y); } | |
- | |
-template<typename _Tp> inline _Tp Point_<_Tp>::dot(const Point_& pt) const | |
-{ return saturate_cast<_Tp>(x*pt.x + y*pt.y); } | |
-template<typename _Tp> inline double Point_<_Tp>::ddot(const Point_& pt) const | |
-{ return (double)x*pt.x + (double)y*pt.y; } | |
- | |
-template<typename _Tp> inline double Point_<_Tp>::cross(const Point_& pt) const | |
-{ return (double)x*pt.y - (double)y*pt.x; } | |
- | |
-template<typename _Tp> static inline Point_<_Tp>& | |
-operator += (Point_<_Tp>& a, const Point_<_Tp>& b) | |
-{ | |
- a.x = saturate_cast<_Tp>(a.x + b.x); | |
- a.y = saturate_cast<_Tp>(a.y + b.y); | |
- return a; | |
-} | |
- | |
-template<typename _Tp> static inline Point_<_Tp>& | |
-operator -= (Point_<_Tp>& a, const Point_<_Tp>& b) | |
-{ | |
- a.x = saturate_cast<_Tp>(a.x - b.x); | |
- a.y = saturate_cast<_Tp>(a.y - b.y); | |
- return a; | |
-} | |
- | |
-template<typename _Tp> static inline Point_<_Tp>& | |
-operator *= (Point_<_Tp>& a, int b) | |
-{ | |
- a.x = saturate_cast<_Tp>(a.x*b); | |
- a.y = saturate_cast<_Tp>(a.y*b); | |
- return a; | |
-} | |
- | |
-template<typename _Tp> static inline Point_<_Tp>& | |
-operator *= (Point_<_Tp>& a, float b) | |
-{ | |
- a.x = saturate_cast<_Tp>(a.x*b); | |
- a.y = saturate_cast<_Tp>(a.y*b); | |
- return a; | |
-} | |
- | |
-template<typename _Tp> static inline Point_<_Tp>& | |
-operator *= (Point_<_Tp>& a, double b) | |
-{ | |
- a.x = saturate_cast<_Tp>(a.x*b); | |
- a.y = saturate_cast<_Tp>(a.y*b); | |
- return a; | |
-} | |
- | |
-template<typename _Tp> static inline double norm(const Point_<_Tp>& pt) | |
-{ return std::sqrt((double)pt.x*pt.x + (double)pt.y*pt.y); } | |
- | |
-template<typename _Tp> static inline bool operator == (const Point_<_Tp>& a, const Point_<_Tp>& b) | |
-{ return a.x == b.x && a.y == b.y; } | |
- | |
-template<typename _Tp> static inline bool operator != (const Point_<_Tp>& a, const Point_<_Tp>& b) | |
-{ return a.x != b.x || a.y != b.y; } | |
- | |
-template<typename _Tp> static inline Point_<_Tp> operator + (const Point_<_Tp>& a, const Point_<_Tp>& b) | |
-{ return Point_<_Tp>( saturate_cast<_Tp>(a.x + b.x), saturate_cast<_Tp>(a.y + b.y) ); } | |
- | |
-template<typename _Tp> static inline Point_<_Tp> operator - (const Point_<_Tp>& a, const Point_<_Tp>& b) | |
-{ return Point_<_Tp>( saturate_cast<_Tp>(a.x - b.x), saturate_cast<_Tp>(a.y - b.y) ); } | |
- | |
-template<typename _Tp> static inline Point_<_Tp> operator - (const Point_<_Tp>& a) | |
-{ return Point_<_Tp>( saturate_cast<_Tp>(-a.x), saturate_cast<_Tp>(-a.y) ); } | |
- | |
-template<typename _Tp> static inline Point_<_Tp> operator * (const Point_<_Tp>& a, int b) | |
-{ return Point_<_Tp>( saturate_cast<_Tp>(a.x*b), saturate_cast<_Tp>(a.y*b) ); } | |
- | |
-template<typename _Tp> static inline Point_<_Tp> operator * (int a, const Point_<_Tp>& b) | |
-{ return Point_<_Tp>( saturate_cast<_Tp>(b.x*a), saturate_cast<_Tp>(b.y*a) ); } | |
- | |
-template<typename _Tp> static inline Point_<_Tp> operator * (const Point_<_Tp>& a, float b) | |
-{ return Point_<_Tp>( saturate_cast<_Tp>(a.x*b), saturate_cast<_Tp>(a.y*b) ); } | |
- | |
-template<typename _Tp> static inline Point_<_Tp> operator * (float a, const Point_<_Tp>& b) | |
-{ return Point_<_Tp>( saturate_cast<_Tp>(b.x*a), saturate_cast<_Tp>(b.y*a) ); } | |
- | |
-template<typename _Tp> static inline Point_<_Tp> operator * (const Point_<_Tp>& a, double b) | |
-{ return Point_<_Tp>( saturate_cast<_Tp>(a.x*b), saturate_cast<_Tp>(a.y*b) ); } | |
- | |
-template<typename _Tp> static inline Point_<_Tp> operator * (double a, const Point_<_Tp>& b) | |
-{ return Point_<_Tp>( saturate_cast<_Tp>(b.x*a), saturate_cast<_Tp>(b.y*a) ); } | |
- | |
-//////////////////////////////// 3D Point //////////////////////////////// | |
- | |
-template<typename _Tp> inline Point3_<_Tp>::Point3_() : x(0), y(0), z(0) {} | |
-template<typename _Tp> inline Point3_<_Tp>::Point3_(_Tp _x, _Tp _y, _Tp _z) : x(_x), y(_y), z(_z) {} | |
-template<typename _Tp> inline Point3_<_Tp>::Point3_(const Point3_& pt) : x(pt.x), y(pt.y), z(pt.z) {} | |
-template<typename _Tp> inline Point3_<_Tp>::Point3_(const Point_<_Tp>& pt) : x(pt.x), y(pt.y), z(_Tp()) {} | |
-template<typename _Tp> inline Point3_<_Tp>::Point3_(const CvPoint3D32f& pt) : | |
- x(saturate_cast<_Tp>(pt.x)), y(saturate_cast<_Tp>(pt.y)), z(saturate_cast<_Tp>(pt.z)) {} | |
-template<typename _Tp> inline Point3_<_Tp>::Point3_(const Vec<_Tp, 3>& v) : x(v[0]), y(v[1]), z(v[2]) {} | |
- | |
-template<typename _Tp> template<typename _Tp2> inline Point3_<_Tp>::operator Point3_<_Tp2>() const | |
-{ return Point3_<_Tp2>(saturate_cast<_Tp2>(x), saturate_cast<_Tp2>(y), saturate_cast<_Tp2>(z)); } | |
- | |
-template<typename _Tp> inline Point3_<_Tp>::operator CvPoint3D32f() const | |
-{ return cvPoint3D32f((float)x, (float)y, (float)z); } | |
- | |
-template<typename _Tp> inline Point3_<_Tp>::operator Vec<_Tp, 3>() const | |
-{ return Vec<_Tp, 3>(x, y, z); } | |
- | |
-template<typename _Tp> inline Point3_<_Tp>& Point3_<_Tp>::operator = (const Point3_& pt) | |
-{ x = pt.x; y = pt.y; z = pt.z; return *this; } | |
- | |
-template<typename _Tp> inline _Tp Point3_<_Tp>::dot(const Point3_& pt) const | |
-{ return saturate_cast<_Tp>(x*pt.x + y*pt.y + z*pt.z); } | |
-template<typename _Tp> inline double Point3_<_Tp>::ddot(const Point3_& pt) const | |
-{ return (double)x*pt.x + (double)y*pt.y + (double)z*pt.z; } | |
- | |
-template<typename _Tp> inline Point3_<_Tp> Point3_<_Tp>::cross(const Point3_<_Tp>& pt) const | |
-{ | |
- return Point3_<_Tp>(y*pt.z - z*pt.y, z*pt.x - x*pt.z, x*pt.y - y*pt.x); | |
-} | |
- | |
-template<typename _Tp> static inline Point3_<_Tp>& | |
-operator += (Point3_<_Tp>& a, const Point3_<_Tp>& b) | |
-{ | |
- a.x = saturate_cast<_Tp>(a.x + b.x); | |
- a.y = saturate_cast<_Tp>(a.y + b.y); | |
- a.z = saturate_cast<_Tp>(a.z + b.z); | |
- return a; | |
-} | |
- | |
-template<typename _Tp> static inline Point3_<_Tp>& | |
-operator -= (Point3_<_Tp>& a, const Point3_<_Tp>& b) | |
-{ | |
- a.x = saturate_cast<_Tp>(a.x - b.x); | |
- a.y = saturate_cast<_Tp>(a.y - b.y); | |
- a.z = saturate_cast<_Tp>(a.z - b.z); | |
- return a; | |
-} | |
- | |
-template<typename _Tp> static inline Point3_<_Tp>& | |
-operator *= (Point3_<_Tp>& a, int b) | |
-{ | |
- a.x = saturate_cast<_Tp>(a.x*b); | |
- a.y = saturate_cast<_Tp>(a.y*b); | |
- a.z = saturate_cast<_Tp>(a.z*b); | |
- return a; | |
-} | |
- | |
-template<typename _Tp> static inline Point3_<_Tp>& | |
-operator *= (Point3_<_Tp>& a, float b) | |
-{ | |
- a.x = saturate_cast<_Tp>(a.x*b); | |
- a.y = saturate_cast<_Tp>(a.y*b); | |
- a.z = saturate_cast<_Tp>(a.z*b); | |
- return a; | |
-} | |
- | |
-template<typename _Tp> static inline Point3_<_Tp>& | |
-operator *= (Point3_<_Tp>& a, double b) | |
-{ | |
- a.x = saturate_cast<_Tp>(a.x*b); | |
- a.y = saturate_cast<_Tp>(a.y*b); | |
- a.z = saturate_cast<_Tp>(a.z*b); | |
- return a; | |
-} | |
- | |
-template<typename _Tp> static inline double norm(const Point3_<_Tp>& pt) | |
-{ return std::sqrt((double)pt.x*pt.x + (double)pt.y*pt.y + (double)pt.z*pt.z); } | |
- | |
-template<typename _Tp> static inline bool operator == (const Point3_<_Tp>& a, const Point3_<_Tp>& b) | |
-{ return a.x == b.x && a.y == b.y && a.z == b.z; } | |
- | |
-template<typename _Tp> static inline bool operator != (const Point3_<_Tp>& a, const Point3_<_Tp>& b) | |
-{ return a.x != b.x || a.y != b.y || a.z != b.z; } | |
- | |
-template<typename _Tp> static inline Point3_<_Tp> operator + (const Point3_<_Tp>& a, const Point3_<_Tp>& b) | |
-{ return Point3_<_Tp>( saturate_cast<_Tp>(a.x + b.x), | |
- saturate_cast<_Tp>(a.y + b.y), | |
- saturate_cast<_Tp>(a.z + b.z)); } | |
- | |
-template<typename _Tp> static inline Point3_<_Tp> operator - (const Point3_<_Tp>& a, const Point3_<_Tp>& b) | |
-{ return Point3_<_Tp>( saturate_cast<_Tp>(a.x - b.x), | |
- saturate_cast<_Tp>(a.y - b.y), | |
- saturate_cast<_Tp>(a.z - b.z)); } | |
- | |
-template<typename _Tp> static inline Point3_<_Tp> operator - (const Point3_<_Tp>& a) | |
-{ return Point3_<_Tp>( saturate_cast<_Tp>(-a.x), | |
- saturate_cast<_Tp>(-a.y), | |
- saturate_cast<_Tp>(-a.z) ); } | |
- | |
-template<typename _Tp> static inline Point3_<_Tp> operator * (const Point3_<_Tp>& a, int b) | |
-{ return Point3_<_Tp>( saturate_cast<_Tp>(a.x*b), | |
- saturate_cast<_Tp>(a.y*b), | |
- saturate_cast<_Tp>(a.z*b) ); } | |
- | |
-template<typename _Tp> static inline Point3_<_Tp> operator * (int a, const Point3_<_Tp>& b) | |
-{ return Point3_<_Tp>( saturate_cast<_Tp>(b.x*a), | |
- saturate_cast<_Tp>(b.y*a), | |
- saturate_cast<_Tp>(b.z*a) ); } | |
- | |
-template<typename _Tp> static inline Point3_<_Tp> operator * (const Point3_<_Tp>& a, float b) | |
-{ return Point3_<_Tp>( saturate_cast<_Tp>(a.x*b), | |
- saturate_cast<_Tp>(a.y*b), | |
- saturate_cast<_Tp>(a.z*b) ); } | |
- | |
-template<typename _Tp> static inline Point3_<_Tp> operator * (float a, const Point3_<_Tp>& b) | |
-{ return Point3_<_Tp>( saturate_cast<_Tp>(b.x*a), | |
- saturate_cast<_Tp>(b.y*a), | |
- saturate_cast<_Tp>(b.z*a) ); } | |
- | |
-template<typename _Tp> static inline Point3_<_Tp> operator * (const Point3_<_Tp>& a, double b) | |
-{ return Point3_<_Tp>( saturate_cast<_Tp>(a.x*b), | |
- saturate_cast<_Tp>(a.y*b), | |
- saturate_cast<_Tp>(a.z*b) ); } | |
- | |
-template<typename _Tp> static inline Point3_<_Tp> operator * (double a, const Point3_<_Tp>& b) | |
-{ return Point3_<_Tp>( saturate_cast<_Tp>(b.x*a), | |
- saturate_cast<_Tp>(b.y*a), | |
- saturate_cast<_Tp>(b.z*a) ); } | |
- | |
-//////////////////////////////// Size //////////////////////////////// | |
- | |
-template<typename _Tp> inline Size_<_Tp>::Size_() | |
- : width(0), height(0) {} | |
-template<typename _Tp> inline Size_<_Tp>::Size_(_Tp _width, _Tp _height) | |
- : width(_width), height(_height) {} | |
-template<typename _Tp> inline Size_<_Tp>::Size_(const Size_& sz) | |
- : width(sz.width), height(sz.height) {} | |
-template<typename _Tp> inline Size_<_Tp>::Size_(const CvSize& sz) | |
- : width(saturate_cast<_Tp>(sz.width)), height(saturate_cast<_Tp>(sz.height)) {} | |
-template<typename _Tp> inline Size_<_Tp>::Size_(const CvSize2D32f& sz) | |
- : width(saturate_cast<_Tp>(sz.width)), height(saturate_cast<_Tp>(sz.height)) {} | |
-template<typename _Tp> inline Size_<_Tp>::Size_(const Point_<_Tp>& pt) : width(pt.x), height(pt.y) {} | |
- | |
-template<typename _Tp> template<typename _Tp2> inline Size_<_Tp>::operator Size_<_Tp2>() const | |
-{ return Size_<_Tp2>(saturate_cast<_Tp2>(width), saturate_cast<_Tp2>(height)); } | |
-template<typename _Tp> inline Size_<_Tp>::operator CvSize() const | |
-{ return cvSize(saturate_cast<int>(width), saturate_cast<int>(height)); } | |
-template<typename _Tp> inline Size_<_Tp>::operator CvSize2D32f() const | |
-{ return cvSize2D32f((float)width, (float)height); } | |
- | |
-template<typename _Tp> inline Size_<_Tp>& Size_<_Tp>::operator = (const Size_<_Tp>& sz) | |
-{ width = sz.width; height = sz.height; return *this; } | |
-template<typename _Tp> static inline Size_<_Tp> operator * (const Size_<_Tp>& a, _Tp b) | |
-{ return Size_<_Tp>(a.width * b, a.height * b); } | |
-template<typename _Tp> static inline Size_<_Tp> operator + (const Size_<_Tp>& a, const Size_<_Tp>& b) | |
-{ return Size_<_Tp>(a.width + b.width, a.height + b.height); } | |
-template<typename _Tp> static inline Size_<_Tp> operator - (const Size_<_Tp>& a, const Size_<_Tp>& b) | |
-{ return Size_<_Tp>(a.width - b.width, a.height - b.height); } | |
-template<typename _Tp> inline _Tp Size_<_Tp>::area() const { return width*height; } | |
- | |
-template<typename _Tp> static inline Size_<_Tp>& operator += (Size_<_Tp>& a, const Size_<_Tp>& b) | |
-{ a.width += b.width; a.height += b.height; return a; } | |
-template<typename _Tp> static inline Size_<_Tp>& operator -= (Size_<_Tp>& a, const Size_<_Tp>& b) | |
-{ a.width -= b.width; a.height -= b.height; return a; } | |
- | |
-template<typename _Tp> static inline bool operator == (const Size_<_Tp>& a, const Size_<_Tp>& b) | |
-{ return a.width == b.width && a.height == b.height; } | |
-template<typename _Tp> static inline bool operator != (const Size_<_Tp>& a, const Size_<_Tp>& b) | |
-{ return a.width != b.width || a.height != b.height; } | |
- | |
-//////////////////////////////// Rect //////////////////////////////// | |
- | |
- | |
-template<typename _Tp> inline Rect_<_Tp>::Rect_() : x(0), y(0), width(0), height(0) {} | |
-template<typename _Tp> inline Rect_<_Tp>::Rect_(_Tp _x, _Tp _y, _Tp _width, _Tp _height) : x(_x), y(_y), width(_width), height(_height) {} | |
-template<typename _Tp> inline Rect_<_Tp>::Rect_(const Rect_<_Tp>& r) : x(r.x), y(r.y), width(r.width), height(r.height) {} | |
-template<typename _Tp> inline Rect_<_Tp>::Rect_(const CvRect& r) : x((_Tp)r.x), y((_Tp)r.y), width((_Tp)r.width), height((_Tp)r.height) {} | |
-template<typename _Tp> inline Rect_<_Tp>::Rect_(const Point_<_Tp>& org, const Size_<_Tp>& sz) : | |
- x(org.x), y(org.y), width(sz.width), height(sz.height) {} | |
-template<typename _Tp> inline Rect_<_Tp>::Rect_(const Point_<_Tp>& pt1, const Point_<_Tp>& pt2) | |
-{ | |
- x = std::min(pt1.x, pt2.x); y = std::min(pt1.y, pt2.y); | |
- width = std::max(pt1.x, pt2.x) - x; height = std::max(pt1.y, pt2.y) - y; | |
-} | |
-template<typename _Tp> inline Rect_<_Tp>& Rect_<_Tp>::operator = ( const Rect_<_Tp>& r ) | |
-{ x = r.x; y = r.y; width = r.width; height = r.height; return *this; } | |
- | |
-template<typename _Tp> inline Point_<_Tp> Rect_<_Tp>::tl() const { return Point_<_Tp>(x,y); } | |
-template<typename _Tp> inline Point_<_Tp> Rect_<_Tp>::br() const { return Point_<_Tp>(x+width, y+height); } | |
- | |
-template<typename _Tp> static inline Rect_<_Tp>& operator += ( Rect_<_Tp>& a, const Point_<_Tp>& b ) | |
-{ a.x += b.x; a.y += b.y; return a; } | |
-template<typename _Tp> static inline Rect_<_Tp>& operator -= ( Rect_<_Tp>& a, const Point_<_Tp>& b ) | |
-{ a.x -= b.x; a.y -= b.y; return a; } | |
- | |
-template<typename _Tp> static inline Rect_<_Tp>& operator += ( Rect_<_Tp>& a, const Size_<_Tp>& b ) | |
-{ a.width += b.width; a.height += b.height; return a; } | |
- | |
-template<typename _Tp> static inline Rect_<_Tp>& operator -= ( Rect_<_Tp>& a, const Size_<_Tp>& b ) | |
-{ a.width -= b.width; a.height -= b.height; return a; } | |
- | |
-template<typename _Tp> static inline Rect_<_Tp>& operator &= ( Rect_<_Tp>& a, const Rect_<_Tp>& b ) | |
-{ | |
- _Tp x1 = std::max(a.x, b.x), y1 = std::max(a.y, b.y); | |
- a.width = std::min(a.x + a.width, b.x + b.width) - x1; | |
- a.height = std::min(a.y + a.height, b.y + b.height) - y1; | |
- a.x = x1; a.y = y1; | |
- if( a.width <= 0 || a.height <= 0 ) | |
- a = Rect(); | |
- return a; | |
-} | |
- | |
-template<typename _Tp> static inline Rect_<_Tp>& operator |= ( Rect_<_Tp>& a, const Rect_<_Tp>& b ) | |
-{ | |
- _Tp x1 = std::min(a.x, b.x), y1 = std::min(a.y, b.y); | |
- a.width = std::max(a.x + a.width, b.x + b.width) - x1; | |
- a.height = std::max(a.y + a.height, b.y + b.height) - y1; | |
- a.x = x1; a.y = y1; | |
- return a; | |
-} | |
- | |
-template<typename _Tp> inline Size_<_Tp> Rect_<_Tp>::size() const { return Size_<_Tp>(width, height); } | |
-template<typename _Tp> inline _Tp Rect_<_Tp>::area() const { return width*height; } | |
- | |
-template<typename _Tp> template<typename _Tp2> inline Rect_<_Tp>::operator Rect_<_Tp2>() const | |
-{ return Rect_<_Tp2>(saturate_cast<_Tp2>(x), saturate_cast<_Tp2>(y), | |
- saturate_cast<_Tp2>(width), saturate_cast<_Tp2>(height)); } | |
-template<typename _Tp> inline Rect_<_Tp>::operator CvRect() const | |
-{ return cvRect(saturate_cast<int>(x), saturate_cast<int>(y), | |
- saturate_cast<int>(width), saturate_cast<int>(height)); } | |
- | |
-template<typename _Tp> inline bool Rect_<_Tp>::contains(const Point_<_Tp>& pt) const | |
-{ return x <= pt.x && pt.x < x + width && y <= pt.y && pt.y < y + height; } | |
- | |
-template<typename _Tp> static inline bool operator == (const Rect_<_Tp>& a, const Rect_<_Tp>& b) | |
-{ | |
- return a.x == b.x && a.y == b.y && a.width == b.width && a.height == b.height; | |
-} | |
- | |
-template<typename _Tp> static inline bool operator != (const Rect_<_Tp>& a, const Rect_<_Tp>& b) | |
-{ | |
- return a.x != b.x || a.y != b.y || a.width != b.width || a.height != b.height; | |
-} | |
- | |
-template<typename _Tp> static inline Rect_<_Tp> operator + (const Rect_<_Tp>& a, const Point_<_Tp>& b) | |
-{ | |
- return Rect_<_Tp>( a.x + b.x, a.y + b.y, a.width, a.height ); | |
-} | |
- | |
-template<typename _Tp> static inline Rect_<_Tp> operator - (const Rect_<_Tp>& a, const Point_<_Tp>& b) | |
-{ | |
- return Rect_<_Tp>( a.x - b.x, a.y - b.y, a.width, a.height ); | |
-} | |
- | |
-template<typename _Tp> static inline Rect_<_Tp> operator + (const Rect_<_Tp>& a, const Size_<_Tp>& b) | |
-{ | |
- return Rect_<_Tp>( a.x, a.y, a.width + b.width, a.height + b.height ); | |
-} | |
- | |
-template<typename _Tp> static inline Rect_<_Tp> operator & (const Rect_<_Tp>& a, const Rect_<_Tp>& b) | |
-{ | |
- Rect_<_Tp> c = a; | |
- return c &= b; | |
-} | |
- | |
-template<typename _Tp> static inline Rect_<_Tp> operator | (const Rect_<_Tp>& a, const Rect_<_Tp>& b) | |
-{ | |
- Rect_<_Tp> c = a; | |
- return c |= b; | |
-} | |
- | |
-template<typename _Tp> inline bool Point_<_Tp>::inside( const Rect_<_Tp>& r ) const | |
-{ | |
- return r.contains(*this); | |
-} | |
- | |
-inline RotatedRect::RotatedRect() { angle = 0; } | |
-inline RotatedRect::RotatedRect(const Point2f& _center, const Size2f& _size, float _angle) | |
- : center(_center), size(_size), angle(_angle) {} | |
-inline RotatedRect::RotatedRect(const CvBox2D& box) | |
- : center(box.center), size(box.size), angle(box.angle) {} | |
-inline RotatedRect::operator CvBox2D() const | |
-{ | |
- CvBox2D box; box.center = center; box.size = size; box.angle = angle; | |
- return box; | |
-} | |
- | |
-//////////////////////////////// Scalar_ /////////////////////////////// | |
- | |
-template<typename _Tp> inline Scalar_<_Tp>::Scalar_() | |
-{ this->val[0] = this->val[1] = this->val[2] = this->val[3] = 0; } | |
- | |
-template<typename _Tp> inline Scalar_<_Tp>::Scalar_(_Tp v0, _Tp v1, _Tp v2, _Tp v3) | |
-{ this->val[0] = v0; this->val[1] = v1; this->val[2] = v2; this->val[3] = v3; } | |
- | |
-template<typename _Tp> inline Scalar_<_Tp>::Scalar_(const CvScalar& s) | |
-{ | |
- this->val[0] = saturate_cast<_Tp>(s.val[0]); | |
- this->val[1] = saturate_cast<_Tp>(s.val[1]); | |
- this->val[2] = saturate_cast<_Tp>(s.val[2]); | |
- this->val[3] = saturate_cast<_Tp>(s.val[3]); | |
-} | |
- | |
-template<typename _Tp> inline Scalar_<_Tp>::Scalar_(_Tp v0) | |
-{ this->val[0] = v0; this->val[1] = this->val[2] = this->val[3] = 0; } | |
- | |
-template<typename _Tp> inline Scalar_<_Tp> Scalar_<_Tp>::all(_Tp v0) | |
-{ return Scalar_<_Tp>(v0, v0, v0, v0); } | |
-template<typename _Tp> inline Scalar_<_Tp>::operator CvScalar() const | |
-{ return cvScalar(this->val[0], this->val[1], this->val[2], this->val[3]); } | |
- | |
-template<typename _Tp> template<typename T2> inline Scalar_<_Tp>::operator Scalar_<T2>() const | |
-{ | |
- return Scalar_<T2>(saturate_cast<T2>(this->val[0]), | |
- saturate_cast<T2>(this->val[1]), | |
- saturate_cast<T2>(this->val[2]), | |
- saturate_cast<T2>(this->val[3])); | |
-} | |
- | |
-template<typename _Tp> static inline Scalar_<_Tp>& operator += (Scalar_<_Tp>& a, const Scalar_<_Tp>& b) | |
-{ | |
- a.val[0] = saturate_cast<_Tp>(a.val[0] + b.val[0]); | |
- a.val[1] = saturate_cast<_Tp>(a.val[1] + b.val[1]); | |
- a.val[2] = saturate_cast<_Tp>(a.val[2] + b.val[2]); | |
- a.val[3] = saturate_cast<_Tp>(a.val[3] + b.val[3]); | |
- return a; | |
-} | |
- | |
-template<typename _Tp> static inline Scalar_<_Tp>& operator -= (Scalar_<_Tp>& a, const Scalar_<_Tp>& b) | |
-{ | |
- a.val[0] = saturate_cast<_Tp>(a.val[0] - b.val[0]); | |
- a.val[1] = saturate_cast<_Tp>(a.val[1] - b.val[1]); | |
- a.val[2] = saturate_cast<_Tp>(a.val[2] - b.val[2]); | |
- a.val[3] = saturate_cast<_Tp>(a.val[3] - b.val[3]); | |
- return a; | |
-} | |
- | |
-template<typename _Tp> static inline Scalar_<_Tp>& operator *= ( Scalar_<_Tp>& a, _Tp v ) | |
-{ | |
- a.val[0] = saturate_cast<_Tp>(a.val[0] * v); | |
- a.val[1] = saturate_cast<_Tp>(a.val[1] * v); | |
- a.val[2] = saturate_cast<_Tp>(a.val[2] * v); | |
- a.val[3] = saturate_cast<_Tp>(a.val[3] * v); | |
- return a; | |
-} | |
- | |
-template<typename _Tp> inline Scalar_<_Tp> Scalar_<_Tp>::mul(const Scalar_<_Tp>& t, double scale ) const | |
-{ | |
- return Scalar_<_Tp>( saturate_cast<_Tp>(this->val[0]*t.val[0]*scale), | |
- saturate_cast<_Tp>(this->val[1]*t.val[1]*scale), | |
- saturate_cast<_Tp>(this->val[2]*t.val[2]*scale), | |
- saturate_cast<_Tp>(this->val[3]*t.val[3]*scale)); | |
-} | |
- | |
-template<typename _Tp> static inline bool operator == ( const Scalar_<_Tp>& a, const Scalar_<_Tp>& b ) | |
-{ | |
- return a.val[0] == b.val[0] && a.val[1] == b.val[1] && | |
- a.val[2] == b.val[2] && a.val[3] == b.val[3]; | |
-} | |
- | |
-template<typename _Tp> static inline bool operator != ( const Scalar_<_Tp>& a, const Scalar_<_Tp>& b ) | |
-{ | |
- return a.val[0] != b.val[0] || a.val[1] != b.val[1] || | |
- a.val[2] != b.val[2] || a.val[3] != b.val[3]; | |
-} | |
- | |
-template<typename _Tp> static inline Scalar_<_Tp> operator + (const Scalar_<_Tp>& a, const Scalar_<_Tp>& b) | |
-{ | |
- return Scalar_<_Tp>(saturate_cast<_Tp>(a.val[0] + b.val[0]), | |
- saturate_cast<_Tp>(a.val[1] + b.val[1]), | |
- saturate_cast<_Tp>(a.val[2] + b.val[2]), | |
- saturate_cast<_Tp>(a.val[3] + b.val[3])); | |
-} | |
- | |
-template<typename _Tp> static inline Scalar_<_Tp> operator - (const Scalar_<_Tp>& a, const Scalar_<_Tp>& b) | |
-{ | |
- return Scalar_<_Tp>(saturate_cast<_Tp>(a.val[0] - b.val[0]), | |
- saturate_cast<_Tp>(a.val[1] - b.val[1]), | |
- saturate_cast<_Tp>(a.val[2] - b.val[2]), | |
- saturate_cast<_Tp>(a.val[3] - b.val[3])); | |
-} | |
- | |
-template<typename _Tp> static inline Scalar_<_Tp> operator * (const Scalar_<_Tp>& a, _Tp alpha) | |
-{ | |
- return Scalar_<_Tp>(saturate_cast<_Tp>(a.val[0] * alpha), | |
- saturate_cast<_Tp>(a.val[1] * alpha), | |
- saturate_cast<_Tp>(a.val[2] * alpha), | |
- saturate_cast<_Tp>(a.val[3] * alpha)); | |
-} | |
- | |
-template<typename _Tp> static inline Scalar_<_Tp> operator * (_Tp alpha, const Scalar_<_Tp>& a) | |
-{ | |
- return a*alpha; | |
-} | |
- | |
-template<typename _Tp> static inline Scalar_<_Tp> operator - (const Scalar_<_Tp>& a) | |
-{ | |
- return Scalar_<_Tp>(saturate_cast<_Tp>(-a.val[0]), saturate_cast<_Tp>(-a.val[1]), | |
- saturate_cast<_Tp>(-a.val[2]), saturate_cast<_Tp>(-a.val[3])); | |
-} | |
- | |
- | |
-template<typename _Tp> static inline Scalar_<_Tp> | |
-operator * (const Scalar_<_Tp>& a, const Scalar_<_Tp>& b) | |
-{ | |
- return Scalar_<_Tp>(saturate_cast<_Tp>(a[0]*b[0] - a[1]*b[1] - a[2]*b[2] - a[3]*b[3]), | |
- saturate_cast<_Tp>(a[0]*b[1] + a[1]*b[0] + a[2]*b[3] - a[3]*b[2]), | |
- saturate_cast<_Tp>(a[0]*b[2] - a[1]*b[3] + a[2]*b[0] + a[3]*b[1]), | |
- saturate_cast<_Tp>(a[0]*b[3] + a[1]*b[2] - a[2]*b[1] + a[3]*b[0])); | |
-} | |
- | |
-template<typename _Tp> static inline Scalar_<_Tp>& | |
-operator *= (Scalar_<_Tp>& a, const Scalar_<_Tp>& b) | |
-{ | |
- a = a*b; | |
- return a; | |
-} | |
- | |
-template<typename _Tp> inline Scalar_<_Tp> Scalar_<_Tp>::conj() const | |
-{ | |
- return Scalar_<_Tp>(saturate_cast<_Tp>(this->val[0]), | |
- saturate_cast<_Tp>(-this->val[1]), | |
- saturate_cast<_Tp>(-this->val[2]), | |
- saturate_cast<_Tp>(-this->val[3])); | |
-} | |
- | |
-template<typename _Tp> inline bool Scalar_<_Tp>::isReal() const | |
-{ | |
- return this->val[1] == 0 && this->val[2] == 0 && this->val[3] == 0; | |
-} | |
- | |
-template<typename _Tp> static inline | |
-Scalar_<_Tp> operator / (const Scalar_<_Tp>& a, _Tp alpha) | |
-{ | |
- return Scalar_<_Tp>(saturate_cast<_Tp>(a.val[0] / alpha), | |
- saturate_cast<_Tp>(a.val[1] / alpha), | |
- saturate_cast<_Tp>(a.val[2] / alpha), | |
- saturate_cast<_Tp>(a.val[3] / alpha)); | |
-} | |
- | |
-template<typename _Tp> static inline | |
-Scalar_<float> operator / (const Scalar_<float>& a, float alpha) | |
-{ | |
- float s = 1/alpha; | |
- return Scalar_<float>(a.val[0]*s, a.val[1]*s, a.val[2]*s, a.val[3]*s); | |
-} | |
- | |
-template<typename _Tp> static inline | |
-Scalar_<double> operator / (const Scalar_<double>& a, double alpha) | |
-{ | |
- double s = 1/alpha; | |
- return Scalar_<double>(a.val[0]*s, a.val[1]*s, a.val[2]*s, a.val[3]*s); | |
-} | |
- | |
-template<typename _Tp> static inline | |
-Scalar_<_Tp>& operator /= (Scalar_<_Tp>& a, _Tp alpha) | |
-{ | |
- a = a/alpha; | |
- return a; | |
-} | |
- | |
-template<typename _Tp> static inline | |
-Scalar_<_Tp> operator / (_Tp a, const Scalar_<_Tp>& b) | |
-{ | |
- _Tp s = a/(b[0]*b[0] + b[1]*b[1] + b[2]*b[2] + b[3]*b[3]); | |
- return b.conj()*s; | |
-} | |
- | |
-template<typename _Tp> static inline | |
-Scalar_<_Tp> operator / (const Scalar_<_Tp>& a, const Scalar_<_Tp>& b) | |
-{ | |
- return a*((_Tp)1/b); | |
-} | |
- | |
-template<typename _Tp> static inline | |
-Scalar_<_Tp>& operator /= (Scalar_<_Tp>& a, const Scalar_<_Tp>& b) | |
-{ | |
- a = a/b; | |
- return a; | |
-} | |
- | |
-//////////////////////////////// Range ///////////////////////////////// | |
- | |
-inline Range::Range() : start(0), end(0) {} | |
-inline Range::Range(int _start, int _end) : start(_start), end(_end) {} | |
-inline Range::Range(const CvSlice& slice) : start(slice.start_index), end(slice.end_index) | |
-{ | |
- if( start == 0 && end == CV_WHOLE_SEQ_END_INDEX ) | |
- *this = Range::all(); | |
-} | |
- | |
-inline int Range::size() const { return end - start; } | |
-inline bool Range::empty() const { return start == end; } | |
-inline Range Range::all() { return Range(INT_MIN, INT_MAX); } | |
- | |
-static inline bool operator == (const Range& r1, const Range& r2) | |
-{ return r1.start == r2.start && r1.end == r2.end; } | |
- | |
-static inline bool operator != (const Range& r1, const Range& r2) | |
-{ return !(r1 == r2); } | |
- | |
-static inline bool operator !(const Range& r) | |
-{ return r.start == r.end; } | |
- | |
-static inline Range operator & (const Range& r1, const Range& r2) | |
-{ | |
- Range r(std::max(r1.start, r2.start), std::min(r1.end, r2.end)); | |
- r.end = std::max(r.end, r.start); | |
- return r; | |
-} | |
- | |
-static inline Range& operator &= (Range& r1, const Range& r2) | |
-{ | |
- r1 = r1 & r2; | |
- return r1; | |
-} | |
- | |
-static inline Range operator + (const Range& r1, int delta) | |
-{ | |
- return Range(r1.start + delta, r1.end + delta); | |
-} | |
- | |
-static inline Range operator + (int delta, const Range& r1) | |
-{ | |
- return Range(r1.start + delta, r1.end + delta); | |
-} | |
- | |
-static inline Range operator - (const Range& r1, int delta) | |
-{ | |
- return r1 + (-delta); | |
-} | |
- | |
-inline Range::operator CvSlice() const | |
-{ return *this != Range::all() ? cvSlice(start, end) : CV_WHOLE_SEQ; } | |
- | |
- | |
- | |
-//////////////////////////////// Vector //////////////////////////////// | |
- | |
-// template vector class. It is similar to STL's vector, | |
-// with a few important differences: | |
-// 1) it can be created on top of user-allocated data w/o copying it | |
-// 2) vector b = a means copying the header, | |
-// not the underlying data (use clone() to make a deep copy) | |
-template <typename _Tp> class CV_EXPORTS Vector | |
-{ | |
-public: | |
- typedef _Tp value_type; | |
- typedef _Tp* iterator; | |
- typedef const _Tp* const_iterator; | |
- typedef _Tp& reference; | |
- typedef const _Tp& const_reference; | |
- | |
- struct CV_EXPORTS Hdr | |
- { | |
- Hdr() : data(0), datastart(0), refcount(0), size(0), capacity(0) {}; | |
- _Tp* data; | |
- _Tp* datastart; | |
- int* refcount; | |
- size_t size; | |
- size_t capacity; | |
- }; | |
- | |
- Vector() {} | |
- Vector(size_t _size) { resize(_size); } | |
- Vector(size_t _size, const _Tp& val) | |
- { | |
- resize(_size); | |
- for(size_t i = 0; i < _size; i++) | |
- hdr.data[i] = val; | |
- } | |
- Vector(_Tp* _data, size_t _size, bool _copyData=false) | |
- { set(_data, _size, _copyData); } | |
- | |
- template<int n> Vector(const Vec<_Tp, n>& vec) | |
- { set((_Tp*)&vec.val[0], n, true); } | |
- | |
- Vector(const std::vector<_Tp>& vec, bool _copyData=false) | |
- { set(!vec.empty() ? (_Tp*)&vec[0] : 0, vec.size(), _copyData); } | |
- | |
- Vector(const Vector& d) { *this = d; } | |
- | |
- Vector(const Vector& d, const Range& r_) | |
- { | |
- Range r = r_ == Range::all() ? Range(0, d.size()) : r_; | |
- /*if( r == Range::all() ) | |
- r = Range(0, d.size());*/ | |
- if( r.size() > 0 && r.start >= 0 && r.end <= d.size() ) | |
- { | |
- if( d.hdr.refcount ) | |
- CV_XADD(d.hdr.refcount, 1); | |
- hdr.refcount = d.hdr.refcount; | |
- hdr.datastart = d.hdr.datastart; | |
- hdr.data = d.hdr.data + r.start; | |
- hdr.capacity = hdr.size = r.size(); | |
- } | |
- } | |
- | |
- Vector<_Tp>& operator = (const Vector& d) | |
- { | |
- if( this != &d ) | |
- { | |
- if( d.hdr.refcount ) | |
- CV_XADD(d.hdr.refcount, 1); | |
- release(); | |
- hdr = d.hdr; | |
- } | |
- return *this; | |
- } | |
- | |
- ~Vector() { release(); } | |
- | |
- Vector<_Tp> clone() const | |
- { return hdr.data ? Vector<_Tp>(hdr.data, hdr.size, true) : Vector<_Tp>(); } | |
- | |
- void copyTo(Vector<_Tp>& vec) const | |
- { | |
- size_t i, sz = size(); | |
- vec.resize(sz); | |
- const _Tp* src = hdr.data; | |
- _Tp* dst = vec.hdr.data; | |
- for( i = 0; i < sz; i++ ) | |
- dst[i] = src[i]; | |
- } | |
- | |
- void copyTo(std::vector<_Tp>& vec) const | |
- { | |
- size_t i, sz = size(); | |
- vec.resize(sz); | |
- const _Tp* src = hdr.data; | |
- _Tp* dst = sz ? &vec[0] : 0; | |
- for( i = 0; i < sz; i++ ) | |
- dst[i] = src[i]; | |
- } | |
- | |
- operator CvMat() const | |
- { return cvMat((int)size(), 1, type(), (void*)hdr.data); } | |
- | |
- _Tp& operator [] (size_t i) { CV_DbgAssert( i < size() ); return hdr.data[i]; } | |
- const _Tp& operator [] (size_t i) const { CV_DbgAssert( i < size() ); return hdr.data[i]; } | |
- Vector operator() (const Range& r) const { return Vector(*this, r); } | |
- _Tp& back() { CV_DbgAssert(!empty()); return hdr.data[hdr.size-1]; } | |
- const _Tp& back() const { CV_DbgAssert(!empty()); return hdr.data[hdr.size-1]; } | |
- _Tp& front() { CV_DbgAssert(!empty()); return hdr.data[0]; } | |
- const _Tp& front() const { CV_DbgAssert(!empty()); return hdr.data[0]; } | |
- | |
- _Tp* begin() { return hdr.data; } | |
- _Tp* end() { return hdr.data + hdr.size; } | |
- const _Tp* begin() const { return hdr.data; } | |
- const _Tp* end() const { return hdr.data + hdr.size; } | |
- | |
- void addref() { if( hdr.refcount ) CV_XADD(hdr.refcount, 1); } | |
- void release() | |
- { | |
- if( hdr.refcount && CV_XADD(hdr.refcount, -1) == 1 ) | |
- { | |
- delete[] hdr.datastart; | |
- delete hdr.refcount; | |
- } | |
- hdr = Hdr(); | |
- } | |
- | |
- void set(_Tp* _data, size_t _size, bool _copyData=false) | |
- { | |
- if( !_copyData ) | |
- { | |
- release(); | |
- hdr.data = hdr.datastart = _data; | |
- hdr.size = hdr.capacity = _size; | |
- hdr.refcount = 0; | |
- } | |
- else | |
- { | |
- reserve(_size); | |
- for( size_t i = 0; i < _size; i++ ) | |
- hdr.data[i] = _data[i]; | |
- hdr.size = _size; | |
- } | |
- } | |
- | |
- void reserve(size_t newCapacity) | |
- { | |
- _Tp* newData; | |
- int* newRefcount; | |
- size_t i, oldSize = hdr.size; | |
- if( (!hdr.refcount || *hdr.refcount == 1) && hdr.capacity >= newCapacity ) | |
- return; | |
- newCapacity = std::max(newCapacity, oldSize); | |
- newData = new _Tp[newCapacity]; | |
- newRefcount = new int(1); | |
- for( i = 0; i < oldSize; i++ ) | |
- newData[i] = hdr.data[i]; | |
- release(); | |
- hdr.data = hdr.datastart = newData; | |
- hdr.capacity = newCapacity; | |
- hdr.size = oldSize; | |
- hdr.refcount = newRefcount; | |
- } | |
- | |
- void resize(size_t newSize) | |
- { | |
- size_t i; | |
- newSize = std::max(newSize, (size_t)0); | |
- if( (!hdr.refcount || *hdr.refcount == 1) && hdr.size == newSize ) | |
- return; | |
- if( newSize > hdr.capacity ) | |
- reserve(std::max(newSize, std::max((size_t)4, hdr.capacity*2))); | |
- for( i = hdr.size; i < newSize; i++ ) | |
- hdr.data[i] = _Tp(); | |
- hdr.size = newSize; | |
- } | |
- | |
- Vector<_Tp>& push_back(const _Tp& elem) | |
- { | |
- if( hdr.size == hdr.capacity ) | |
- reserve( std::max((size_t)4, hdr.capacity*2) ); | |
- hdr.data[hdr.size++] = elem; | |
- return *this; | |
- } | |
- | |
- Vector<_Tp>& pop_back() | |
- { | |
- if( hdr.size > 0 ) | |
- --hdr.size; | |
- return *this; | |
- } | |
- | |
- size_t size() const { return hdr.size; } | |
- size_t capacity() const { return hdr.capacity; } | |
- bool empty() const { return hdr.size == 0; } | |
- void clear() { resize(0); } | |
- int type() const { return DataType<_Tp>::type; } | |
- | |
-protected: | |
- Hdr hdr; | |
-}; | |
- | |
- | |
-template<typename _Tp> inline typename DataType<_Tp>::work_type | |
-dot(const Vector<_Tp>& v1, const Vector<_Tp>& v2) | |
-{ | |
- typedef typename DataType<_Tp>::work_type _Tw; | |
- size_t i = 0, n = v1.size(); | |
- assert(v1.size() == v2.size()); | |
- | |
- _Tw s = 0; | |
- if( n > 0 ) | |
- { | |
- const _Tp *ptr1 = &v1[0], *ptr2 = &v2[0]; | |
- #if CV_ENABLE_UNROLLED | |
- for(; i <= n - 4; i += 4 ) | |
- s += (_Tw)ptr1[i]*ptr2[i] + (_Tw)ptr1[i+1]*ptr2[i+1] + | |
- (_Tw)ptr1[i+2]*ptr2[i+2] + (_Tw)ptr1[i+3]*ptr2[i+3]; | |
- #endif | |
- for( ; i < n; i++ ) | |
- s += (_Tw)ptr1[i]*ptr2[i]; | |
- } | |
- return s; | |
-} | |
- | |
-// Multiply-with-Carry RNG | |
-inline RNG::RNG() { state = 0xffffffff; } | |
-inline RNG::RNG(uint64 _state) { state = _state ? _state : 0xffffffff; } | |
-inline unsigned RNG::next() | |
-{ | |
- state = (uint64)(unsigned)state*CV_RNG_COEFF + (unsigned)(state >> 32); | |
- return (unsigned)state; | |
-} | |
- | |
-inline RNG::operator uchar() { return (uchar)next(); } | |
-inline RNG::operator schar() { return (schar)next(); } | |
-inline RNG::operator ushort() { return (ushort)next(); } | |
-inline RNG::operator short() { return (short)next(); } | |
-inline RNG::operator unsigned() { return next(); } | |
-inline unsigned RNG::operator ()(unsigned N) {return (unsigned)uniform(0,N);} | |
-inline unsigned RNG::operator ()() {return next();} | |
-inline RNG::operator int() { return (int)next(); } | |
-// * (2^32-1)^-1 | |
-inline RNG::operator float() { return next()*2.3283064365386962890625e-10f; } | |
-inline RNG::operator double() | |
-{ | |
- unsigned t = next(); | |
- return (((uint64)t << 32) | next())*5.4210108624275221700372640043497e-20; | |
-} | |
-inline int RNG::uniform(int a, int b) { return a == b ? a : next()%(b - a) + a; } | |
-inline float RNG::uniform(float a, float b) { return ((float)*this)*(b - a) + a; } | |
-inline double RNG::uniform(double a, double b) { return ((double)*this)*(b - a) + a; } | |
- | |
-inline TermCriteria::TermCriteria() : type(0), maxCount(0), epsilon(0) {} | |
-inline TermCriteria::TermCriteria(int _type, int _maxCount, double _epsilon) | |
- : type(_type), maxCount(_maxCount), epsilon(_epsilon) {} | |
-inline TermCriteria::TermCriteria(const CvTermCriteria& criteria) | |
- : type(criteria.type), maxCount(criteria.max_iter), epsilon(criteria.epsilon) {} | |
-inline TermCriteria::operator CvTermCriteria() const | |
-{ return cvTermCriteria(type, maxCount, epsilon); } | |
- | |
-inline uchar* LineIterator::operator *() { return ptr; } | |
-inline LineIterator& LineIterator::operator ++() | |
-{ | |
- int mask = err < 0 ? -1 : 0; | |
- err += minusDelta + (plusDelta & mask); | |
- ptr += minusStep + (plusStep & mask); | |
- return *this; | |
-} | |
-inline LineIterator LineIterator::operator ++(int) | |
-{ | |
- LineIterator it = *this; | |
- ++(*this); | |
- return it; | |
-} | |
-inline Point LineIterator::pos() const | |
-{ | |
- Point p; | |
- p.y = (int)((ptr - ptr0)/step); | |
- p.x = (int)(((ptr - ptr0) - p.y*step)/elemSize); | |
- return p; | |
-} | |
- | |
-/////////////////////////////// AutoBuffer //////////////////////////////////////// | |
- | |
-template<typename _Tp, size_t fixed_size> inline AutoBuffer<_Tp, fixed_size>::AutoBuffer() | |
-{ | |
- ptr = buf; | |
- size = fixed_size; | |
-} | |
- | |
-template<typename _Tp, size_t fixed_size> inline AutoBuffer<_Tp, fixed_size>::AutoBuffer(size_t _size) | |
-{ | |
- ptr = buf; | |
- size = fixed_size; | |
- allocate(_size); | |
-} | |
- | |
-template<typename _Tp, size_t fixed_size> inline AutoBuffer<_Tp, fixed_size>::~AutoBuffer() | |
-{ deallocate(); } | |
- | |
-template<typename _Tp, size_t fixed_size> inline void AutoBuffer<_Tp, fixed_size>::allocate(size_t _size) | |
-{ | |
- if(_size <= size) | |
- return; | |
- deallocate(); | |
- if(_size > fixed_size) | |
- { | |
- ptr = cv::allocate<_Tp>(_size); | |
- size = _size; | |
- } | |
-} | |
- | |
-template<typename _Tp, size_t fixed_size> inline void AutoBuffer<_Tp, fixed_size>::deallocate() | |
-{ | |
- if( ptr != buf ) | |
- { | |
- cv::deallocate<_Tp>(ptr, size); | |
- ptr = buf; | |
- size = fixed_size; | |
- } | |
-} | |
- | |
-template<typename _Tp, size_t fixed_size> inline AutoBuffer<_Tp, fixed_size>::operator _Tp* () | |
-{ return ptr; } | |
- | |
-template<typename _Tp, size_t fixed_size> inline AutoBuffer<_Tp, fixed_size>::operator const _Tp* () const | |
-{ return ptr; } | |
- | |
- | |
-/////////////////////////////////// Ptr //////////////////////////////////////// | |
- | |
-template<typename _Tp> inline Ptr<_Tp>::Ptr() : obj(0), refcount(0) {} | |
-template<typename _Tp> inline Ptr<_Tp>::Ptr(_Tp* _obj) : obj(_obj) | |
-{ | |
- if(obj) | |
- { | |
- refcount = (int*)fastMalloc(sizeof(*refcount)); | |
- *refcount = 1; | |
- } | |
- else | |
- refcount = 0; | |
-} | |
- | |
-template<typename _Tp> inline void Ptr<_Tp>::addref() | |
-{ if( refcount ) CV_XADD(refcount, 1); } | |
- | |
-template<typename _Tp> inline void Ptr<_Tp>::release() | |
-{ | |
- if( refcount && CV_XADD(refcount, -1) == 1 ) | |
- { | |
- delete_obj(); | |
- fastFree(refcount); | |
- } | |
- refcount = 0; | |
- obj = 0; | |
-} | |
- | |
-template<typename _Tp> inline void Ptr<_Tp>::delete_obj() | |
-{ | |
- if( obj ) delete obj; | |
-} | |
- | |
-template<typename _Tp> inline Ptr<_Tp>::~Ptr() { release(); } | |
- | |
-template<typename _Tp> inline Ptr<_Tp>::Ptr(const Ptr<_Tp>& ptr) | |
-{ | |
- obj = ptr.obj; | |
- refcount = ptr.refcount; | |
- addref(); | |
-} | |
- | |
-template<typename _Tp> inline Ptr<_Tp>& Ptr<_Tp>::operator = (const Ptr<_Tp>& ptr) | |
-{ | |
- int* _refcount = ptr.refcount; | |
- if( _refcount ) | |
- CV_XADD(_refcount, 1); | |
- release(); | |
- obj = ptr.obj; | |
- refcount = _refcount; | |
- return *this; | |
-} | |
- | |
-template<typename _Tp> inline _Tp* Ptr<_Tp>::operator -> () { return obj; } | |
-template<typename _Tp> inline const _Tp* Ptr<_Tp>::operator -> () const { return obj; } | |
- | |
-template<typename _Tp> inline Ptr<_Tp>::operator _Tp* () { return obj; } | |
-template<typename _Tp> inline Ptr<_Tp>::operator const _Tp*() const { return obj; } | |
- | |
-template<typename _Tp> inline bool Ptr<_Tp>::empty() const { return obj == 0; } | |
- | |
-template<typename _Tp> template<typename _Tp2> inline Ptr<_Tp2> Ptr<_Tp>::ptr() | |
-{ | |
- Ptr<_Tp2> p; | |
- if( !obj ) | |
- return p; | |
- if( refcount ) | |
- CV_XADD(refcount, 1); | |
- p.obj = dynamic_cast<_Tp2*>(obj); | |
- p.refcount = refcount; | |
- return p; | |
-} | |
- | |
-template<typename _Tp> template<typename _Tp2> inline const Ptr<_Tp2> Ptr<_Tp>::ptr() const | |
-{ | |
- Ptr<_Tp2> p; | |
- if( !obj ) | |
- return p; | |
- if( refcount ) | |
- CV_XADD(refcount, 1); | |
- p.obj = dynamic_cast<_Tp2*>(obj); | |
- p.refcount = refcount; | |
- return p; | |
-} | |
- | |
-//// specializied implementations of Ptr::delete_obj() for classic OpenCV types | |
- | |
-template<> CV_EXPORTS void Ptr<CvMat>::delete_obj(); | |
-template<> CV_EXPORTS void Ptr<IplImage>::delete_obj(); | |
-template<> CV_EXPORTS void Ptr<CvMatND>::delete_obj(); | |
-template<> CV_EXPORTS void Ptr<CvSparseMat>::delete_obj(); | |
-template<> CV_EXPORTS void Ptr<CvMemStorage>::delete_obj(); | |
-template<> CV_EXPORTS void Ptr<CvFileStorage>::delete_obj(); | |
- | |
-//////////////////////////////////////// XML & YAML I/O //////////////////////////////////// | |
- | |
-CV_EXPORTS_W void write( FileStorage& fs, const string& name, int value ); | |
-CV_EXPORTS_W void write( FileStorage& fs, const string& name, float value ); | |
-CV_EXPORTS_W void write( FileStorage& fs, const string& name, double value ); | |
-CV_EXPORTS_W void write( FileStorage& fs, const string& name, const string& value ); | |
- | |
-template<typename _Tp> inline void write(FileStorage& fs, const _Tp& value) | |
-{ write(fs, string(), value); } | |
- | |
-CV_EXPORTS void writeScalar( FileStorage& fs, int value ); | |
-CV_EXPORTS void writeScalar( FileStorage& fs, float value ); | |
-CV_EXPORTS void writeScalar( FileStorage& fs, double value ); | |
-CV_EXPORTS void writeScalar( FileStorage& fs, const string& value ); | |
- | |
-template<> inline void write( FileStorage& fs, const int& value ) | |
-{ | |
- writeScalar(fs, value); | |
-} | |
- | |
-template<> inline void write( FileStorage& fs, const float& value ) | |
-{ | |
- writeScalar(fs, value); | |
-} | |
- | |
-template<> inline void write( FileStorage& fs, const double& value ) | |
-{ | |
- writeScalar(fs, value); | |
-} | |
- | |
-template<> inline void write( FileStorage& fs, const string& value ) | |
-{ | |
- writeScalar(fs, value); | |
-} | |
- | |
-template<typename _Tp> inline void write(FileStorage& fs, const Point_<_Tp>& pt ) | |
-{ | |
- write(fs, pt.x); | |
- write(fs, pt.y); | |
-} | |
- | |
-template<typename _Tp> inline void write(FileStorage& fs, const Point3_<_Tp>& pt ) | |
-{ | |
- write(fs, pt.x); | |
- write(fs, pt.y); | |
- write(fs, pt.z); | |
-} | |
- | |
-template<typename _Tp> inline void write(FileStorage& fs, const Size_<_Tp>& sz ) | |
-{ | |
- write(fs, sz.width); | |
- write(fs, sz.height); | |
-} | |
- | |
-template<typename _Tp> inline void write(FileStorage& fs, const Complex<_Tp>& c ) | |
-{ | |
- write(fs, c.re); | |
- write(fs, c.im); | |
-} | |
- | |
-template<typename _Tp> inline void write(FileStorage& fs, const Rect_<_Tp>& r ) | |
-{ | |
- write(fs, r.x); | |
- write(fs, r.y); | |
- write(fs, r.width); | |
- write(fs, r.height); | |
-} | |
- | |
-template<typename _Tp, int cn> inline void write(FileStorage& fs, const Vec<_Tp, cn>& v ) | |
-{ | |
- for(int i = 0; i < cn; i++) | |
- write(fs, v.val[i]); | |
-} | |
- | |
-template<typename _Tp> inline void write(FileStorage& fs, const Scalar_<_Tp>& s ) | |
-{ | |
- write(fs, s.val[0]); | |
- write(fs, s.val[1]); | |
- write(fs, s.val[2]); | |
- write(fs, s.val[3]); | |
-} | |
- | |
-inline void write(FileStorage& fs, const Range& r ) | |
-{ | |
- write(fs, r.start); | |
- write(fs, r.end); | |
-} | |
- | |
-class CV_EXPORTS WriteStructContext | |
-{ | |
-public: | |
- WriteStructContext(FileStorage& _fs, const string& name, | |
- int flags, const string& typeName=string()); | |
- ~WriteStructContext(); | |
- FileStorage* fs; | |
-}; | |
- | |
-template<typename _Tp> inline void write(FileStorage& fs, const string& name, const Point_<_Tp>& pt ) | |
-{ | |
- WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW); | |
- write(fs, pt.x); | |
- write(fs, pt.y); | |
-} | |
- | |
-template<typename _Tp> inline void write(FileStorage& fs, const string& name, const Point3_<_Tp>& pt ) | |
-{ | |
- WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW); | |
- write(fs, pt.x); | |
- write(fs, pt.y); | |
- write(fs, pt.z); | |
-} | |
- | |
-template<typename _Tp> inline void write(FileStorage& fs, const string& name, const Size_<_Tp>& sz ) | |
-{ | |
- WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW); | |
- write(fs, sz.width); | |
- write(fs, sz.height); | |
-} | |
- | |
-template<typename _Tp> inline void write(FileStorage& fs, const string& name, const Complex<_Tp>& c ) | |
-{ | |
- WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW); | |
- write(fs, c.re); | |
- write(fs, c.im); | |
-} | |
- | |
-template<typename _Tp> inline void write(FileStorage& fs, const string& name, const Rect_<_Tp>& r ) | |
-{ | |
- WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW); | |
- write(fs, r.x); | |
- write(fs, r.y); | |
- write(fs, r.width); | |
- write(fs, r.height); | |
-} | |
- | |
-template<typename _Tp, int cn> inline void write(FileStorage& fs, const string& name, const Vec<_Tp, cn>& v ) | |
-{ | |
- WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW); | |
- for(int i = 0; i < cn; i++) | |
- write(fs, v.val[i]); | |
-} | |
- | |
-template<typename _Tp> inline void write(FileStorage& fs, const string& name, const Scalar_<_Tp>& s ) | |
-{ | |
- WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW); | |
- write(fs, s.val[0]); | |
- write(fs, s.val[1]); | |
- write(fs, s.val[2]); | |
- write(fs, s.val[3]); | |
-} | |
- | |
-inline void write(FileStorage& fs, const string& name, const Range& r ) | |
-{ | |
- WriteStructContext ws(fs, name, CV_NODE_SEQ+CV_NODE_FLOW); | |
- write(fs, r.start); | |
- write(fs, r.end); | |
-} | |
- | |
-template<typename _Tp, int numflag> class CV_EXPORTS VecWriterProxy | |
-{ | |
-public: | |
- VecWriterProxy( FileStorage* _fs ) : fs(_fs) {} | |
- void operator()(const vector<_Tp>& vec) const | |
- { | |
- size_t i, count = vec.size(); | |
- for( i = 0; i < count; i++ ) | |
- write( *fs, vec[i] ); | |
- } | |
- FileStorage* fs; | |
-}; | |
- | |
-template<typename _Tp> class CV_EXPORTS VecWriterProxy<_Tp,1> | |
-{ | |
-public: | |
- VecWriterProxy( FileStorage* _fs ) : fs(_fs) {} | |
- void operator()(const vector<_Tp>& vec) const | |
- { | |
- int _fmt = DataType<_Tp>::fmt; | |
- char fmt[] = { (char)((_fmt>>8)+'1'), (char)_fmt, '\0' }; | |
- fs->writeRaw( string(fmt), !vec.empty() ? (uchar*)&vec[0] : 0, vec.size()*sizeof(_Tp) ); | |
- } | |
- FileStorage* fs; | |
-}; | |
- | |
-template<typename _Tp> static inline void write( FileStorage& fs, const vector<_Tp>& vec ) | |
-{ | |
- VecWriterProxy<_Tp, DataType<_Tp>::fmt != 0> w(&fs); | |
- w(vec); | |
-} | |
- | |
-template<typename _Tp> static inline void write( FileStorage& fs, const string& name, | |
- const vector<_Tp>& vec ) | |
-{ | |
- WriteStructContext ws(fs, name, CV_NODE_SEQ+(DataType<_Tp>::fmt != 0 ? CV_NODE_FLOW : 0)); | |
- write(fs, vec); | |
-} | |
- | |
-CV_EXPORTS_W void write( FileStorage& fs, const string& name, const Mat& value ); | |
-CV_EXPORTS void write( FileStorage& fs, const string& name, const SparseMat& value ); | |
- | |
-template<typename _Tp> static inline FileStorage& operator << (FileStorage& fs, const _Tp& value) | |
-{ | |
- if( !fs.isOpened() ) | |
- return fs; | |
- if( fs.state == FileStorage::NAME_EXPECTED + FileStorage::INSIDE_MAP ) | |
- CV_Error( CV_StsError, "No element name has been given" ); | |
- write( fs, fs.elname, value ); | |
- if( fs.state & FileStorage::INSIDE_MAP ) | |
- fs.state = FileStorage::NAME_EXPECTED + FileStorage::INSIDE_MAP; | |
- return fs; | |
-} | |
- | |
-CV_EXPORTS FileStorage& operator << (FileStorage& fs, const string& str); | |
- | |
-static inline FileStorage& operator << (FileStorage& fs, const char* str) | |
-{ return (fs << string(str)); } | |
- | |
-inline FileNode::FileNode() : fs(0), node(0) {} | |
-inline FileNode::FileNode(const CvFileStorage* _fs, const CvFileNode* _node) | |
- : fs(_fs), node(_node) {} | |
- | |
-inline FileNode::FileNode(const FileNode& _node) : fs(_node.fs), node(_node.node) {} | |
- | |
-inline int FileNode::type() const { return !node ? NONE : (node->tag & TYPE_MASK); } | |
-inline bool FileNode::empty() const { return node == 0; } | |
-inline bool FileNode::isNone() const { return type() == NONE; } | |
-inline bool FileNode::isSeq() const { return type() == SEQ; } | |
-inline bool FileNode::isMap() const { return type() == MAP; } | |
-inline bool FileNode::isInt() const { return type() == INT; } | |
-inline bool FileNode::isReal() const { return type() == REAL; } | |
-inline bool FileNode::isString() const { return type() == STR; } | |
-inline bool FileNode::isNamed() const { return !node ? false : (node->tag & NAMED) != 0; } | |
-inline size_t FileNode::size() const | |
-{ | |
- int t = type(); | |
- return t == MAP ? ((CvSet*)node->data.map)->active_count : | |
- t == SEQ ? node->data.seq->total : (size_t)!isNone(); | |
-} | |
- | |
-inline CvFileNode* FileNode::operator *() { return (CvFileNode*)node; } | |
-inline const CvFileNode* FileNode::operator* () const { return node; } | |
- | |
-static inline void read(const FileNode& node, int& value, int default_value) | |
-{ | |
- value = !node.node ? default_value : | |
- CV_NODE_IS_INT(node.node->tag) ? node.node->data.i : | |
- CV_NODE_IS_REAL(node.node->tag) ? cvRound(node.node->data.f) : 0x7fffffff; | |
-} | |
- | |
-static inline void read(const FileNode& node, bool& value, bool default_value) | |
-{ | |
- int temp; read(node, temp, (int)default_value); | |
- value = temp != 0; | |
-} | |
- | |
-static inline void read(const FileNode& node, uchar& value, uchar default_value) | |
-{ | |
- int temp; read(node, temp, (int)default_value); | |
- value = saturate_cast<uchar>(temp); | |
-} | |
- | |
-static inline void read(const FileNode& node, schar& value, schar default_value) | |
-{ | |
- int temp; read(node, temp, (int)default_value); | |
- value = saturate_cast<schar>(temp); | |
-} | |
- | |
-static inline void read(const FileNode& node, ushort& value, ushort default_value) | |
-{ | |
- int temp; read(node, temp, (int)default_value); | |
- value = saturate_cast<ushort>(temp); | |
-} | |
- | |
-static inline void read(const FileNode& node, short& value, short default_value) | |
-{ | |
- int temp; read(node, temp, (int)default_value); | |
- value = saturate_cast<short>(temp); | |
-} | |
- | |
-static inline void read(const FileNode& node, float& value, float default_value) | |
-{ | |
- value = !node.node ? default_value : | |
- CV_NODE_IS_INT(node.node->tag) ? (float)node.node->data.i : | |
- CV_NODE_IS_REAL(node.node->tag) ? (float)node.node->data.f : 1e30f; | |
-} | |
- | |
-static inline void read(const FileNode& node, double& value, double default_value) | |
-{ | |
- value = !node.node ? default_value : | |
- CV_NODE_IS_INT(node.node->tag) ? (double)node.node->data.i : | |
- CV_NODE_IS_REAL(node.node->tag) ? node.node->data.f : 1e300; | |
-} | |
- | |
-static inline void read(const FileNode& node, string& value, const string& default_value) | |
-{ | |
- value = !node.node ? default_value : CV_NODE_IS_STRING(node.node->tag) ? string(node.node->data.str.ptr) : string(""); | |
-} | |
- | |
-CV_EXPORTS_W void read(const FileNode& node, Mat& mat, const Mat& default_mat=Mat() ); | |
-CV_EXPORTS void read(const FileNode& node, SparseMat& mat, const SparseMat& default_mat=SparseMat() ); | |
- | |
-inline FileNode::operator int() const | |
-{ | |
- int value; | |
- read(*this, value, 0); | |
- return value; | |
-} | |
-inline FileNode::operator float() const | |
-{ | |
- float value; | |
- read(*this, value, 0.f); | |
- return value; | |
-} | |
-inline FileNode::operator double() const | |
-{ | |
- double value; | |
- read(*this, value, 0.); | |
- return value; | |
-} | |
-inline FileNode::operator string() const | |
-{ | |
- string value; | |
- read(*this, value, value); | |
- return value; | |
-} | |
- | |
-inline void FileNode::readRaw( const string& fmt, uchar* vec, size_t len ) const | |
-{ | |
- begin().readRaw( fmt, vec, len ); | |
-} | |
- | |
-template<typename _Tp, int numflag> class CV_EXPORTS VecReaderProxy | |
-{ | |
-public: | |
- VecReaderProxy( FileNodeIterator* _it ) : it(_it) {} | |
- void operator()(vector<_Tp>& vec, size_t count) const | |
- { | |
- count = std::min(count, it->remaining); | |
- vec.resize(count); | |
- for( size_t i = 0; i < count; i++, ++(*it) ) | |
- read(**it, vec[i], _Tp()); | |
- } | |
- FileNodeIterator* it; | |
-}; | |
- | |
-template<typename _Tp> class CV_EXPORTS VecReaderProxy<_Tp,1> | |
-{ | |
-public: | |
- VecReaderProxy( FileNodeIterator* _it ) : it(_it) {} | |
- void operator()(vector<_Tp>& vec, size_t count) const | |
- { | |
- size_t remaining = it->remaining, cn = DataType<_Tp>::channels; | |
- int _fmt = DataType<_Tp>::fmt; | |
- char fmt[] = { (char)((_fmt>>8)+'1'), (char)_fmt, '\0' }; | |
- size_t remaining1 = remaining/cn; | |
- count = count < remaining1 ? count : remaining1; | |
- vec.resize(count); | |
- it->readRaw( string(fmt), !vec.empty() ? (uchar*)&vec[0] : 0, count*sizeof(_Tp) ); | |
- } | |
- FileNodeIterator* it; | |
-}; | |
- | |
-template<typename _Tp> static inline void | |
-read( FileNodeIterator& it, vector<_Tp>& vec, size_t maxCount=(size_t)INT_MAX ) | |
-{ | |
- VecReaderProxy<_Tp, DataType<_Tp>::fmt != 0> r(&it); | |
- r(vec, maxCount); | |
-} | |
- | |
-template<typename _Tp> static inline void | |
-read( const FileNode& node, vector<_Tp>& vec, const vector<_Tp>& default_value=vector<_Tp>() ) | |
-{ | |
- if(!node.node) | |
- vec = default_value; | |
- else | |
- { | |
- FileNodeIterator it = node.begin(); | |
- read( it, vec ); | |
- } | |
-} | |
- | |
-inline FileNodeIterator FileNode::begin() const | |
-{ | |
- return FileNodeIterator(fs, node); | |
-} | |
- | |
-inline FileNodeIterator FileNode::end() const | |
-{ | |
- return FileNodeIterator(fs, node, size()); | |
-} | |
- | |
-inline FileNode FileNodeIterator::operator *() const | |
-{ return FileNode(fs, (const CvFileNode*)reader.ptr); } | |
- | |
-inline FileNode FileNodeIterator::operator ->() const | |
-{ return FileNode(fs, (const CvFileNode*)reader.ptr); } | |
- | |
-template<typename _Tp> static inline FileNodeIterator& operator >> (FileNodeIterator& it, _Tp& value) | |
-{ read( *it, value, _Tp()); return ++it; } | |
- | |
-template<typename _Tp> static inline | |
-FileNodeIterator& operator >> (FileNodeIterator& it, vector<_Tp>& vec) | |
-{ | |
- VecReaderProxy<_Tp, DataType<_Tp>::fmt != 0> r(&it); | |
- r(vec, (size_t)INT_MAX); | |
- return it; | |
-} | |
- | |
-template<typename _Tp> static inline void operator >> (const FileNode& n, _Tp& value) | |
-{ read( n, value, _Tp()); } | |
- | |
-template<typename _Tp> static inline void operator >> (const FileNode& n, vector<_Tp>& vec) | |
-{ FileNodeIterator it = n.begin(); it >> vec; } | |
- | |
-static inline bool operator == (const FileNodeIterator& it1, const FileNodeIterator& it2) | |
-{ | |
- return it1.fs == it2.fs && it1.container == it2.container && | |
- it1.reader.ptr == it2.reader.ptr && it1.remaining == it2.remaining; | |
-} | |
- | |
-static inline bool operator != (const FileNodeIterator& it1, const FileNodeIterator& it2) | |
-{ | |
- return !(it1 == it2); | |
-} | |
- | |
-static inline ptrdiff_t operator - (const FileNodeIterator& it1, const FileNodeIterator& it2) | |
-{ | |
- return it2.remaining - it1.remaining; | |
-} | |
- | |
-static inline bool operator < (const FileNodeIterator& it1, const FileNodeIterator& it2) | |
-{ | |
- return it1.remaining > it2.remaining; | |
-} | |
- | |
-inline FileNode FileStorage::getFirstTopLevelNode() const | |
-{ | |
- FileNode r = root(); | |
- FileNodeIterator it = r.begin(); | |
- return it != r.end() ? *it : FileNode(); | |
-} | |
- | |
-//////////////////////////////////////// Various algorithms //////////////////////////////////// | |
- | |
-template<typename _Tp> static inline _Tp gcd(_Tp a, _Tp b) | |
-{ | |
- if( a < b ) | |
- std::swap(a, b); | |
- while( b > 0 ) | |
- { | |
- _Tp r = a % b; | |
- a = b; | |
- b = r; | |
- } | |
- return a; | |
-} | |
- | |
-/****************************************************************************************\ | |
- | |
- Generic implementation of QuickSort algorithm | |
- Use it as: vector<_Tp> a; ... sort(a,<less_than_predictor>); | |
- | |
- The current implementation was derived from *BSD system qsort(): | |
- | |
- * Copyright (c) 1992, 1993 | |
- * The Regents of the University of California. All rights reserved. | |
- * | |
- * Redistribution and use in source and binary forms, with or without | |
- * modification, are permitted provided that the following conditions | |
- * are met: | |
- * 1. Redistributions of source code must retain the above copyright | |
- * notice, this list of conditions and the following disclaimer. | |
- * 2. Redistributions in binary form must reproduce the above copyright | |
- * notice, this list of conditions and the following disclaimer in the | |
- * documentation and/or other materials provided with the distribution. | |
- * 3. All advertising materials mentioning features or use of this software | |
- * must display the following acknowledgement: | |
- * This product includes software developed by the University of | |
- * California, Berkeley and its contributors. | |
- * 4. Neither the name of the University nor the names of its contributors | |
- * may be used to endorse or promote products derived from this software | |
- * without specific prior written permission. | |
- * | |
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | |
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | |
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
- * SUCH DAMAGE. | |
- | |
-\****************************************************************************************/ | |
- | |
-template<typename _Tp, class _LT> void sort( vector<_Tp>& vec, _LT LT=_LT() ) | |
-{ | |
- int isort_thresh = 7; | |
- int sp = 0; | |
- | |
- struct | |
- { | |
- _Tp *lb; | |
- _Tp *ub; | |
- } stack[48]; | |
- | |
- size_t total = vec.size(); | |
- | |
- if( total <= 1 ) | |
- return; | |
- | |
- _Tp* arr = &vec[0]; | |
- stack[0].lb = arr; | |
- stack[0].ub = arr + (total - 1); | |
- | |
- while( sp >= 0 ) | |
- { | |
- _Tp* left = stack[sp].lb; | |
- _Tp* right = stack[sp--].ub; | |
- | |
- for(;;) | |
- { | |
- int i, n = (int)(right - left) + 1, m; | |
- _Tp* ptr; | |
- _Tp* ptr2; | |
- | |
- if( n <= isort_thresh ) | |
- { | |
- insert_sort: | |
- for( ptr = left + 1; ptr <= right; ptr++ ) | |
- { | |
- for( ptr2 = ptr; ptr2 > left && LT(ptr2[0],ptr2[-1]); ptr2--) | |
- std::swap( ptr2[0], ptr2[-1] ); | |
- } | |
- break; | |
- } | |
- else | |
- { | |
- _Tp* left0; | |
- _Tp* left1; | |
- _Tp* right0; | |
- _Tp* right1; | |
- _Tp* pivot; | |
- _Tp* a; | |
- _Tp* b; | |
- _Tp* c; | |
- int swap_cnt = 0; | |
- | |
- left0 = left; | |
- right0 = right; | |
- pivot = left + (n/2); | |
- | |
- if( n > 40 ) | |
- { | |
- int d = n / 8; | |
- a = left, b = left + d, c = left + 2*d; | |
- left = LT(*a, *b) ? (LT(*b, *c) ? b : (LT(*a, *c) ? c : a)) | |
- : (LT(*c, *b) ? b : (LT(*a, *c) ? a : c)); | |
- | |
- a = pivot - d, b = pivot, c = pivot + d; | |
- pivot = LT(*a, *b) ? (LT(*b, *c) ? b : (LT(*a, *c) ? c : a)) | |
- : (LT(*c, *b) ? b : (LT(*a, *c) ? a : c)); | |
- | |
- a = right - 2*d, b = right - d, c = right; | |
- right = LT(*a, *b) ? (LT(*b, *c) ? b : (LT(*a, *c) ? c : a)) | |
- : (LT(*c, *b) ? b : (LT(*a, *c) ? a : c)); | |
- } | |
- | |
- a = left, b = pivot, c = right; | |
- pivot = LT(*a, *b) ? (LT(*b, *c) ? b : (LT(*a, *c) ? c : a)) | |
- : (LT(*c, *b) ? b : (LT(*a, *c) ? a : c)); | |
- if( pivot != left0 ) | |
- { | |
- std::swap( *pivot, *left0 ); | |
- pivot = left0; | |
- } | |
- left = left1 = left0 + 1; | |
- right = right1 = right0; | |
- | |
- for(;;) | |
- { | |
- while( left <= right && !LT(*pivot, *left) ) | |
- { | |
- if( !LT(*left, *pivot) ) | |
- { | |
- if( left > left1 ) | |
- std::swap( *left1, *left ); | |
- swap_cnt = 1; | |
- left1++; | |
- } | |
- left++; | |
- } | |
- | |
- while( left <= right && !LT(*right, *pivot) ) | |
- { | |
- if( !LT(*pivot, *right) ) | |
- { | |
- if( right < right1 ) | |
- std::swap( *right1, *right ); | |
- swap_cnt = 1; | |
- right1--; | |
- } | |
- right--; | |
- } | |
- | |
- if( left > right ) | |
- break; | |
- std::swap( *left, *right ); | |
- swap_cnt = 1; | |
- left++; | |
- right--; | |
- } | |
- | |
- if( swap_cnt == 0 ) | |
- { | |
- left = left0, right = right0; | |
- goto insert_sort; | |
- } | |
- | |
- n = std::min( (int)(left1 - left0), (int)(left - left1) ); | |
- for( i = 0; i < n; i++ ) | |
- std::swap( left0[i], left[i-n] ); | |
- | |
- n = std::min( (int)(right0 - right1), (int)(right1 - right) ); | |
- for( i = 0; i < n; i++ ) | |
- std::swap( left[i], right0[i-n+1] ); | |
- n = (int)(left - left1); | |
- m = (int)(right1 - right); | |
- if( n > 1 ) | |
- { | |
- if( m > 1 ) | |
- { | |
- if( n > m ) | |
- { | |
- stack[++sp].lb = left0; | |
- stack[sp].ub = left0 + n - 1; | |
- left = right0 - m + 1, right = right0; | |
- } | |
- else | |
- { | |
- stack[++sp].lb = right0 - m + 1; | |
- stack[sp].ub = right0; | |
- left = left0, right = left0 + n - 1; | |
- } | |
- } | |
- else | |
- left = left0, right = left0 + n - 1; | |
- } | |
- else if( m > 1 ) | |
- left = right0 - m + 1, right = right0; | |
- else | |
- break; | |
- } | |
- } | |
- } | |
-} | |
- | |
-template<typename _Tp> class CV_EXPORTS LessThan | |
-{ | |
-public: | |
- bool operator()(const _Tp& a, const _Tp& b) const { return a < b; } | |
-}; | |
- | |
-template<typename _Tp> class CV_EXPORTS GreaterEq | |
-{ | |
-public: | |
- bool operator()(const _Tp& a, const _Tp& b) const { return a >= b; } | |
-}; | |
- | |
-template<typename _Tp> class CV_EXPORTS LessThanIdx | |
-{ | |
-public: | |
- LessThanIdx( const _Tp* _arr ) : arr(_arr) {} | |
- bool operator()(int a, int b) const { return arr[a] < arr[b]; } | |
- const _Tp* arr; | |
-}; | |
- | |
-template<typename _Tp> class CV_EXPORTS GreaterEqIdx | |
-{ | |
-public: | |
- GreaterEqIdx( const _Tp* _arr ) : arr(_arr) {} | |
- bool operator()(int a, int b) const { return arr[a] >= arr[b]; } | |
- const _Tp* arr; | |
-}; | |
- | |
- | |
-// This function splits the input sequence or set into one or more equivalence classes and | |
-// returns the vector of labels - 0-based class indexes for each element. | |
-// predicate(a,b) returns true if the two sequence elements certainly belong to the same class. | |
-// | |
-// The algorithm is described in "Introduction to Algorithms" | |
-// by Cormen, Leiserson and Rivest, the chapter "Data structures for disjoint sets" | |
-template<typename _Tp, class _EqPredicate> int | |
-partition( const vector<_Tp>& _vec, vector<int>& labels, | |
- _EqPredicate predicate=_EqPredicate()) | |
-{ | |
- int i, j, N = (int)_vec.size(); | |
- const _Tp* vec = &_vec[0]; | |
- | |
- const int PARENT=0; | |
- const int RANK=1; | |
- | |
- vector<int> _nodes(N*2); | |
- int (*nodes)[2] = (int(*)[2])&_nodes[0]; | |
- | |
- // The first O(N) pass: create N single-vertex trees | |
- for(i = 0; i < N; i++) | |
- { | |
- nodes[i][PARENT]=-1; | |
- nodes[i][RANK] = 0; | |
- } | |
- | |
- // The main O(N^2) pass: merge connected components | |
- for( i = 0; i < N; i++ ) | |
- { | |
- int root = i; | |
- | |
- // find root | |
- while( nodes[root][PARENT] >= 0 ) | |
- root = nodes[root][PARENT]; | |
- | |
- for( j = 0; j < N; j++ ) | |
- { | |
- if( i == j || !predicate(vec[i], vec[j])) | |
- continue; | |
- int root2 = j; | |
- | |
- while( nodes[root2][PARENT] >= 0 ) | |
- root2 = nodes[root2][PARENT]; | |
- | |
- if( root2 != root ) | |
- { | |
- // unite both trees | |
- int rank = nodes[root][RANK], rank2 = nodes[root2][RANK]; | |
- if( rank > rank2 ) | |
- nodes[root2][PARENT] = root; | |
- else | |
- { | |
- nodes[root][PARENT] = root2; | |
- nodes[root2][RANK] += rank == rank2; | |
- root = root2; | |
- } | |
- assert( nodes[root][PARENT] < 0 ); | |
- | |
- int k = j, parent; | |
- | |
- // compress the path from node2 to root | |
- while( (parent = nodes[k][PARENT]) >= 0 ) | |
- { | |
- nodes[k][PARENT] = root; | |
- k = parent; | |
- } | |
- | |
- // compress the path from node to root | |
- k = i; | |
- while( (parent = nodes[k][PARENT]) >= 0 ) | |
- { | |
- nodes[k][PARENT] = root; | |
- k = parent; | |
- } | |
- } | |
- } | |
- } | |
- | |
- // Final O(N) pass: enumerate classes | |
- labels.resize(N); | |
- int nclasses = 0; | |
- | |
- for( i = 0; i < N; i++ ) | |
- { | |
- int root = i; | |
- while( nodes[root][PARENT] >= 0 ) | |
- root = nodes[root][PARENT]; | |
- // re-use the rank as the class label | |
- if( nodes[root][RANK] >= 0 ) | |
- nodes[root][RANK] = ~nclasses++; | |
- labels[i] = ~nodes[root][RANK]; | |
- } | |
- | |
- return nclasses; | |
-} | |
- | |
- | |
-////////////////////////////////////////////////////////////////////////////// | |
- | |
-// bridge C++ => C Seq API | |
-CV_EXPORTS schar* seqPush( CvSeq* seq, const void* element=0); | |
-CV_EXPORTS schar* seqPushFront( CvSeq* seq, const void* element=0); | |
-CV_EXPORTS void seqPop( CvSeq* seq, void* element=0); | |
-CV_EXPORTS void seqPopFront( CvSeq* seq, void* element=0); | |
-CV_EXPORTS void seqPopMulti( CvSeq* seq, void* elements, | |
- int count, int in_front=0 ); | |
-CV_EXPORTS void seqRemove( CvSeq* seq, int index ); | |
-CV_EXPORTS void clearSeq( CvSeq* seq ); | |
-CV_EXPORTS schar* getSeqElem( const CvSeq* seq, int index ); | |
-CV_EXPORTS void seqRemoveSlice( CvSeq* seq, CvSlice slice ); | |
-CV_EXPORTS void seqInsertSlice( CvSeq* seq, int before_index, const CvArr* from_arr ); | |
- | |
-template<typename _Tp> inline Seq<_Tp>::Seq() : seq(0) {} | |
-template<typename _Tp> inline Seq<_Tp>::Seq( const CvSeq* _seq ) : seq((CvSeq*)_seq) | |
-{ | |
- CV_Assert(!_seq || _seq->elem_size == sizeof(_Tp)); | |
-} | |
- | |
-template<typename _Tp> inline Seq<_Tp>::Seq( MemStorage& storage, | |
- int headerSize ) | |
-{ | |
- CV_Assert(headerSize >= (int)sizeof(CvSeq)); | |
- seq = cvCreateSeq(DataType<_Tp>::type, headerSize, sizeof(_Tp), storage); | |
-} | |
- | |
-template<typename _Tp> inline _Tp& Seq<_Tp>::operator [](int idx) | |
-{ return *(_Tp*)getSeqElem(seq, idx); } | |
- | |
-template<typename _Tp> inline const _Tp& Seq<_Tp>::operator [](int idx) const | |
-{ return *(_Tp*)getSeqElem(seq, idx); } | |
- | |
-template<typename _Tp> inline SeqIterator<_Tp> Seq<_Tp>::begin() const | |
-{ return SeqIterator<_Tp>(*this); } | |
- | |
-template<typename _Tp> inline SeqIterator<_Tp> Seq<_Tp>::end() const | |
-{ return SeqIterator<_Tp>(*this, true); } | |
- | |
-template<typename _Tp> inline size_t Seq<_Tp>::size() const | |
-{ return seq ? seq->total : 0; } | |
- | |
-template<typename _Tp> inline int Seq<_Tp>::type() const | |
-{ return seq ? CV_MAT_TYPE(seq->flags) : 0; } | |
- | |
-template<typename _Tp> inline int Seq<_Tp>::depth() const | |
-{ return seq ? CV_MAT_DEPTH(seq->flags) : 0; } | |
- | |
-template<typename _Tp> inline int Seq<_Tp>::channels() const | |
-{ return seq ? CV_MAT_CN(seq->flags) : 0; } | |
- | |
-template<typename _Tp> inline size_t Seq<_Tp>::elemSize() const | |
-{ return seq ? seq->elem_size : 0; } | |
- | |
-template<typename _Tp> inline size_t Seq<_Tp>::index(const _Tp& elem) const | |
-{ return cvSeqElemIdx(seq, &elem); } | |
- | |
-template<typename _Tp> inline void Seq<_Tp>::push_back(const _Tp& elem) | |
-{ cvSeqPush(seq, &elem); } | |
- | |
-template<typename _Tp> inline void Seq<_Tp>::push_front(const _Tp& elem) | |
-{ cvSeqPushFront(seq, &elem); } | |
- | |
-template<typename _Tp> inline void Seq<_Tp>::push_back(const _Tp* elem, size_t count) | |
-{ cvSeqPushMulti(seq, elem, (int)count, 0); } | |
- | |
-template<typename _Tp> inline void Seq<_Tp>::push_front(const _Tp* elem, size_t count) | |
-{ cvSeqPushMulti(seq, elem, (int)count, 1); } | |
- | |
-template<typename _Tp> inline _Tp& Seq<_Tp>::back() | |
-{ return *(_Tp*)getSeqElem(seq, -1); } | |
- | |
-template<typename _Tp> inline const _Tp& Seq<_Tp>::back() const | |
-{ return *(const _Tp*)getSeqElem(seq, -1); } | |
- | |
-template<typename _Tp> inline _Tp& Seq<_Tp>::front() | |
-{ return *(_Tp*)getSeqElem(seq, 0); } | |
- | |
-template<typename _Tp> inline const _Tp& Seq<_Tp>::front() const | |
-{ return *(const _Tp*)getSeqElem(seq, 0); } | |
- | |
-template<typename _Tp> inline bool Seq<_Tp>::empty() const | |
-{ return !seq || seq->total == 0; } | |
- | |
-template<typename _Tp> inline void Seq<_Tp>::clear() | |
-{ if(seq) clearSeq(seq); } | |
- | |
-template<typename _Tp> inline void Seq<_Tp>::pop_back() | |
-{ seqPop(seq); } | |
- | |
-template<typename _Tp> inline void Seq<_Tp>::pop_front() | |
-{ seqPopFront(seq); } | |
- | |
-template<typename _Tp> inline void Seq<_Tp>::pop_back(_Tp* elem, size_t count) | |
-{ seqPopMulti(seq, elem, (int)count, 0); } | |
- | |
-template<typename _Tp> inline void Seq<_Tp>::pop_front(_Tp* elem, size_t count) | |
-{ seqPopMulti(seq, elem, (int)count, 1); } | |
- | |
-template<typename _Tp> inline void Seq<_Tp>::insert(int idx, const _Tp& elem) | |
-{ seqInsert(seq, idx, &elem); } | |
- | |
-template<typename _Tp> inline void Seq<_Tp>::insert(int idx, const _Tp* elems, size_t count) | |
-{ | |
- CvMat m = cvMat(1, count, DataType<_Tp>::type, elems); | |
- seqInsertSlice(seq, idx, &m); | |
-} | |
- | |
-template<typename _Tp> inline void Seq<_Tp>::remove(int idx) | |
-{ seqRemove(seq, idx); } | |
- | |
-template<typename _Tp> inline void Seq<_Tp>::remove(const Range& r) | |
-{ seqRemoveSlice(seq, r); } | |
- | |
-template<typename _Tp> inline void Seq<_Tp>::copyTo(vector<_Tp>& vec, const Range& range) const | |
-{ | |
- size_t len = !seq ? 0 : range == Range::all() ? seq->total : range.end - range.start; | |
- vec.resize(len); | |
- if( seq && len ) | |
- cvCvtSeqToArray(seq, &vec[0], range); | |
-} | |
- | |
-template<typename _Tp> inline Seq<_Tp>::operator vector<_Tp>() const | |
-{ | |
- vector<_Tp> vec; | |
- copyTo(vec); | |
- return vec; | |
-} | |
- | |
-template<typename _Tp> inline SeqIterator<_Tp>::SeqIterator() | |
-{ memset(this, 0, sizeof(*this)); } | |
- | |
-template<typename _Tp> inline SeqIterator<_Tp>::SeqIterator(const Seq<_Tp>& seq, bool seekEnd) | |
-{ | |
- cvStartReadSeq(seq.seq, this); | |
- index = seekEnd ? seq.seq->total : 0; | |
-} | |
- | |
-template<typename _Tp> inline void SeqIterator<_Tp>::seek(size_t pos) | |
-{ | |
- cvSetSeqReaderPos(this, (int)pos, false); | |
- index = pos; | |
-} | |
- | |
-template<typename _Tp> inline size_t SeqIterator<_Tp>::tell() const | |
-{ return index; } | |
- | |
-template<typename _Tp> inline _Tp& SeqIterator<_Tp>::operator *() | |
-{ return *(_Tp*)ptr; } | |
- | |
-template<typename _Tp> inline const _Tp& SeqIterator<_Tp>::operator *() const | |
-{ return *(const _Tp*)ptr; } | |
- | |
-template<typename _Tp> inline SeqIterator<_Tp>& SeqIterator<_Tp>::operator ++() | |
-{ | |
- CV_NEXT_SEQ_ELEM(sizeof(_Tp), *this); | |
- if( ++index >= seq->total*2 ) | |
- index = 0; | |
- return *this; | |
-} | |
- | |
-template<typename _Tp> inline SeqIterator<_Tp> SeqIterator<_Tp>::operator ++(int) const | |
-{ | |
- SeqIterator<_Tp> it = *this; | |
- ++*this; | |
- return it; | |
-} | |
- | |
-template<typename _Tp> inline SeqIterator<_Tp>& SeqIterator<_Tp>::operator --() | |
-{ | |
- CV_PREV_SEQ_ELEM(sizeof(_Tp), *this); | |
- if( --index < 0 ) | |
- index = seq->total*2-1; | |
- return *this; | |
-} | |
- | |
-template<typename _Tp> inline SeqIterator<_Tp> SeqIterator<_Tp>::operator --(int) const | |
-{ | |
- SeqIterator<_Tp> it = *this; | |
- --*this; | |
- return it; | |
-} | |
- | |
-template<typename _Tp> inline SeqIterator<_Tp>& SeqIterator<_Tp>::operator +=(int delta) | |
-{ | |
- cvSetSeqReaderPos(this, delta, 1); | |
- index += delta; | |
- int n = seq->total*2; | |
- if( index < 0 ) | |
- index += n; | |
- if( index >= n ) | |
- index -= n; | |
- return *this; | |
-} | |
- | |
-template<typename _Tp> inline SeqIterator<_Tp>& SeqIterator<_Tp>::operator -=(int delta) | |
-{ | |
- return (*this += -delta); | |
-} | |
- | |
-template<typename _Tp> inline ptrdiff_t operator - (const SeqIterator<_Tp>& a, | |
- const SeqIterator<_Tp>& b) | |
-{ | |
- ptrdiff_t delta = a.index - b.index, n = a.seq->total; | |
- if( std::abs(static_cast<long>(delta)) > n ) | |
- delta += delta < 0 ? n : -n; | |
- return delta; | |
-} | |
- | |
-template<typename _Tp> inline bool operator == (const SeqIterator<_Tp>& a, | |
- const SeqIterator<_Tp>& b) | |
-{ | |
- return a.seq == b.seq && a.index == b.index; | |
-} | |
- | |
-template<typename _Tp> inline bool operator != (const SeqIterator<_Tp>& a, | |
- const SeqIterator<_Tp>& b) | |
-{ | |
- return !(a == b); | |
-} | |
- | |
- | |
-template<typename _ClsName> struct CV_EXPORTS RTTIImpl | |
-{ | |
-public: | |
- static int isInstance(const void* ptr) | |
- { | |
- static _ClsName dummy; | |
- static void* dummyp = &dummy; | |
- union | |
- { | |
- const void* p; | |
- const void** pp; | |
- } a, b; | |
- a.p = dummyp; | |
- b.p = ptr; | |
- return *a.pp == *b.pp; | |
- } | |
- static void release(void** dbptr) | |
- { | |
- if(dbptr && *dbptr) | |
- { | |
- delete (_ClsName*)*dbptr; | |
- *dbptr = 0; | |
- } | |
- } | |
- static void* read(CvFileStorage* fs, CvFileNode* n) | |
- { | |
- FileNode fn(fs, n); | |
- _ClsName* obj = new _ClsName; | |
- if(obj->read(fn)) | |
- return obj; | |
- delete obj; | |
- return 0; | |
- } | |
- | |
- static void write(CvFileStorage* _fs, const char* name, const void* ptr, CvAttrList) | |
- { | |
- if(ptr && _fs) | |
- { | |
- FileStorage fs(_fs); | |
- fs.fs.addref(); | |
- ((const _ClsName*)ptr)->write(fs, string(name)); | |
- } | |
- } | |
- | |
- static void* clone(const void* ptr) | |
- { | |
- if(!ptr) | |
- return 0; | |
- return new _ClsName(*(const _ClsName*)ptr); | |
- } | |
-}; | |
- | |
- | |
-class CV_EXPORTS Formatter | |
-{ | |
-public: | |
- virtual ~Formatter() {} | |
- virtual void write(std::ostream& out, const Mat& m, const int* params=0, int nparams=0) const = 0; | |
- virtual void write(std::ostream& out, const void* data, int nelems, int type, | |
- const int* params=0, int nparams=0) const = 0; | |
- static const Formatter* get(const char* fmt=""); | |
- static const Formatter* setDefault(const Formatter* fmt); | |
-}; | |
- | |
- | |
-struct CV_EXPORTS Formatted | |
-{ | |
- Formatted(const Mat& m, const Formatter* fmt, | |
- const vector<int>& params); | |
- Formatted(const Mat& m, const Formatter* fmt, | |
- const int* params=0); | |
- Mat mtx; | |
- const Formatter* fmt; | |
- vector<int> params; | |
-}; | |
- | |
- | |
-/** Writes a point to an output stream in Matlab notation | |
- */ | |
-template<typename _Tp> inline std::ostream& operator<<(std::ostream& out, const Point_<_Tp>& p) | |
-{ | |
- out << "[" << p.x << ", " << p.y << "]"; | |
- return out; | |
-} | |
- | |
-/** Writes a point to an output stream in Matlab notation | |
- */ | |
-template<typename _Tp> inline std::ostream& operator<<(std::ostream& out, const Point3_<_Tp>& p) | |
-{ | |
- out << "[" << p.x << ", " << p.y << ", " << p.z << "]"; | |
- return out; | |
-} | |
- | |
-static inline Formatted format(const Mat& mtx, const char* fmt, | |
- const vector<int>& params=vector<int>()) | |
-{ | |
- return Formatted(mtx, Formatter::get(fmt), params); | |
-} | |
- | |
-template<typename _Tp> static inline Formatted format(const vector<Point_<_Tp> >& vec, | |
- const char* fmt, const vector<int>& params=vector<int>()) | |
-{ | |
- return Formatted(Mat(vec), Formatter::get(fmt), params); | |
-} | |
- | |
-template<typename _Tp> static inline Formatted format(const vector<Point3_<_Tp> >& vec, | |
- const char* fmt, const vector<int>& params=vector<int>()) | |
-{ | |
- return Formatted(Mat(vec), Formatter::get(fmt), params); | |
-} | |
- | |
-/** \brief prints Mat to the output stream in Matlab notation | |
- * use like | |
- @verbatim | |
- Mat my_mat = Mat::eye(3,3,CV_32F); | |
- std::cout << my_mat; | |
- @endverbatim | |
- */ | |
-static inline std::ostream& operator << (std::ostream& out, const Mat& mtx) | |
-{ | |
- Formatter::get()->write(out, mtx); | |
- return out; | |
-} | |
- | |
-/** \brief prints Mat to the output stream allows in the specified notation (see format) | |
- * use like | |
- @verbatim | |
- Mat my_mat = Mat::eye(3,3,CV_32F); | |
- std::cout << my_mat; | |
- @endverbatim | |
- */ | |
-static inline std::ostream& operator << (std::ostream& out, const Formatted& fmtd) | |
-{ | |
- fmtd.fmt->write(out, fmtd.mtx); | |
- return out; | |
-} | |
- | |
- | |
-template<typename _Tp> static inline std::ostream& operator << (std::ostream& out, | |
- const vector<Point_<_Tp> >& vec) | |
-{ | |
- Formatter::get()->write(out, Mat(vec)); | |
- return out; | |
-} | |
- | |
- | |
-template<typename _Tp> static inline std::ostream& operator << (std::ostream& out, | |
- const vector<Point3_<_Tp> >& vec) | |
-{ | |
- Formatter::get()->write(out, Mat(vec)); | |
- return out; | |
-} | |
- | |
- | |
-template<typename _Tp> inline Ptr<_Tp> Algorithm::create(const string& name) | |
-{ | |
- return _create(name).ptr<_Tp>(); | |
-} | |
- | |
-template<typename _Tp> inline typename ParamType<_Tp>::member_type Algorithm::get(const string& name) const | |
-{ | |
- typename ParamType<_Tp>::member_type value; | |
- info()->get(this, name.c_str(), ParamType<_Tp>::type, &value); | |
- return value; | |
-} | |
- | |
-template<typename _Tp> inline typename ParamType<_Tp>::member_type Algorithm::get(const char* name) const | |
-{ | |
- typename ParamType<_Tp>::member_type value; | |
- info()->get(this, name, ParamType<_Tp>::type, &value); | |
- return value; | |
-} | |
- | |
-} | |
- | |
-#endif // __cplusplus | |
-#endif | |
diff --git a/card.io/src/main/jni/opencv2/core/types_c.h b/card.io/src/main/jni/opencv2/core/types_c.h | |
deleted file mode 100644 | |
index 8c4dfcd..0000000 | |
--- a/card.io/src/main/jni/opencv2/core/types_c.h | |
+++ /dev/null | |
@@ -1,1886 +0,0 @@ | |
-/*M/////////////////////////////////////////////////////////////////////////////////////// | |
-// | |
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. | |
-// | |
-// By downloading, copying, installing or using the software you agree to this license. | |
-// If you do not agree to this license, do not download, install, | |
-// copy or use the software. | |
-// | |
-// | |
-// License Agreement | |
-// For Open Source Computer Vision Library | |
-// | |
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. | |
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved. | |
-// Third party copyrights are property of their respective owners. | |
-// | |
-// Redistribution and use in source and binary forms, with or without modification, | |
-// are permitted provided that the following conditions are met: | |
-// | |
-// * Redistribution's of source code must retain the above copyright notice, | |
-// this list of conditions and the following disclaimer. | |
-// | |
-// * Redistribution's in binary form must reproduce the above copyright notice, | |
-// this list of conditions and the following disclaimer in the documentation | |
-// and/or other materials provided with the distribution. | |
-// | |
-// * The name of the copyright holders may not be used to endorse or promote products | |
-// derived from this software without specific prior written permission. | |
-// | |
-// This software is provided by the copyright holders and contributors "as is" and | |
-// any express or implied warranties, including, but not limited to, the implied | |
-// warranties of merchantability and fitness for a particular purpose are disclaimed. | |
-// In no event shall the Intel Corporation or contributors be liable for any direct, | |
-// indirect, incidental, special, exemplary, or consequential damages | |
-// (including, but not limited to, procurement of substitute goods or services; | |
-// loss of use, data, or profits; or business interruption) however caused | |
-// and on any theory of liability, whether in contract, strict liability, | |
-// or tort (including negligence or otherwise) arising in any way out of | |
-// the use of this software, even if advised of the possibility of such damage. | |
-// | |
-//M*/ | |
- | |
-#ifndef __OPENCV_CORE_TYPES_H__ | |
-#define __OPENCV_CORE_TYPES_H__ | |
- | |
-#if !defined _CRT_SECURE_NO_DEPRECATE && _MSC_VER > 1300 | |
-#define _CRT_SECURE_NO_DEPRECATE /* to avoid multiple Visual Studio 2005 warnings */ | |
-#endif | |
- | |
- | |
-#ifndef SKIP_INCLUDES | |
- #include <assert.h> | |
- #include <stdlib.h> | |
- #include <string.h> | |
- #include <float.h> | |
- | |
-#if !defined _MSC_VER && !defined __BORLANDC__ | |
- #include <stdint.h> | |
-#endif | |
- | |
- #if defined __ICL | |
- #define CV_ICC __ICL | |
- #elif defined __ICC | |
- #define CV_ICC __ICC | |
- #elif defined __ECL | |
- #define CV_ICC __ECL | |
- #elif defined __ECC | |
- #define CV_ICC __ECC | |
- #elif defined __INTEL_COMPILER | |
- #define CV_ICC __INTEL_COMPILER | |
- #endif | |
- | |
- #if (_MSC_VER >= 1400 && defined _M_X64) || (__GNUC__ >= 4 && defined __x86_64__) | |
- #if defined WIN32 | |
- #include <intrin.h> | |
- #endif | |
- #if __SSE2__ || !defined __GNUC__ | |
- #include <emmintrin.h> | |
- #endif | |
- #endif | |
- | |
- #if defined __BORLANDC__ | |
- #include <fastmath.h> | |
- #else | |
- #include <math.h> | |
- #endif | |
- | |
- #ifdef HAVE_IPL | |
- #ifndef __IPL_H__ | |
- #if defined WIN32 || defined _WIN32 | |
- #include <ipl.h> | |
- #else | |
- #include <ipl/ipl.h> | |
- #endif | |
- #endif | |
- #elif defined __IPL_H__ | |
- #define HAVE_IPL | |
- #endif | |
-#endif // SKIP_INCLUDES | |
- | |
-#if defined WIN32 || defined _WIN32 | |
- #define CV_CDECL __cdecl | |
- #define CV_STDCALL __stdcall | |
-#else | |
- #define CV_CDECL | |
- #define CV_STDCALL | |
-#endif | |
- | |
-#ifndef CV_EXTERN_C | |
- #ifdef __cplusplus | |
- #define CV_EXTERN_C extern "C" | |
- #define CV_DEFAULT(val) = val | |
- #else | |
- #define CV_EXTERN_C | |
- #define CV_DEFAULT(val) | |
- #endif | |
-#endif | |
- | |
-#ifndef CV_EXTERN_C_FUNCPTR | |
- #ifdef __cplusplus | |
- #define CV_EXTERN_C_FUNCPTR(x) extern "C" { typedef x; } | |
- #else | |
- #define CV_EXTERN_C_FUNCPTR(x) typedef x | |
- #endif | |
-#endif | |
- | |
-#ifndef CV_INLINE | |
-#if defined __cplusplus | |
- #define CV_INLINE inline | |
-#elif (defined WIN32 || defined _WIN32 || defined WINCE) && !defined __GNUC__ | |
- #define CV_INLINE __inline | |
-#else | |
- #define CV_INLINE static | |
-#endif | |
-#endif /* CV_INLINE */ | |
- | |
-#if (defined WIN32 || defined _WIN32 || defined WINCE) && defined CVAPI_EXPORTS | |
- #define CV_EXPORTS __declspec(dllexport) | |
-#else | |
- #define CV_EXPORTS | |
-#endif | |
- | |
-#ifndef CVAPI | |
- #define CVAPI(rettype) CV_EXTERN_C CV_EXPORTS rettype CV_CDECL | |
-#endif | |
- | |
-#if defined _MSC_VER || defined __BORLANDC__ | |
-typedef __int64 int64; | |
-typedef unsigned __int64 uint64; | |
-#define CV_BIG_INT(n) n##I64 | |
-#define CV_BIG_UINT(n) n##UI64 | |
-#else | |
-typedef int64_t int64; | |
-typedef uint64_t uint64; | |
-#define CV_BIG_INT(n) n##LL | |
-#define CV_BIG_UINT(n) n##ULL | |
-#endif | |
- | |
-#ifndef HAVE_IPL | |
-typedef unsigned char uchar; | |
-typedef unsigned short ushort; | |
-#endif | |
- | |
-typedef signed char schar; | |
- | |
-/* special informative macros for wrapper generators */ | |
-#define CV_CARRAY(counter) | |
-#define CV_CUSTOM_CARRAY(args) | |
-#define CV_EXPORTS_W CV_EXPORTS | |
-#define CV_EXPORTS_W_SIMPLE CV_EXPORTS | |
-#define CV_EXPORTS_AS(synonym) CV_EXPORTS | |
-#define CV_EXPORTS_W_MAP CV_EXPORTS | |
-#define CV_IN_OUT | |
-#define CV_OUT | |
-#define CV_PROP | |
-#define CV_PROP_RW | |
-#define CV_WRAP | |
-#define CV_WRAP_AS(synonym) | |
-#define CV_WRAP_DEFAULT(value) | |
- | |
-/* CvArr* is used to pass arbitrary | |
- * array-like data structures | |
- * into functions where the particular | |
- * array type is recognized at runtime: | |
- */ | |
-typedef void CvArr; | |
- | |
-typedef union Cv32suf | |
-{ | |
- int i; | |
- unsigned u; | |
- float f; | |
-} | |
-Cv32suf; | |
- | |
-typedef union Cv64suf | |
-{ | |
- int64 i; | |
- uint64 u; | |
- double f; | |
-} | |
-Cv64suf; | |
- | |
-typedef int CVStatus; | |
- | |
-enum { | |
- CV_StsOk= 0, /* everithing is ok */ | |
- CV_StsBackTrace= -1, /* pseudo error for back trace */ | |
- CV_StsError= -2, /* unknown /unspecified error */ | |
- CV_StsInternal= -3, /* internal error (bad state) */ | |
- CV_StsNoMem= -4, /* insufficient memory */ | |
- CV_StsBadArg= -5, /* function arg/param is bad */ | |
- CV_StsBadFunc= -6, /* unsupported function */ | |
- CV_StsNoConv= -7, /* iter. didn't converge */ | |
- CV_StsAutoTrace= -8, /* tracing */ | |
- CV_HeaderIsNull= -9, /* image header is NULL */ | |
- CV_BadImageSize= -10, /* image size is invalid */ | |
- CV_BadOffset= -11, /* offset is invalid */ | |
- CV_BadDataPtr= -12, /**/ | |
- CV_BadStep= -13, /**/ | |
- CV_BadModelOrChSeq= -14, /**/ | |
- CV_BadNumChannels= -15, /**/ | |
- CV_BadNumChannel1U= -16, /**/ | |
- CV_BadDepth= -17, /**/ | |
- CV_BadAlphaChannel= -18, /**/ | |
- CV_BadOrder= -19, /**/ | |
- CV_BadOrigin= -20, /**/ | |
- CV_BadAlign= -21, /**/ | |
- CV_BadCallBack= -22, /**/ | |
- CV_BadTileSize= -23, /**/ | |
- CV_BadCOI= -24, /**/ | |
- CV_BadROISize= -25, /**/ | |
- CV_MaskIsTiled= -26, /**/ | |
- CV_StsNullPtr= -27, /* null pointer */ | |
- CV_StsVecLengthErr= -28, /* incorrect vector length */ | |
- CV_StsFilterStructContentErr= -29, /* incorr. filter structure content */ | |
- CV_StsKernelStructContentErr= -30, /* incorr. transform kernel content */ | |
- CV_StsFilterOffsetErr= -31, /* incorrect filter ofset value */ | |
- CV_StsBadSize= -201, /* the input/output structure size is incorrect */ | |
- CV_StsDivByZero= -202, /* division by zero */ | |
- CV_StsInplaceNotSupported= -203, /* in-place operation is not supported */ | |
- CV_StsObjectNotFound= -204, /* request can't be completed */ | |
- CV_StsUnmatchedFormats= -205, /* formats of input/output arrays differ */ | |
- CV_StsBadFlag= -206, /* flag is wrong or not supported */ | |
- CV_StsBadPoint= -207, /* bad CvPoint */ | |
- CV_StsBadMask= -208, /* bad format of mask (neither 8uC1 nor 8sC1)*/ | |
- CV_StsUnmatchedSizes= -209, /* sizes of input/output structures do not match */ | |
- CV_StsUnsupportedFormat= -210, /* the data format/type is not supported by the function*/ | |
- CV_StsOutOfRange= -211, /* some of parameters are out of range */ | |
- CV_StsParseError= -212, /* invalid syntax/structure of the parsed file */ | |
- CV_StsNotImplemented= -213, /* the requested function/feature is not implemented */ | |
- CV_StsBadMemBlock= -214, /* an allocated block has been corrupted */ | |
- CV_StsAssert= -215, /* assertion failed */ | |
- CV_GpuNotSupported= -216, | |
- CV_GpuApiCallError= -217, | |
- CV_OpenGlNotSupported= -218, | |
- CV_OpenGlApiCallError= -219 | |
-}; | |
- | |
-/****************************************************************************************\ | |
-* Common macros and inline functions * | |
-\****************************************************************************************/ | |
- | |
-#ifdef HAVE_TEGRA_OPTIMIZATION | |
-# include "tegra_round.hpp" | |
-#endif | |
- | |
-#define CV_PI 3.1415926535897932384626433832795 | |
-#define CV_LOG2 0.69314718055994530941723212145818 | |
- | |
-#define CV_SWAP(a,b,t) ((t) = (a), (a) = (b), (b) = (t)) | |
- | |
-#ifndef MIN | |
-#define MIN(a,b) ((a) > (b) ? (b) : (a)) | |
-#endif | |
- | |
-#ifndef MAX | |
-#define MAX(a,b) ((a) < (b) ? (b) : (a)) | |
-#endif | |
- | |
-/* min & max without jumps */ | |
-#define CV_IMIN(a, b) ((a) ^ (((a)^(b)) & (((a) < (b)) - 1))) | |
- | |
-#define CV_IMAX(a, b) ((a) ^ (((a)^(b)) & (((a) > (b)) - 1))) | |
- | |
-/* absolute value without jumps */ | |
-#ifndef __cplusplus | |
-#define CV_IABS(a) (((a) ^ ((a) < 0 ? -1 : 0)) - ((a) < 0 ? -1 : 0)) | |
-#else | |
-#define CV_IABS(a) abs(a) | |
-#endif | |
-#define CV_CMP(a,b) (((a) > (b)) - ((a) < (b))) | |
-#define CV_SIGN(a) CV_CMP((a),0) | |
- | |
-CV_INLINE int cvRound( double value ) | |
-{ | |
-#if (defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__ && __SSE2__ && !defined __APPLE__) | |
- __m128d t = _mm_set_sd( value ); | |
- return _mm_cvtsd_si32(t); | |
-#elif defined _MSC_VER && defined _M_IX86 | |
- int t; | |
- __asm | |
- { | |
- fld value; | |
- fistp t; | |
- } | |
- return t; | |
-#elif defined HAVE_LRINT || defined CV_ICC || defined __GNUC__ | |
-# ifdef HAVE_TEGRA_OPTIMIZATION | |
- TEGRA_ROUND(value); | |
-# else | |
- return (int)lrint(value); | |
-# endif | |
-#else | |
- // while this is not IEEE754-compliant rounding, it's usually a good enough approximation | |
- return (int)(value + (value >= 0 ? 0.5 : -0.5)); | |
-#endif | |
-} | |
- | |
-#if defined __SSE2__ || (defined _M_IX86_FP && 2 == _M_IX86_FP) | |
-#include "emmintrin.h" | |
-#endif | |
- | |
-CV_INLINE int cvFloor( double value ) | |
-{ | |
-#if defined _MSC_VER && defined _M_X64 || (defined __GNUC__ && defined __SSE2__ && !defined __APPLE__) | |
- __m128d t = _mm_set_sd( value ); | |
- int i = _mm_cvtsd_si32(t); | |
- return i - _mm_movemask_pd(_mm_cmplt_sd(t, _mm_cvtsi32_sd(t,i))); | |
-#elif defined __GNUC__ | |
- int i = (int)value; | |
- return i - (i > value); | |
-#else | |
- int i = cvRound(value); | |
- Cv32suf diff; | |
- diff.f = (float)(value - i); | |
- return i - (diff.i < 0); | |
-#endif | |
-} | |
- | |
- | |
-CV_INLINE int cvCeil( double value ) | |
-{ | |
-#if defined _MSC_VER && defined _M_X64 || (defined __GNUC__ && defined __SSE2__&& !defined __APPLE__) | |
- __m128d t = _mm_set_sd( value ); | |
- int i = _mm_cvtsd_si32(t); | |
- return i + _mm_movemask_pd(_mm_cmplt_sd(_mm_cvtsi32_sd(t,i), t)); | |
-#elif defined __GNUC__ | |
- int i = (int)value; | |
- return i + (i < value); | |
-#else | |
- int i = cvRound(value); | |
- Cv32suf diff; | |
- diff.f = (float)(i - value); | |
- return i + (diff.i < 0); | |
-#endif | |
-} | |
- | |
-#define cvInvSqrt(value) ((float)(1./sqrt(value))) | |
-#define cvSqrt(value) ((float)sqrt(value)) | |
- | |
-CV_INLINE int cvIsNaN( double value ) | |
-{ | |
-#if 1/*defined _MSC_VER || defined __BORLANDC__ | |
- return _isnan(value); | |
-#elif defined __GNUC__ | |
- return isnan(value); | |
-#else*/ | |
- Cv64suf ieee754; | |
- ieee754.f = value; | |
- return ((unsigned)(ieee754.u >> 32) & 0x7fffffff) + | |
- ((unsigned)ieee754.u != 0) > 0x7ff00000; | |
-#endif | |
-} | |
- | |
- | |
-CV_INLINE int cvIsInf( double value ) | |
-{ | |
-#if 1/*defined _MSC_VER || defined __BORLANDC__ | |
- return !_finite(value); | |
-#elif defined __GNUC__ | |
- return isinf(value); | |
-#else*/ | |
- Cv64suf ieee754; | |
- ieee754.f = value; | |
- return ((unsigned)(ieee754.u >> 32) & 0x7fffffff) == 0x7ff00000 && | |
- (unsigned)ieee754.u == 0; | |
-#endif | |
-} | |
- | |
- | |
-/*************** Random number generation *******************/ | |
- | |
-typedef uint64 CvRNG; | |
- | |
-#define CV_RNG_COEFF 4164903690U | |
- | |
-CV_INLINE CvRNG cvRNG( int64 seed CV_DEFAULT(-1)) | |
-{ | |
- CvRNG rng = seed ? (uint64)seed : (uint64)(int64)-1; | |
- return rng; | |
-} | |
- | |
-/* Return random 32-bit unsigned integer: */ | |
-CV_INLINE unsigned cvRandInt( CvRNG* rng ) | |
-{ | |
- uint64 temp = *rng; | |
- temp = (uint64)(unsigned)temp*CV_RNG_COEFF + (temp >> 32); | |
- *rng = temp; | |
- return (unsigned)temp; | |
-} | |
- | |
-/* Returns random floating-point number between 0 and 1: */ | |
-CV_INLINE double cvRandReal( CvRNG* rng ) | |
-{ | |
- return cvRandInt(rng)*2.3283064365386962890625e-10 /* 2^-32 */; | |
-} | |
- | |
-/****************************************************************************************\ | |
-* Image type (IplImage) * | |
-\****************************************************************************************/ | |
- | |
-#ifndef HAVE_IPL | |
- | |
-/* | |
- * The following definitions (until #endif) | |
- * is an extract from IPL headers. | |
- * Copyright (c) 1995 Intel Corporation. | |
- */ | |
-#define IPL_DEPTH_SIGN 0x80000000 | |
- | |
-#define IPL_DEPTH_1U 1 | |
-#define IPL_DEPTH_8U 8 | |
-#define IPL_DEPTH_16U 16 | |
-#define IPL_DEPTH_32F 32 | |
- | |
-#define IPL_DEPTH_8S (IPL_DEPTH_SIGN| 8) | |
-#define IPL_DEPTH_16S (IPL_DEPTH_SIGN|16) | |
-#define IPL_DEPTH_32S (IPL_DEPTH_SIGN|32) | |
- | |
-#define IPL_DATA_ORDER_PIXEL 0 | |
-#define IPL_DATA_ORDER_PLANE 1 | |
- | |
-#define IPL_ORIGIN_TL 0 | |
-#define IPL_ORIGIN_BL 1 | |
- | |
-#define IPL_ALIGN_4BYTES 4 | |
-#define IPL_ALIGN_8BYTES 8 | |
-#define IPL_ALIGN_16BYTES 16 | |
-#define IPL_ALIGN_32BYTES 32 | |
- | |
-#define IPL_ALIGN_DWORD IPL_ALIGN_4BYTES | |
-#define IPL_ALIGN_QWORD IPL_ALIGN_8BYTES | |
- | |
-#define IPL_BORDER_CONSTANT 0 | |
-#define IPL_BORDER_REPLICATE 1 | |
-#define IPL_BORDER_REFLECT 2 | |
-#define IPL_BORDER_WRAP 3 | |
- | |
-typedef struct _IplImage | |
-{ | |
- int nSize; /* sizeof(IplImage) */ | |
- int ID; /* version (=0)*/ | |
- int nChannels; /* Most of OpenCV functions support 1,2,3 or 4 channels */ | |
- int alphaChannel; /* Ignored by OpenCV */ | |
- int depth; /* Pixel depth in bits: IPL_DEPTH_8U, IPL_DEPTH_8S, IPL_DEPTH_16S, | |
- IPL_DEPTH_32S, IPL_DEPTH_32F and IPL_DEPTH_64F are supported. */ | |
- char colorModel[4]; /* Ignored by OpenCV */ | |
- char channelSeq[4]; /* ditto */ | |
- int dataOrder; /* 0 - interleaved color channels, 1 - separate color channels. | |
- cvCreateImage can only create interleaved images */ | |
- int origin; /* 0 - top-left origin, | |
- 1 - bottom-left origin (Windows bitmaps style). */ | |
- int align; /* Alignment of image rows (4 or 8). | |
- OpenCV ignores it and uses widthStep instead. */ | |
- int width; /* Image width in pixels. */ | |
- int height; /* Image height in pixels. */ | |
- struct _IplROI *roi; /* Image ROI. If NULL, the whole image is selected. */ | |
- struct _IplImage *maskROI; /* Must be NULL. */ | |
- void *imageId; /* " " */ | |
- struct _IplTileInfo *tileInfo; /* " " */ | |
- int imageSize; /* Image data size in bytes | |
- (==image->height*image->widthStep | |
- in case of interleaved data)*/ | |
- char *imageData; /* Pointer to aligned image data. */ | |
- int widthStep; /* Size of aligned image row in bytes. */ | |
- int BorderMode[4]; /* Ignored by OpenCV. */ | |
- int BorderConst[4]; /* Ditto. */ | |
- char *imageDataOrigin; /* Pointer to very origin of image data | |
- (not necessarily aligned) - | |
- needed for correct deallocation */ | |
-} | |
-IplImage; | |
- | |
-typedef struct _IplTileInfo IplTileInfo; | |
- | |
-typedef struct _IplROI | |
-{ | |
- int coi; /* 0 - no COI (all channels are selected), 1 - 0th channel is selected ...*/ | |
- int xOffset; | |
- int yOffset; | |
- int width; | |
- int height; | |
-} | |
-IplROI; | |
- | |
-typedef struct _IplConvKernel | |
-{ | |
- int nCols; | |
- int nRows; | |
- int anchorX; | |
- int anchorY; | |
- int *values; | |
- int nShiftR; | |
-} | |
-IplConvKernel; | |
- | |
-typedef struct _IplConvKernelFP | |
-{ | |
- int nCols; | |
- int nRows; | |
- int anchorX; | |
- int anchorY; | |
- float *values; | |
-} | |
-IplConvKernelFP; | |
- | |
-#define IPL_IMAGE_HEADER 1 | |
-#define IPL_IMAGE_DATA 2 | |
-#define IPL_IMAGE_ROI 4 | |
- | |
-#endif/*HAVE_IPL*/ | |
- | |
-/* extra border mode */ | |
-#define IPL_BORDER_REFLECT_101 4 | |
-#define IPL_BORDER_TRANSPARENT 5 | |
- | |
-#define IPL_IMAGE_MAGIC_VAL ((int)sizeof(IplImage)) | |
-#define CV_TYPE_NAME_IMAGE "opencv-image" | |
- | |
-#define CV_IS_IMAGE_HDR(img) \ | |
- ((img) != NULL && ((const IplImage*)(img))->nSize == sizeof(IplImage)) | |
- | |
-#define CV_IS_IMAGE(img) \ | |
- (CV_IS_IMAGE_HDR(img) && ((IplImage*)img)->imageData != NULL) | |
- | |
-/* for storing double-precision | |
- floating point data in IplImage's */ | |
-#define IPL_DEPTH_64F 64 | |
- | |
-/* get reference to pixel at (col,row), | |
- for multi-channel images (col) should be multiplied by number of channels */ | |
-#define CV_IMAGE_ELEM( image, elemtype, row, col ) \ | |
- (((elemtype*)((image)->imageData + (image)->widthStep*(row)))[(col)]) | |
- | |
-/****************************************************************************************\ | |
-* Matrix type (CvMat) * | |
-\****************************************************************************************/ | |
- | |
-#define CV_CN_MAX 512 | |
-#define CV_CN_SHIFT 3 | |
-#define CV_DEPTH_MAX (1 << CV_CN_SHIFT) | |
- | |
-#define CV_8U 0 | |
-#define CV_8S 1 | |
-#define CV_16U 2 | |
-#define CV_16S 3 | |
-#define CV_32S 4 | |
-#define CV_32F 5 | |
-#define CV_64F 6 | |
-#define CV_USRTYPE1 7 | |
- | |
-#define CV_MAT_DEPTH_MASK (CV_DEPTH_MAX - 1) | |
-#define CV_MAT_DEPTH(flags) ((flags) & CV_MAT_DEPTH_MASK) | |
- | |
-#define CV_MAKETYPE(depth,cn) (CV_MAT_DEPTH(depth) + (((cn)-1) << CV_CN_SHIFT)) | |
-#define CV_MAKE_TYPE CV_MAKETYPE | |
- | |
-#define CV_8UC1 CV_MAKETYPE(CV_8U,1) | |
-#define CV_8UC2 CV_MAKETYPE(CV_8U,2) | |
-#define CV_8UC3 CV_MAKETYPE(CV_8U,3) | |
-#define CV_8UC4 CV_MAKETYPE(CV_8U,4) | |
-#define CV_8UC(n) CV_MAKETYPE(CV_8U,(n)) | |
- | |
-#define CV_8SC1 CV_MAKETYPE(CV_8S,1) | |
-#define CV_8SC2 CV_MAKETYPE(CV_8S,2) | |
-#define CV_8SC3 CV_MAKETYPE(CV_8S,3) | |
-#define CV_8SC4 CV_MAKETYPE(CV_8S,4) | |
-#define CV_8SC(n) CV_MAKETYPE(CV_8S,(n)) | |
- | |
-#define CV_16UC1 CV_MAKETYPE(CV_16U,1) | |
-#define CV_16UC2 CV_MAKETYPE(CV_16U,2) | |
-#define CV_16UC3 CV_MAKETYPE(CV_16U,3) | |
-#define CV_16UC4 CV_MAKETYPE(CV_16U,4) | |
-#define CV_16UC(n) CV_MAKETYPE(CV_16U,(n)) | |
- | |
-#define CV_16SC1 CV_MAKETYPE(CV_16S,1) | |
-#define CV_16SC2 CV_MAKETYPE(CV_16S,2) | |
-#define CV_16SC3 CV_MAKETYPE(CV_16S,3) | |
-#define CV_16SC4 CV_MAKETYPE(CV_16S,4) | |
-#define CV_16SC(n) CV_MAKETYPE(CV_16S,(n)) | |
- | |
-#define CV_32SC1 CV_MAKETYPE(CV_32S,1) | |
-#define CV_32SC2 CV_MAKETYPE(CV_32S,2) | |
-#define CV_32SC3 CV_MAKETYPE(CV_32S,3) | |
-#define CV_32SC4 CV_MAKETYPE(CV_32S,4) | |
-#define CV_32SC(n) CV_MAKETYPE(CV_32S,(n)) | |
- | |
-#define CV_32FC1 CV_MAKETYPE(CV_32F,1) | |
-#define CV_32FC2 CV_MAKETYPE(CV_32F,2) | |
-#define CV_32FC3 CV_MAKETYPE(CV_32F,3) | |
-#define CV_32FC4 CV_MAKETYPE(CV_32F,4) | |
-#define CV_32FC(n) CV_MAKETYPE(CV_32F,(n)) | |
- | |
-#define CV_64FC1 CV_MAKETYPE(CV_64F,1) | |
-#define CV_64FC2 CV_MAKETYPE(CV_64F,2) | |
-#define CV_64FC3 CV_MAKETYPE(CV_64F,3) | |
-#define CV_64FC4 CV_MAKETYPE(CV_64F,4) | |
-#define CV_64FC(n) CV_MAKETYPE(CV_64F,(n)) | |
- | |
-#define CV_AUTO_STEP 0x7fffffff | |
-#define CV_WHOLE_ARR cvSlice( 0, 0x3fffffff ) | |
- | |
-#define CV_MAT_CN_MASK ((CV_CN_MAX - 1) << CV_CN_SHIFT) | |
-#define CV_MAT_CN(flags) ((((flags) & CV_MAT_CN_MASK) >> CV_CN_SHIFT) + 1) | |
-#define CV_MAT_TYPE_MASK (CV_DEPTH_MAX*CV_CN_MAX - 1) | |
-#define CV_MAT_TYPE(flags) ((flags) & CV_MAT_TYPE_MASK) | |
-#define CV_MAT_CONT_FLAG_SHIFT 14 | |
-#define CV_MAT_CONT_FLAG (1 << CV_MAT_CONT_FLAG_SHIFT) | |
-#define CV_IS_MAT_CONT(flags) ((flags) & CV_MAT_CONT_FLAG) | |
-#define CV_IS_CONT_MAT CV_IS_MAT_CONT | |
-#define CV_SUBMAT_FLAG_SHIFT 15 | |
-#define CV_SUBMAT_FLAG (1 << CV_SUBMAT_FLAG_SHIFT) | |
-#define CV_IS_SUBMAT(flags) ((flags) & CV_MAT_SUBMAT_FLAG) | |
- | |
-#define CV_MAGIC_MASK 0xFFFF0000 | |
-#define CV_MAT_MAGIC_VAL 0x42420000 | |
-#define CV_TYPE_NAME_MAT "opencv-matrix" | |
- | |
-typedef struct CvMat | |
-{ | |
- int type; | |
- int step; | |
- | |
- /* for internal use only */ | |
- int* refcount; | |
- int hdr_refcount; | |
- | |
- union | |
- { | |
- uchar* ptr; | |
- short* s; | |
- int* i; | |
- float* fl; | |
- double* db; | |
- } data; | |
- | |
-#ifdef __cplusplus | |
- union | |
- { | |
- int rows; | |
- int height; | |
- }; | |
- | |
- union | |
- { | |
- int cols; | |
- int width; | |
- }; | |
-#else | |
- int rows; | |
- int cols; | |
-#endif | |
- | |
-} | |
-CvMat; | |
- | |
- | |
-#define CV_IS_MAT_HDR(mat) \ | |
- ((mat) != NULL && \ | |
- (((const CvMat*)(mat))->type & CV_MAGIC_MASK) == CV_MAT_MAGIC_VAL && \ | |
- ((const CvMat*)(mat))->cols > 0 && ((const CvMat*)(mat))->rows > 0) | |
- | |
-#define CV_IS_MAT_HDR_Z(mat) \ | |
- ((mat) != NULL && \ | |
- (((const CvMat*)(mat))->type & CV_MAGIC_MASK) == CV_MAT_MAGIC_VAL && \ | |
- ((const CvMat*)(mat))->cols >= 0 && ((const CvMat*)(mat))->rows >= 0) | |
- | |
-#define CV_IS_MAT(mat) \ | |
- (CV_IS_MAT_HDR(mat) && ((const CvMat*)(mat))->data.ptr != NULL) | |
- | |
-#define CV_IS_MASK_ARR(mat) \ | |
- (((mat)->type & (CV_MAT_TYPE_MASK & ~CV_8SC1)) == 0) | |
- | |
-#define CV_ARE_TYPES_EQ(mat1, mat2) \ | |
- ((((mat1)->type ^ (mat2)->type) & CV_MAT_TYPE_MASK) == 0) | |
- | |
-#define CV_ARE_CNS_EQ(mat1, mat2) \ | |
- ((((mat1)->type ^ (mat2)->type) & CV_MAT_CN_MASK) == 0) | |
- | |
-#define CV_ARE_DEPTHS_EQ(mat1, mat2) \ | |
- ((((mat1)->type ^ (mat2)->type) & CV_MAT_DEPTH_MASK) == 0) | |
- | |
-#define CV_ARE_SIZES_EQ(mat1, mat2) \ | |
- ((mat1)->rows == (mat2)->rows && (mat1)->cols == (mat2)->cols) | |
- | |
-#define CV_IS_MAT_CONST(mat) \ | |
- (((mat)->rows|(mat)->cols) == 1) | |
- | |
-/* Size of each channel item, | |
- 0x124489 = 1000 0100 0100 0010 0010 0001 0001 ~ array of sizeof(arr_type_elem) */ | |
-#define CV_ELEM_SIZE1(type) \ | |
- ((((sizeof(size_t)<<28)|0x8442211) >> CV_MAT_DEPTH(type)*4) & 15) | |
- | |
-/* 0x3a50 = 11 10 10 01 01 00 00 ~ array of log2(sizeof(arr_type_elem)) */ | |
-#define CV_ELEM_SIZE(type) \ | |
- (CV_MAT_CN(type) << ((((sizeof(size_t)/4+1)*16384|0x3a50) >> CV_MAT_DEPTH(type)*2) & 3)) | |
- | |
-#define IPL2CV_DEPTH(depth) \ | |
- ((((CV_8U)+(CV_16U<<4)+(CV_32F<<8)+(CV_64F<<16)+(CV_8S<<20)+ \ | |
- (CV_16S<<24)+(CV_32S<<28)) >> ((((depth) & 0xF0) >> 2) + \ | |
- (((depth) & IPL_DEPTH_SIGN) ? 20 : 0))) & 15) | |
- | |
-/* Inline constructor. No data is allocated internally!!! | |
- * (Use together with cvCreateData, or use cvCreateMat instead to | |
- * get a matrix with allocated data): | |
- */ | |
-CV_INLINE CvMat cvMat( int rows, int cols, int type, void* data CV_DEFAULT(NULL)) | |
-{ | |
- CvMat m; | |
- | |
- assert( (unsigned)CV_MAT_DEPTH(type) <= CV_64F ); | |
- type = CV_MAT_TYPE(type); | |
- m.type = CV_MAT_MAGIC_VAL | CV_MAT_CONT_FLAG | type; | |
- m.cols = cols; | |
- m.rows = rows; | |
- m.step = m.cols*CV_ELEM_SIZE(type); | |
- m.data.ptr = (uchar*)data; | |
- m.refcount = NULL; | |
- m.hdr_refcount = 0; | |
- | |
- return m; | |
-} | |
- | |
- | |
-#define CV_MAT_ELEM_PTR_FAST( mat, row, col, pix_size ) \ | |
- (assert( (unsigned)(row) < (unsigned)(mat).rows && \ | |
- (unsigned)(col) < (unsigned)(mat).cols ), \ | |
- (mat).data.ptr + (size_t)(mat).step*(row) + (pix_size)*(col)) | |
- | |
-#define CV_MAT_ELEM_PTR( mat, row, col ) \ | |
- CV_MAT_ELEM_PTR_FAST( mat, row, col, CV_ELEM_SIZE((mat).type) ) | |
- | |
-#define CV_MAT_ELEM( mat, elemtype, row, col ) \ | |
- (*(elemtype*)CV_MAT_ELEM_PTR_FAST( mat, row, col, sizeof(elemtype))) | |
- | |
- | |
-CV_INLINE double cvmGet( const CvMat* mat, int row, int col ) | |
-{ | |
- int type; | |
- | |
- type = CV_MAT_TYPE(mat->type); | |
- assert( (unsigned)row < (unsigned)mat->rows && | |
- (unsigned)col < (unsigned)mat->cols ); | |
- | |
- if( type == CV_32FC1 ) | |
- return ((float*)(mat->data.ptr + (size_t)mat->step*row))[col]; | |
- else | |
- { | |
- assert( type == CV_64FC1 ); | |
- return ((double*)(mat->data.ptr + (size_t)mat->step*row))[col]; | |
- } | |
-} | |
- | |
- | |
-CV_INLINE void cvmSet( CvMat* mat, int row, int col, double value ) | |
-{ | |
- int type; | |
- type = CV_MAT_TYPE(mat->type); | |
- assert( (unsigned)row < (unsigned)mat->rows && | |
- (unsigned)col < (unsigned)mat->cols ); | |
- | |
- if( type == CV_32FC1 ) | |
- ((float*)(mat->data.ptr + (size_t)mat->step*row))[col] = (float)value; | |
- else | |
- { | |
- assert( type == CV_64FC1 ); | |
- ((double*)(mat->data.ptr + (size_t)mat->step*row))[col] = (double)value; | |
- } | |
-} | |
- | |
- | |
-CV_INLINE int cvIplDepth( int type ) | |
-{ | |
- int depth = CV_MAT_DEPTH(type); | |
- return CV_ELEM_SIZE1(depth)*8 | (depth == CV_8S || depth == CV_16S || | |
- depth == CV_32S ? IPL_DEPTH_SIGN : 0); | |
-} | |
- | |
- | |
-/****************************************************************************************\ | |
-* Multi-dimensional dense array (CvMatND) * | |
-\****************************************************************************************/ | |
- | |
-#define CV_MATND_MAGIC_VAL 0x42430000 | |
-#define CV_TYPE_NAME_MATND "opencv-nd-matrix" | |
- | |
-#define CV_MAX_DIM 32 | |
-#define CV_MAX_DIM_HEAP 1024 | |
- | |
-typedef struct CvMatND | |
-{ | |
- int type; | |
- int dims; | |
- | |
- int* refcount; | |
- int hdr_refcount; | |
- | |
- union | |
- { | |
- uchar* ptr; | |
- float* fl; | |
- double* db; | |
- int* i; | |
- short* s; | |
- } data; | |
- | |
- struct | |
- { | |
- int size; | |
- int step; | |
- } | |
- dim[CV_MAX_DIM]; | |
-} | |
-CvMatND; | |
- | |
-#define CV_IS_MATND_HDR(mat) \ | |
- ((mat) != NULL && (((const CvMatND*)(mat))->type & CV_MAGIC_MASK) == CV_MATND_MAGIC_VAL) | |
- | |
-#define CV_IS_MATND(mat) \ | |
- (CV_IS_MATND_HDR(mat) && ((const CvMatND*)(mat))->data.ptr != NULL) | |
- | |
- | |
-/****************************************************************************************\ | |
-* Multi-dimensional sparse array (CvSparseMat) * | |
-\****************************************************************************************/ | |
- | |
-#define CV_SPARSE_MAT_MAGIC_VAL 0x42440000 | |
-#define CV_TYPE_NAME_SPARSE_MAT "opencv-sparse-matrix" | |
- | |
-struct CvSet; | |
- | |
-typedef struct CvSparseMat | |
-{ | |
- int type; | |
- int dims; | |
- int* refcount; | |
- int hdr_refcount; | |
- | |
- struct CvSet* heap; | |
- void** hashtable; | |
- int hashsize; | |
- int valoffset; | |
- int idxoffset; | |
- int size[CV_MAX_DIM]; | |
-} | |
-CvSparseMat; | |
- | |
-#define CV_IS_SPARSE_MAT_HDR(mat) \ | |
- ((mat) != NULL && \ | |
- (((const CvSparseMat*)(mat))->type & CV_MAGIC_MASK) == CV_SPARSE_MAT_MAGIC_VAL) | |
- | |
-#define CV_IS_SPARSE_MAT(mat) \ | |
- CV_IS_SPARSE_MAT_HDR(mat) | |
- | |
-/**************** iteration through a sparse array *****************/ | |
- | |
-typedef struct CvSparseNode | |
-{ | |
- unsigned hashval; | |
- struct CvSparseNode* next; | |
-} | |
-CvSparseNode; | |
- | |
-typedef struct CvSparseMatIterator | |
-{ | |
- CvSparseMat* mat; | |
- CvSparseNode* node; | |
- int curidx; | |
-} | |
-CvSparseMatIterator; | |
- | |
-#define CV_NODE_VAL(mat,node) ((void*)((uchar*)(node) + (mat)->valoffset)) | |
-#define CV_NODE_IDX(mat,node) ((int*)((uchar*)(node) + (mat)->idxoffset)) | |
- | |
-/****************************************************************************************\ | |
-* Histogram * | |
-\****************************************************************************************/ | |
- | |
-typedef int CvHistType; | |
- | |
-#define CV_HIST_MAGIC_VAL 0x42450000 | |
-#define CV_HIST_UNIFORM_FLAG (1 << 10) | |
- | |
-/* indicates whether bin ranges are set already or not */ | |
-#define CV_HIST_RANGES_FLAG (1 << 11) | |
- | |
-#define CV_HIST_ARRAY 0 | |
-#define CV_HIST_SPARSE 1 | |
-#define CV_HIST_TREE CV_HIST_SPARSE | |
- | |
-/* should be used as a parameter only, | |
- it turns to CV_HIST_UNIFORM_FLAG of hist->type */ | |
-#define CV_HIST_UNIFORM 1 | |
- | |
-typedef struct CvHistogram | |
-{ | |
- int type; | |
- CvArr* bins; | |
- float thresh[CV_MAX_DIM][2]; /* For uniform histograms. */ | |
- float** thresh2; /* For non-uniform histograms. */ | |
- CvMatND mat; /* Embedded matrix header for array histograms. */ | |
-} | |
-CvHistogram; | |
- | |
-#define CV_IS_HIST( hist ) \ | |
- ((hist) != NULL && \ | |
- (((CvHistogram*)(hist))->type & CV_MAGIC_MASK) == CV_HIST_MAGIC_VAL && \ | |
- (hist)->bins != NULL) | |
- | |
-#define CV_IS_UNIFORM_HIST( hist ) \ | |
- (((hist)->type & CV_HIST_UNIFORM_FLAG) != 0) | |
- | |
-#define CV_IS_SPARSE_HIST( hist ) \ | |
- CV_IS_SPARSE_MAT((hist)->bins) | |
- | |
-#define CV_HIST_HAS_RANGES( hist ) \ | |
- (((hist)->type & CV_HIST_RANGES_FLAG) != 0) | |
- | |
-/****************************************************************************************\ | |
-* Other supplementary data type definitions * | |
-\****************************************************************************************/ | |
- | |
-/*************************************** CvRect *****************************************/ | |
- | |
-typedef struct CvRect | |
-{ | |
- int x; | |
- int y; | |
- int width; | |
- int height; | |
-} | |
-CvRect; | |
- | |
-CV_INLINE CvRect cvRect( int x, int y, int width, int height ) | |
-{ | |
- CvRect r; | |
- | |
- r.x = x; | |
- r.y = y; | |
- r.width = width; | |
- r.height = height; | |
- | |
- return r; | |
-} | |
- | |
- | |
-CV_INLINE IplROI cvRectToROI( CvRect rect, int coi ) | |
-{ | |
- IplROI roi; | |
- roi.xOffset = rect.x; | |
- roi.yOffset = rect.y; | |
- roi.width = rect.width; | |
- roi.height = rect.height; | |
- roi.coi = coi; | |
- | |
- return roi; | |
-} | |
- | |
- | |
-CV_INLINE CvRect cvROIToRect( IplROI roi ) | |
-{ | |
- return cvRect( roi.xOffset, roi.yOffset, roi.width, roi.height ); | |
-} | |
- | |
-/*********************************** CvTermCriteria *************************************/ | |
- | |
-#define CV_TERMCRIT_ITER 1 | |
-#define CV_TERMCRIT_NUMBER CV_TERMCRIT_ITER | |
-#define CV_TERMCRIT_EPS 2 | |
- | |
-typedef struct CvTermCriteria | |
-{ | |
- int type; /* may be combination of | |
- CV_TERMCRIT_ITER | |
- CV_TERMCRIT_EPS */ | |
- int max_iter; | |
- double epsilon; | |
-} | |
-CvTermCriteria; | |
- | |
-CV_INLINE CvTermCriteria cvTermCriteria( int type, int max_iter, double epsilon ) | |
-{ | |
- CvTermCriteria t; | |
- | |
- t.type = type; | |
- t.max_iter = max_iter; | |
- t.epsilon = (float)epsilon; | |
- | |
- return t; | |
-} | |
- | |
- | |
-/******************************* CvPoint and variants ***********************************/ | |
- | |
-typedef struct CvPoint | |
-{ | |
- int x; | |
- int y; | |
-} | |
-CvPoint; | |
- | |
- | |
-CV_INLINE CvPoint cvPoint( int x, int y ) | |
-{ | |
- CvPoint p; | |
- | |
- p.x = x; | |
- p.y = y; | |
- | |
- return p; | |
-} | |
- | |
- | |
-typedef struct CvPoint2D32f | |
-{ | |
- float x; | |
- float y; | |
-} | |
-CvPoint2D32f; | |
- | |
- | |
-CV_INLINE CvPoint2D32f cvPoint2D32f( double x, double y ) | |
-{ | |
- CvPoint2D32f p; | |
- | |
- p.x = (float)x; | |
- p.y = (float)y; | |
- | |
- return p; | |
-} | |
- | |
- | |
-CV_INLINE CvPoint2D32f cvPointTo32f( CvPoint point ) | |
-{ | |
- return cvPoint2D32f( (float)point.x, (float)point.y ); | |
-} | |
- | |
- | |
-CV_INLINE CvPoint cvPointFrom32f( CvPoint2D32f point ) | |
-{ | |
- CvPoint ipt; | |
- ipt.x = cvRound(point.x); | |
- ipt.y = cvRound(point.y); | |
- | |
- return ipt; | |
-} | |
- | |
- | |
-typedef struct CvPoint3D32f | |
-{ | |
- float x; | |
- float y; | |
- float z; | |
-} | |
-CvPoint3D32f; | |
- | |
- | |
-CV_INLINE CvPoint3D32f cvPoint3D32f( double x, double y, double z ) | |
-{ | |
- CvPoint3D32f p; | |
- | |
- p.x = (float)x; | |
- p.y = (float)y; | |
- p.z = (float)z; | |
- | |
- return p; | |
-} | |
- | |
- | |
-typedef struct CvPoint2D64f | |
-{ | |
- double x; | |
- double y; | |
-} | |
-CvPoint2D64f; | |
- | |
- | |
-CV_INLINE CvPoint2D64f cvPoint2D64f( double x, double y ) | |
-{ | |
- CvPoint2D64f p; | |
- | |
- p.x = x; | |
- p.y = y; | |
- | |
- return p; | |
-} | |
- | |
- | |
-typedef struct CvPoint3D64f | |
-{ | |
- double x; | |
- double y; | |
- double z; | |
-} | |
-CvPoint3D64f; | |
- | |
- | |
-CV_INLINE CvPoint3D64f cvPoint3D64f( double x, double y, double z ) | |
-{ | |
- CvPoint3D64f p; | |
- | |
- p.x = x; | |
- p.y = y; | |
- p.z = z; | |
- | |
- return p; | |
-} | |
- | |
- | |
-/******************************** CvSize's & CvBox **************************************/ | |
- | |
-typedef struct | |
-{ | |
- int width; | |
- int height; | |
-} | |
-CvSize; | |
- | |
-CV_INLINE CvSize cvSize( int width, int height ) | |
-{ | |
- CvSize s; | |
- | |
- s.width = width; | |
- s.height = height; | |
- | |
- return s; | |
-} | |
- | |
-typedef struct CvSize2D32f | |
-{ | |
- float width; | |
- float height; | |
-} | |
-CvSize2D32f; | |
- | |
- | |
-CV_INLINE CvSize2D32f cvSize2D32f( double width, double height ) | |
-{ | |
- CvSize2D32f s; | |
- | |
- s.width = (float)width; | |
- s.height = (float)height; | |
- | |
- return s; | |
-} | |
- | |
-typedef struct CvBox2D | |
-{ | |
- CvPoint2D32f center; /* Center of the box. */ | |
- CvSize2D32f size; /* Box width and length. */ | |
- float angle; /* Angle between the horizontal axis */ | |
- /* and the first side (i.e. length) in degrees */ | |
-} | |
-CvBox2D; | |
- | |
- | |
-/* Line iterator state: */ | |
-typedef struct CvLineIterator | |
-{ | |
- /* Pointer to the current point: */ | |
- uchar* ptr; | |
- | |
- /* Bresenham algorithm state: */ | |
- int err; | |
- int plus_delta; | |
- int minus_delta; | |
- int plus_step; | |
- int minus_step; | |
-} | |
-CvLineIterator; | |
- | |
- | |
- | |
-/************************************* CvSlice ******************************************/ | |
- | |
-typedef struct CvSlice | |
-{ | |
- int start_index, end_index; | |
-} | |
-CvSlice; | |
- | |
-CV_INLINE CvSlice cvSlice( int start, int end ) | |
-{ | |
- CvSlice slice; | |
- slice.start_index = start; | |
- slice.end_index = end; | |
- | |
- return slice; | |
-} | |
- | |
-#define CV_WHOLE_SEQ_END_INDEX 0x3fffffff | |
-#define CV_WHOLE_SEQ cvSlice(0, CV_WHOLE_SEQ_END_INDEX) | |
- | |
- | |
-/************************************* CvScalar *****************************************/ | |
- | |
-typedef struct CvScalar | |
-{ | |
- double val[4]; | |
-} | |
-CvScalar; | |
- | |
-CV_INLINE CvScalar cvScalar( double val0, double val1 CV_DEFAULT(0), | |
- double val2 CV_DEFAULT(0), double val3 CV_DEFAULT(0)) | |
-{ | |
- CvScalar scalar; | |
- scalar.val[0] = val0; scalar.val[1] = val1; | |
- scalar.val[2] = val2; scalar.val[3] = val3; | |
- return scalar; | |
-} | |
- | |
- | |
-CV_INLINE CvScalar cvRealScalar( double val0 ) | |
-{ | |
- CvScalar scalar; | |
- scalar.val[0] = val0; | |
- scalar.val[1] = scalar.val[2] = scalar.val[3] = 0; | |
- return scalar; | |
-} | |
- | |
-CV_INLINE CvScalar cvScalarAll( double val0123 ) | |
-{ | |
- CvScalar scalar; | |
- scalar.val[0] = val0123; | |
- scalar.val[1] = val0123; | |
- scalar.val[2] = val0123; | |
- scalar.val[3] = val0123; | |
- return scalar; | |
-} | |
- | |
-/****************************************************************************************\ | |
-* Dynamic Data structures * | |
-\****************************************************************************************/ | |
- | |
-/******************************** Memory storage ****************************************/ | |
- | |
-typedef struct CvMemBlock | |
-{ | |
- struct CvMemBlock* prev; | |
- struct CvMemBlock* next; | |
-} | |
-CvMemBlock; | |
- | |
-#define CV_STORAGE_MAGIC_VAL 0x42890000 | |
- | |
-typedef struct CvMemStorage | |
-{ | |
- int signature; | |
- CvMemBlock* bottom; /* First allocated block. */ | |
- CvMemBlock* top; /* Current memory block - top of the stack. */ | |
- struct CvMemStorage* parent; /* We get new blocks from parent as needed. */ | |
- int block_size; /* Block size. */ | |
- int free_space; /* Remaining free space in current block. */ | |
-} | |
-CvMemStorage; | |
- | |
-#define CV_IS_STORAGE(storage) \ | |
- ((storage) != NULL && \ | |
- (((CvMemStorage*)(storage))->signature & CV_MAGIC_MASK) == CV_STORAGE_MAGIC_VAL) | |
- | |
- | |
-typedef struct CvMemStoragePos | |
-{ | |
- CvMemBlock* top; | |
- int free_space; | |
-} | |
-CvMemStoragePos; | |
- | |
- | |
-/*********************************** Sequence *******************************************/ | |
- | |
-typedef struct CvSeqBlock | |
-{ | |
- struct CvSeqBlock* prev; /* Previous sequence block. */ | |
- struct CvSeqBlock* next; /* Next sequence block. */ | |
- int start_index; /* Index of the first element in the block + */ | |
- /* sequence->first->start_index. */ | |
- int count; /* Number of elements in the block. */ | |
- schar* data; /* Pointer to the first element of the block. */ | |
-} | |
-CvSeqBlock; | |
- | |
- | |
-#define CV_TREE_NODE_FIELDS(node_type) \ | |
- int flags; /* Miscellaneous flags. */ \ | |
- int header_size; /* Size of sequence header. */ \ | |
- struct node_type* h_prev; /* Previous sequence. */ \ | |
- struct node_type* h_next; /* Next sequence. */ \ | |
- struct node_type* v_prev; /* 2nd previous sequence. */ \ | |
- struct node_type* v_next /* 2nd next sequence. */ | |
- | |
-/* | |
- Read/Write sequence. | |
- Elements can be dynamically inserted to or deleted from the sequence. | |
-*/ | |
-#define CV_SEQUENCE_FIELDS() \ | |
- CV_TREE_NODE_FIELDS(CvSeq); \ | |
- int total; /* Total number of elements. */ \ | |
- int elem_size; /* Size of sequence element in bytes. */ \ | |
- schar* block_max; /* Maximal bound of the last block. */ \ | |
- schar* ptr; /* Current write pointer. */ \ | |
- int delta_elems; /* Grow seq this many at a time. */ \ | |
- CvMemStorage* storage; /* Where the seq is stored. */ \ | |
- CvSeqBlock* free_blocks; /* Free blocks list. */ \ | |
- CvSeqBlock* first; /* Pointer to the first sequence block. */ | |
- | |
-typedef struct CvSeq | |
-{ | |
- CV_SEQUENCE_FIELDS() | |
-} | |
-CvSeq; | |
- | |
-#define CV_TYPE_NAME_SEQ "opencv-sequence" | |
-#define CV_TYPE_NAME_SEQ_TREE "opencv-sequence-tree" | |
- | |
-/*************************************** Set ********************************************/ | |
-/* | |
- Set. | |
- Order is not preserved. There can be gaps between sequence elements. | |
- After the element has been inserted it stays in the same place all the time. | |
- The MSB(most-significant or sign bit) of the first field (flags) is 0 iff the element exists. | |
-*/ | |
-#define CV_SET_ELEM_FIELDS(elem_type) \ | |
- int flags; \ | |
- struct elem_type* next_free; | |
- | |
-typedef struct CvSetElem | |
-{ | |
- CV_SET_ELEM_FIELDS(CvSetElem) | |
-} | |
-CvSetElem; | |
- | |
-#define CV_SET_FIELDS() \ | |
- CV_SEQUENCE_FIELDS() \ | |
- CvSetElem* free_elems; \ | |
- int active_count; | |
- | |
-typedef struct CvSet | |
-{ | |
- CV_SET_FIELDS() | |
-} | |
-CvSet; | |
- | |
- | |
-#define CV_SET_ELEM_IDX_MASK ((1 << 26) - 1) | |
-#define CV_SET_ELEM_FREE_FLAG (1 << (sizeof(int)*8-1)) | |
- | |
-/* Checks whether the element pointed by ptr belongs to a set or not */ | |
-#define CV_IS_SET_ELEM( ptr ) (((CvSetElem*)(ptr))->flags >= 0) | |
- | |
-/************************************* Graph ********************************************/ | |
- | |
-/* | |
- We represent a graph as a set of vertices. | |
- Vertices contain their adjacency lists (more exactly, pointers to first incoming or | |
- outcoming edge (or 0 if isolated vertex)). Edges are stored in another set. | |
- There is a singly-linked list of incoming/outcoming edges for each vertex. | |
- | |
- Each edge consists of | |
- | |
- o Two pointers to the starting and ending vertices | |
- (vtx[0] and vtx[1] respectively). | |
- | |
- A graph may be oriented or not. In the latter case, edges between | |
- vertex i to vertex j are not distinguished during search operations. | |
- | |
- o Two pointers to next edges for the starting and ending vertices, where | |
- next[0] points to the next edge in the vtx[0] adjacency list and | |
- next[1] points to the next edge in the vtx[1] adjacency list. | |
-*/ | |
-#define CV_GRAPH_EDGE_FIELDS() \ | |
- int flags; \ | |
- float weight; \ | |
- struct CvGraphEdge* next[2]; \ | |
- struct CvGraphVtx* vtx[2]; | |
- | |
- | |
-#define CV_GRAPH_VERTEX_FIELDS() \ | |
- int flags; \ | |
- struct CvGraphEdge* first; | |
- | |
- | |
-typedef struct CvGraphEdge | |
-{ | |
- CV_GRAPH_EDGE_FIELDS() | |
-} | |
-CvGraphEdge; | |
- | |
-typedef struct CvGraphVtx | |
-{ | |
- CV_GRAPH_VERTEX_FIELDS() | |
-} | |
-CvGraphVtx; | |
- | |
-typedef struct CvGraphVtx2D | |
-{ | |
- CV_GRAPH_VERTEX_FIELDS() | |
- CvPoint2D32f* ptr; | |
-} | |
-CvGraphVtx2D; | |
- | |
-/* | |
- Graph is "derived" from the set (this is set a of vertices) | |
- and includes another set (edges) | |
-*/ | |
-#define CV_GRAPH_FIELDS() \ | |
- CV_SET_FIELDS() \ | |
- CvSet* edges; | |
- | |
-typedef struct CvGraph | |
-{ | |
- CV_GRAPH_FIELDS() | |
-} | |
-CvGraph; | |
- | |
-#define CV_TYPE_NAME_GRAPH "opencv-graph" | |
- | |
-/*********************************** Chain/Countour *************************************/ | |
- | |
-typedef struct CvChain | |
-{ | |
- CV_SEQUENCE_FIELDS() | |
- CvPoint origin; | |
-} | |
-CvChain; | |
- | |
-#define CV_CONTOUR_FIELDS() \ | |
- CV_SEQUENCE_FIELDS() \ | |
- CvRect rect; \ | |
- int color; \ | |
- int reserved[3]; | |
- | |
-typedef struct CvContour | |
-{ | |
- CV_CONTOUR_FIELDS() | |
-} | |
-CvContour; | |
- | |
-typedef CvContour CvPoint2DSeq; | |
- | |
-/****************************************************************************************\ | |
-* Sequence types * | |
-\****************************************************************************************/ | |
- | |
-#define CV_SEQ_MAGIC_VAL 0x42990000 | |
- | |
-#define CV_IS_SEQ(seq) \ | |
- ((seq) != NULL && (((CvSeq*)(seq))->flags & CV_MAGIC_MASK) == CV_SEQ_MAGIC_VAL) | |
- | |
-#define CV_SET_MAGIC_VAL 0x42980000 | |
-#define CV_IS_SET(set) \ | |
- ((set) != NULL && (((CvSeq*)(set))->flags & CV_MAGIC_MASK) == CV_SET_MAGIC_VAL) | |
- | |
-#define CV_SEQ_ELTYPE_BITS 12 | |
-#define CV_SEQ_ELTYPE_MASK ((1 << CV_SEQ_ELTYPE_BITS) - 1) | |
- | |
-#define CV_SEQ_ELTYPE_POINT CV_32SC2 /* (x,y) */ | |
-#define CV_SEQ_ELTYPE_CODE CV_8UC1 /* freeman code: 0..7 */ | |
-#define CV_SEQ_ELTYPE_GENERIC 0 | |
-#define CV_SEQ_ELTYPE_PTR CV_USRTYPE1 | |
-#define CV_SEQ_ELTYPE_PPOINT CV_SEQ_ELTYPE_PTR /* &(x,y) */ | |
-#define CV_SEQ_ELTYPE_INDEX CV_32SC1 /* #(x,y) */ | |
-#define CV_SEQ_ELTYPE_GRAPH_EDGE 0 /* &next_o, &next_d, &vtx_o, &vtx_d */ | |
-#define CV_SEQ_ELTYPE_GRAPH_VERTEX 0 /* first_edge, &(x,y) */ | |
-#define CV_SEQ_ELTYPE_TRIAN_ATR 0 /* vertex of the binary tree */ | |
-#define CV_SEQ_ELTYPE_CONNECTED_COMP 0 /* connected component */ | |
-#define CV_SEQ_ELTYPE_POINT3D CV_32FC3 /* (x,y,z) */ | |
- | |
-#define CV_SEQ_KIND_BITS 2 | |
-#define CV_SEQ_KIND_MASK (((1 << CV_SEQ_KIND_BITS) - 1)<<CV_SEQ_ELTYPE_BITS) | |
- | |
-/* types of sequences */ | |
-#define CV_SEQ_KIND_GENERIC (0 << CV_SEQ_ELTYPE_BITS) | |
-#define CV_SEQ_KIND_CURVE (1 << CV_SEQ_ELTYPE_BITS) | |
-#define CV_SEQ_KIND_BIN_TREE (2 << CV_SEQ_ELTYPE_BITS) | |
- | |
-/* types of sparse sequences (sets) */ | |
-#define CV_SEQ_KIND_GRAPH (1 << CV_SEQ_ELTYPE_BITS) | |
-#define CV_SEQ_KIND_SUBDIV2D (2 << CV_SEQ_ELTYPE_BITS) | |
- | |
-#define CV_SEQ_FLAG_SHIFT (CV_SEQ_KIND_BITS + CV_SEQ_ELTYPE_BITS) | |
- | |
-/* flags for curves */ | |
-#define CV_SEQ_FLAG_CLOSED (1 << CV_SEQ_FLAG_SHIFT) | |
-#define CV_SEQ_FLAG_SIMPLE (0 << CV_SEQ_FLAG_SHIFT) | |
-#define CV_SEQ_FLAG_CONVEX (0 << CV_SEQ_FLAG_SHIFT) | |
-#define CV_SEQ_FLAG_HOLE (2 << CV_SEQ_FLAG_SHIFT) | |
- | |
-/* flags for graphs */ | |
-#define CV_GRAPH_FLAG_ORIENTED (1 << CV_SEQ_FLAG_SHIFT) | |
- | |
-#define CV_GRAPH CV_SEQ_KIND_GRAPH | |
-#define CV_ORIENTED_GRAPH (CV_SEQ_KIND_GRAPH|CV_GRAPH_FLAG_ORIENTED) | |
- | |
-/* point sets */ | |
-#define CV_SEQ_POINT_SET (CV_SEQ_KIND_GENERIC| CV_SEQ_ELTYPE_POINT) | |
-#define CV_SEQ_POINT3D_SET (CV_SEQ_KIND_GENERIC| CV_SEQ_ELTYPE_POINT3D) | |
-#define CV_SEQ_POLYLINE (CV_SEQ_KIND_CURVE | CV_SEQ_ELTYPE_POINT) | |
-#define CV_SEQ_POLYGON (CV_SEQ_FLAG_CLOSED | CV_SEQ_POLYLINE ) | |
-#define CV_SEQ_CONTOUR CV_SEQ_POLYGON | |
-#define CV_SEQ_SIMPLE_POLYGON (CV_SEQ_FLAG_SIMPLE | CV_SEQ_POLYGON ) | |
- | |
-/* chain-coded curves */ | |
-#define CV_SEQ_CHAIN (CV_SEQ_KIND_CURVE | CV_SEQ_ELTYPE_CODE) | |
-#define CV_SEQ_CHAIN_CONTOUR (CV_SEQ_FLAG_CLOSED | CV_SEQ_CHAIN) | |
- | |
-/* binary tree for the contour */ | |
-#define CV_SEQ_POLYGON_TREE (CV_SEQ_KIND_BIN_TREE | CV_SEQ_ELTYPE_TRIAN_ATR) | |
- | |
-/* sequence of the connected components */ | |
-#define CV_SEQ_CONNECTED_COMP (CV_SEQ_KIND_GENERIC | CV_SEQ_ELTYPE_CONNECTED_COMP) | |
- | |
-/* sequence of the integer numbers */ | |
-#define CV_SEQ_INDEX (CV_SEQ_KIND_GENERIC | CV_SEQ_ELTYPE_INDEX) | |
- | |
-#define CV_SEQ_ELTYPE( seq ) ((seq)->flags & CV_SEQ_ELTYPE_MASK) | |
-#define CV_SEQ_KIND( seq ) ((seq)->flags & CV_SEQ_KIND_MASK ) | |
- | |
-/* flag checking */ | |
-#define CV_IS_SEQ_INDEX( seq ) ((CV_SEQ_ELTYPE(seq) == CV_SEQ_ELTYPE_INDEX) && \ | |
- (CV_SEQ_KIND(seq) == CV_SEQ_KIND_GENERIC)) | |
- | |
-#define CV_IS_SEQ_CURVE( seq ) (CV_SEQ_KIND(seq) == CV_SEQ_KIND_CURVE) | |
-#define CV_IS_SEQ_CLOSED( seq ) (((seq)->flags & CV_SEQ_FLAG_CLOSED) != 0) | |
-#define CV_IS_SEQ_CONVEX( seq ) 0 | |
-#define CV_IS_SEQ_HOLE( seq ) (((seq)->flags & CV_SEQ_FLAG_HOLE) != 0) | |
-#define CV_IS_SEQ_SIMPLE( seq ) 1 | |
- | |
-/* type checking macros */ | |
-#define CV_IS_SEQ_POINT_SET( seq ) \ | |
- ((CV_SEQ_ELTYPE(seq) == CV_32SC2 || CV_SEQ_ELTYPE(seq) == CV_32FC2)) | |
- | |
-#define CV_IS_SEQ_POINT_SUBSET( seq ) \ | |
- (CV_IS_SEQ_INDEX( seq ) || CV_SEQ_ELTYPE(seq) == CV_SEQ_ELTYPE_PPOINT) | |
- | |
-#define CV_IS_SEQ_POLYLINE( seq ) \ | |
- (CV_SEQ_KIND(seq) == CV_SEQ_KIND_CURVE && CV_IS_SEQ_POINT_SET(seq)) | |
- | |
-#define CV_IS_SEQ_POLYGON( seq ) \ | |
- (CV_IS_SEQ_POLYLINE(seq) && CV_IS_SEQ_CLOSED(seq)) | |
- | |
-#define CV_IS_SEQ_CHAIN( seq ) \ | |
- (CV_SEQ_KIND(seq) == CV_SEQ_KIND_CURVE && (seq)->elem_size == 1) | |
- | |
-#define CV_IS_SEQ_CONTOUR( seq ) \ | |
- (CV_IS_SEQ_CLOSED(seq) && (CV_IS_SEQ_POLYLINE(seq) || CV_IS_SEQ_CHAIN(seq))) | |
- | |
-#define CV_IS_SEQ_CHAIN_CONTOUR( seq ) \ | |
- (CV_IS_SEQ_CHAIN( seq ) && CV_IS_SEQ_CLOSED( seq )) | |
- | |
-#define CV_IS_SEQ_POLYGON_TREE( seq ) \ | |
- (CV_SEQ_ELTYPE (seq) == CV_SEQ_ELTYPE_TRIAN_ATR && \ | |
- CV_SEQ_KIND( seq ) == CV_SEQ_KIND_BIN_TREE ) | |
- | |
-#define CV_IS_GRAPH( seq ) \ | |
- (CV_IS_SET(seq) && CV_SEQ_KIND((CvSet*)(seq)) == CV_SEQ_KIND_GRAPH) | |
- | |
-#define CV_IS_GRAPH_ORIENTED( seq ) \ | |
- (((seq)->flags & CV_GRAPH_FLAG_ORIENTED) != 0) | |
- | |
-#define CV_IS_SUBDIV2D( seq ) \ | |
- (CV_IS_SET(seq) && CV_SEQ_KIND((CvSet*)(seq)) == CV_SEQ_KIND_SUBDIV2D) | |
- | |
-/****************************************************************************************/ | |
-/* Sequence writer & reader */ | |
-/****************************************************************************************/ | |
- | |
-#define CV_SEQ_WRITER_FIELDS() \ | |
- int header_size; \ | |
- CvSeq* seq; /* the sequence written */ \ | |
- CvSeqBlock* block; /* current block */ \ | |
- schar* ptr; /* pointer to free space */ \ | |
- schar* block_min; /* pointer to the beginning of block*/\ | |
- schar* block_max; /* pointer to the end of block */ | |
- | |
-typedef struct CvSeqWriter | |
-{ | |
- CV_SEQ_WRITER_FIELDS() | |
-} | |
-CvSeqWriter; | |
- | |
- | |
-#define CV_SEQ_READER_FIELDS() \ | |
- int header_size; \ | |
- CvSeq* seq; /* sequence, beign read */ \ | |
- CvSeqBlock* block; /* current block */ \ | |
- schar* ptr; /* pointer to element be read next */ \ | |
- schar* block_min; /* pointer to the beginning of block */\ | |
- schar* block_max; /* pointer to the end of block */ \ | |
- int delta_index;/* = seq->first->start_index */ \ | |
- schar* prev_elem; /* pointer to previous element */ | |
- | |
- | |
-typedef struct CvSeqReader | |
-{ | |
- CV_SEQ_READER_FIELDS() | |
-} | |
-CvSeqReader; | |
- | |
-/****************************************************************************************/ | |
-/* Operations on sequences */ | |
-/****************************************************************************************/ | |
- | |
-#define CV_SEQ_ELEM( seq, elem_type, index ) \ | |
-/* assert gives some guarantee that <seq> parameter is valid */ \ | |
-( assert(sizeof((seq)->first[0]) == sizeof(CvSeqBlock) && \ | |
- (seq)->elem_size == sizeof(elem_type)), \ | |
- (elem_type*)((seq)->first && (unsigned)index < \ | |
- (unsigned)((seq)->first->count) ? \ | |
- (seq)->first->data + (index) * sizeof(elem_type) : \ | |
- cvGetSeqElem( (CvSeq*)(seq), (index) ))) | |
-#define CV_GET_SEQ_ELEM( elem_type, seq, index ) CV_SEQ_ELEM( (seq), elem_type, (index) ) | |
- | |
-/* Add element to sequence: */ | |
-#define CV_WRITE_SEQ_ELEM_VAR( elem_ptr, writer ) \ | |
-{ \ | |
- if( (writer).ptr >= (writer).block_max ) \ | |
- { \ | |
- cvCreateSeqBlock( &writer); \ | |
- } \ | |
- memcpy((writer).ptr, elem_ptr, (writer).seq->elem_size);\ | |
- (writer).ptr += (writer).seq->elem_size; \ | |
-} | |
- | |
-#define CV_WRITE_SEQ_ELEM( elem, writer ) \ | |
-{ \ | |
- assert( (writer).seq->elem_size == sizeof(elem)); \ | |
- if( (writer).ptr >= (writer).block_max ) \ | |
- { \ | |
- cvCreateSeqBlock( &writer); \ | |
- } \ | |
- assert( (writer).ptr <= (writer).block_max - sizeof(elem));\ | |
- memcpy((writer).ptr, &(elem), sizeof(elem)); \ | |
- (writer).ptr += sizeof(elem); \ | |
-} | |
- | |
- | |
-/* Move reader position forward: */ | |
-#define CV_NEXT_SEQ_ELEM( elem_size, reader ) \ | |
-{ \ | |
- if( ((reader).ptr += (elem_size)) >= (reader).block_max ) \ | |
- { \ | |
- cvChangeSeqBlock( &(reader), 1 ); \ | |
- } \ | |
-} | |
- | |
- | |
-/* Move reader position backward: */ | |
-#define CV_PREV_SEQ_ELEM( elem_size, reader ) \ | |
-{ \ | |
- if( ((reader).ptr -= (elem_size)) < (reader).block_min ) \ | |
- { \ | |
- cvChangeSeqBlock( &(reader), -1 ); \ | |
- } \ | |
-} | |
- | |
-/* Read element and move read position forward: */ | |
-#define CV_READ_SEQ_ELEM( elem, reader ) \ | |
-{ \ | |
- assert( (reader).seq->elem_size == sizeof(elem)); \ | |
- memcpy( &(elem), (reader).ptr, sizeof((elem))); \ | |
- CV_NEXT_SEQ_ELEM( sizeof(elem), reader ) \ | |
-} | |
- | |
-/* Read element and move read position backward: */ | |
-#define CV_REV_READ_SEQ_ELEM( elem, reader ) \ | |
-{ \ | |
- assert( (reader).seq->elem_size == sizeof(elem)); \ | |
- memcpy(&(elem), (reader).ptr, sizeof((elem))); \ | |
- CV_PREV_SEQ_ELEM( sizeof(elem), reader ) \ | |
-} | |
- | |
- | |
-#define CV_READ_CHAIN_POINT( _pt, reader ) \ | |
-{ \ | |
- (_pt) = (reader).pt; \ | |
- if( (reader).ptr ) \ | |
- { \ | |
- CV_READ_SEQ_ELEM( (reader).code, (reader)); \ | |
- assert( ((reader).code & ~7) == 0 ); \ | |
- (reader).pt.x += (reader).deltas[(int)(reader).code][0]; \ | |
- (reader).pt.y += (reader).deltas[(int)(reader).code][1]; \ | |
- } \ | |
-} | |
- | |
-#define CV_CURRENT_POINT( reader ) (*((CvPoint*)((reader).ptr))) | |
-#define CV_PREV_POINT( reader ) (*((CvPoint*)((reader).prev_elem))) | |
- | |
-#define CV_READ_EDGE( pt1, pt2, reader ) \ | |
-{ \ | |
- assert( sizeof(pt1) == sizeof(CvPoint) && \ | |
- sizeof(pt2) == sizeof(CvPoint) && \ | |
- reader.seq->elem_size == sizeof(CvPoint)); \ | |
- (pt1) = CV_PREV_POINT( reader ); \ | |
- (pt2) = CV_CURRENT_POINT( reader ); \ | |
- (reader).prev_elem = (reader).ptr; \ | |
- CV_NEXT_SEQ_ELEM( sizeof(CvPoint), (reader)); \ | |
-} | |
- | |
-/************ Graph macros ************/ | |
- | |
-/* Return next graph edge for given vertex: */ | |
-#define CV_NEXT_GRAPH_EDGE( edge, vertex ) \ | |
- (assert((edge)->vtx[0] == (vertex) || (edge)->vtx[1] == (vertex)), \ | |
- (edge)->next[(edge)->vtx[1] == (vertex)]) | |
- | |
- | |
- | |
-/****************************************************************************************\ | |
-* Data structures for persistence (a.k.a serialization) functionality * | |
-\****************************************************************************************/ | |
- | |
-/* "black box" file storage */ | |
-typedef struct CvFileStorage CvFileStorage; | |
- | |
-/* Storage flags: */ | |
-#define CV_STORAGE_READ 0 | |
-#define CV_STORAGE_WRITE 1 | |
-#define CV_STORAGE_WRITE_TEXT CV_STORAGE_WRITE | |
-#define CV_STORAGE_WRITE_BINARY CV_STORAGE_WRITE | |
-#define CV_STORAGE_APPEND 2 | |
- | |
-/* List of attributes: */ | |
-typedef struct CvAttrList | |
-{ | |
- const char** attr; /* NULL-terminated array of (attribute_name,attribute_value) pairs. */ | |
- struct CvAttrList* next; /* Pointer to next chunk of the attributes list. */ | |
-} | |
-CvAttrList; | |
- | |
-CV_INLINE CvAttrList cvAttrList( const char** attr CV_DEFAULT(NULL), | |
- CvAttrList* next CV_DEFAULT(NULL) ) | |
-{ | |
- CvAttrList l; | |
- l.attr = attr; | |
- l.next = next; | |
- | |
- return l; | |
-} | |
- | |
-struct CvTypeInfo; | |
- | |
-#define CV_NODE_NONE 0 | |
-#define CV_NODE_INT 1 | |
-#define CV_NODE_INTEGER CV_NODE_INT | |
-#define CV_NODE_REAL 2 | |
-#define CV_NODE_FLOAT CV_NODE_REAL | |
-#define CV_NODE_STR 3 | |
-#define CV_NODE_STRING CV_NODE_STR | |
-#define CV_NODE_REF 4 /* not used */ | |
-#define CV_NODE_SEQ 5 | |
-#define CV_NODE_MAP 6 | |
-#define CV_NODE_TYPE_MASK 7 | |
- | |
-#define CV_NODE_TYPE(flags) ((flags) & CV_NODE_TYPE_MASK) | |
- | |
-/* file node flags */ | |
-#define CV_NODE_FLOW 8 /* Used only for writing structures in YAML format. */ | |
-#define CV_NODE_USER 16 | |
-#define CV_NODE_EMPTY 32 | |
-#define CV_NODE_NAMED 64 | |
- | |
-#define CV_NODE_IS_INT(flags) (CV_NODE_TYPE(flags) == CV_NODE_INT) | |
-#define CV_NODE_IS_REAL(flags) (CV_NODE_TYPE(flags) == CV_NODE_REAL) | |
-#define CV_NODE_IS_STRING(flags) (CV_NODE_TYPE(flags) == CV_NODE_STRING) | |
-#define CV_NODE_IS_SEQ(flags) (CV_NODE_TYPE(flags) == CV_NODE_SEQ) | |
-#define CV_NODE_IS_MAP(flags) (CV_NODE_TYPE(flags) == CV_NODE_MAP) | |
-#define CV_NODE_IS_COLLECTION(flags) (CV_NODE_TYPE(flags) >= CV_NODE_SEQ) | |
-#define CV_NODE_IS_FLOW(flags) (((flags) & CV_NODE_FLOW) != 0) | |
-#define CV_NODE_IS_EMPTY(flags) (((flags) & CV_NODE_EMPTY) != 0) | |
-#define CV_NODE_IS_USER(flags) (((flags) & CV_NODE_USER) != 0) | |
-#define CV_NODE_HAS_NAME(flags) (((flags) & CV_NODE_NAMED) != 0) | |
- | |
-#define CV_NODE_SEQ_SIMPLE 256 | |
-#define CV_NODE_SEQ_IS_SIMPLE(seq) (((seq)->flags & CV_NODE_SEQ_SIMPLE) != 0) | |
- | |
-typedef struct CvString | |
-{ | |
- int len; | |
- char* ptr; | |
-} | |
-CvString; | |
- | |
-/* All the keys (names) of elements in the readed file storage | |
- are stored in the hash to speed up the lookup operations: */ | |
-typedef struct CvStringHashNode | |
-{ | |
- unsigned hashval; | |
- CvString str; | |
- struct CvStringHashNode* next; | |
-} | |
-CvStringHashNode; | |
- | |
-typedef struct CvGenericHash CvFileNodeHash; | |
- | |
-/* Basic element of the file storage - scalar or collection: */ | |
-typedef struct CvFileNode | |
-{ | |
- int tag; | |
- struct CvTypeInfo* info; /* type information | |
- (only for user-defined object, for others it is 0) */ | |
- union | |
- { | |
- double f; /* scalar floating-point number */ | |
- int i; /* scalar integer number */ | |
- CvString str; /* text string */ | |
- CvSeq* seq; /* sequence (ordered collection of file nodes) */ | |
- CvFileNodeHash* map; /* map (collection of named file nodes) */ | |
- } data; | |
-} | |
-CvFileNode; | |
- | |
-#ifdef __cplusplus | |
-extern "C" { | |
-#endif | |
-typedef int (CV_CDECL *CvIsInstanceFunc)( const void* struct_ptr ); | |
-typedef void (CV_CDECL *CvReleaseFunc)( void** struct_dblptr ); | |
-typedef void* (CV_CDECL *CvReadFunc)( CvFileStorage* storage, CvFileNode* node ); | |
-typedef void (CV_CDECL *CvWriteFunc)( CvFileStorage* storage, const char* name, | |
- const void* struct_ptr, CvAttrList attributes ); | |
-typedef void* (CV_CDECL *CvCloneFunc)( const void* struct_ptr ); | |
-#ifdef __cplusplus | |
-} | |
-#endif | |
- | |
-typedef struct CvTypeInfo | |
-{ | |
- int flags; | |
- int header_size; | |
- struct CvTypeInfo* prev; | |
- struct CvTypeInfo* next; | |
- const char* type_name; | |
- CvIsInstanceFunc is_instance; | |
- CvReleaseFunc release; | |
- CvReadFunc read; | |
- CvWriteFunc write; | |
- CvCloneFunc clone; | |
-} | |
-CvTypeInfo; | |
- | |
- | |
-/**** System data types ******/ | |
- | |
-typedef struct CvPluginFuncInfo | |
-{ | |
- void** func_addr; | |
- void* default_func_addr; | |
- const char* func_names; | |
- int search_modules; | |
- int loaded_from; | |
-} | |
-CvPluginFuncInfo; | |
- | |
-typedef struct CvModuleInfo | |
-{ | |
- struct CvModuleInfo* next; | |
- const char* name; | |
- const char* version; | |
- CvPluginFuncInfo* func_tab; | |
-} | |
-CvModuleInfo; | |
- | |
-#endif /*_CXCORE_TYPES_H_*/ | |
- | |
-/* End of file. */ | |
diff --git a/card.io/src/main/jni/opencv2/core/version.hpp b/card.io/src/main/jni/opencv2/core/version.hpp | |
deleted file mode 100644 | |
index a0c99ad..0000000 | |
--- a/card.io/src/main/jni/opencv2/core/version.hpp | |
+++ /dev/null | |
@@ -1,58 +0,0 @@ | |
-/*M/////////////////////////////////////////////////////////////////////////////////////// | |
-// | |
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. | |
-// | |
-// By downloading, copying, installing or using the software you agree to this license. | |
-// If you do not agree to this license, do not download, install, | |
-// copy or use the software. | |
-// | |
-// | |
-// Intel License Agreement | |
-// For Open Source Computer Vision Library | |
-// | |
-// Copyright( C) 2000, Intel Corporation, all rights reserved. | |
-// Third party copyrights are property of their respective owners. | |
-// | |
-// Redistribution and use in source and binary forms, with or without modification, | |
-// are permitted provided that the following conditions are met: | |
-// | |
-// * Redistribution's of source code must retain the above copyright notice, | |
-// this list of conditions and the following disclaimer. | |
-// | |
-// * Redistribution's in binary form must reproduce the above copyright notice, | |
-// this list of conditions and the following disclaimer in the documentation | |
-// and/or other materials provided with the distribution. | |
-// | |
-// * The name of Intel Corporation may not be used to endorse or promote products | |
-// derived from this software without specific prior written permission. | |
-// | |
-// This software is provided by the copyright holders and contributors "as is" and | |
-// any express or implied warranties, including, but not limited to, the implied | |
-// warranties of merchantability and fitness for a particular purpose are disclaimed. | |
-// In no event shall the Intel Corporation or contributors be liable for any direct, | |
-// indirect, incidental, special, exemplary, or consequential damages | |
-//(including, but not limited to, procurement of substitute goods or services; | |
-// loss of use, data, or profits; or business interruption) however caused | |
-// and on any theory of liability, whether in contract, strict liability, | |
-// or tort(including negligence or otherwise) arising in any way out of | |
-// the use of this software, even if advised of the possibility of such damage. | |
-// | |
-//M*/ | |
- | |
-/* | |
- definition of the current version of OpenCV | |
- Usefull to test in user programs | |
-*/ | |
- | |
-#ifndef __OPENCV_VERSION_HPP__ | |
-#define __OPENCV_VERSION_HPP__ | |
- | |
-#define CV_MAJOR_VERSION 2 | |
-#define CV_MINOR_VERSION 4 | |
-#define CV_SUBMINOR_VERSION 0 | |
- | |
-#define CVAUX_STR_EXP(__A) #__A | |
-#define CVAUX_STR(__A) CVAUX_STR_EXP(__A) | |
-#define CV_VERSION CVAUX_STR(CV_MAJOR_VERSION) "." CVAUX_STR(CV_MINOR_VERSION) "." CVAUX_STR(CV_SUBMINOR_VERSION) | |
- | |
-#endif | |
diff --git a/card.io/src/main/jni/opencv2/core/wimage.hpp b/card.io/src/main/jni/opencv2/core/wimage.hpp | |
deleted file mode 100644 | |
index 579c009..0000000 | |
--- a/card.io/src/main/jni/opencv2/core/wimage.hpp | |
+++ /dev/null | |
@@ -1,621 +0,0 @@ | |
-/////////////////////////////////////////////////////////////////////////////// | |
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. | |
-// | |
-// By downloading, copying, installing or using the software you agree to | |
-// this license. If you do not agree to this license, do not download, | |
-// install, copy or use the software. | |
-// | |
-// License Agreement | |
-// For Open Source Computer Vision Library | |
-// | |
-// Copyright (C) 2008, Google, all rights reserved. | |
-// Third party copyrights are property of their respective owners. | |
-// | |
-// Redistribution and use in source and binary forms, with or without | |
-// modification, are permitted provided that the following conditions are met: | |
-// | |
-// * Redistribution's of source code must retain the above copyright notice, | |
-// this list of conditions and the following disclaimer. | |
-// | |
-// * Redistribution's in binary form must reproduce the above copyright notice, | |
-// this list of conditions and the following disclaimer in the documentation | |
-// and/or other materials provided with the distribution. | |
-// | |
-// * The name of Intel Corporation or contributors may not be used to endorse | |
-// or promote products derived from this software without specific | |
-// prior written permission. | |
-// | |
-// This software is provided by the copyright holders and contributors "as is" | |
-// and any express or implied warranties, including, but not limited to, the | |
-// implied warranties of merchantability and fitness for a particular purpose | |
-// are disclaimed. In no event shall the Intel Corporation or contributors be | |
-// liable for any direct, indirect, incidental, special, exemplary, or | |
-// consequential damages | |
-// (including, but not limited to, procurement of substitute goods or services; | |
-// loss of use, data, or profits; or business interruption) however caused | |
-// and on any theory of liability, whether in contract, strict liability, | |
-// or tort (including negligence or otherwise) arising in any way out of | |
-// the use of this software, even if advised of the possibility of such damage. | |
- | |
- | |
-///////////////////////////////////////////////////////////////////////////////// | |
-// | |
-// Image class which provides a thin layer around an IplImage. The goals | |
-// of the class design are: | |
-// 1. All the data has explicit ownership to avoid memory leaks | |
-// 2. No hidden allocations or copies for performance. | |
-// 3. Easy access to OpenCV methods (which will access IPP if available) | |
-// 4. Can easily treat external data as an image | |
-// 5. Easy to create images which are subsets of other images | |
-// 6. Fast pixel access which can take advantage of number of channels | |
-// if known at compile time. | |
-// | |
-// The WImage class is the image class which provides the data accessors. | |
-// The 'W' comes from the fact that it is also a wrapper around the popular | |
-// but inconvenient IplImage class. A WImage can be constructed either using a | |
-// WImageBuffer class which allocates and frees the data, | |
-// or using a WImageView class which constructs a subimage or a view into | |
-// external data. The view class does no memory management. Each class | |
-// actually has two versions, one when the number of channels is known at | |
-// compile time and one when it isn't. Using the one with the number of | |
-// channels specified can provide some compile time optimizations by using the | |
-// fact that the number of channels is a constant. | |
-// | |
-// We use the convention (c,r) to refer to column c and row r with (0,0) being | |
-// the upper left corner. This is similar to standard Euclidean coordinates | |
-// with the first coordinate varying in the horizontal direction and the second | |
-// coordinate varying in the vertical direction. | |
-// Thus (c,r) is usually in the domain [0, width) X [0, height) | |
-// | |
-// Example usage: | |
-// WImageBuffer3_b im(5,7); // Make a 5X7 3 channel image of type uchar | |
-// WImageView3_b sub_im(im, 2,2, 3,3); // 3X3 submatrix | |
-// vector<float> vec(10, 3.0f); | |
-// WImageView1_f user_im(&vec[0], 2, 5); // 2X5 image w/ supplied data | |
-// | |
-// im.SetZero(); // same as cvSetZero(im.Ipl()) | |
-// *im(2, 3) = 15; // Modify the element at column 2, row 3 | |
-// MySetRand(&sub_im); | |
-// | |
-// // Copy the second row into the first. This can be done with no memory | |
-// // allocation and will use SSE if IPP is available. | |
-// int w = im.Width(); | |
-// im.View(0,0, w,1).CopyFrom(im.View(0,1, w,1)); | |
-// | |
-// // Doesn't care about source of data since using WImage | |
-// void MySetRand(WImage_b* im) { // Works with any number of channels | |
-// for (int r = 0; r < im->Height(); ++r) { | |
-// float* row = im->Row(r); | |
-// for (int c = 0; c < im->Width(); ++c) { | |
-// for (int ch = 0; ch < im->Channels(); ++ch, ++row) { | |
-// *row = uchar(rand() & 255); | |
-// } | |
-// } | |
-// } | |
-// } | |
-// | |
-// Functions that are not part of the basic image allocation, viewing, and | |
-// access should come from OpenCV, except some useful functions that are not | |
-// part of OpenCV can be found in wimage_util.h | |
-#ifndef __OPENCV_CORE_WIMAGE_HPP__ | |
-#define __OPENCV_CORE_WIMAGE_HPP__ | |
- | |
-#include "opencv2/core/core_c.h" | |
- | |
-#ifdef __cplusplus | |
- | |
-namespace cv { | |
- | |
-template <typename T> class WImage; | |
-template <typename T> class WImageBuffer; | |
-template <typename T> class WImageView; | |
- | |
-template<typename T, int C> class WImageC; | |
-template<typename T, int C> class WImageBufferC; | |
-template<typename T, int C> class WImageViewC; | |
- | |
-// Commonly used typedefs. | |
-typedef WImage<uchar> WImage_b; | |
-typedef WImageView<uchar> WImageView_b; | |
-typedef WImageBuffer<uchar> WImageBuffer_b; | |
- | |
-typedef WImageC<uchar, 1> WImage1_b; | |
-typedef WImageViewC<uchar, 1> WImageView1_b; | |
-typedef WImageBufferC<uchar, 1> WImageBuffer1_b; | |
- | |
-typedef WImageC<uchar, 3> WImage3_b; | |
-typedef WImageViewC<uchar, 3> WImageView3_b; | |
-typedef WImageBufferC<uchar, 3> WImageBuffer3_b; | |
- | |
-typedef WImage<float> WImage_f; | |
-typedef WImageView<float> WImageView_f; | |
-typedef WImageBuffer<float> WImageBuffer_f; | |
- | |
-typedef WImageC<float, 1> WImage1_f; | |
-typedef WImageViewC<float, 1> WImageView1_f; | |
-typedef WImageBufferC<float, 1> WImageBuffer1_f; | |
- | |
-typedef WImageC<float, 3> WImage3_f; | |
-typedef WImageViewC<float, 3> WImageView3_f; | |
-typedef WImageBufferC<float, 3> WImageBuffer3_f; | |
- | |
-// There isn't a standard for signed and unsigned short so be more | |
-// explicit in the typename for these cases. | |
-typedef WImage<short> WImage_16s; | |
-typedef WImageView<short> WImageView_16s; | |
-typedef WImageBuffer<short> WImageBuffer_16s; | |
- | |
-typedef WImageC<short, 1> WImage1_16s; | |
-typedef WImageViewC<short, 1> WImageView1_16s; | |
-typedef WImageBufferC<short, 1> WImageBuffer1_16s; | |
- | |
-typedef WImageC<short, 3> WImage3_16s; | |
-typedef WImageViewC<short, 3> WImageView3_16s; | |
-typedef WImageBufferC<short, 3> WImageBuffer3_16s; | |
- | |
-typedef WImage<ushort> WImage_16u; | |
-typedef WImageView<ushort> WImageView_16u; | |
-typedef WImageBuffer<ushort> WImageBuffer_16u; | |
- | |
-typedef WImageC<ushort, 1> WImage1_16u; | |
-typedef WImageViewC<ushort, 1> WImageView1_16u; | |
-typedef WImageBufferC<ushort, 1> WImageBuffer1_16u; | |
- | |
-typedef WImageC<ushort, 3> WImage3_16u; | |
-typedef WImageViewC<ushort, 3> WImageView3_16u; | |
-typedef WImageBufferC<ushort, 3> WImageBuffer3_16u; | |
- | |
-// | |
-// WImage definitions | |
-// | |
-// This WImage class gives access to the data it refers to. It can be | |
-// constructed either by allocating the data with a WImageBuffer class or | |
-// using the WImageView class to refer to a subimage or outside data. | |
-template<typename T> | |
-class WImage | |
-{ | |
-public: | |
- typedef T BaseType; | |
- | |
- // WImage is an abstract class with no other virtual methods so make the | |
- // destructor virtual. | |
- virtual ~WImage() = 0; | |
- | |
- // Accessors | |
- IplImage* Ipl() {return image_; } | |
- const IplImage* Ipl() const {return image_; } | |
- T* ImageData() { return reinterpret_cast<T*>(image_->imageData); } | |
- const T* ImageData() const { | |
- return reinterpret_cast<const T*>(image_->imageData); | |
- } | |
- | |
- int Width() const {return image_->width; } | |
- int Height() const {return image_->height; } | |
- | |
- // WidthStep is the number of bytes to go to the pixel with the next y coord | |
- int WidthStep() const {return image_->widthStep; } | |
- | |
- int Channels() const {return image_->nChannels; } | |
- int ChannelSize() const {return sizeof(T); } // number of bytes per channel | |
- | |
- // Number of bytes per pixel | |
- int PixelSize() const {return Channels() * ChannelSize(); } | |
- | |
- // Return depth type (e.g. IPL_DEPTH_8U, IPL_DEPTH_32F) which is the number | |
- // of bits per channel and with the signed bit set. | |
- // This is known at compile time using specializations. | |
- int Depth() const; | |
- | |
- inline const T* Row(int r) const { | |
- return reinterpret_cast<T*>(image_->imageData + r*image_->widthStep); | |
- } | |
- | |
- inline T* Row(int r) { | |
- return reinterpret_cast<T*>(image_->imageData + r*image_->widthStep); | |
- } | |
- | |
- // Pixel accessors which returns a pointer to the start of the channel | |
- inline T* operator() (int c, int r) { | |
- return reinterpret_cast<T*>(image_->imageData + r*image_->widthStep) + | |
- c*Channels(); | |
- } | |
- | |
- inline const T* operator() (int c, int r) const { | |
- return reinterpret_cast<T*>(image_->imageData + r*image_->widthStep) + | |
- c*Channels(); | |
- } | |
- | |
- // Copy the contents from another image which is just a convenience to cvCopy | |
- void CopyFrom(const WImage<T>& src) { cvCopy(src.Ipl(), image_); } | |
- | |
- // Set contents to zero which is just a convenient to cvSetZero | |
- void SetZero() { cvSetZero(image_); } | |
- | |
- // Construct a view into a region of this image | |
- WImageView<T> View(int c, int r, int width, int height); | |
- | |
-protected: | |
- // Disallow copy and assignment | |
- WImage(const WImage&); | |
- void operator=(const WImage&); | |
- | |
- explicit WImage(IplImage* img) : image_(img) { | |
- assert(!img || img->depth == Depth()); | |
- } | |
- | |
- void SetIpl(IplImage* image) { | |
- assert(!image || image->depth == Depth()); | |
- image_ = image; | |
- } | |
- | |
- IplImage* image_; | |
-}; | |
- | |
- | |
- | |
-// Image class when both the pixel type and number of channels | |
-// are known at compile time. This wrapper will speed up some of the operations | |
-// like accessing individual pixels using the () operator. | |
-template<typename T, int C> | |
-class WImageC : public WImage<T> | |
-{ | |
-public: | |
- typedef typename WImage<T>::BaseType BaseType; | |
- enum { kChannels = C }; | |
- | |
- explicit WImageC(IplImage* img) : WImage<T>(img) { | |
- assert(!img || img->nChannels == Channels()); | |
- } | |
- | |
- // Construct a view into a region of this image | |
- WImageViewC<T, C> View(int c, int r, int width, int height); | |
- | |
- // Copy the contents from another image which is just a convenience to cvCopy | |
- void CopyFrom(const WImageC<T, C>& src) { | |
- cvCopy(src.Ipl(), WImage<T>::image_); | |
- } | |
- | |
- // WImageC is an abstract class with no other virtual methods so make the | |
- // destructor virtual. | |
- virtual ~WImageC() = 0; | |
- | |
- int Channels() const {return C; } | |
- | |
-protected: | |
- // Disallow copy and assignment | |
- WImageC(const WImageC&); | |
- void operator=(const WImageC&); | |
- | |
- void SetIpl(IplImage* image) { | |
- assert(!image || image->depth == WImage<T>::Depth()); | |
- WImage<T>::SetIpl(image); | |
- } | |
-}; | |
- | |
-// | |
-// WImageBuffer definitions | |
-// | |
-// Image class which owns the data, so it can be allocated and is always | |
-// freed. It cannot be copied but can be explicity cloned. | |
-// | |
-template<typename T> | |
-class WImageBuffer : public WImage<T> | |
-{ | |
-public: | |
- typedef typename WImage<T>::BaseType BaseType; | |
- | |
- // Default constructor which creates an object that can be | |
- WImageBuffer() : WImage<T>(0) {} | |
- | |
- WImageBuffer(int width, int height, int nchannels) : WImage<T>(0) { | |
- Allocate(width, height, nchannels); | |
- } | |
- | |
- // Constructor which takes ownership of a given IplImage so releases | |
- // the image on destruction. | |
- explicit WImageBuffer(IplImage* img) : WImage<T>(img) {} | |
- | |
- // Allocate an image. Does nothing if current size is the same as | |
- // the new size. | |
- void Allocate(int width, int height, int nchannels); | |
- | |
- // Set the data to point to an image, releasing the old data | |
- void SetIpl(IplImage* img) { | |
- ReleaseImage(); | |
- WImage<T>::SetIpl(img); | |
- } | |
- | |
- // Clone an image which reallocates the image if of a different dimension. | |
- void CloneFrom(const WImage<T>& src) { | |
- Allocate(src.Width(), src.Height(), src.Channels()); | |
- CopyFrom(src); | |
- } | |
- | |
- ~WImageBuffer() { | |
- ReleaseImage(); | |
- } | |
- | |
- // Release the image if it isn't null. | |
- void ReleaseImage() { | |
- if (WImage<T>::image_) { | |
- IplImage* image = WImage<T>::image_; | |
- cvReleaseImage(&image); | |
- WImage<T>::SetIpl(0); | |
- } | |
- } | |
- | |
- bool IsNull() const {return WImage<T>::image_ == NULL; } | |
- | |
-private: | |
- // Disallow copy and assignment | |
- WImageBuffer(const WImageBuffer&); | |
- void operator=(const WImageBuffer&); | |
-}; | |
- | |
-// Like a WImageBuffer class but when the number of channels is known | |
-// at compile time. | |
-template<typename T, int C> | |
-class WImageBufferC : public WImageC<T, C> | |
-{ | |
-public: | |
- typedef typename WImage<T>::BaseType BaseType; | |
- enum { kChannels = C }; | |
- | |
- // Default constructor which creates an object that can be | |
- WImageBufferC() : WImageC<T, C>(0) {} | |
- | |
- WImageBufferC(int width, int height) : WImageC<T, C>(0) { | |
- Allocate(width, height); | |
- } | |
- | |
- // Constructor which takes ownership of a given IplImage so releases | |
- // the image on destruction. | |
- explicit WImageBufferC(IplImage* img) : WImageC<T, C>(img) {} | |
- | |
- // Allocate an image. Does nothing if current size is the same as | |
- // the new size. | |
- void Allocate(int width, int height); | |
- | |
- // Set the data to point to an image, releasing the old data | |
- void SetIpl(IplImage* img) { | |
- ReleaseImage(); | |
- WImageC<T, C>::SetIpl(img); | |
- } | |
- | |
- // Clone an image which reallocates the image if of a different dimension. | |
- void CloneFrom(const WImageC<T, C>& src) { | |
- Allocate(src.Width(), src.Height()); | |
- CopyFrom(src); | |
- } | |
- | |
- ~WImageBufferC() { | |
- ReleaseImage(); | |
- } | |
- | |
- // Release the image if it isn't null. | |
- void ReleaseImage() { | |
- if (WImage<T>::image_) { | |
- IplImage* image = WImage<T>::image_; | |
- cvReleaseImage(&image); | |
- WImageC<T, C>::SetIpl(0); | |
- } | |
- } | |
- | |
- bool IsNull() const {return WImage<T>::image_ == NULL; } | |
- | |
-private: | |
- // Disallow copy and assignment | |
- WImageBufferC(const WImageBufferC&); | |
- void operator=(const WImageBufferC&); | |
-}; | |
- | |
-// | |
-// WImageView definitions | |
-// | |
-// View into an image class which allows treating a subimage as an image | |
-// or treating external data as an image | |
-// | |
-template<typename T> | |
-class WImageView : public WImage<T> | |
-{ | |
-public: | |
- typedef typename WImage<T>::BaseType BaseType; | |
- | |
- // Construct a subimage. No checks are done that the subimage lies | |
- // completely inside the original image. | |
- WImageView(WImage<T>* img, int c, int r, int width, int height); | |
- | |
- // Refer to external data. | |
- // If not given width_step assumed to be same as width. | |
- WImageView(T* data, int width, int height, int channels, int width_step = -1); | |
- | |
- // Refer to external data. This does NOT take ownership | |
- // of the supplied IplImage. | |
- WImageView(IplImage* img) : WImage<T>(img) {} | |
- | |
- // Copy constructor | |
- WImageView(const WImage<T>& img) : WImage<T>(0) { | |
- header_ = *(img.Ipl()); | |
- WImage<T>::SetIpl(&header_); | |
- } | |
- | |
- WImageView& operator=(const WImage<T>& img) { | |
- header_ = *(img.Ipl()); | |
- WImage<T>::SetIpl(&header_); | |
- return *this; | |
- } | |
- | |
-protected: | |
- IplImage header_; | |
-}; | |
- | |
- | |
-template<typename T, int C> | |
-class WImageViewC : public WImageC<T, C> | |
-{ | |
-public: | |
- typedef typename WImage<T>::BaseType BaseType; | |
- enum { kChannels = C }; | |
- | |
- // Default constructor needed for vectors of views. | |
- WImageViewC(); | |
- | |
- virtual ~WImageViewC() {} | |
- | |
- // Construct a subimage. No checks are done that the subimage lies | |
- // completely inside the original image. | |
- WImageViewC(WImageC<T, C>* img, | |
- int c, int r, int width, int height); | |
- | |
- // Refer to external data | |
- WImageViewC(T* data, int width, int height, int width_step = -1); | |
- | |
- // Refer to external data. This does NOT take ownership | |
- // of the supplied IplImage. | |
- WImageViewC(IplImage* img) : WImageC<T, C>(img) {} | |
- | |
- // Copy constructor which does a shallow copy to allow multiple views | |
- // of same data. gcc-4.1.1 gets confused if both versions of | |
- // the constructor and assignment operator are not provided. | |
- WImageViewC(const WImageC<T, C>& img) : WImageC<T, C>(0) { | |
- header_ = *(img.Ipl()); | |
- WImageC<T, C>::SetIpl(&header_); | |
- } | |
- WImageViewC(const WImageViewC<T, C>& img) : WImageC<T, C>(0) { | |
- header_ = *(img.Ipl()); | |
- WImageC<T, C>::SetIpl(&header_); | |
- } | |
- | |
- WImageViewC& operator=(const WImageC<T, C>& img) { | |
- header_ = *(img.Ipl()); | |
- WImageC<T, C>::SetIpl(&header_); | |
- return *this; | |
- } | |
- WImageViewC& operator=(const WImageViewC<T, C>& img) { | |
- header_ = *(img.Ipl()); | |
- WImageC<T, C>::SetIpl(&header_); | |
- return *this; | |
- } | |
- | |
-protected: | |
- IplImage header_; | |
-}; | |
- | |
- | |
-// Specializations for depth | |
-template<> | |
-inline int WImage<uchar>::Depth() const {return IPL_DEPTH_8U; } | |
-template<> | |
-inline int WImage<signed char>::Depth() const {return IPL_DEPTH_8S; } | |
-template<> | |
-inline int WImage<short>::Depth() const {return IPL_DEPTH_16S; } | |
-template<> | |
-inline int WImage<ushort>::Depth() const {return IPL_DEPTH_16U; } | |
-template<> | |
-inline int WImage<int>::Depth() const {return IPL_DEPTH_32S; } | |
-template<> | |
-inline int WImage<float>::Depth() const {return IPL_DEPTH_32F; } | |
-template<> | |
-inline int WImage<double>::Depth() const {return IPL_DEPTH_64F; } | |
- | |
-// | |
-// Pure virtual destructors still need to be defined. | |
-// | |
-template<typename T> inline WImage<T>::~WImage() {} | |
-template<typename T, int C> inline WImageC<T, C>::~WImageC() {} | |
- | |
-// | |
-// Allocate ImageData | |
-// | |
-template<typename T> | |
-inline void WImageBuffer<T>::Allocate(int width, int height, int nchannels) | |
-{ | |
- if (IsNull() || WImage<T>::Width() != width || | |
- WImage<T>::Height() != height || WImage<T>::Channels() != nchannels) { | |
- ReleaseImage(); | |
- WImage<T>::image_ = cvCreateImage(cvSize(width, height), | |
- WImage<T>::Depth(), nchannels); | |
- } | |
-} | |
- | |
-template<typename T, int C> | |
-inline void WImageBufferC<T, C>::Allocate(int width, int height) | |
-{ | |
- if (IsNull() || WImage<T>::Width() != width || WImage<T>::Height() != height) { | |
- ReleaseImage(); | |
- WImageC<T, C>::SetIpl(cvCreateImage(cvSize(width, height),WImage<T>::Depth(), C)); | |
- } | |
-} | |
- | |
-// | |
-// ImageView methods | |
-// | |
-template<typename T> | |
-WImageView<T>::WImageView(WImage<T>* img, int c, int r, int width, int height) | |
- : WImage<T>(0) | |
-{ | |
- header_ = *(img->Ipl()); | |
- header_.imageData = reinterpret_cast<char*>((*img)(c, r)); | |
- header_.width = width; | |
- header_.height = height; | |
- WImage<T>::SetIpl(&header_); | |
-} | |
- | |
-template<typename T> | |
-WImageView<T>::WImageView(T* data, int width, int height, int nchannels, int width_step) | |
- : WImage<T>(0) | |
-{ | |
- cvInitImageHeader(&header_, cvSize(width, height), WImage<T>::Depth(), nchannels); | |
- header_.imageData = reinterpret_cast<char*>(data); | |
- if (width_step > 0) { | |
- header_.widthStep = width_step; | |
- } | |
- WImage<T>::SetIpl(&header_); | |
-} | |
- | |
-template<typename T, int C> | |
-WImageViewC<T, C>::WImageViewC(WImageC<T, C>* img, int c, int r, int width, int height) | |
- : WImageC<T, C>(0) | |
-{ | |
- header_ = *(img->Ipl()); | |
- header_.imageData = reinterpret_cast<char*>((*img)(c, r)); | |
- header_.width = width; | |
- header_.height = height; | |
- WImageC<T, C>::SetIpl(&header_); | |
-} | |
- | |
-template<typename T, int C> | |
-WImageViewC<T, C>::WImageViewC() : WImageC<T, C>(0) { | |
- cvInitImageHeader(&header_, cvSize(0, 0), WImage<T>::Depth(), C); | |
- header_.imageData = reinterpret_cast<char*>(0); | |
- WImageC<T, C>::SetIpl(&header_); | |
-} | |
- | |
-template<typename T, int C> | |
-WImageViewC<T, C>::WImageViewC(T* data, int width, int height, int width_step) | |
- : WImageC<T, C>(0) | |
-{ | |
- cvInitImageHeader(&header_, cvSize(width, height), WImage<T>::Depth(), C); | |
- header_.imageData = reinterpret_cast<char*>(data); | |
- if (width_step > 0) { | |
- header_.widthStep = width_step; | |
- } | |
- WImageC<T, C>::SetIpl(&header_); | |
-} | |
- | |
-// Construct a view into a region of an image | |
-template<typename T> | |
-WImageView<T> WImage<T>::View(int c, int r, int width, int height) { | |
- return WImageView<T>(this, c, r, width, height); | |
-} | |
- | |
-template<typename T, int C> | |
-WImageViewC<T, C> WImageC<T, C>::View(int c, int r, int width, int height) { | |
- return WImageViewC<T, C>(this, c, r, width, height); | |
-} | |
- | |
-} // end of namespace | |
- | |
-#endif // __cplusplus | |
- | |
-#endif | |
diff --git a/card.io/src/main/jni/opencv2/imgproc/imgproc.hpp b/card.io/src/main/jni/opencv2/imgproc/imgproc.hpp | |
deleted file mode 100644 | |
index 3562a92..0000000 | |
--- a/card.io/src/main/jni/opencv2/imgproc/imgproc.hpp | |
+++ /dev/null | |
@@ -1,1227 +0,0 @@ | |
-/*! \file imgproc.hpp | |
- \brief The Image Processing | |
- */ | |
- | |
-/*M/////////////////////////////////////////////////////////////////////////////////////// | |
-// | |
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. | |
-// | |
-// By downloading, copying, installing or using the software you agree to this license. | |
-// If you do not agree to this license, do not download, install, | |
-// copy or use the software. | |
-// | |
-// | |
-// License Agreement | |
-// For Open Source Computer Vision Library | |
-// | |
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. | |
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved. | |
-// Third party copyrights are property of their respective owners. | |
-// | |
-// Redistribution and use in source and binary forms, with or without modification, | |
-// are permitted provided that the following conditions are met: | |
-// | |
-// * Redistribution's of source code must retain the above copyright notice, | |
-// this list of conditions and the following disclaimer. | |
-// | |
-// * Redistribution's in binary form must reproduce the above copyright notice, | |
-// this list of conditions and the following disclaimer in the documentation | |
-// and/or other materials provided with the distribution. | |
-// | |
-// * The name of the copyright holders may not be used to endorse or promote products | |
-// derived from this software without specific prior written permission. | |
-// | |
-// This software is provided by the copyright holders and contributors "as is" and | |
-// any express or implied warranties, including, but not limited to, the implied | |
-// warranties of merchantability and fitness for a particular purpose are disclaimed. | |
-// In no event shall the Intel Corporation or contributors be liable for any direct, | |
-// indirect, incidental, special, exemplary, or consequential damages | |
-// (including, but not limited to, procurement of substitute goods or services; | |
-// loss of use, data, or profits; or business interruption) however caused | |
-// and on any theory of liability, whether in contract, strict liability, | |
-// or tort (including negligence or otherwise) arising in any way out of | |
-// the use of this software, even if advised of the possibility of such damage. | |
-// | |
-//M*/ | |
- | |
-#ifndef __OPENCV_IMGPROC_HPP__ | |
-#define __OPENCV_IMGPROC_HPP__ | |
- | |
-#include "opencv2/core/core.hpp" | |
-#include "opencv2/imgproc/types_c.h" | |
- | |
-#ifdef __cplusplus | |
- | |
-/*! \namespace cv | |
- Namespace where all the C++ OpenCV functionality resides | |
- */ | |
-namespace cv | |
-{ | |
- | |
-//! various border interpolation methods | |
-enum { BORDER_REPLICATE=IPL_BORDER_REPLICATE, BORDER_CONSTANT=IPL_BORDER_CONSTANT, | |
- BORDER_REFLECT=IPL_BORDER_REFLECT, BORDER_WRAP=IPL_BORDER_WRAP, | |
- BORDER_REFLECT_101=IPL_BORDER_REFLECT_101, BORDER_REFLECT101=BORDER_REFLECT_101, | |
- BORDER_TRANSPARENT=IPL_BORDER_TRANSPARENT, | |
- BORDER_DEFAULT=BORDER_REFLECT_101, BORDER_ISOLATED=16 }; | |
- | |
-//! 1D interpolation function: returns coordinate of the "donor" pixel for the specified location p. | |
-CV_EXPORTS_W int borderInterpolate( int p, int len, int borderType ); | |
- | |
-/*! | |
- The Base Class for 1D or Row-wise Filters | |
- | |
- This is the base class for linear or non-linear filters that process 1D data. | |
- In particular, such filters are used for the "horizontal" filtering parts in separable filters. | |
- | |
- Several functions in OpenCV return Ptr<BaseRowFilter> for the specific types of filters, | |
- and those pointers can be used directly or within cv::FilterEngine. | |
-*/ | |
-class CV_EXPORTS BaseRowFilter | |
-{ | |
-public: | |
- //! the default constructor | |
- BaseRowFilter(); | |
- //! the destructor | |
- virtual ~BaseRowFilter(); | |
- //! the filtering operator. Must be overrided in the derived classes. The horizontal border interpolation is done outside of the class. | |
- virtual void operator()(const uchar* src, uchar* dst, | |
- int width, int cn) = 0; | |
- int ksize, anchor; | |
-}; | |
- | |
- | |
-/*! | |
- The Base Class for Column-wise Filters | |
- | |
- This is the base class for linear or non-linear filters that process columns of 2D arrays. | |
- Such filters are used for the "vertical" filtering parts in separable filters. | |
- | |
- Several functions in OpenCV return Ptr<BaseColumnFilter> for the specific types of filters, | |
- and those pointers can be used directly or within cv::FilterEngine. | |
- | |
- Unlike cv::BaseRowFilter, cv::BaseColumnFilter may have some context information, | |
- i.e. box filter keeps the sliding sum of elements. To reset the state BaseColumnFilter::reset() | |
- must be called (e.g. the method is called by cv::FilterEngine) | |
- */ | |
-class CV_EXPORTS BaseColumnFilter | |
-{ | |
-public: | |
- //! the default constructor | |
- BaseColumnFilter(); | |
- //! the destructor | |
- virtual ~BaseColumnFilter(); | |
- //! the filtering operator. Must be overrided in the derived classes. The vertical border interpolation is done outside of the class. | |
- virtual void operator()(const uchar** src, uchar* dst, int dststep, | |
- int dstcount, int width) = 0; | |
- //! resets the internal buffers, if any | |
- virtual void reset(); | |
- int ksize, anchor; | |
-}; | |
- | |
-/*! | |
- The Base Class for Non-Separable 2D Filters. | |
- | |
- This is the base class for linear or non-linear 2D filters. | |
- | |
- Several functions in OpenCV return Ptr<BaseFilter> for the specific types of filters, | |
- and those pointers can be used directly or within cv::FilterEngine. | |
- | |
- Similar to cv::BaseColumnFilter, the class may have some context information, | |
- that should be reset using BaseFilter::reset() method before processing the new array. | |
-*/ | |
-class CV_EXPORTS BaseFilter | |
-{ | |
-public: | |
- //! the default constructor | |
- BaseFilter(); | |
- //! the destructor | |
- virtual ~BaseFilter(); | |
- //! the filtering operator. The horizontal and the vertical border interpolation is done outside of the class. | |
- virtual void operator()(const uchar** src, uchar* dst, int dststep, | |
- int dstcount, int width, int cn) = 0; | |
- //! resets the internal buffers, if any | |
- virtual void reset(); | |
- Size ksize; | |
- Point anchor; | |
-}; | |
- | |
-/*! | |
- The Main Class for Image Filtering. | |
- | |
- The class can be used to apply an arbitrary filtering operation to an image. | |
- It contains all the necessary intermediate buffers, it computes extrapolated values | |
- of the "virtual" pixels outside of the image etc. | |
- Pointers to the initialized cv::FilterEngine instances | |
- are returned by various OpenCV functions, such as cv::createSeparableLinearFilter(), | |
- cv::createLinearFilter(), cv::createGaussianFilter(), cv::createDerivFilter(), | |
- cv::createBoxFilter() and cv::createMorphologyFilter(). | |
- | |
- Using the class you can process large images by parts and build complex pipelines | |
- that include filtering as some of the stages. If all you need is to apply some pre-defined | |
- filtering operation, you may use cv::filter2D(), cv::erode(), cv::dilate() etc. | |
- functions that create FilterEngine internally. | |
- | |
- Here is the example on how to use the class to implement Laplacian operator, which is the sum of | |
- second-order derivatives. More complex variant for different types is implemented in cv::Laplacian(). | |
- | |
- \code | |
- void laplace_f(const Mat& src, Mat& dst) | |
- { | |
- CV_Assert( src.type() == CV_32F ); | |
- // make sure the destination array has the proper size and type | |
- dst.create(src.size(), src.type()); | |
- | |
- // get the derivative and smooth kernels for d2I/dx2. | |
- // for d2I/dy2 we could use the same kernels, just swapped | |
- Mat kd, ks; | |
- getSobelKernels( kd, ks, 2, 0, ksize, false, ktype ); | |
- | |
- // let's process 10 source rows at once | |
- int DELTA = std::min(10, src.rows); | |
- Ptr<FilterEngine> Fxx = createSeparableLinearFilter(src.type(), | |
- dst.type(), kd, ks, Point(-1,-1), 0, borderType, borderType, Scalar() ); | |
- Ptr<FilterEngine> Fyy = createSeparableLinearFilter(src.type(), | |
- dst.type(), ks, kd, Point(-1,-1), 0, borderType, borderType, Scalar() ); | |
- | |
- int y = Fxx->start(src), dsty = 0, dy = 0; | |
- Fyy->start(src); | |
- const uchar* sptr = src.data + y*src.step; | |
- | |
- // allocate the buffers for the spatial image derivatives; | |
- // the buffers need to have more than DELTA rows, because at the | |
- // last iteration the output may take max(kd.rows-1,ks.rows-1) | |
- // rows more than the input. | |
- Mat Ixx( DELTA + kd.rows - 1, src.cols, dst.type() ); | |
- Mat Iyy( DELTA + kd.rows - 1, src.cols, dst.type() ); | |
- | |
- // inside the loop we always pass DELTA rows to the filter | |
- // (note that the "proceed" method takes care of possibe overflow, since | |
- // it was given the actual image height in the "start" method) | |
- // on output we can get: | |
- // * < DELTA rows (the initial buffer accumulation stage) | |
- // * = DELTA rows (settled state in the middle) | |
- // * > DELTA rows (then the input image is over, but we generate | |
- // "virtual" rows using the border mode and filter them) | |
- // this variable number of output rows is dy. | |
- // dsty is the current output row. | |
- // sptr is the pointer to the first input row in the portion to process | |
- for( ; dsty < dst.rows; sptr += DELTA*src.step, dsty += dy ) | |
- { | |
- Fxx->proceed( sptr, (int)src.step, DELTA, Ixx.data, (int)Ixx.step ); | |
- dy = Fyy->proceed( sptr, (int)src.step, DELTA, d2y.data, (int)Iyy.step ); | |
- if( dy > 0 ) | |
- { | |
- Mat dstripe = dst.rowRange(dsty, dsty + dy); | |
- add(Ixx.rowRange(0, dy), Iyy.rowRange(0, dy), dstripe); | |
- } | |
- } | |
- } | |
- \endcode | |
-*/ | |
-class CV_EXPORTS FilterEngine | |
-{ | |
-public: | |
- //! the default constructor | |
- FilterEngine(); | |
- //! the full constructor. Either _filter2D or both _rowFilter and _columnFilter must be non-empty. | |
- FilterEngine(const Ptr<BaseFilter>& _filter2D, | |
- const Ptr<BaseRowFilter>& _rowFilter, | |
- const Ptr<BaseColumnFilter>& _columnFilter, | |
- int srcType, int dstType, int bufType, | |
- int _rowBorderType=BORDER_REPLICATE, | |
- int _columnBorderType=-1, | |
- const Scalar& _borderValue=Scalar()); | |
- //! the destructor | |
- virtual ~FilterEngine(); | |
- //! reinitializes the engine. The previously assigned filters are released. | |
- void init(const Ptr<BaseFilter>& _filter2D, | |
- const Ptr<BaseRowFilter>& _rowFilter, | |
- const Ptr<BaseColumnFilter>& _columnFilter, | |
- int srcType, int dstType, int bufType, | |
- int _rowBorderType=BORDER_REPLICATE, int _columnBorderType=-1, | |
- const Scalar& _borderValue=Scalar()); | |
- //! starts filtering of the specified ROI of an image of size wholeSize. | |
- virtual int start(Size wholeSize, Rect roi, int maxBufRows=-1); | |
- //! starts filtering of the specified ROI of the specified image. | |
- virtual int start(const Mat& src, const Rect& srcRoi=Rect(0,0,-1,-1), | |
- bool isolated=false, int maxBufRows=-1); | |
- //! processes the next srcCount rows of the image. | |
- virtual int proceed(const uchar* src, int srcStep, int srcCount, | |
- uchar* dst, int dstStep); | |
- //! applies filter to the specified ROI of the image. if srcRoi=(0,0,-1,-1), the whole image is filtered. | |
- virtual void apply( const Mat& src, Mat& dst, | |
- const Rect& srcRoi=Rect(0,0,-1,-1), | |
- Point dstOfs=Point(0,0), | |
- bool isolated=false); | |
- //! returns true if the filter is separable | |
- bool isSeparable() const { return (const BaseFilter*)filter2D == 0; } | |
- //! returns the number | |
- int remainingInputRows() const; | |
- int remainingOutputRows() const; | |
- | |
- int srcType, dstType, bufType; | |
- Size ksize; | |
- Point anchor; | |
- int maxWidth; | |
- Size wholeSize; | |
- Rect roi; | |
- int dx1, dx2; | |
- int rowBorderType, columnBorderType; | |
- vector<int> borderTab; | |
- int borderElemSize; | |
- vector<uchar> ringBuf; | |
- vector<uchar> srcRow; | |
- vector<uchar> constBorderValue; | |
- vector<uchar> constBorderRow; | |
- int bufStep, startY, startY0, endY, rowCount, dstY; | |
- vector<uchar*> rows; | |
- | |
- Ptr<BaseFilter> filter2D; | |
- Ptr<BaseRowFilter> rowFilter; | |
- Ptr<BaseColumnFilter> columnFilter; | |
-}; | |
- | |
-//! type of the kernel | |
-enum { KERNEL_GENERAL=0, KERNEL_SYMMETRICAL=1, KERNEL_ASYMMETRICAL=2, | |
- KERNEL_SMOOTH=4, KERNEL_INTEGER=8 }; | |
- | |
-//! returns type (one of KERNEL_*) of 1D or 2D kernel specified by its coefficients. | |
-CV_EXPORTS int getKernelType(InputArray kernel, Point anchor); | |
- | |
-//! returns the primitive row filter with the specified kernel | |
-CV_EXPORTS Ptr<BaseRowFilter> getLinearRowFilter(int srcType, int bufType, | |
- InputArray kernel, int anchor, | |
- int symmetryType); | |
- | |
-//! returns the primitive column filter with the specified kernel | |
-CV_EXPORTS Ptr<BaseColumnFilter> getLinearColumnFilter(int bufType, int dstType, | |
- InputArray kernel, int anchor, | |
- int symmetryType, double delta=0, | |
- int bits=0); | |
- | |
-//! returns 2D filter with the specified kernel | |
-CV_EXPORTS Ptr<BaseFilter> getLinearFilter(int srcType, int dstType, | |
- InputArray kernel, | |
- Point anchor=Point(-1,-1), | |
- double delta=0, int bits=0); | |
- | |
-//! returns the separable linear filter engine | |
-CV_EXPORTS Ptr<FilterEngine> createSeparableLinearFilter(int srcType, int dstType, | |
- InputArray rowKernel, InputArray columnKernel, | |
- Point _anchor=Point(-1,-1), double delta=0, | |
- int _rowBorderType=BORDER_DEFAULT, | |
- int _columnBorderType=-1, | |
- const Scalar& _borderValue=Scalar()); | |
- | |
-//! returns the non-separable linear filter engine | |
-CV_EXPORTS Ptr<FilterEngine> createLinearFilter(int srcType, int dstType, | |
- InputArray kernel, Point _anchor=Point(-1,-1), | |
- double delta=0, int _rowBorderType=BORDER_DEFAULT, | |
- int _columnBorderType=-1, const Scalar& _borderValue=Scalar()); | |
- | |
-//! returns the Gaussian kernel with the specified parameters | |
-CV_EXPORTS_W Mat getGaussianKernel( int ksize, double sigma, int ktype=CV_64F ); | |
- | |
-//! returns the Gaussian filter engine | |
-CV_EXPORTS Ptr<FilterEngine> createGaussianFilter( int type, Size ksize, | |
- double sigma1, double sigma2=0, | |
- int borderType=BORDER_DEFAULT); | |
-//! initializes kernels of the generalized Sobel operator | |
-CV_EXPORTS_W void getDerivKernels( OutputArray kx, OutputArray ky, | |
- int dx, int dy, int ksize, | |
- bool normalize=false, int ktype=CV_32F ); | |
-//! returns filter engine for the generalized Sobel operator | |
-CV_EXPORTS Ptr<FilterEngine> createDerivFilter( int srcType, int dstType, | |
- int dx, int dy, int ksize, | |
- int borderType=BORDER_DEFAULT ); | |
-//! returns horizontal 1D box filter | |
-CV_EXPORTS Ptr<BaseRowFilter> getRowSumFilter(int srcType, int sumType, | |
- int ksize, int anchor=-1); | |
-//! returns vertical 1D box filter | |
-CV_EXPORTS Ptr<BaseColumnFilter> getColumnSumFilter( int sumType, int dstType, | |
- int ksize, int anchor=-1, | |
- double scale=1); | |
-//! returns box filter engine | |
-CV_EXPORTS Ptr<FilterEngine> createBoxFilter( int srcType, int dstType, Size ksize, | |
- Point anchor=Point(-1,-1), | |
- bool normalize=true, | |
- int borderType=BORDER_DEFAULT); | |
- | |
-//! returns the Gabor kernel with the specified parameters | |
-CV_EXPORTS_W Mat getGaborKernel( Size ksize, double sigma, double theta, double lambd, | |
- double gamma, double psi=CV_PI*0.5, int ktype=CV_64F ); | |
- | |
-//! type of morphological operation | |
-enum { MORPH_ERODE=CV_MOP_ERODE, MORPH_DILATE=CV_MOP_DILATE, | |
- MORPH_OPEN=CV_MOP_OPEN, MORPH_CLOSE=CV_MOP_CLOSE, | |
- MORPH_GRADIENT=CV_MOP_GRADIENT, MORPH_TOPHAT=CV_MOP_TOPHAT, | |
- MORPH_BLACKHAT=CV_MOP_BLACKHAT }; | |
- | |
-//! returns horizontal 1D morphological filter | |
-CV_EXPORTS Ptr<BaseRowFilter> getMorphologyRowFilter(int op, int type, int ksize, int anchor=-1); | |
-//! returns vertical 1D morphological filter | |
-CV_EXPORTS Ptr<BaseColumnFilter> getMorphologyColumnFilter(int op, int type, int ksize, int anchor=-1); | |
-//! returns 2D morphological filter | |
-CV_EXPORTS Ptr<BaseFilter> getMorphologyFilter(int op, int type, InputArray kernel, | |
- Point anchor=Point(-1,-1)); | |
- | |
-//! returns "magic" border value for erosion and dilation. It is automatically transformed to Scalar::all(-DBL_MAX) for dilation. | |
-static inline Scalar morphologyDefaultBorderValue() { return Scalar::all(DBL_MAX); } | |
- | |
-//! returns morphological filter engine. Only MORPH_ERODE and MORPH_DILATE are supported. | |
-CV_EXPORTS Ptr<FilterEngine> createMorphologyFilter(int op, int type, InputArray kernel, | |
- Point anchor=Point(-1,-1), int _rowBorderType=BORDER_CONSTANT, | |
- int _columnBorderType=-1, | |
- const Scalar& _borderValue=morphologyDefaultBorderValue()); | |
- | |
-//! shape of the structuring element | |
-enum { MORPH_RECT=0, MORPH_CROSS=1, MORPH_ELLIPSE=2 }; | |
-//! returns structuring element of the specified shape and size | |
-CV_EXPORTS_W Mat getStructuringElement(int shape, Size ksize, Point anchor=Point(-1,-1)); | |
- | |
-template<> CV_EXPORTS void Ptr<IplConvKernel>::delete_obj(); | |
- | |
-//! copies 2D array to a larger destination array with extrapolation of the outer part of src using the specified border mode | |
-CV_EXPORTS_W void copyMakeBorder( InputArray src, OutputArray dst, | |
- int top, int bottom, int left, int right, | |
- int borderType, const Scalar& value=Scalar() ); | |
- | |
-//! smooths the image using median filter. | |
-CV_EXPORTS_W void medianBlur( InputArray src, OutputArray dst, int ksize ); | |
-//! smooths the image using Gaussian filter. | |
-CV_EXPORTS_W void GaussianBlur( InputArray src, | |
- OutputArray dst, Size ksize, | |
- double sigma1, double sigma2=0, | |
- int borderType=BORDER_DEFAULT ); | |
-//! smooths the image using bilateral filter | |
-CV_EXPORTS_W void bilateralFilter( InputArray src, OutputArray dst, int d, | |
- double sigmaColor, double sigmaSpace, | |
- int borderType=BORDER_DEFAULT ); | |
-//! smooths the image using the box filter. Each pixel is processed in O(1) time | |
-CV_EXPORTS_W void boxFilter( InputArray src, OutputArray dst, int ddepth, | |
- Size ksize, Point anchor=Point(-1,-1), | |
- bool normalize=true, | |
- int borderType=BORDER_DEFAULT ); | |
-//! a synonym for normalized box filter | |
-CV_EXPORTS_W void blur( InputArray src, OutputArray dst, | |
- Size ksize, Point anchor=Point(-1,-1), | |
- int borderType=BORDER_DEFAULT ); | |
- | |
-//! applies non-separable 2D linear filter to the image | |
-CV_EXPORTS_W void filter2D( InputArray src, OutputArray dst, int ddepth, | |
- InputArray kernel, Point anchor=Point(-1,-1), | |
- double delta=0, int borderType=BORDER_DEFAULT ); | |
- | |
-//! applies separable 2D linear filter to the image | |
-CV_EXPORTS_W void sepFilter2D( InputArray src, OutputArray dst, int ddepth, | |
- InputArray kernelX, InputArray kernelY, | |
- Point anchor=Point(-1,-1), | |
- double delta=0, int borderType=BORDER_DEFAULT ); | |
- | |
-//! applies generalized Sobel operator to the image | |
-CV_EXPORTS_W void Sobel( InputArray src, OutputArray dst, int ddepth, | |
- int dx, int dy, int ksize=3, | |
- double scale=1, double delta=0, | |
- int borderType=BORDER_DEFAULT ); | |
- | |
-//! applies the vertical or horizontal Scharr operator to the image | |
-CV_EXPORTS_W void Scharr( InputArray src, OutputArray dst, int ddepth, | |
- int dx, int dy, double scale=1, double delta=0, | |
- int borderType=BORDER_DEFAULT ); | |
- | |
-//! applies Laplacian operator to the image | |
-CV_EXPORTS_W void Laplacian( InputArray src, OutputArray dst, int ddepth, | |
- int ksize=1, double scale=1, double delta=0, | |
- int borderType=BORDER_DEFAULT ); | |
- | |
-//! applies Canny edge detector and produces the edge map. | |
-CV_EXPORTS_W void Canny( InputArray image, OutputArray edges, | |
- double threshold1, double threshold2, | |
- int apertureSize=3, bool L2gradient=false ); | |
- | |
-//! computes minimum eigen value of 2x2 derivative covariation matrix at each pixel - the cornerness criteria | |
-CV_EXPORTS_W void cornerMinEigenVal( InputArray src, OutputArray dst, | |
- int blockSize, int ksize=3, | |
- int borderType=BORDER_DEFAULT ); | |
- | |
-//! computes Harris cornerness criteria at each image pixel | |
-CV_EXPORTS_W void cornerHarris( InputArray src, OutputArray dst, int blockSize, | |
- int ksize, double k, | |
- int borderType=BORDER_DEFAULT ); | |
- | |
-// low-level function for computing eigenvalues and eigenvectors of 2x2 matrices | |
-CV_EXPORTS void eigen2x2( const float* a, float* e, int n ); | |
- | |
-//! computes both eigenvalues and the eigenvectors of 2x2 derivative covariation matrix at each pixel. The output is stored as 6-channel matrix. | |
-CV_EXPORTS_W void cornerEigenValsAndVecs( InputArray src, OutputArray dst, | |
- int blockSize, int ksize, | |
- int borderType=BORDER_DEFAULT ); | |
- | |
-//! computes another complex cornerness criteria at each pixel | |
-CV_EXPORTS_W void preCornerDetect( InputArray src, OutputArray dst, int ksize, | |
- int borderType=BORDER_DEFAULT ); | |
- | |
-//! adjusts the corner locations with sub-pixel accuracy to maximize the certain cornerness criteria | |
-CV_EXPORTS_W void cornerSubPix( InputArray image, InputOutputArray corners, | |
- Size winSize, Size zeroZone, | |
- TermCriteria criteria ); | |
- | |
-//! finds the strong enough corners where the cornerMinEigenVal() or cornerHarris() report the local maxima | |
-CV_EXPORTS_W void goodFeaturesToTrack( InputArray image, OutputArray corners, | |
- int maxCorners, double qualityLevel, double minDistance, | |
- InputArray mask=noArray(), int blockSize=3, | |
- bool useHarrisDetector=false, double k=0.04 ); | |
- | |
-//! finds lines in the black-n-white image using the standard or pyramid Hough transform | |
-CV_EXPORTS_W void HoughLines( InputArray image, OutputArray lines, | |
- double rho, double theta, int threshold, | |
- double srn=0, double stn=0 ); | |
- | |
-//! finds line segments in the black-n-white image using probabalistic Hough transform | |
-CV_EXPORTS_W void HoughLinesP( InputArray image, OutputArray lines, | |
- double rho, double theta, int threshold, | |
- double minLineLength=0, double maxLineGap=0 ); | |
- | |
-//! finds circles in the grayscale image using 2+1 gradient Hough transform | |
-CV_EXPORTS_W void HoughCircles( InputArray image, OutputArray circles, | |
- int method, double dp, double minDist, | |
- double param1=100, double param2=100, | |
- int minRadius=0, int maxRadius=0 ); | |
- | |
-//! erodes the image (applies the local minimum operator) | |
-CV_EXPORTS_W void erode( InputArray src, OutputArray dst, InputArray kernel, | |
- Point anchor=Point(-1,-1), int iterations=1, | |
- int borderType=BORDER_CONSTANT, | |
- const Scalar& borderValue=morphologyDefaultBorderValue() ); | |
- | |
-//! dilates the image (applies the local maximum operator) | |
-CV_EXPORTS_W void dilate( InputArray src, OutputArray dst, InputArray kernel, | |
- Point anchor=Point(-1,-1), int iterations=1, | |
- int borderType=BORDER_CONSTANT, | |
- const Scalar& borderValue=morphologyDefaultBorderValue() ); | |
- | |
-//! applies an advanced morphological operation to the image | |
-CV_EXPORTS_W void morphologyEx( InputArray src, OutputArray dst, | |
- int op, InputArray kernel, | |
- Point anchor=Point(-1,-1), int iterations=1, | |
- int borderType=BORDER_CONSTANT, | |
- const Scalar& borderValue=morphologyDefaultBorderValue() ); | |
- | |
-//! interpolation algorithm | |
-enum | |
-{ | |
- INTER_NEAREST=CV_INTER_NN, //!< nearest neighbor interpolation | |
- INTER_LINEAR=CV_INTER_LINEAR, //!< bilinear interpolation | |
- INTER_CUBIC=CV_INTER_CUBIC, //!< bicubic interpolation | |
- INTER_AREA=CV_INTER_AREA, //!< area-based (or super) interpolation | |
- INTER_LANCZOS4=CV_INTER_LANCZOS4, //!< Lanczos interpolation over 8x8 neighborhood | |
- INTER_MAX=7, | |
- WARP_INVERSE_MAP=CV_WARP_INVERSE_MAP | |
-}; | |
- | |
-//! resizes the image | |
-CV_EXPORTS_W void resize( InputArray src, OutputArray dst, | |
- Size dsize, double fx=0, double fy=0, | |
- int interpolation=INTER_LINEAR ); | |
- | |
-//! warps the image using affine transformation | |
-CV_EXPORTS_W void warpAffine( InputArray src, OutputArray dst, | |
- InputArray M, Size dsize, | |
- int flags=INTER_LINEAR, | |
- int borderMode=BORDER_CONSTANT, | |
- const Scalar& borderValue=Scalar()); | |
- | |
-//! warps the image using perspective transformation | |
-CV_EXPORTS_W void warpPerspective( InputArray src, OutputArray dst, | |
- InputArray M, Size dsize, | |
- int flags=INTER_LINEAR, | |
- int borderMode=BORDER_CONSTANT, | |
- const Scalar& borderValue=Scalar()); | |
- | |
-enum | |
-{ | |
- INTER_BITS=5, INTER_BITS2=INTER_BITS*2, | |
- INTER_TAB_SIZE=(1<<INTER_BITS), | |
- INTER_TAB_SIZE2=INTER_TAB_SIZE*INTER_TAB_SIZE | |
-}; | |
- | |
-//! warps the image using the precomputed maps. The maps are stored in either floating-point or integer fixed-point format | |
-CV_EXPORTS_W void remap( InputArray src, OutputArray dst, | |
- InputArray map1, InputArray map2, | |
- int interpolation, int borderMode=BORDER_CONSTANT, | |
- const Scalar& borderValue=Scalar()); | |
- | |
-//! converts maps for remap from floating-point to fixed-point format or backwards | |
-CV_EXPORTS_W void convertMaps( InputArray map1, InputArray map2, | |
- OutputArray dstmap1, OutputArray dstmap2, | |
- int dstmap1type, bool nninterpolation=false ); | |
- | |
-//! returns 2x3 affine transformation matrix for the planar rotation. | |
-CV_EXPORTS_W Mat getRotationMatrix2D( Point2f center, double angle, double scale ); | |
-//! returns 3x3 perspective transformation for the corresponding 4 point pairs. | |
-CV_EXPORTS Mat getPerspectiveTransform( const Point2f src[], const Point2f dst[] ); | |
-//! returns 2x3 affine transformation for the corresponding 3 point pairs. | |
-CV_EXPORTS Mat getAffineTransform( const Point2f src[], const Point2f dst[] ); | |
-//! computes 2x3 affine transformation matrix that is inverse to the specified 2x3 affine transformation. | |
-CV_EXPORTS_W void invertAffineTransform( InputArray M, OutputArray iM ); | |
- | |
-CV_EXPORTS_W Mat getPerspectiveTransform( InputArray src, InputArray dst ); | |
-CV_EXPORTS_W Mat getAffineTransform( InputArray src, InputArray dst ); | |
- | |
-//! extracts rectangle from the image at sub-pixel location | |
-CV_EXPORTS_W void getRectSubPix( InputArray image, Size patchSize, | |
- Point2f center, OutputArray patch, int patchType=-1 ); | |
- | |
-//! computes the integral image | |
-CV_EXPORTS_W void integral( InputArray src, OutputArray sum, int sdepth=-1 ); | |
- | |
-//! computes the integral image and integral for the squared image | |
-CV_EXPORTS_AS(integral2) void integral( InputArray src, OutputArray sum, | |
- OutputArray sqsum, int sdepth=-1 ); | |
-//! computes the integral image, integral for the squared image and the tilted integral image | |
-CV_EXPORTS_AS(integral3) void integral( InputArray src, OutputArray sum, | |
- OutputArray sqsum, OutputArray tilted, | |
- int sdepth=-1 ); | |
- | |
-//! adds image to the accumulator (dst += src). Unlike cv::add, dst and src can have different types. | |
-CV_EXPORTS_W void accumulate( InputArray src, InputOutputArray dst, | |
- InputArray mask=noArray() ); | |
-//! adds squared src image to the accumulator (dst += src*src). | |
-CV_EXPORTS_W void accumulateSquare( InputArray src, InputOutputArray dst, | |
- InputArray mask=noArray() ); | |
-//! adds product of the 2 images to the accumulator (dst += src1*src2). | |
-CV_EXPORTS_W void accumulateProduct( InputArray src1, InputArray src2, | |
- InputOutputArray dst, InputArray mask=noArray() ); | |
-//! updates the running average (dst = dst*(1-alpha) + src*alpha) | |
-CV_EXPORTS_W void accumulateWeighted( InputArray src, InputOutputArray dst, | |
- double alpha, InputArray mask=noArray() ); | |
- | |
-//! computes PSNR image/video quality metric | |
-CV_EXPORTS_W double PSNR(InputArray src1, InputArray src2); | |
- | |
-CV_EXPORTS_W Point2d phaseCorrelate(InputArray src1, InputArray src2, InputArray window = noArray()); | |
-CV_EXPORTS_W void createHanningWindow(OutputArray dst, Size winSize, int type); | |
- | |
-//! type of the threshold operation | |
-enum { THRESH_BINARY=CV_THRESH_BINARY, THRESH_BINARY_INV=CV_THRESH_BINARY_INV, | |
- THRESH_TRUNC=CV_THRESH_TRUNC, THRESH_TOZERO=CV_THRESH_TOZERO, | |
- THRESH_TOZERO_INV=CV_THRESH_TOZERO_INV, THRESH_MASK=CV_THRESH_MASK, | |
- THRESH_OTSU=CV_THRESH_OTSU }; | |
- | |
-//! applies fixed threshold to the image | |
-CV_EXPORTS_W double threshold( InputArray src, OutputArray dst, | |
- double thresh, double maxval, int type ); | |
- | |
-//! adaptive threshold algorithm | |
-enum { ADAPTIVE_THRESH_MEAN_C=0, ADAPTIVE_THRESH_GAUSSIAN_C=1 }; | |
- | |
-//! applies variable (adaptive) threshold to the image | |
-CV_EXPORTS_W void adaptiveThreshold( InputArray src, OutputArray dst, | |
- double maxValue, int adaptiveMethod, | |
- int thresholdType, int blockSize, double C ); | |
- | |
-//! smooths and downsamples the image | |
-CV_EXPORTS_W void pyrDown( InputArray src, OutputArray dst, | |
- const Size& dstsize=Size(), int borderType=BORDER_DEFAULT ); | |
-//! upsamples and smoothes the image | |
-CV_EXPORTS_W void pyrUp( InputArray src, OutputArray dst, | |
- const Size& dstsize=Size(), int borderType=BORDER_DEFAULT ); | |
- | |
-//! builds the gaussian pyramid using pyrDown() as a basic operation | |
-CV_EXPORTS void buildPyramid( InputArray src, OutputArrayOfArrays dst, | |
- int maxlevel, int borderType=BORDER_DEFAULT ); | |
- | |
-//! corrects lens distortion for the given camera matrix and distortion coefficients | |
-CV_EXPORTS_W void undistort( InputArray src, OutputArray dst, | |
- InputArray cameraMatrix, | |
- InputArray distCoeffs, | |
- InputArray newCameraMatrix=noArray() ); | |
- | |
-//! initializes maps for cv::remap() to correct lens distortion and optionally rectify the image | |
-CV_EXPORTS_W void initUndistortRectifyMap( InputArray cameraMatrix, InputArray distCoeffs, | |
- InputArray R, InputArray newCameraMatrix, | |
- Size size, int m1type, OutputArray map1, OutputArray map2 ); | |
- | |
-enum | |
-{ | |
- PROJ_SPHERICAL_ORTHO = 0, | |
- PROJ_SPHERICAL_EQRECT = 1 | |
-}; | |
- | |
-//! initializes maps for cv::remap() for wide-angle | |
-CV_EXPORTS_W float initWideAngleProjMap( InputArray cameraMatrix, InputArray distCoeffs, | |
- Size imageSize, int destImageWidth, | |
- int m1type, OutputArray map1, OutputArray map2, | |
- int projType=PROJ_SPHERICAL_EQRECT, double alpha=0); | |
- | |
-//! returns the default new camera matrix (by default it is the same as cameraMatrix unless centerPricipalPoint=true) | |
-CV_EXPORTS_W Mat getDefaultNewCameraMatrix( InputArray cameraMatrix, Size imgsize=Size(), | |
- bool centerPrincipalPoint=false ); | |
- | |
-//! returns points' coordinates after lens distortion correction | |
-CV_EXPORTS_W void undistortPoints( InputArray src, OutputArray dst, | |
- InputArray cameraMatrix, InputArray distCoeffs, | |
- InputArray R=noArray(), InputArray P=noArray()); | |
- | |
-template<> CV_EXPORTS void Ptr<CvHistogram>::delete_obj(); | |
- | |
-//! computes the joint dense histogram for a set of images. | |
-CV_EXPORTS void calcHist( const Mat* images, int nimages, | |
- const int* channels, InputArray mask, | |
- OutputArray hist, int dims, const int* histSize, | |
- const float** ranges, bool uniform=true, bool accumulate=false ); | |
- | |
-//! computes the joint sparse histogram for a set of images. | |
-CV_EXPORTS void calcHist( const Mat* images, int nimages, | |
- const int* channels, InputArray mask, | |
- SparseMat& hist, int dims, | |
- const int* histSize, const float** ranges, | |
- bool uniform=true, bool accumulate=false ); | |
- | |
-CV_EXPORTS_W void calcHist( InputArrayOfArrays images, | |
- const vector<int>& channels, | |
- InputArray mask, OutputArray hist, | |
- const vector<int>& histSize, | |
- const vector<float>& ranges, | |
- bool accumulate=false ); | |
- | |
-//! computes back projection for the set of images | |
-CV_EXPORTS void calcBackProject( const Mat* images, int nimages, | |
- const int* channels, InputArray hist, | |
- OutputArray backProject, const float** ranges, | |
- double scale=1, bool uniform=true ); | |
- | |
-//! computes back projection for the set of images | |
-CV_EXPORTS void calcBackProject( const Mat* images, int nimages, | |
- const int* channels, const SparseMat& hist, | |
- OutputArray backProject, const float** ranges, | |
- double scale=1, bool uniform=true ); | |
- | |
-CV_EXPORTS_W void calcBackProject( InputArrayOfArrays images, const vector<int>& channels, | |
- InputArray hist, OutputArray dst, | |
- const vector<float>& ranges, | |
- double scale ); | |
- | |
-/*CV_EXPORTS void calcBackProjectPatch( const Mat* images, int nimages, const int* channels, | |
- InputArray hist, OutputArray dst, Size patchSize, | |
- int method, double factor=1 ); | |
- | |
-CV_EXPORTS_W void calcBackProjectPatch( InputArrayOfArrays images, const vector<int>& channels, | |
- InputArray hist, OutputArray dst, Size patchSize, | |
- int method, double factor=1 );*/ | |
- | |
-//! compares two histograms stored in dense arrays | |
-CV_EXPORTS_W double compareHist( InputArray H1, InputArray H2, int method ); | |
- | |
-//! compares two histograms stored in sparse arrays | |
-CV_EXPORTS double compareHist( const SparseMat& H1, const SparseMat& H2, int method ); | |
- | |
-//! normalizes the grayscale image brightness and contrast by normalizing its histogram | |
-CV_EXPORTS_W void equalizeHist( InputArray src, OutputArray dst ); | |
- | |
-CV_EXPORTS float EMD( InputArray signature1, InputArray signature2, | |
- int distType, InputArray cost=noArray(), | |
- float* lowerBound=0, OutputArray flow=noArray() ); | |
- | |
-//! segments the image using watershed algorithm | |
-CV_EXPORTS_W void watershed( InputArray image, InputOutputArray markers ); | |
- | |
-//! filters image using meanshift algorithm | |
-CV_EXPORTS_W void pyrMeanShiftFiltering( InputArray src, OutputArray dst, | |
- double sp, double sr, int maxLevel=1, | |
- TermCriteria termcrit=TermCriteria( | |
- TermCriteria::MAX_ITER+TermCriteria::EPS,5,1) ); | |
- | |
-//! class of the pixel in GrabCut algorithm | |
-enum | |
-{ | |
- GC_BGD = 0, //!< background | |
- GC_FGD = 1, //!< foreground | |
- GC_PR_BGD = 2, //!< most probably background | |
- GC_PR_FGD = 3 //!< most probably foreground | |
-}; | |
- | |
-//! GrabCut algorithm flags | |
-enum | |
-{ | |
- GC_INIT_WITH_RECT = 0, | |
- GC_INIT_WITH_MASK = 1, | |
- GC_EVAL = 2 | |
-}; | |
- | |
-//! segments the image using GrabCut algorithm | |
-CV_EXPORTS_W void grabCut( InputArray img, InputOutputArray mask, Rect rect, | |
- InputOutputArray bgdModel, InputOutputArray fgdModel, | |
- int iterCount, int mode = GC_EVAL ); | |
- | |
-enum | |
-{ | |
- DIST_LABEL_CCOMP = 0, | |
- DIST_LABEL_PIXEL = 1 | |
-}; | |
- | |
-//! builds the discrete Voronoi diagram | |
-CV_EXPORTS_AS(distanceTransformWithLabels) void distanceTransform( InputArray src, OutputArray dst, | |
- OutputArray labels, int distanceType, int maskSize, | |
- int labelType=DIST_LABEL_CCOMP ); | |
- | |
-//! computes the distance transform map | |
-CV_EXPORTS_W void distanceTransform( InputArray src, OutputArray dst, | |
- int distanceType, int maskSize ); | |
- | |
-enum { FLOODFILL_FIXED_RANGE = 1 << 16, FLOODFILL_MASK_ONLY = 1 << 17 }; | |
- | |
-//! fills the semi-uniform image region starting from the specified seed point | |
-CV_EXPORTS int floodFill( InputOutputArray image, | |
- Point seedPoint, Scalar newVal, CV_OUT Rect* rect=0, | |
- Scalar loDiff=Scalar(), Scalar upDiff=Scalar(), | |
- int flags=4 ); | |
- | |
-//! fills the semi-uniform image region and/or the mask starting from the specified seed point | |
-CV_EXPORTS_W int floodFill( InputOutputArray image, InputOutputArray mask, | |
- Point seedPoint, Scalar newVal, CV_OUT Rect* rect=0, | |
- Scalar loDiff=Scalar(), Scalar upDiff=Scalar(), | |
- int flags=4 ); | |
- | |
- | |
-enum | |
-{ | |
- COLOR_BGR2BGRA =0, | |
- COLOR_RGB2RGBA =COLOR_BGR2BGRA, | |
- | |
- COLOR_BGRA2BGR =1, | |
- COLOR_RGBA2RGB =COLOR_BGRA2BGR, | |
- | |
- COLOR_BGR2RGBA =2, | |
- COLOR_RGB2BGRA =COLOR_BGR2RGBA, | |
- | |
- COLOR_RGBA2BGR =3, | |
- COLOR_BGRA2RGB =COLOR_RGBA2BGR, | |
- | |
- COLOR_BGR2RGB =4, | |
- COLOR_RGB2BGR =COLOR_BGR2RGB, | |
- | |
- COLOR_BGRA2RGBA =5, | |
- COLOR_RGBA2BGRA =COLOR_BGRA2RGBA, | |
- | |
- COLOR_BGR2GRAY =6, | |
- COLOR_RGB2GRAY =7, | |
- COLOR_GRAY2BGR =8, | |
- COLOR_GRAY2RGB =COLOR_GRAY2BGR, | |
- COLOR_GRAY2BGRA =9, | |
- COLOR_GRAY2RGBA =COLOR_GRAY2BGRA, | |
- COLOR_BGRA2GRAY =10, | |
- COLOR_RGBA2GRAY =11, | |
- | |
- COLOR_BGR2BGR565 =12, | |
- COLOR_RGB2BGR565 =13, | |
- COLOR_BGR5652BGR =14, | |
- COLOR_BGR5652RGB =15, | |
- COLOR_BGRA2BGR565 =16, | |
- COLOR_RGBA2BGR565 =17, | |
- COLOR_BGR5652BGRA =18, | |
- COLOR_BGR5652RGBA =19, | |
- | |
- COLOR_GRAY2BGR565 =20, | |
- COLOR_BGR5652GRAY =21, | |
- | |
- COLOR_BGR2BGR555 =22, | |
- COLOR_RGB2BGR555 =23, | |
- COLOR_BGR5552BGR =24, | |
- COLOR_BGR5552RGB =25, | |
- COLOR_BGRA2BGR555 =26, | |
- COLOR_RGBA2BGR555 =27, | |
- COLOR_BGR5552BGRA =28, | |
- COLOR_BGR5552RGBA =29, | |
- | |
- COLOR_GRAY2BGR555 =30, | |
- COLOR_BGR5552GRAY =31, | |
- | |
- COLOR_BGR2XYZ =32, | |
- COLOR_RGB2XYZ =33, | |
- COLOR_XYZ2BGR =34, | |
- COLOR_XYZ2RGB =35, | |
- | |
- COLOR_BGR2YCrCb =36, | |
- COLOR_RGB2YCrCb =37, | |
- COLOR_YCrCb2BGR =38, | |
- COLOR_YCrCb2RGB =39, | |
- | |
- COLOR_BGR2HSV =40, | |
- COLOR_RGB2HSV =41, | |
- | |
- COLOR_BGR2Lab =44, | |
- COLOR_RGB2Lab =45, | |
- | |
- COLOR_BayerBG2BGR =46, | |
- COLOR_BayerGB2BGR =47, | |
- COLOR_BayerRG2BGR =48, | |
- COLOR_BayerGR2BGR =49, | |
- | |
- COLOR_BayerBG2RGB =COLOR_BayerRG2BGR, | |
- COLOR_BayerGB2RGB =COLOR_BayerGR2BGR, | |
- COLOR_BayerRG2RGB =COLOR_BayerBG2BGR, | |
- COLOR_BayerGR2RGB =COLOR_BayerGB2BGR, | |
- | |
- COLOR_BGR2Luv =50, | |
- COLOR_RGB2Luv =51, | |
- COLOR_BGR2HLS =52, | |
- COLOR_RGB2HLS =53, | |
- | |
- COLOR_HSV2BGR =54, | |
- COLOR_HSV2RGB =55, | |
- | |
- COLOR_Lab2BGR =56, | |
- COLOR_Lab2RGB =57, | |
- COLOR_Luv2BGR =58, | |
- COLOR_Luv2RGB =59, | |
- COLOR_HLS2BGR =60, | |
- COLOR_HLS2RGB =61, | |
- | |
- COLOR_BayerBG2BGR_VNG =62, | |
- COLOR_BayerGB2BGR_VNG =63, | |
- COLOR_BayerRG2BGR_VNG =64, | |
- COLOR_BayerGR2BGR_VNG =65, | |
- | |
- COLOR_BayerBG2RGB_VNG =COLOR_BayerRG2BGR_VNG, | |
- COLOR_BayerGB2RGB_VNG =COLOR_BayerGR2BGR_VNG, | |
- COLOR_BayerRG2RGB_VNG =COLOR_BayerBG2BGR_VNG, | |
- COLOR_BayerGR2RGB_VNG =COLOR_BayerGB2BGR_VNG, | |
- | |
- COLOR_BGR2HSV_FULL = 66, | |
- COLOR_RGB2HSV_FULL = 67, | |
- COLOR_BGR2HLS_FULL = 68, | |
- COLOR_RGB2HLS_FULL = 69, | |
- | |
- COLOR_HSV2BGR_FULL = 70, | |
- COLOR_HSV2RGB_FULL = 71, | |
- COLOR_HLS2BGR_FULL = 72, | |
- COLOR_HLS2RGB_FULL = 73, | |
- | |
- COLOR_LBGR2Lab = 74, | |
- COLOR_LRGB2Lab = 75, | |
- COLOR_LBGR2Luv = 76, | |
- COLOR_LRGB2Luv = 77, | |
- | |
- COLOR_Lab2LBGR = 78, | |
- COLOR_Lab2LRGB = 79, | |
- COLOR_Luv2LBGR = 80, | |
- COLOR_Luv2LRGB = 81, | |
- | |
- COLOR_BGR2YUV = 82, | |
- COLOR_RGB2YUV = 83, | |
- COLOR_YUV2BGR = 84, | |
- COLOR_YUV2RGB = 85, | |
- | |
- COLOR_BayerBG2GRAY = 86, | |
- COLOR_BayerGB2GRAY = 87, | |
- COLOR_BayerRG2GRAY = 88, | |
- COLOR_BayerGR2GRAY = 89, | |
- | |
- //YUV 4:2:0 formats family | |
- COLOR_YUV2RGB_NV12 = 90, | |
- COLOR_YUV2BGR_NV12 = 91, | |
- COLOR_YUV2RGB_NV21 = 92, | |
- COLOR_YUV2BGR_NV21 = 93, | |
- COLOR_YUV420sp2RGB = COLOR_YUV2RGB_NV21, | |
- COLOR_YUV420sp2BGR = COLOR_YUV2BGR_NV21, | |
- | |
- COLOR_YUV2RGBA_NV12 = 94, | |
- COLOR_YUV2BGRA_NV12 = 95, | |
- COLOR_YUV2RGBA_NV21 = 96, | |
- COLOR_YUV2BGRA_NV21 = 97, | |
- COLOR_YUV420sp2RGBA = COLOR_YUV2RGBA_NV21, | |
- COLOR_YUV420sp2BGRA = COLOR_YUV2BGRA_NV21, | |
- | |
- COLOR_YUV2RGB_YV12 = 98, | |
- COLOR_YUV2BGR_YV12 = 99, | |
- COLOR_YUV2RGB_IYUV = 100, | |
- COLOR_YUV2BGR_IYUV = 101, | |
- COLOR_YUV2RGB_I420 = COLOR_YUV2RGB_IYUV, | |
- COLOR_YUV2BGR_I420 = COLOR_YUV2BGR_IYUV, | |
- COLOR_YUV420p2RGB = COLOR_YUV2RGB_YV12, | |
- COLOR_YUV420p2BGR = COLOR_YUV2BGR_YV12, | |
- | |
- COLOR_YUV2RGBA_YV12 = 102, | |
- COLOR_YUV2BGRA_YV12 = 103, | |
- COLOR_YUV2RGBA_IYUV = 104, | |
- COLOR_YUV2BGRA_IYUV = 105, | |
- COLOR_YUV2RGBA_I420 = COLOR_YUV2RGBA_IYUV, | |
- COLOR_YUV2BGRA_I420 = COLOR_YUV2BGRA_IYUV, | |
- COLOR_YUV420p2RGBA = COLOR_YUV2RGBA_YV12, | |
- COLOR_YUV420p2BGRA = COLOR_YUV2BGRA_YV12, | |
- | |
- COLOR_YUV2GRAY_420 = 106, | |
- COLOR_YUV2GRAY_NV21 = COLOR_YUV2GRAY_420, | |
- COLOR_YUV2GRAY_NV12 = COLOR_YUV2GRAY_420, | |
- COLOR_YUV2GRAY_YV12 = COLOR_YUV2GRAY_420, | |
- COLOR_YUV2GRAY_IYUV = COLOR_YUV2GRAY_420, | |
- COLOR_YUV2GRAY_I420 = COLOR_YUV2GRAY_420, | |
- COLOR_YUV420sp2GRAY = COLOR_YUV2GRAY_420, | |
- COLOR_YUV420p2GRAY = COLOR_YUV2GRAY_420, | |
- | |
- //YUV 4:2:2 formats family | |
- COLOR_YUV2RGB_UYVY = 107, | |
- COLOR_YUV2BGR_UYVY = 108, | |
- //COLOR_YUV2RGB_VYUY = 109, | |
- //COLOR_YUV2BGR_VYUY = 110, | |
- COLOR_YUV2RGB_Y422 = COLOR_YUV2RGB_UYVY, | |
- COLOR_YUV2BGR_Y422 = COLOR_YUV2BGR_UYVY, | |
- COLOR_YUV2RGB_UYNV = COLOR_YUV2RGB_UYVY, | |
- COLOR_YUV2BGR_UYNV = COLOR_YUV2BGR_UYVY, | |
- | |
- COLOR_YUV2RGBA_UYVY = 111, | |
- COLOR_YUV2BGRA_UYVY = 112, | |
- //COLOR_YUV2RGBA_VYUY = 113, | |
- //COLOR_YUV2BGRA_VYUY = 114, | |
- COLOR_YUV2RGBA_Y422 = COLOR_YUV2RGBA_UYVY, | |
- COLOR_YUV2BGRA_Y422 = COLOR_YUV2BGRA_UYVY, | |
- COLOR_YUV2RGBA_UYNV = COLOR_YUV2RGBA_UYVY, | |
- COLOR_YUV2BGRA_UYNV = COLOR_YUV2BGRA_UYVY, | |
- | |
- COLOR_YUV2RGB_YUY2 = 115, | |
- COLOR_YUV2BGR_YUY2 = 116, | |
- COLOR_YUV2RGB_YVYU = 117, | |
- COLOR_YUV2BGR_YVYU = 118, | |
- COLOR_YUV2RGB_YUYV = COLOR_YUV2RGB_YUY2, | |
- COLOR_YUV2BGR_YUYV = COLOR_YUV2BGR_YUY2, | |
- COLOR_YUV2RGB_YUNV = COLOR_YUV2RGB_YUY2, | |
- COLOR_YUV2BGR_YUNV = COLOR_YUV2BGR_YUY2, | |
- | |
- COLOR_YUV2RGBA_YUY2 = 119, | |
- COLOR_YUV2BGRA_YUY2 = 120, | |
- COLOR_YUV2RGBA_YVYU = 121, | |
- COLOR_YUV2BGRA_YVYU = 122, | |
- COLOR_YUV2RGBA_YUYV = COLOR_YUV2RGBA_YUY2, | |
- COLOR_YUV2BGRA_YUYV = COLOR_YUV2BGRA_YUY2, | |
- COLOR_YUV2RGBA_YUNV = COLOR_YUV2RGBA_YUY2, | |
- COLOR_YUV2BGRA_YUNV = COLOR_YUV2BGRA_YUY2, | |
- | |
- COLOR_YUV2GRAY_UYVY = 123, | |
- COLOR_YUV2GRAY_YUY2 = 124, | |
- //COLOR_YUV2GRAY_VYUY = COLOR_YUV2GRAY_UYVY, | |
- COLOR_YUV2GRAY_Y422 = COLOR_YUV2GRAY_UYVY, | |
- COLOR_YUV2GRAY_UYNV = COLOR_YUV2GRAY_UYVY, | |
- COLOR_YUV2GRAY_YVYU = COLOR_YUV2GRAY_YUY2, | |
- COLOR_YUV2GRAY_YUYV = COLOR_YUV2GRAY_YUY2, | |
- COLOR_YUV2GRAY_YUNV = COLOR_YUV2GRAY_YUY2, | |
- | |
- COLOR_COLORCVT_MAX = 125 | |
-}; | |
- | |
- | |
-//! converts image from one color space to another | |
-CV_EXPORTS_W void cvtColor( InputArray src, OutputArray dst, int code, int dstCn=0 ); | |
- | |
-//! raster image moments | |
-class CV_EXPORTS_W_MAP Moments | |
-{ | |
-public: | |
- //! the default constructor | |
- Moments(); | |
- //! the full constructor | |
- Moments(double m00, double m10, double m01, double m20, double m11, | |
- double m02, double m30, double m21, double m12, double m03 ); | |
- //! the conversion from CvMoments | |
- Moments( const CvMoments& moments ); | |
- //! the conversion to CvMoments | |
- operator CvMoments() const; | |
- | |
- //! spatial moments | |
- CV_PROP_RW double m00, m10, m01, m20, m11, m02, m30, m21, m12, m03; | |
- //! central moments | |
- CV_PROP_RW double mu20, mu11, mu02, mu30, mu21, mu12, mu03; | |
- //! central normalized moments | |
- CV_PROP_RW double nu20, nu11, nu02, nu30, nu21, nu12, nu03; | |
-}; | |
- | |
-//! computes moments of the rasterized shape or a vector of points | |
-CV_EXPORTS_W Moments moments( InputArray array, bool binaryImage=false ); | |
- | |
-//! computes 7 Hu invariants from the moments | |
-CV_EXPORTS void HuMoments( const Moments& moments, double hu[7] ); | |
-CV_EXPORTS_W void HuMoments( const Moments& m, CV_OUT OutputArray hu ); | |
- | |
-//! type of the template matching operation | |
-enum { TM_SQDIFF=0, TM_SQDIFF_NORMED=1, TM_CCORR=2, TM_CCORR_NORMED=3, TM_CCOEFF=4, TM_CCOEFF_NORMED=5 }; | |
- | |
-//! computes the proximity map for the raster template and the image where the template is searched for | |
-CV_EXPORTS_W void matchTemplate( InputArray image, InputArray templ, | |
- OutputArray result, int method ); | |
- | |
-//! mode of the contour retrieval algorithm | |
-enum | |
-{ | |
- RETR_EXTERNAL=CV_RETR_EXTERNAL, //!< retrieve only the most external (top-level) contours | |
- RETR_LIST=CV_RETR_LIST, //!< retrieve all the contours without any hierarchical information | |
- RETR_CCOMP=CV_RETR_CCOMP, //!< retrieve the connected components (that can possibly be nested) | |
- RETR_TREE=CV_RETR_TREE, //!< retrieve all the contours and the whole hierarchy | |
- RETR_FLOODFILL=CV_RETR_FLOODFILL | |
-}; | |
- | |
-//! the contour approximation algorithm | |
-enum | |
-{ | |
- CHAIN_APPROX_NONE=CV_CHAIN_APPROX_NONE, | |
- CHAIN_APPROX_SIMPLE=CV_CHAIN_APPROX_SIMPLE, | |
- CHAIN_APPROX_TC89_L1=CV_CHAIN_APPROX_TC89_L1, | |
- CHAIN_APPROX_TC89_KCOS=CV_CHAIN_APPROX_TC89_KCOS | |
-}; | |
- | |
-//! retrieves contours and the hierarchical information from black-n-white image. | |
-CV_EXPORTS_W void findContours( InputOutputArray image, OutputArrayOfArrays contours, | |
- OutputArray hierarchy, int mode, | |
- int method, Point offset=Point()); | |
- | |
-//! retrieves contours from black-n-white image. | |
-CV_EXPORTS void findContours( InputOutputArray image, OutputArrayOfArrays contours, | |
- int mode, int method, Point offset=Point()); | |
- | |
-//! draws contours in the image | |
-CV_EXPORTS_W void drawContours( InputOutputArray image, InputArrayOfArrays contours, | |
- int contourIdx, const Scalar& color, | |
- int thickness=1, int lineType=8, | |
- InputArray hierarchy=noArray(), | |
- int maxLevel=INT_MAX, Point offset=Point() ); | |
- | |
-//! approximates contour or a curve using Douglas-Peucker algorithm | |
-CV_EXPORTS_W void approxPolyDP( InputArray curve, | |
- OutputArray approxCurve, | |
- double epsilon, bool closed ); | |
- | |
-//! computes the contour perimeter (closed=true) or a curve length | |
-CV_EXPORTS_W double arcLength( InputArray curve, bool closed ); | |
-//! computes the bounding rectangle for a contour | |
-CV_EXPORTS_W Rect boundingRect( InputArray points ); | |
-//! computes the contour area | |
-CV_EXPORTS_W double contourArea( InputArray contour, bool oriented=false ); | |
-//! computes the minimal rotated rectangle for a set of points | |
-CV_EXPORTS_W RotatedRect minAreaRect( InputArray points ); | |
-//! computes the minimal enclosing circle for a set of points | |
-CV_EXPORTS_W void minEnclosingCircle( InputArray points, | |
- CV_OUT Point2f& center, CV_OUT float& radius ); | |
-//! matches two contours using one of the available algorithms | |
-CV_EXPORTS_W double matchShapes( InputArray contour1, InputArray contour2, | |
- int method, double parameter ); | |
-//! computes convex hull for a set of 2D points. | |
-CV_EXPORTS_W void convexHull( InputArray points, OutputArray hull, | |
- bool clockwise=false, bool returnPoints=true ); | |
-//! computes the contour convexity defects | |
-CV_EXPORTS_W void convexityDefects( InputArray contour, InputArray convexhull, OutputArray convexityDefects ); | |
- | |
-//! returns true if the contour is convex. Does not support contours with self-intersection | |
-CV_EXPORTS_W bool isContourConvex( InputArray contour ); | |
- | |
-//! finds intersection of two convex polygons | |
-CV_EXPORTS_W float intersectConvexConvex( InputArray _p1, InputArray _p2, | |
- OutputArray _p12, bool handleNested=true ); | |
- | |
-//! fits ellipse to the set of 2D points | |
-CV_EXPORTS_W RotatedRect fitEllipse( InputArray points ); | |
- | |
-//! fits line to the set of 2D points using M-estimator algorithm | |
-CV_EXPORTS_W void fitLine( InputArray points, OutputArray line, int distType, | |
- double param, double reps, double aeps ); | |
-//! checks if the point is inside the contour. Optionally computes the signed distance from the point to the contour boundary | |
-CV_EXPORTS_W double pointPolygonTest( InputArray contour, Point2f pt, bool measureDist ); | |
- | |
- | |
-class CV_EXPORTS_W Subdiv2D | |
-{ | |
-public: | |
- enum | |
- { | |
- PTLOC_ERROR = -2, | |
- PTLOC_OUTSIDE_RECT = -1, | |
- PTLOC_INSIDE = 0, | |
- PTLOC_VERTEX = 1, | |
- PTLOC_ON_EDGE = 2 | |
- }; | |
- | |
- enum | |
- { | |
- NEXT_AROUND_ORG = 0x00, | |
- NEXT_AROUND_DST = 0x22, | |
- PREV_AROUND_ORG = 0x11, | |
- PREV_AROUND_DST = 0x33, | |
- NEXT_AROUND_LEFT = 0x13, | |
- NEXT_AROUND_RIGHT = 0x31, | |
- PREV_AROUND_LEFT = 0x20, | |
- PREV_AROUND_RIGHT = 0x02 | |
- }; | |
- | |
- CV_WRAP Subdiv2D(); | |
- CV_WRAP Subdiv2D(Rect rect); | |
- CV_WRAP void initDelaunay(Rect rect); | |
- | |
- CV_WRAP int insert(Point2f pt); | |
- CV_WRAP void insert(const vector<Point2f>& ptvec); | |
- CV_WRAP int locate(Point2f pt, CV_OUT int& edge, CV_OUT int& vertex); | |
- | |
- CV_WRAP int findNearest(Point2f pt, CV_OUT Point2f* nearestPt=0); | |
- CV_WRAP void getEdgeList(CV_OUT vector<Vec4f>& edgeList) const; | |
- CV_WRAP void getTriangleList(CV_OUT vector<Vec6f>& triangleList) const; | |
- CV_WRAP void getVoronoiFacetList(const vector<int>& idx, CV_OUT vector<vector<Point2f> >& facetList, | |
- CV_OUT vector<Point2f>& facetCenters); | |
- | |
- CV_WRAP Point2f getVertex(int vertex, CV_OUT int* firstEdge=0) const; | |
- | |
- CV_WRAP int getEdge( int edge, int nextEdgeType ) const; | |
- CV_WRAP int nextEdge(int edge) const; | |
- CV_WRAP int rotateEdge(int edge, int rotate) const; | |
- CV_WRAP int symEdge(int edge) const; | |
- CV_WRAP int edgeOrg(int edge, CV_OUT Point2f* orgpt=0) const; | |
- CV_WRAP int edgeDst(int edge, CV_OUT Point2f* dstpt=0) const; | |
- | |
-protected: | |
- int newEdge(); | |
- void deleteEdge(int edge); | |
- int newPoint(Point2f pt, bool isvirtual, int firstEdge=0); | |
- void deletePoint(int vtx); | |
- void setEdgePoints( int edge, int orgPt, int dstPt ); | |
- void splice( int edgeA, int edgeB ); | |
- int connectEdges( int edgeA, int edgeB ); | |
- void swapEdges( int edge ); | |
- int isRightOf(Point2f pt, int edge) const; | |
- void calcVoronoi(); | |
- void clearVoronoi(); | |
- void checkSubdiv() const; | |
- | |
- struct CV_EXPORTS Vertex | |
- { | |
- Vertex(); | |
- Vertex(Point2f pt, bool _isvirtual, int _firstEdge=0); | |
- bool isvirtual() const; | |
- bool isfree() const; | |
- int firstEdge; | |
- int type; | |
- Point2f pt; | |
- }; | |
- struct CV_EXPORTS QuadEdge | |
- { | |
- QuadEdge(); | |
- QuadEdge(int edgeidx); | |
- bool isfree() const; | |
- int next[4]; | |
- int pt[4]; | |
- }; | |
- | |
- vector<Vertex> vtx; | |
- vector<QuadEdge> qedges; | |
- int freeQEdge; | |
- int freePoint; | |
- bool validGeometry; | |
- | |
- int recentEdge; | |
- Point2f topLeft; | |
- Point2f bottomRight; | |
-}; | |
- | |
-} | |
- | |
-#endif /* __cplusplus */ | |
- | |
-#endif | |
- | |
-/* End of file. */ | |
diff --git a/card.io/src/main/jni/opencv2/imgproc/imgproc_c.h b/card.io/src/main/jni/opencv2/imgproc/imgproc_c.h | |
deleted file mode 100644 | |
index 440490c..0000000 | |
--- a/card.io/src/main/jni/opencv2/imgproc/imgproc_c.h | |
+++ /dev/null | |
@@ -1,623 +0,0 @@ | |
-/*M/////////////////////////////////////////////////////////////////////////////////////// | |
-// | |
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. | |
-// | |
-// By downloading, copying, installing or using the software you agree to this license. | |
-// If you do not agree to this license, do not download, install, | |
-// copy or use the software. | |
-// | |
-// | |
-// License Agreement | |
-// For Open Source Computer Vision Library | |
-// | |
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. | |
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved. | |
-// Third party copyrights are property of their respective owners. | |
-// | |
-// Redistribution and use in source and binary forms, with or without modification, | |
-// are permitted provided that the following conditions are met: | |
-// | |
-// * Redistribution's of source code must retain the above copyright notice, | |
-// this list of conditions and the following disclaimer. | |
-// | |
-// * Redistribution's in binary form must reproduce the above copyright notice, | |
-// this list of conditions and the following disclaimer in the documentation | |
-// and/or other materials provided with the distribution. | |
-// | |
-// * The name of the copyright holders may not be used to endorse or promote products | |
-// derived from this software without specific prior written permission. | |
-// | |
-// This software is provided by the copyright holders and contributors "as is" and | |
-// any express or implied warranties, including, but not limited to, the implied | |
-// warranties of merchantability and fitness for a particular purpose are disclaimed. | |
-// In no event shall the Intel Corporation or contributors be liable for any direct, | |
-// indirect, incidental, special, exemplary, or consequential damages | |
-// (including, but not limited to, procurement of substitute goods or services; | |
-// loss of use, data, or profits; or business interruption) however caused | |
-// and on any theory of liability, whether in contract, strict liability, | |
-// or tort (including negligence or otherwise) arising in any way out of | |
-// the use of this software, even if advised of the possibility of such damage. | |
-// | |
-//M*/ | |
- | |
-#ifndef __OPENCV_IMGPROC_IMGPROC_C_H__ | |
-#define __OPENCV_IMGPROC_IMGPROC_C_H__ | |
- | |
-#include "opencv2/core/core_c.h" | |
-#include "opencv2/imgproc/types_c.h" | |
- | |
-#ifdef __cplusplus | |
-extern "C" { | |
-#endif | |
- | |
-/*********************** Background statistics accumulation *****************************/ | |
- | |
-/* Adds image to accumulator */ | |
-CVAPI(void) cvAcc( const CvArr* image, CvArr* sum, | |
- const CvArr* mask CV_DEFAULT(NULL) ); | |
- | |
-/* Adds squared image to accumulator */ | |
-CVAPI(void) cvSquareAcc( const CvArr* image, CvArr* sqsum, | |
- const CvArr* mask CV_DEFAULT(NULL) ); | |
- | |
-/* Adds a product of two images to accumulator */ | |
-CVAPI(void) cvMultiplyAcc( const CvArr* image1, const CvArr* image2, CvArr* acc, | |
- const CvArr* mask CV_DEFAULT(NULL) ); | |
- | |
-/* Adds image to accumulator with weights: acc = acc*(1-alpha) + image*alpha */ | |
-CVAPI(void) cvRunningAvg( const CvArr* image, CvArr* acc, double alpha, | |
- const CvArr* mask CV_DEFAULT(NULL) ); | |
- | |
-/****************************************************************************************\ | |
-* Image Processing * | |
-\****************************************************************************************/ | |
- | |
-/* Copies source 2D array inside of the larger destination array and | |
- makes a border of the specified type (IPL_BORDER_*) around the copied area. */ | |
-CVAPI(void) cvCopyMakeBorder( const CvArr* src, CvArr* dst, CvPoint offset, | |
- int bordertype, CvScalar value CV_DEFAULT(cvScalarAll(0))); | |
- | |
-/* Smoothes array (removes noise) */ | |
-CVAPI(void) cvSmooth( const CvArr* src, CvArr* dst, | |
- int smoothtype CV_DEFAULT(CV_GAUSSIAN), | |
- int size1 CV_DEFAULT(3), | |
- int size2 CV_DEFAULT(0), | |
- double sigma1 CV_DEFAULT(0), | |
- double sigma2 CV_DEFAULT(0)); | |
- | |
-/* Convolves the image with the kernel */ | |
-CVAPI(void) cvFilter2D( const CvArr* src, CvArr* dst, const CvMat* kernel, | |
- CvPoint anchor CV_DEFAULT(cvPoint(-1,-1))); | |
- | |
-/* Finds integral image: SUM(X,Y) = sum(x<X,y<Y)I(x,y) */ | |
-CVAPI(void) cvIntegral( const CvArr* image, CvArr* sum, | |
- CvArr* sqsum CV_DEFAULT(NULL), | |
- CvArr* tilted_sum CV_DEFAULT(NULL)); | |
- | |
-/* | |
- Smoothes the input image with gaussian kernel and then down-samples it. | |
- dst_width = floor(src_width/2)[+1], | |
- dst_height = floor(src_height/2)[+1] | |
-*/ | |
-CVAPI(void) cvPyrDown( const CvArr* src, CvArr* dst, | |
- int filter CV_DEFAULT(CV_GAUSSIAN_5x5) ); | |
- | |
-/* | |
- Up-samples image and smoothes the result with gaussian kernel. | |
- dst_width = src_width*2, | |
- dst_height = src_height*2 | |
-*/ | |
-CVAPI(void) cvPyrUp( const CvArr* src, CvArr* dst, | |
- int filter CV_DEFAULT(CV_GAUSSIAN_5x5) ); | |
- | |
-/* Builds pyramid for an image */ | |
-CVAPI(CvMat**) cvCreatePyramid( const CvArr* img, int extra_layers, double rate, | |
- const CvSize* layer_sizes CV_DEFAULT(0), | |
- CvArr* bufarr CV_DEFAULT(0), | |
- int calc CV_DEFAULT(1), | |
- int filter CV_DEFAULT(CV_GAUSSIAN_5x5) ); | |
- | |
-/* Releases pyramid */ | |
-CVAPI(void) cvReleasePyramid( CvMat*** pyramid, int extra_layers ); | |
- | |
- | |
-/* Filters image using meanshift algorithm */ | |
-CVAPI(void) cvPyrMeanShiftFiltering( const CvArr* src, CvArr* dst, | |
- double sp, double sr, int max_level CV_DEFAULT(1), | |
- CvTermCriteria termcrit CV_DEFAULT(cvTermCriteria(CV_TERMCRIT_ITER+CV_TERMCRIT_EPS,5,1))); | |
- | |
-/* Segments image using seed "markers" */ | |
-CVAPI(void) cvWatershed( const CvArr* image, CvArr* markers ); | |
- | |
-/* Calculates an image derivative using generalized Sobel | |
- (aperture_size = 1,3,5,7) or Scharr (aperture_size = -1) operator. | |
- Scharr can be used only for the first dx or dy derivative */ | |
-CVAPI(void) cvSobel( const CvArr* src, CvArr* dst, | |
- int xorder, int yorder, | |
- int aperture_size CV_DEFAULT(3)); | |
- | |
-/* Calculates the image Laplacian: (d2/dx + d2/dy)I */ | |
-CVAPI(void) cvLaplace( const CvArr* src, CvArr* dst, | |
- int aperture_size CV_DEFAULT(3) ); | |
- | |
-/* Converts input array pixels from one color space to another */ | |
-CVAPI(void) cvCvtColor( const CvArr* src, CvArr* dst, int code ); | |
- | |
- | |
-/* Resizes image (input array is resized to fit the destination array) */ | |
-CVAPI(void) cvResize( const CvArr* src, CvArr* dst, | |
- int interpolation CV_DEFAULT( CV_INTER_LINEAR )); | |
- | |
-/* Warps image with affine transform */ | |
-CVAPI(void) cvWarpAffine( const CvArr* src, CvArr* dst, const CvMat* map_matrix, | |
- int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS), | |
- CvScalar fillval CV_DEFAULT(cvScalarAll(0)) ); | |
- | |
-/* Computes affine transform matrix for mapping src[i] to dst[i] (i=0,1,2) */ | |
-CVAPI(CvMat*) cvGetAffineTransform( const CvPoint2D32f * src, | |
- const CvPoint2D32f * dst, | |
- CvMat * map_matrix ); | |
- | |
-/* Computes rotation_matrix matrix */ | |
-CVAPI(CvMat*) cv2DRotationMatrix( CvPoint2D32f center, double angle, | |
- double scale, CvMat* map_matrix ); | |
- | |
-/* Warps image with perspective (projective) transform */ | |
-CVAPI(void) cvWarpPerspective( const CvArr* src, CvArr* dst, const CvMat* map_matrix, | |
- int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS), | |
- CvScalar fillval CV_DEFAULT(cvScalarAll(0)) ); | |
- | |
-/* Computes perspective transform matrix for mapping src[i] to dst[i] (i=0,1,2,3) */ | |
-CVAPI(CvMat*) cvGetPerspectiveTransform( const CvPoint2D32f* src, | |
- const CvPoint2D32f* dst, | |
- CvMat* map_matrix ); | |
- | |
-/* Performs generic geometric transformation using the specified coordinate maps */ | |
-CVAPI(void) cvRemap( const CvArr* src, CvArr* dst, | |
- const CvArr* mapx, const CvArr* mapy, | |
- int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS), | |
- CvScalar fillval CV_DEFAULT(cvScalarAll(0)) ); | |
- | |
-/* Converts mapx & mapy from floating-point to integer formats for cvRemap */ | |
-CVAPI(void) cvConvertMaps( const CvArr* mapx, const CvArr* mapy, | |
- CvArr* mapxy, CvArr* mapalpha ); | |
- | |
-/* Performs forward or inverse log-polar image transform */ | |
-CVAPI(void) cvLogPolar( const CvArr* src, CvArr* dst, | |
- CvPoint2D32f center, double M, | |
- int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS)); | |
- | |
-/* Performs forward or inverse linear-polar image transform */ | |
-CVAPI(void) cvLinearPolar( const CvArr* src, CvArr* dst, | |
- CvPoint2D32f center, double maxRadius, | |
- int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS)); | |
- | |
-/* Transforms the input image to compensate lens distortion */ | |
-CVAPI(void) cvUndistort2( const CvArr* src, CvArr* dst, | |
- const CvMat* camera_matrix, | |
- const CvMat* distortion_coeffs, | |
- const CvMat* new_camera_matrix CV_DEFAULT(0) ); | |
- | |
-/* Computes transformation map from intrinsic camera parameters | |
- that can used by cvRemap */ | |
-CVAPI(void) cvInitUndistortMap( const CvMat* camera_matrix, | |
- const CvMat* distortion_coeffs, | |
- CvArr* mapx, CvArr* mapy ); | |
- | |
-/* Computes undistortion+rectification map for a head of stereo camera */ | |
-CVAPI(void) cvInitUndistortRectifyMap( const CvMat* camera_matrix, | |
- const CvMat* dist_coeffs, | |
- const CvMat *R, const CvMat* new_camera_matrix, | |
- CvArr* mapx, CvArr* mapy ); | |
- | |
-/* Computes the original (undistorted) feature coordinates | |
- from the observed (distorted) coordinates */ | |
-CVAPI(void) cvUndistortPoints( const CvMat* src, CvMat* dst, | |
- const CvMat* camera_matrix, | |
- const CvMat* dist_coeffs, | |
- const CvMat* R CV_DEFAULT(0), | |
- const CvMat* P CV_DEFAULT(0)); | |
- | |
-/* creates structuring element used for morphological operations */ | |
-CVAPI(IplConvKernel*) cvCreateStructuringElementEx( | |
- int cols, int rows, int anchor_x, int anchor_y, | |
- int shape, int* values CV_DEFAULT(NULL) ); | |
- | |
-/* releases structuring element */ | |
-CVAPI(void) cvReleaseStructuringElement( IplConvKernel** element ); | |
- | |
-/* erodes input image (applies minimum filter) one or more times. | |
- If element pointer is NULL, 3x3 rectangular element is used */ | |
-CVAPI(void) cvErode( const CvArr* src, CvArr* dst, | |
- IplConvKernel* element CV_DEFAULT(NULL), | |
- int iterations CV_DEFAULT(1) ); | |
- | |
-/* dilates input image (applies maximum filter) one or more times. | |
- If element pointer is NULL, 3x3 rectangular element is used */ | |
-CVAPI(void) cvDilate( const CvArr* src, CvArr* dst, | |
- IplConvKernel* element CV_DEFAULT(NULL), | |
- int iterations CV_DEFAULT(1) ); | |
- | |
-/* Performs complex morphological transformation */ | |
-CVAPI(void) cvMorphologyEx( const CvArr* src, CvArr* dst, | |
- CvArr* temp, IplConvKernel* element, | |
- int operation, int iterations CV_DEFAULT(1) ); | |
- | |
-/* Calculates all spatial and central moments up to the 3rd order */ | |
-CVAPI(void) cvMoments( const CvArr* arr, CvMoments* moments, int binary CV_DEFAULT(0)); | |
- | |
-/* Retrieve particular spatial, central or normalized central moments */ | |
-CVAPI(double) cvGetSpatialMoment( CvMoments* moments, int x_order, int y_order ); | |
-CVAPI(double) cvGetCentralMoment( CvMoments* moments, int x_order, int y_order ); | |
-CVAPI(double) cvGetNormalizedCentralMoment( CvMoments* moments, | |
- int x_order, int y_order ); | |
- | |
-/* Calculates 7 Hu's invariants from precalculated spatial and central moments */ | |
-CVAPI(void) cvGetHuMoments( CvMoments* moments, CvHuMoments* hu_moments ); | |
- | |
-/*********************************** data sampling **************************************/ | |
- | |
-/* Fetches pixels that belong to the specified line segment and stores them to the buffer. | |
- Returns the number of retrieved points. */ | |
-CVAPI(int) cvSampleLine( const CvArr* image, CvPoint pt1, CvPoint pt2, void* buffer, | |
- int connectivity CV_DEFAULT(8)); | |
- | |
-/* Retrieves the rectangular image region with specified center from the input array. | |
- dst(x,y) <- src(x + center.x - dst_width/2, y + center.y - dst_height/2). | |
- Values of pixels with fractional coordinates are retrieved using bilinear interpolation*/ | |
-CVAPI(void) cvGetRectSubPix( const CvArr* src, CvArr* dst, CvPoint2D32f center ); | |
- | |
- | |
-/* Retrieves quadrangle from the input array. | |
- matrixarr = ( a11 a12 | b1 ) dst(x,y) <- src(A[x y]' + b) | |
- ( a21 a22 | b2 ) (bilinear interpolation is used to retrieve pixels | |
- with fractional coordinates) | |
-*/ | |
-CVAPI(void) cvGetQuadrangleSubPix( const CvArr* src, CvArr* dst, | |
- const CvMat* map_matrix ); | |
- | |
-/* Measures similarity between template and overlapped windows in the source image | |
- and fills the resultant image with the measurements */ | |
-CVAPI(void) cvMatchTemplate( const CvArr* image, const CvArr* templ, | |
- CvArr* result, int method ); | |
- | |
-/* Computes earth mover distance between | |
- two weighted point sets (called signatures) */ | |
-CVAPI(float) cvCalcEMD2( const CvArr* signature1, | |
- const CvArr* signature2, | |
- int distance_type, | |
- CvDistanceFunction distance_func CV_DEFAULT(NULL), | |
- const CvArr* cost_matrix CV_DEFAULT(NULL), | |
- CvArr* flow CV_DEFAULT(NULL), | |
- float* lower_bound CV_DEFAULT(NULL), | |
- void* userdata CV_DEFAULT(NULL)); | |
- | |
-/****************************************************************************************\ | |
-* Contours retrieving * | |
-\****************************************************************************************/ | |
- | |
-/* Retrieves outer and optionally inner boundaries of white (non-zero) connected | |
- components in the black (zero) background */ | |
-CVAPI(int) cvFindContours( CvArr* image, CvMemStorage* storage, CvSeq** first_contour, | |
- int header_size CV_DEFAULT(sizeof(CvContour)), | |
- int mode CV_DEFAULT(CV_RETR_LIST), | |
- int method CV_DEFAULT(CV_CHAIN_APPROX_SIMPLE), | |
- CvPoint offset CV_DEFAULT(cvPoint(0,0))); | |
- | |
-/* Initalizes contour retrieving process. | |
- Calls cvStartFindContours. | |
- Calls cvFindNextContour until null pointer is returned | |
- or some other condition becomes true. | |
- Calls cvEndFindContours at the end. */ | |
-CVAPI(CvContourScanner) cvStartFindContours( CvArr* image, CvMemStorage* storage, | |
- int header_size CV_DEFAULT(sizeof(CvContour)), | |
- int mode CV_DEFAULT(CV_RETR_LIST), | |
- int method CV_DEFAULT(CV_CHAIN_APPROX_SIMPLE), | |
- CvPoint offset CV_DEFAULT(cvPoint(0,0))); | |
- | |
-/* Retrieves next contour */ | |
-CVAPI(CvSeq*) cvFindNextContour( CvContourScanner scanner ); | |
- | |
- | |
-/* Substitutes the last retrieved contour with the new one | |
- (if the substitutor is null, the last retrieved contour is removed from the tree) */ | |
-CVAPI(void) cvSubstituteContour( CvContourScanner scanner, CvSeq* new_contour ); | |
- | |
- | |
-/* Releases contour scanner and returns pointer to the first outer contour */ | |
-CVAPI(CvSeq*) cvEndFindContours( CvContourScanner* scanner ); | |
- | |
-/* Approximates a single Freeman chain or a tree of chains to polygonal curves */ | |
-CVAPI(CvSeq*) cvApproxChains( CvSeq* src_seq, CvMemStorage* storage, | |
- int method CV_DEFAULT(CV_CHAIN_APPROX_SIMPLE), | |
- double parameter CV_DEFAULT(0), | |
- int minimal_perimeter CV_DEFAULT(0), | |
- int recursive CV_DEFAULT(0)); | |
- | |
-/* Initalizes Freeman chain reader. | |
- The reader is used to iteratively get coordinates of all the chain points. | |
- If the Freeman codes should be read as is, a simple sequence reader should be used */ | |
-CVAPI(void) cvStartReadChainPoints( CvChain* chain, CvChainPtReader* reader ); | |
- | |
-/* Retrieves the next chain point */ | |
-CVAPI(CvPoint) cvReadChainPoint( CvChainPtReader* reader ); | |
- | |
- | |
-/****************************************************************************************\ | |
-* Contour Processing and Shape Analysis * | |
-\****************************************************************************************/ | |
- | |
-/* Approximates a single polygonal curve (contour) or | |
- a tree of polygonal curves (contours) */ | |
-CVAPI(CvSeq*) cvApproxPoly( const void* src_seq, | |
- int header_size, CvMemStorage* storage, | |
- int method, double parameter, | |
- int parameter2 CV_DEFAULT(0)); | |
- | |
-/* Calculates perimeter of a contour or length of a part of contour */ | |
-CVAPI(double) cvArcLength( const void* curve, | |
- CvSlice slice CV_DEFAULT(CV_WHOLE_SEQ), | |
- int is_closed CV_DEFAULT(-1)); | |
- | |
-CV_INLINE double cvContourPerimeter( const void* contour ) | |
-{ | |
- return cvArcLength( contour, CV_WHOLE_SEQ, 1 ); | |
-} | |
- | |
- | |
-/* Calculates contour boundning rectangle (update=1) or | |
- just retrieves pre-calculated rectangle (update=0) */ | |
-CVAPI(CvRect) cvBoundingRect( CvArr* points, int update CV_DEFAULT(0) ); | |
- | |
-/* Calculates area of a contour or contour segment */ | |
-CVAPI(double) cvContourArea( const CvArr* contour, | |
- CvSlice slice CV_DEFAULT(CV_WHOLE_SEQ), | |
- int oriented CV_DEFAULT(0)); | |
- | |
-/* Finds minimum area rotated rectangle bounding a set of points */ | |
-CVAPI(CvBox2D) cvMinAreaRect2( const CvArr* points, | |
- CvMemStorage* storage CV_DEFAULT(NULL)); | |
- | |
-/* Finds minimum enclosing circle for a set of points */ | |
-CVAPI(int) cvMinEnclosingCircle( const CvArr* points, | |
- CvPoint2D32f* center, float* radius ); | |
- | |
-/* Compares two contours by matching their moments */ | |
-CVAPI(double) cvMatchShapes( const void* object1, const void* object2, | |
- int method, double parameter CV_DEFAULT(0)); | |
- | |
-/* Calculates exact convex hull of 2d point set */ | |
-CVAPI(CvSeq*) cvConvexHull2( const CvArr* input, | |
- void* hull_storage CV_DEFAULT(NULL), | |
- int orientation CV_DEFAULT(CV_CLOCKWISE), | |
- int return_points CV_DEFAULT(0)); | |
- | |
-/* Checks whether the contour is convex or not (returns 1 if convex, 0 if not) */ | |
-CVAPI(int) cvCheckContourConvexity( const CvArr* contour ); | |
- | |
- | |
-/* Finds convexity defects for the contour */ | |
-CVAPI(CvSeq*) cvConvexityDefects( const CvArr* contour, const CvArr* convexhull, | |
- CvMemStorage* storage CV_DEFAULT(NULL)); | |
- | |
-/* Fits ellipse into a set of 2d points */ | |
-CVAPI(CvBox2D) cvFitEllipse2( const CvArr* points ); | |
- | |
-/* Finds minimum rectangle containing two given rectangles */ | |
-CVAPI(CvRect) cvMaxRect( const CvRect* rect1, const CvRect* rect2 ); | |
- | |
-/* Finds coordinates of the box vertices */ | |
-CVAPI(void) cvBoxPoints( CvBox2D box, CvPoint2D32f pt[4] ); | |
- | |
-/* Initializes sequence header for a matrix (column or row vector) of points - | |
- a wrapper for cvMakeSeqHeaderForArray (it does not initialize bounding rectangle!!!) */ | |
-CVAPI(CvSeq*) cvPointSeqFromMat( int seq_kind, const CvArr* mat, | |
- CvContour* contour_header, | |
- CvSeqBlock* block ); | |
- | |
-/* Checks whether the point is inside polygon, outside, on an edge (at a vertex). | |
- Returns positive, negative or zero value, correspondingly. | |
- Optionally, measures a signed distance between | |
- the point and the nearest polygon edge (measure_dist=1) */ | |
-CVAPI(double) cvPointPolygonTest( const CvArr* contour, | |
- CvPoint2D32f pt, int measure_dist ); | |
- | |
-/****************************************************************************************\ | |
-* Histogram functions * | |
-\****************************************************************************************/ | |
- | |
-/* Creates new histogram */ | |
-CVAPI(CvHistogram*) cvCreateHist( int dims, int* sizes, int type, | |
- float** ranges CV_DEFAULT(NULL), | |
- int uniform CV_DEFAULT(1)); | |
- | |
-/* Assignes histogram bin ranges */ | |
-CVAPI(void) cvSetHistBinRanges( CvHistogram* hist, float** ranges, | |
- int uniform CV_DEFAULT(1)); | |
- | |
-/* Creates histogram header for array */ | |
-CVAPI(CvHistogram*) cvMakeHistHeaderForArray( | |
- int dims, int* sizes, CvHistogram* hist, | |
- float* data, float** ranges CV_DEFAULT(NULL), | |
- int uniform CV_DEFAULT(1)); | |
- | |
-/* Releases histogram */ | |
-CVAPI(void) cvReleaseHist( CvHistogram** hist ); | |
- | |
-/* Clears all the histogram bins */ | |
-CVAPI(void) cvClearHist( CvHistogram* hist ); | |
- | |
-/* Finds indices and values of minimum and maximum histogram bins */ | |
-CVAPI(void) cvGetMinMaxHistValue( const CvHistogram* hist, | |
- float* min_value, float* max_value, | |
- int* min_idx CV_DEFAULT(NULL), | |
- int* max_idx CV_DEFAULT(NULL)); | |
- | |
- | |
-/* Normalizes histogram by dividing all bins by sum of the bins, multiplied by <factor>. | |
- After that sum of histogram bins is equal to <factor> */ | |
-CVAPI(void) cvNormalizeHist( CvHistogram* hist, double factor ); | |
- | |
- | |
-/* Clear all histogram bins that are below the threshold */ | |
-CVAPI(void) cvThreshHist( CvHistogram* hist, double threshold ); | |
- | |
- | |
-/* Compares two histogram */ | |
-CVAPI(double) cvCompareHist( const CvHistogram* hist1, | |
- const CvHistogram* hist2, | |
- int method); | |
- | |
-/* Copies one histogram to another. Destination histogram is created if | |
- the destination pointer is NULL */ | |
-CVAPI(void) cvCopyHist( const CvHistogram* src, CvHistogram** dst ); | |
- | |
- | |
-/* Calculates bayesian probabilistic histograms | |
- (each or src and dst is an array of <number> histograms */ | |
-CVAPI(void) cvCalcBayesianProb( CvHistogram** src, int number, | |
- CvHistogram** dst); | |
- | |
-/* Calculates array histogram */ | |
-CVAPI(void) cvCalcArrHist( CvArr** arr, CvHistogram* hist, | |
- int accumulate CV_DEFAULT(0), | |
- const CvArr* mask CV_DEFAULT(NULL) ); | |
- | |
-CV_INLINE void cvCalcHist( IplImage** image, CvHistogram* hist, | |
- int accumulate CV_DEFAULT(0), | |
- const CvArr* mask CV_DEFAULT(NULL) ) | |
-{ | |
- cvCalcArrHist( (CvArr**)image, hist, accumulate, mask ); | |
-} | |
- | |
-/* Calculates back project */ | |
-CVAPI(void) cvCalcArrBackProject( CvArr** image, CvArr* dst, | |
- const CvHistogram* hist ); | |
-#define cvCalcBackProject(image, dst, hist) cvCalcArrBackProject((CvArr**)image, dst, hist) | |
- | |
- | |
-/* Does some sort of template matching but compares histograms of | |
- template and each window location */ | |
-CVAPI(void) cvCalcArrBackProjectPatch( CvArr** image, CvArr* dst, CvSize range, | |
- CvHistogram* hist, int method, | |
- double factor ); | |
-#define cvCalcBackProjectPatch( image, dst, range, hist, method, factor ) \ | |
- cvCalcArrBackProjectPatch( (CvArr**)image, dst, range, hist, method, factor ) | |
- | |
- | |
-/* calculates probabilistic density (divides one histogram by another) */ | |
-CVAPI(void) cvCalcProbDensity( const CvHistogram* hist1, const CvHistogram* hist2, | |
- CvHistogram* dst_hist, double scale CV_DEFAULT(255) ); | |
- | |
-/* equalizes histogram of 8-bit single-channel image */ | |
-CVAPI(void) cvEqualizeHist( const CvArr* src, CvArr* dst ); | |
- | |
- | |
-/* Applies distance transform to binary image */ | |
-CVAPI(void) cvDistTransform( const CvArr* src, CvArr* dst, | |
- int distance_type CV_DEFAULT(CV_DIST_L2), | |
- int mask_size CV_DEFAULT(3), | |
- const float* mask CV_DEFAULT(NULL), | |
- CvArr* labels CV_DEFAULT(NULL), | |
- int labelType CV_DEFAULT(CV_DIST_LABEL_CCOMP)); | |
- | |
- | |
-/* Applies fixed-level threshold to grayscale image. | |
- This is a basic operation applied before retrieving contours */ | |
-CVAPI(double) cvThreshold( const CvArr* src, CvArr* dst, | |
- double threshold, double max_value, | |
- int threshold_type ); | |
- | |
-/* Applies adaptive threshold to grayscale image. | |
- The two parameters for methods CV_ADAPTIVE_THRESH_MEAN_C and | |
- CV_ADAPTIVE_THRESH_GAUSSIAN_C are: | |
- neighborhood size (3, 5, 7 etc.), | |
- and a constant subtracted from mean (...,-3,-2,-1,0,1,2,3,...) */ | |
-CVAPI(void) cvAdaptiveThreshold( const CvArr* src, CvArr* dst, double max_value, | |
- int adaptive_method CV_DEFAULT(CV_ADAPTIVE_THRESH_MEAN_C), | |
- int threshold_type CV_DEFAULT(CV_THRESH_BINARY), | |
- int block_size CV_DEFAULT(3), | |
- double param1 CV_DEFAULT(5)); | |
- | |
-/* Fills the connected component until the color difference gets large enough */ | |
-CVAPI(void) cvFloodFill( CvArr* image, CvPoint seed_point, | |
- CvScalar new_val, CvScalar lo_diff CV_DEFAULT(cvScalarAll(0)), | |
- CvScalar up_diff CV_DEFAULT(cvScalarAll(0)), | |
- CvConnectedComp* comp CV_DEFAULT(NULL), | |
- int flags CV_DEFAULT(4), | |
- CvArr* mask CV_DEFAULT(NULL)); | |
- | |
-/****************************************************************************************\ | |
-* Feature detection * | |
-\****************************************************************************************/ | |
- | |
-/* Runs canny edge detector */ | |
-CVAPI(void) cvCanny( const CvArr* image, CvArr* edges, double threshold1, | |
- double threshold2, int aperture_size CV_DEFAULT(3) ); | |
- | |
-/* Calculates constraint image for corner detection | |
- Dx^2 * Dyy + Dxx * Dy^2 - 2 * Dx * Dy * Dxy. | |
- Applying threshold to the result gives coordinates of corners */ | |
-CVAPI(void) cvPreCornerDetect( const CvArr* image, CvArr* corners, | |
- int aperture_size CV_DEFAULT(3) ); | |
- | |
-/* Calculates eigen values and vectors of 2x2 | |
- gradient covariation matrix at every image pixel */ | |
-CVAPI(void) cvCornerEigenValsAndVecs( const CvArr* image, CvArr* eigenvv, | |
- int block_size, int aperture_size CV_DEFAULT(3) ); | |
- | |
-/* Calculates minimal eigenvalue for 2x2 gradient covariation matrix at | |
- every image pixel */ | |
-CVAPI(void) cvCornerMinEigenVal( const CvArr* image, CvArr* eigenval, | |
- int block_size, int aperture_size CV_DEFAULT(3) ); | |
- | |
-/* Harris corner detector: | |
- Calculates det(M) - k*(trace(M)^2), where M is 2x2 gradient covariation matrix for each pixel */ | |
-CVAPI(void) cvCornerHarris( const CvArr* image, CvArr* harris_responce, | |
- int block_size, int aperture_size CV_DEFAULT(3), | |
- double k CV_DEFAULT(0.04) ); | |
- | |
-/* Adjust corner position using some sort of gradient search */ | |
-CVAPI(void) cvFindCornerSubPix( const CvArr* image, CvPoint2D32f* corners, | |
- int count, CvSize win, CvSize zero_zone, | |
- CvTermCriteria criteria ); | |
- | |
-/* Finds a sparse set of points within the selected region | |
- that seem to be easy to track */ | |
-CVAPI(void) cvGoodFeaturesToTrack( const CvArr* image, CvArr* eig_image, | |
- CvArr* temp_image, CvPoint2D32f* corners, | |
- int* corner_count, double quality_level, | |
- double min_distance, | |
- const CvArr* mask CV_DEFAULT(NULL), | |
- int block_size CV_DEFAULT(3), | |
- int use_harris CV_DEFAULT(0), | |
- double k CV_DEFAULT(0.04) ); | |
- | |
-/* Finds lines on binary image using one of several methods. | |
- line_storage is either memory storage or 1 x <max number of lines> CvMat, its | |
- number of columns is changed by the function. | |
- method is one of CV_HOUGH_*; | |
- rho, theta and threshold are used for each of those methods; | |
- param1 ~ line length, param2 ~ line gap - for probabilistic, | |
- param1 ~ srn, param2 ~ stn - for multi-scale */ | |
-CVAPI(CvSeq*) cvHoughLines2( CvArr* image, void* line_storage, int method, | |
- double rho, double theta, int threshold, | |
- double param1 CV_DEFAULT(0), double param2 CV_DEFAULT(0)); | |
- | |
-/* Finds circles in the image */ | |
-CVAPI(CvSeq*) cvHoughCircles( CvArr* image, void* circle_storage, | |
- int method, double dp, double min_dist, | |
- double param1 CV_DEFAULT(100), | |
- double param2 CV_DEFAULT(100), | |
- int min_radius CV_DEFAULT(0), | |
- int max_radius CV_DEFAULT(0)); | |
- | |
-/* Fits a line into set of 2d or 3d points in a robust way (M-estimator technique) */ | |
-CVAPI(void) cvFitLine( const CvArr* points, int dist_type, double param, | |
- double reps, double aeps, float* line ); | |
- | |
-#ifdef __cplusplus | |
-} | |
-#endif | |
- | |
-#endif | |
diff --git a/card.io/src/main/jni/opencv2/imgproc/types_c.h b/card.io/src/main/jni/opencv2/imgproc/types_c.h | |
deleted file mode 100644 | |
index 126b457..0000000 | |
--- a/card.io/src/main/jni/opencv2/imgproc/types_c.h | |
+++ /dev/null | |
@@ -1,621 +0,0 @@ | |
-/*M/////////////////////////////////////////////////////////////////////////////////////// | |
-// | |
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. | |
-// | |
-// By downloading, copying, installing or using the software you agree to this license. | |
-// If you do not agree to this license, do not download, install, | |
-// copy or use the software. | |
-// | |
-// | |
-// License Agreement | |
-// For Open Source Computer Vision Library | |
-// | |
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. | |
-// Copyright (C) 2009, Willow Garage Inc., all rights reserved. | |
-// Third party copyrights are property of their respective owners. | |
-// | |
-// Redistribution and use in source and binary forms, with or without modification, | |
-// are permitted provided that the following conditions are met: | |
-// | |
-// * Redistribution's of source code must retain the above copyright notice, | |
-// this list of conditions and the following disclaimer. | |
-// | |
-// * Redistribution's in binary form must reproduce the above copyright notice, | |
-// this list of conditions and the following disclaimer in the documentation | |
-// and/or other materials provided with the distribution. | |
-// | |
-// * The name of the copyright holders may not be used to endorse or promote products | |
-// derived from this software without specific prior written permission. | |
-// | |
-// This software is provided by the copyright holders and contributors "as is" and | |
-// any express or implied warranties, including, but not limited to, the implied | |
-// warranties of merchantability and fitness for a particular purpose are disclaimed. | |
-// In no event shall the Intel Corporation or contributors be liable for any direct, | |
-// indirect, incidental, special, exemplary, or consequential damages | |
-// (including, but not limited to, procurement of substitute goods or services; | |
-// loss of use, data, or profits; or business interruption) however caused | |
-// and on any theory of liability, whether in contract, strict liability, | |
-// or tort (including negligence or otherwise) arising in any way out of | |
-// the use of this software, even if advised of the possibility of such damage. | |
-// | |
-//M*/ | |
- | |
-#ifndef __OPENCV_IMGPROC_TYPES_C_H__ | |
-#define __OPENCV_IMGPROC_TYPES_C_H__ | |
- | |
-#include "opencv2/core/core_c.h" | |
- | |
-#ifdef __cplusplus | |
-extern "C" { | |
-#endif | |
- | |
-/* Connected component structure */ | |
-typedef struct CvConnectedComp | |
-{ | |
- double area; /* area of the connected component */ | |
- CvScalar value; /* average color of the connected component */ | |
- CvRect rect; /* ROI of the component */ | |
- CvSeq* contour; /* optional component boundary | |
- (the contour might have child contours corresponding to the holes)*/ | |
-} | |
-CvConnectedComp; | |
- | |
-/* Image smooth methods */ | |
-enum | |
-{ | |
- CV_BLUR_NO_SCALE =0, | |
- CV_BLUR =1, | |
- CV_GAUSSIAN =2, | |
- CV_MEDIAN =3, | |
- CV_BILATERAL =4 | |
-}; | |
- | |
-/* Filters used in pyramid decomposition */ | |
-enum | |
-{ | |
- CV_GAUSSIAN_5x5 = 7 | |
-}; | |
- | |
-/* Special filters */ | |
-enum | |
-{ | |
- CV_SCHARR =-1, | |
- CV_MAX_SOBEL_KSIZE =7 | |
-}; | |
- | |
-/* Constants for color conversion */ | |
-enum | |
-{ | |
- CV_BGR2BGRA =0, | |
- CV_RGB2RGBA =CV_BGR2BGRA, | |
- | |
- CV_BGRA2BGR =1, | |
- CV_RGBA2RGB =CV_BGRA2BGR, | |
- | |
- CV_BGR2RGBA =2, | |
- CV_RGB2BGRA =CV_BGR2RGBA, | |
- | |
- CV_RGBA2BGR =3, | |
- CV_BGRA2RGB =CV_RGBA2BGR, | |
- | |
- CV_BGR2RGB =4, | |
- CV_RGB2BGR =CV_BGR2RGB, | |
- | |
- CV_BGRA2RGBA =5, | |
- CV_RGBA2BGRA =CV_BGRA2RGBA, | |
- | |
- CV_BGR2GRAY =6, | |
- CV_RGB2GRAY =7, | |
- CV_GRAY2BGR =8, | |
- CV_GRAY2RGB =CV_GRAY2BGR, | |
- CV_GRAY2BGRA =9, | |
- CV_GRAY2RGBA =CV_GRAY2BGRA, | |
- CV_BGRA2GRAY =10, | |
- CV_RGBA2GRAY =11, | |
- | |
- CV_BGR2BGR565 =12, | |
- CV_RGB2BGR565 =13, | |
- CV_BGR5652BGR =14, | |
- CV_BGR5652RGB =15, | |
- CV_BGRA2BGR565 =16, | |
- CV_RGBA2BGR565 =17, | |
- CV_BGR5652BGRA =18, | |
- CV_BGR5652RGBA =19, | |
- | |
- CV_GRAY2BGR565 =20, | |
- CV_BGR5652GRAY =21, | |
- | |
- CV_BGR2BGR555 =22, | |
- CV_RGB2BGR555 =23, | |
- CV_BGR5552BGR =24, | |
- CV_BGR5552RGB =25, | |
- CV_BGRA2BGR555 =26, | |
- CV_RGBA2BGR555 =27, | |
- CV_BGR5552BGRA =28, | |
- CV_BGR5552RGBA =29, | |
- | |
- CV_GRAY2BGR555 =30, | |
- CV_BGR5552GRAY =31, | |
- | |
- CV_BGR2XYZ =32, | |
- CV_RGB2XYZ =33, | |
- CV_XYZ2BGR =34, | |
- CV_XYZ2RGB =35, | |
- | |
- CV_BGR2YCrCb =36, | |
- CV_RGB2YCrCb =37, | |
- CV_YCrCb2BGR =38, | |
- CV_YCrCb2RGB =39, | |
- | |
- CV_BGR2HSV =40, | |
- CV_RGB2HSV =41, | |
- | |
- CV_BGR2Lab =44, | |
- CV_RGB2Lab =45, | |
- | |
- CV_BayerBG2BGR =46, | |
- CV_BayerGB2BGR =47, | |
- CV_BayerRG2BGR =48, | |
- CV_BayerGR2BGR =49, | |
- | |
- CV_BayerBG2RGB =CV_BayerRG2BGR, | |
- CV_BayerGB2RGB =CV_BayerGR2BGR, | |
- CV_BayerRG2RGB =CV_BayerBG2BGR, | |
- CV_BayerGR2RGB =CV_BayerGB2BGR, | |
- | |
- CV_BGR2Luv =50, | |
- CV_RGB2Luv =51, | |
- CV_BGR2HLS =52, | |
- CV_RGB2HLS =53, | |
- | |
- CV_HSV2BGR =54, | |
- CV_HSV2RGB =55, | |
- | |
- CV_Lab2BGR =56, | |
- CV_Lab2RGB =57, | |
- CV_Luv2BGR =58, | |
- CV_Luv2RGB =59, | |
- CV_HLS2BGR =60, | |
- CV_HLS2RGB =61, | |
- | |
- CV_BayerBG2BGR_VNG =62, | |
- CV_BayerGB2BGR_VNG =63, | |
- CV_BayerRG2BGR_VNG =64, | |
- CV_BayerGR2BGR_VNG =65, | |
- | |
- CV_BayerBG2RGB_VNG =CV_BayerRG2BGR_VNG, | |
- CV_BayerGB2RGB_VNG =CV_BayerGR2BGR_VNG, | |
- CV_BayerRG2RGB_VNG =CV_BayerBG2BGR_VNG, | |
- CV_BayerGR2RGB_VNG =CV_BayerGB2BGR_VNG, | |
- | |
- CV_BGR2HSV_FULL = 66, | |
- CV_RGB2HSV_FULL = 67, | |
- CV_BGR2HLS_FULL = 68, | |
- CV_RGB2HLS_FULL = 69, | |
- | |
- CV_HSV2BGR_FULL = 70, | |
- CV_HSV2RGB_FULL = 71, | |
- CV_HLS2BGR_FULL = 72, | |
- CV_HLS2RGB_FULL = 73, | |
- | |
- CV_LBGR2Lab = 74, | |
- CV_LRGB2Lab = 75, | |
- CV_LBGR2Luv = 76, | |
- CV_LRGB2Luv = 77, | |
- | |
- CV_Lab2LBGR = 78, | |
- CV_Lab2LRGB = 79, | |
- CV_Luv2LBGR = 80, | |
- CV_Luv2LRGB = 81, | |
- | |
- CV_BGR2YUV = 82, | |
- CV_RGB2YUV = 83, | |
- CV_YUV2BGR = 84, | |
- CV_YUV2RGB = 85, | |
- | |
- CV_BayerBG2GRAY = 86, | |
- CV_BayerGB2GRAY = 87, | |
- CV_BayerRG2GRAY = 88, | |
- CV_BayerGR2GRAY = 89, | |
- | |
- //YUV 4:2:0 formats family | |
- CV_YUV2RGB_NV12 = 90, | |
- CV_YUV2BGR_NV12 = 91, | |
- CV_YUV2RGB_NV21 = 92, | |
- CV_YUV2BGR_NV21 = 93, | |
- CV_YUV420sp2RGB = CV_YUV2RGB_NV21, | |
- CV_YUV420sp2BGR = CV_YUV2BGR_NV21, | |
- | |
- CV_YUV2RGBA_NV12 = 94, | |
- CV_YUV2BGRA_NV12 = 95, | |
- CV_YUV2RGBA_NV21 = 96, | |
- CV_YUV2BGRA_NV21 = 97, | |
- CV_YUV420sp2RGBA = CV_YUV2RGBA_NV21, | |
- CV_YUV420sp2BGRA = CV_YUV2BGRA_NV21, | |
- | |
- CV_YUV2RGB_YV12 = 98, | |
- CV_YUV2BGR_YV12 = 99, | |
- CV_YUV2RGB_IYUV = 100, | |
- CV_YUV2BGR_IYUV = 101, | |
- CV_YUV2RGB_I420 = CV_YUV2RGB_IYUV, | |
- CV_YUV2BGR_I420 = CV_YUV2BGR_IYUV, | |
- CV_YUV420p2RGB = CV_YUV2RGB_YV12, | |
- CV_YUV420p2BGR = CV_YUV2BGR_YV12, | |
- | |
- CV_YUV2RGBA_YV12 = 102, | |
- CV_YUV2BGRA_YV12 = 103, | |
- CV_YUV2RGBA_IYUV = 104, | |
- CV_YUV2BGRA_IYUV = 105, | |
- CV_YUV2RGBA_I420 = CV_YUV2RGBA_IYUV, | |
- CV_YUV2BGRA_I420 = CV_YUV2BGRA_IYUV, | |
- CV_YUV420p2RGBA = CV_YUV2RGBA_YV12, | |
- CV_YUV420p2BGRA = CV_YUV2BGRA_YV12, | |
- | |
- CV_YUV2GRAY_420 = 106, | |
- CV_YUV2GRAY_NV21 = CV_YUV2GRAY_420, | |
- CV_YUV2GRAY_NV12 = CV_YUV2GRAY_420, | |
- CV_YUV2GRAY_YV12 = CV_YUV2GRAY_420, | |
- CV_YUV2GRAY_IYUV = CV_YUV2GRAY_420, | |
- CV_YUV2GRAY_I420 = CV_YUV2GRAY_420, | |
- CV_YUV420sp2GRAY = CV_YUV2GRAY_420, | |
- CV_YUV420p2GRAY = CV_YUV2GRAY_420, | |
- | |
- //YUV 4:2:2 formats family | |
- CV_YUV2RGB_UYVY = 107, | |
- CV_YUV2BGR_UYVY = 108, | |
- //CV_YUV2RGB_VYUY = 109, | |
- //CV_YUV2BGR_VYUY = 110, | |
- CV_YUV2RGB_Y422 = CV_YUV2RGB_UYVY, | |
- CV_YUV2BGR_Y422 = CV_YUV2BGR_UYVY, | |
- CV_YUV2RGB_UYNV = CV_YUV2RGB_UYVY, | |
- CV_YUV2BGR_UYNV = CV_YUV2BGR_UYVY, | |
- | |
- CV_YUV2RGBA_UYVY = 111, | |
- CV_YUV2BGRA_UYVY = 112, | |
- //CV_YUV2RGBA_VYUY = 113, | |
- //CV_YUV2BGRA_VYUY = 114, | |
- CV_YUV2RGBA_Y422 = CV_YUV2RGBA_UYVY, | |
- CV_YUV2BGRA_Y422 = CV_YUV2BGRA_UYVY, | |
- CV_YUV2RGBA_UYNV = CV_YUV2RGBA_UYVY, | |
- CV_YUV2BGRA_UYNV = CV_YUV2BGRA_UYVY, | |
- | |
- CV_YUV2RGB_YUY2 = 115, | |
- CV_YUV2BGR_YUY2 = 116, | |
- CV_YUV2RGB_YVYU = 117, | |
- CV_YUV2BGR_YVYU = 118, | |
- CV_YUV2RGB_YUYV = CV_YUV2RGB_YUY2, | |
- CV_YUV2BGR_YUYV = CV_YUV2BGR_YUY2, | |
- CV_YUV2RGB_YUNV = CV_YUV2RGB_YUY2, | |
- CV_YUV2BGR_YUNV = CV_YUV2BGR_YUY2, | |
- | |
- CV_YUV2RGBA_YUY2 = 119, | |
- CV_YUV2BGRA_YUY2 = 120, | |
- CV_YUV2RGBA_YVYU = 121, | |
- CV_YUV2BGRA_YVYU = 122, | |
- CV_YUV2RGBA_YUYV = CV_YUV2RGBA_YUY2, | |
- CV_YUV2BGRA_YUYV = CV_YUV2BGRA_YUY2, | |
- CV_YUV2RGBA_YUNV = CV_YUV2RGBA_YUY2, | |
- CV_YUV2BGRA_YUNV = CV_YUV2BGRA_YUY2, | |
- | |
- CV_YUV2GRAY_UYVY = 123, | |
- CV_YUV2GRAY_YUY2 = 124, | |
- //CV_YUV2GRAY_VYUY = CV_YUV2GRAY_UYVY, | |
- CV_YUV2GRAY_Y422 = CV_YUV2GRAY_UYVY, | |
- CV_YUV2GRAY_UYNV = CV_YUV2GRAY_UYVY, | |
- CV_YUV2GRAY_YVYU = CV_YUV2GRAY_YUY2, | |
- CV_YUV2GRAY_YUYV = CV_YUV2GRAY_YUY2, | |
- CV_YUV2GRAY_YUNV = CV_YUV2GRAY_YUY2, | |
- | |
- CV_COLORCVT_MAX = 125 | |
-}; | |
- | |
- | |
-/* Sub-pixel interpolation methods */ | |
-enum | |
-{ | |
- CV_INTER_NN =0, | |
- CV_INTER_LINEAR =1, | |
- CV_INTER_CUBIC =2, | |
- CV_INTER_AREA =3, | |
- CV_INTER_LANCZOS4 =4 | |
-}; | |
- | |
-/* ... and other image warping flags */ | |
-enum | |
-{ | |
- CV_WARP_FILL_OUTLIERS =8, | |
- CV_WARP_INVERSE_MAP =16 | |
-}; | |
- | |
-/* Shapes of a structuring element for morphological operations */ | |
-enum | |
-{ | |
- CV_SHAPE_RECT =0, | |
- CV_SHAPE_CROSS =1, | |
- CV_SHAPE_ELLIPSE =2, | |
- CV_SHAPE_CUSTOM =100 | |
-}; | |
- | |
-/* Morphological operations */ | |
-enum | |
-{ | |
- CV_MOP_ERODE =0, | |
- CV_MOP_DILATE =1, | |
- CV_MOP_OPEN =2, | |
- CV_MOP_CLOSE =3, | |
- CV_MOP_GRADIENT =4, | |
- CV_MOP_TOPHAT =5, | |
- CV_MOP_BLACKHAT =6 | |
-}; | |
- | |
-/* Spatial and central moments */ | |
-typedef struct CvMoments | |
-{ | |
- double m00, m10, m01, m20, m11, m02, m30, m21, m12, m03; /* spatial moments */ | |
- double mu20, mu11, mu02, mu30, mu21, mu12, mu03; /* central moments */ | |
- double inv_sqrt_m00; /* m00 != 0 ? 1/sqrt(m00) : 0 */ | |
-} | |
-CvMoments; | |
- | |
-/* Hu invariants */ | |
-typedef struct CvHuMoments | |
-{ | |
- double hu1, hu2, hu3, hu4, hu5, hu6, hu7; /* Hu invariants */ | |
-} | |
-CvHuMoments; | |
- | |
-/* Template matching methods */ | |
-enum | |
-{ | |
- CV_TM_SQDIFF =0, | |
- CV_TM_SQDIFF_NORMED =1, | |
- CV_TM_CCORR =2, | |
- CV_TM_CCORR_NORMED =3, | |
- CV_TM_CCOEFF =4, | |
- CV_TM_CCOEFF_NORMED =5 | |
-}; | |
- | |
-typedef float (CV_CDECL * CvDistanceFunction)( const float* a, const float* b, void* user_param ); | |
- | |
-/* Contour retrieval modes */ | |
-enum | |
-{ | |
- CV_RETR_EXTERNAL=0, | |
- CV_RETR_LIST=1, | |
- CV_RETR_CCOMP=2, | |
- CV_RETR_TREE=3, | |
- CV_RETR_FLOODFILL=4 | |
-}; | |
- | |
-/* Contour approximation methods */ | |
-enum | |
-{ | |
- CV_CHAIN_CODE=0, | |
- CV_CHAIN_APPROX_NONE=1, | |
- CV_CHAIN_APPROX_SIMPLE=2, | |
- CV_CHAIN_APPROX_TC89_L1=3, | |
- CV_CHAIN_APPROX_TC89_KCOS=4, | |
- CV_LINK_RUNS=5 | |
-}; | |
- | |
-/* | |
-Internal structure that is used for sequental retrieving contours from the image. | |
-It supports both hierarchical and plane variants of Suzuki algorithm. | |
-*/ | |
-typedef struct _CvContourScanner* CvContourScanner; | |
- | |
-/* Freeman chain reader state */ | |
-typedef struct CvChainPtReader | |
-{ | |
- CV_SEQ_READER_FIELDS() | |
- char code; | |
- CvPoint pt; | |
- schar deltas[8][2]; | |
-} | |
-CvChainPtReader; | |
- | |
-/* initializes 8-element array for fast access to 3x3 neighborhood of a pixel */ | |
-#define CV_INIT_3X3_DELTAS( deltas, step, nch ) \ | |
- ((deltas)[0] = (nch), (deltas)[1] = -(step) + (nch), \ | |
- (deltas)[2] = -(step), (deltas)[3] = -(step) - (nch), \ | |
- (deltas)[4] = -(nch), (deltas)[5] = (step) - (nch), \ | |
- (deltas)[6] = (step), (deltas)[7] = (step) + (nch)) | |
- | |
- | |
-/****************************************************************************************\ | |
-* Planar subdivisions * | |
-\****************************************************************************************/ | |
- | |
-typedef size_t CvSubdiv2DEdge; | |
- | |
-#define CV_QUADEDGE2D_FIELDS() \ | |
- int flags; \ | |
- struct CvSubdiv2DPoint* pt[4]; \ | |
- CvSubdiv2DEdge next[4]; | |
- | |
-#define CV_SUBDIV2D_POINT_FIELDS()\ | |
- int flags; \ | |
- CvSubdiv2DEdge first; \ | |
- CvPoint2D32f pt; \ | |
- int id; | |
- | |
-#define CV_SUBDIV2D_VIRTUAL_POINT_FLAG (1 << 30) | |
- | |
-typedef struct CvQuadEdge2D | |
-{ | |
- CV_QUADEDGE2D_FIELDS() | |
-} | |
-CvQuadEdge2D; | |
- | |
-typedef struct CvSubdiv2DPoint | |
-{ | |
- CV_SUBDIV2D_POINT_FIELDS() | |
-} | |
-CvSubdiv2DPoint; | |
- | |
-#define CV_SUBDIV2D_FIELDS() \ | |
- CV_GRAPH_FIELDS() \ | |
- int quad_edges; \ | |
- int is_geometry_valid; \ | |
- CvSubdiv2DEdge recent_edge; \ | |
- CvPoint2D32f topleft; \ | |
- CvPoint2D32f bottomright; | |
- | |
-typedef struct CvSubdiv2D | |
-{ | |
- CV_SUBDIV2D_FIELDS() | |
-} | |
-CvSubdiv2D; | |
- | |
- | |
-typedef enum CvSubdiv2DPointLocation | |
-{ | |
- CV_PTLOC_ERROR = -2, | |
- CV_PTLOC_OUTSIDE_RECT = -1, | |
- CV_PTLOC_INSIDE = 0, | |
- CV_PTLOC_VERTEX = 1, | |
- CV_PTLOC_ON_EDGE = 2 | |
-} | |
-CvSubdiv2DPointLocation; | |
- | |
-typedef enum CvNextEdgeType | |
-{ | |
- CV_NEXT_AROUND_ORG = 0x00, | |
- CV_NEXT_AROUND_DST = 0x22, | |
- CV_PREV_AROUND_ORG = 0x11, | |
- CV_PREV_AROUND_DST = 0x33, | |
- CV_NEXT_AROUND_LEFT = 0x13, | |
- CV_NEXT_AROUND_RIGHT = 0x31, | |
- CV_PREV_AROUND_LEFT = 0x20, | |
- CV_PREV_AROUND_RIGHT = 0x02 | |
-} | |
-CvNextEdgeType; | |
- | |
-/* get the next edge with the same origin point (counterwise) */ | |
-#define CV_SUBDIV2D_NEXT_EDGE( edge ) (((CvQuadEdge2D*)((edge) & ~3))->next[(edge)&3]) | |
- | |
- | |
-/* Contour approximation algorithms */ | |
-enum | |
-{ | |
- CV_POLY_APPROX_DP = 0 | |
-}; | |
- | |
-/* Shape matching methods */ | |
-enum | |
-{ | |
- CV_CONTOURS_MATCH_I1 =1, | |
- CV_CONTOURS_MATCH_I2 =2, | |
- CV_CONTOURS_MATCH_I3 =3 | |
-}; | |
- | |
-/* Shape orientation */ | |
-enum | |
-{ | |
- CV_CLOCKWISE =1, | |
- CV_COUNTER_CLOCKWISE =2 | |
-}; | |
- | |
- | |
-/* Convexity defect */ | |
-typedef struct CvConvexityDefect | |
-{ | |
- CvPoint* start; /* point of the contour where the defect begins */ | |
- CvPoint* end; /* point of the contour where the defect ends */ | |
- CvPoint* depth_point; /* the farthest from the convex hull point within the defect */ | |
- float depth; /* distance between the farthest point and the convex hull */ | |
-} CvConvexityDefect; | |
- | |
- | |
-/* Histogram comparison methods */ | |
-enum | |
-{ | |
- CV_COMP_CORREL =0, | |
- CV_COMP_CHISQR =1, | |
- CV_COMP_INTERSECT =2, | |
- CV_COMP_BHATTACHARYYA =3 | |
-}; | |
- | |
-/* Mask size for distance transform */ | |
-enum | |
-{ | |
- CV_DIST_MASK_3 =3, | |
- CV_DIST_MASK_5 =5, | |
- CV_DIST_MASK_PRECISE =0 | |
-}; | |
- | |
-/* Content of output label array: connected components or pixels */ | |
-enum | |
-{ | |
- CV_DIST_LABEL_CCOMP = 0, | |
- CV_DIST_LABEL_PIXEL = 1 | |
-}; | |
- | |
-/* Distance types for Distance Transform and M-estimators */ | |
-enum | |
-{ | |
- CV_DIST_USER =-1, /* User defined distance */ | |
- CV_DIST_L1 =1, /* distance = |x1-x2| + |y1-y2| */ | |
- CV_DIST_L2 =2, /* the simple euclidean distance */ | |
- CV_DIST_C =3, /* distance = max(|x1-x2|,|y1-y2|) */ | |
- CV_DIST_L12 =4, /* L1-L2 metric: distance = 2(sqrt(1+x*x/2) - 1)) */ | |
- CV_DIST_FAIR =5, /* distance = c^2(|x|/c-log(1+|x|/c)), c = 1.3998 */ | |
- CV_DIST_WELSCH =6, /* distance = c^2/2(1-exp(-(x/c)^2)), c = 2.9846 */ | |
- CV_DIST_HUBER =7 /* distance = |x|<c ? x^2/2 : c(|x|-c/2), c=1.345 */ | |
-}; | |
- | |
- | |
-/* Threshold types */ | |
-enum | |
-{ | |
- CV_THRESH_BINARY =0, /* value = value > threshold ? max_value : 0 */ | |
- CV_THRESH_BINARY_INV =1, /* value = value > threshold ? 0 : max_value */ | |
- CV_THRESH_TRUNC =2, /* value = value > threshold ? threshold : value */ | |
- CV_THRESH_TOZERO =3, /* value = value > threshold ? value : 0 */ | |
- CV_THRESH_TOZERO_INV =4, /* value = value > threshold ? 0 : value */ | |
- CV_THRESH_MASK =7, | |
- CV_THRESH_OTSU =8 /* use Otsu algorithm to choose the optimal threshold value; | |
- combine the flag with one of the above CV_THRESH_* values */ | |
-}; | |
- | |
-/* Adaptive threshold methods */ | |
-enum | |
-{ | |
- CV_ADAPTIVE_THRESH_MEAN_C =0, | |
- CV_ADAPTIVE_THRESH_GAUSSIAN_C =1 | |
-}; | |
- | |
-/* FloodFill flags */ | |
-enum | |
-{ | |
- CV_FLOODFILL_FIXED_RANGE =(1 << 16), | |
- CV_FLOODFILL_MASK_ONLY =(1 << 17) | |
-}; | |
- | |
- | |
-/* Canny edge detector flags */ | |
-enum | |
-{ | |
- CV_CANNY_L2_GRADIENT =(1 << 31) | |
-}; | |
- | |
-/* Variants of a Hough transform */ | |
-enum | |
-{ | |
- CV_HOUGH_STANDARD =0, | |
- CV_HOUGH_PROBABILISTIC =1, | |
- CV_HOUGH_MULTI_SCALE =2, | |
- CV_HOUGH_GRADIENT =3 | |
-}; | |
- | |
- | |
-/* Fast search data structures */ | |
-struct CvFeatureTree; | |
-struct CvLSH; | |
-struct CvLSHOperations; | |
- | |
-#ifdef __cplusplus | |
-} | |
-#endif | |
- | |
-#endif | |
diff --git a/card.io/src/main/jni/opencv2/opencv.hpp b/card.io/src/main/jni/opencv2/opencv.hpp | |
deleted file mode 100644 | |
index c98cfe1..0000000 | |
--- a/card.io/src/main/jni/opencv2/opencv.hpp | |
+++ /dev/null | |
@@ -1,61 +0,0 @@ | |
-/*M/////////////////////////////////////////////////////////////////////////////////////// | |
-// | |
-// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. | |
-// | |
-// By downloading, copying, installing or using the software you agree to this license. | |
-// If you do not agree to this license, do not download, install, | |
-// copy or use the software. | |
-// | |
-// | |
-// License Agreement | |
-// For Open Source Computer Vision Library | |
-// | |
-// Copyright (C) 2000-2008, Intel Corporation, all rights reserved. | |
-// Copyright (C) 2009-2010, Willow Garage Inc., all rights reserved. | |
-// Third party copyrights are property of their respective owners. | |
-// | |
-// Redistribution and use in source and binary forms, with or without modification, | |
-// are permitted provided that the following conditions are met: | |
-// | |
-// * Redistribution's of source code must retain the above copyright notice, | |
-// this list of conditions and the following disclaimer. | |
-// | |
-// * Redistribution's in binary form must reproduce the above copyright notice, | |
-// this list of conditions and the following disclaimer in the documentation | |
-// and/or other materials provided with the distribution. | |
-// | |
-// * The name of the copyright holders may not be used to endorse or promote products | |
-// derived from this software without specific prior written permission. | |
-// | |
-// This software is provided by the copyright holders and contributors "as is" and | |
-// any express or implied warranties, including, but not limited to, the implied | |
-// warranties of merchantability and fitness for a particular purpose are disclaimed. | |
-// In no event shall the Intel Corporation or contributors be liable for any direct, | |
-// indirect, incidental, special, exemplary, or consequential damages | |
-// (including, but not limited to, procurement of substitute goods or services; | |
-// loss of use, data, or profits; or business interruption) however caused | |
-// and on any theory of liability, whether in contract, strict liability, | |
-// or tort (including negligence or otherwise) arising in any way out of | |
-// the use of this software, even if advised of the possibility of such damage. | |
-// | |
-//M*/ | |
- | |
-#ifndef __OPENCV_ALL_HPP__ | |
-#define __OPENCV_ALL_HPP__ | |
- | |
-#include "opencv2/core/core_c.h" | |
-#include "opencv2/core/core.hpp" | |
-// #include "opencv2/flann/miniflann.hpp" | |
-#include "opencv2/imgproc/imgproc_c.h" | |
-#include "opencv2/imgproc/imgproc.hpp" | |
-// #include "opencv2/photo/photo.hpp" | |
-// #include "opencv2/video/video.hpp" | |
-// #include "opencv2/features2d/features2d.hpp" | |
-// #include "opencv2/objdetect/objdetect.hpp" | |
-// #include "opencv2/calib3d/calib3d.hpp" | |
-// #include "opencv2/ml/ml.hpp" | |
-// #include "opencv2/highgui/highgui_c.h" | |
-// #include "opencv2/highgui/highgui.hpp" | |
-// #include "opencv2/contrib/contrib.hpp" | |
- | |
-#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment