├── .gitignore ├── .idea ├── .name ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── gradle.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── .travis.yml ├── android-opencv-template.iml ├── app ├── .gitignore ├── app.iml ├── build.gradle ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ └── com │ │ └── floatlearning │ │ └── android_opencv_template │ │ └── MainActivity.java │ └── res │ ├── drawable-hdpi │ └── ic_launcher.png │ ├── drawable-mdpi │ └── ic_launcher.png │ ├── drawable-xhdpi │ └── ic_launcher.png │ ├── drawable-xxhdpi │ └── ic_launcher.png │ └── values │ └── strings.xml ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── license.md ├── opencv ├── build.gradle ├── lint.xml ├── opencv.iml └── src │ └── main │ ├── AndroidManifest.xml │ ├── aidl │ └── org │ │ └── opencv │ │ └── engine │ │ └── OpenCVEngineInterface.aidl │ ├── java │ └── org │ │ └── opencv │ │ ├── android │ │ ├── AsyncServiceHelper.java │ │ ├── BaseLoaderCallback.java │ │ ├── CameraBridgeViewBase.java │ │ ├── FpsMeter.java │ │ ├── InstallCallbackInterface.java │ │ ├── JavaCameraView.java │ │ ├── LoaderCallbackInterface.java │ │ ├── NativeCameraView.java │ │ ├── OpenCVLoader.java │ │ ├── StaticHelper.java │ │ └── Utils.java │ │ ├── calib3d │ │ ├── Calib3d.java │ │ ├── StereoBM.java │ │ └── StereoSGBM.java │ │ ├── contrib │ │ ├── Contrib.java │ │ ├── FaceRecognizer.java │ │ └── StereoVar.java │ │ ├── core │ │ ├── Algorithm.java │ │ ├── Core.java │ │ ├── CvException.java │ │ ├── CvType.java │ │ ├── Mat.java │ │ ├── MatOfByte.java │ │ ├── MatOfDMatch.java │ │ ├── MatOfDouble.java │ │ ├── MatOfFloat.java │ │ ├── MatOfFloat4.java │ │ ├── MatOfFloat6.java │ │ ├── MatOfInt.java │ │ ├── MatOfInt4.java │ │ ├── MatOfKeyPoint.java │ │ ├── MatOfPoint.java │ │ ├── MatOfPoint2f.java │ │ ├── MatOfPoint3.java │ │ ├── MatOfPoint3f.java │ │ ├── MatOfRect.java │ │ ├── Point.java │ │ ├── Point3.java │ │ ├── Range.java │ │ ├── Rect.java │ │ ├── RotatedRect.java │ │ ├── Scalar.java │ │ ├── Size.java │ │ └── TermCriteria.java │ │ ├── features2d │ │ ├── DMatch.java │ │ ├── DescriptorExtractor.java │ │ ├── DescriptorMatcher.java │ │ ├── FeatureDetector.java │ │ ├── Features2d.java │ │ ├── GenericDescriptorMatcher.java │ │ └── KeyPoint.java │ │ ├── gpu │ │ ├── DeviceInfo.java │ │ ├── Gpu.java │ │ └── TargetArchs.java │ │ ├── highgui │ │ ├── Highgui.java │ │ └── VideoCapture.java │ │ ├── imgproc │ │ ├── CLAHE.java │ │ ├── Imgproc.java │ │ ├── Moments.java │ │ └── Subdiv2D.java │ │ ├── ml │ │ ├── CvANN_MLP.java │ │ ├── CvANN_MLP_TrainParams.java │ │ ├── CvBoost.java │ │ ├── CvBoostParams.java │ │ ├── CvDTree.java │ │ ├── CvDTreeParams.java │ │ ├── CvERTrees.java │ │ ├── CvGBTrees.java │ │ ├── CvGBTreesParams.java │ │ ├── CvKNearest.java │ │ ├── CvNormalBayesClassifier.java │ │ ├── CvParamGrid.java │ │ ├── CvRTParams.java │ │ ├── CvRTrees.java │ │ ├── CvSVM.java │ │ ├── CvSVMParams.java │ │ ├── CvStatModel.java │ │ ├── EM.java │ │ └── Ml.java │ │ ├── objdetect │ │ ├── CascadeClassifier.java │ │ ├── HOGDescriptor.java │ │ └── Objdetect.java │ │ ├── photo │ │ └── Photo.java │ │ ├── utils │ │ └── Converters.java │ │ └── video │ │ ├── BackgroundSubtractor.java │ │ ├── BackgroundSubtractorMOG.java │ │ ├── BackgroundSubtractorMOG2.java │ │ ├── KalmanFilter.java │ │ └── Video.java │ └── res │ └── values │ └── attrs.xml ├── readme.md └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea/workspace.xml 4 | /.idea/libraries 5 | .DS_Store 6 | /build 7 | /opencv/build -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | android-opencv-template -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: android 2 | android: 3 | components: 4 | - build-tools-19.1.0 5 | - android-14 6 | sudo: false 7 | script: ./gradlew assembleDebug 8 | -------------------------------------------------------------------------------- /android-opencv-template.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/app.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 21 5 | buildToolsVersion "21.1.2" 6 | 7 | defaultConfig { 8 | applicationId "com.floatlearning.android_opencv_template" 9 | minSdkVersion 8 10 | targetSdkVersion 21 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(dir: 'libs', include: ['*.jar']) 24 | compile 'com.android.support:appcompat-v7:21.0.3' 25 | compile project(':opencv') 26 | } 27 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/ionagroup/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 16 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /app/src/main/java/com/floatlearning/android_opencv_template/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.floatlearning.android_opencv_template; 2 | 3 | import android.app.Activity; 4 | import android.os.Bundle; 5 | import android.util.Log; 6 | 7 | import org.opencv.android.BaseLoaderCallback; 8 | import org.opencv.android.CameraBridgeViewBase; 9 | import org.opencv.android.JavaCameraView; 10 | import org.opencv.android.LoaderCallbackInterface; 11 | import org.opencv.android.OpenCVLoader; 12 | import org.opencv.core.Mat; 13 | 14 | 15 | public class MainActivity extends Activity implements CameraBridgeViewBase.CvCameraViewListener2 { 16 | private static final String TAG = "MainActivity"; 17 | 18 | private CameraBridgeViewBase mOpenCVCameraView; 19 | private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) { 20 | @Override 21 | public void onManagerConnected(int status) { 22 | switch (status) { 23 | case LoaderCallbackInterface.SUCCESS: { 24 | Log.i(TAG, "OpenCV load success"); 25 | 26 | mOpenCVCameraView.enableView(); 27 | } break; 28 | default: { 29 | super.onManagerConnected(status); 30 | } break; 31 | } 32 | } 33 | }; 34 | 35 | @Override 36 | protected void onCreate(Bundle savedInstanceState) { 37 | super.onCreate(savedInstanceState); 38 | 39 | mOpenCVCameraView = new JavaCameraView(this, -1); 40 | setContentView(mOpenCVCameraView); 41 | mOpenCVCameraView.setCvCameraViewListener(this); 42 | } 43 | 44 | @Override 45 | public void onPause() { 46 | super.onPause(); 47 | 48 | if (mOpenCVCameraView != null) { 49 | mOpenCVCameraView.disableView(); 50 | } 51 | } 52 | 53 | @Override 54 | public void onResume() { 55 | super.onResume(); 56 | OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_9, this, mLoaderCallback); 57 | } 58 | 59 | @Override 60 | public void onDestroy() { 61 | super.onDestroy(); 62 | 63 | if (mOpenCVCameraView != null) { 64 | mOpenCVCameraView.disableView(); 65 | } 66 | } 67 | 68 | public void onCameraViewStarted(int width, int height) { } 69 | 70 | public Mat onCameraFrame(CameraBridgeViewBase.CvCameraViewFrame inputFrame) { 71 | return inputFrame.rgba(); 72 | } 73 | 74 | public void onCameraViewStopped() { } 75 | } 76 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gowithfloat/android-opencv-template/e6d13c7437f0c13b7e47c7ae586c852bd32f520b/app/src/main/res/drawable-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gowithfloat/android-opencv-template/e6d13c7437f0c13b7e47c7ae586c852bd32f520b/app/src/main/res/drawable-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gowithfloat/android-opencv-template/e6d13c7437f0c13b7e47c7ae586c852bd32f520b/app/src/main/res/drawable-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/drawable-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gowithfloat/android-opencv-template/e6d13c7437f0c13b7e47c7ae586c852bd32f520b/app/src/main/res/drawable-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | android-opencv-template 5 | 6 | 7 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:1.5.0' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gowithfloat/android-opencv-template/e6d13c7437f0c13b7e47c7ae586c852bd32f520b/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Apr 10 15:27:10 PDT 2013 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /license.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Float 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /opencv/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 14 5 | buildToolsVersion "19.1.0" 6 | 7 | defaultConfig { 8 | minSdkVersion 8 9 | targetSdkVersion 8 10 | } 11 | 12 | buildTypes { 13 | release { 14 | minifyEnabled false 15 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /opencv/lint.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /opencv/opencv.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /opencv/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /opencv/src/main/aidl/org/opencv/engine/OpenCVEngineInterface.aidl: -------------------------------------------------------------------------------- 1 | package org.opencv.engine; 2 | 3 | /** 4 | * Class provides a Java interface for OpenCV Engine Service. It's synchronous with native OpenCVEngine class. 5 | */ 6 | interface OpenCVEngineInterface 7 | { 8 | /** 9 | * @return Returns service version. 10 | */ 11 | int getEngineVersion(); 12 | 13 | /** 14 | * Finds an installed OpenCV library. 15 | * @param OpenCV version. 16 | * @return Returns path to OpenCV native libs or an empty string if OpenCV can not be found. 17 | */ 18 | String getLibPathByVersion(String version); 19 | 20 | /** 21 | * Tries to install defined version of OpenCV from Google Play Market. 22 | * @param OpenCV version. 23 | * @return Returns true if installation was successful or OpenCV package has been already installed. 24 | */ 25 | boolean installVersion(String version); 26 | 27 | /** 28 | * Returns list of libraries in loading order, separated by semicolon. 29 | * @param OpenCV version. 30 | * @return Returns names of OpenCV libraries, separated by semicolon. 31 | */ 32 | String getLibraryList(String version); 33 | } 34 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/android/BaseLoaderCallback.java: -------------------------------------------------------------------------------- 1 | package org.opencv.android; 2 | 3 | import android.app.Activity; 4 | import android.app.AlertDialog; 5 | import android.content.Context; 6 | import android.content.DialogInterface; 7 | import android.content.DialogInterface.OnClickListener; 8 | import android.util.Log; 9 | 10 | /** 11 | * Basic implementation of LoaderCallbackInterface. 12 | */ 13 | public abstract class BaseLoaderCallback implements LoaderCallbackInterface { 14 | 15 | public BaseLoaderCallback(Context AppContext) { 16 | mAppContext = AppContext; 17 | } 18 | 19 | public void onManagerConnected(int status) 20 | { 21 | switch (status) 22 | { 23 | /** OpenCV initialization was successful. **/ 24 | case LoaderCallbackInterface.SUCCESS: 25 | { 26 | /** Application must override this method to handle successful library initialization. **/ 27 | } break; 28 | /** OpenCV loader can not start Google Play Market. **/ 29 | case LoaderCallbackInterface.MARKET_ERROR: 30 | { 31 | Log.e(TAG, "Package installation failed!"); 32 | AlertDialog MarketErrorMessage = new AlertDialog.Builder(mAppContext).create(); 33 | MarketErrorMessage.setTitle("OpenCV Manager"); 34 | MarketErrorMessage.setMessage("Package installation failed!"); 35 | MarketErrorMessage.setCancelable(false); // This blocks the 'BACK' button 36 | MarketErrorMessage.setButton(AlertDialog.BUTTON_POSITIVE, "OK", new OnClickListener() { 37 | public void onClick(DialogInterface dialog, int which) { 38 | finish(); 39 | } 40 | }); 41 | MarketErrorMessage.show(); 42 | } break; 43 | /** Package installation has been canceled. **/ 44 | case LoaderCallbackInterface.INSTALL_CANCELED: 45 | { 46 | Log.d(TAG, "OpenCV library instalation was canceled by user"); 47 | finish(); 48 | } break; 49 | /** Application is incompatible with this version of OpenCV Manager. Possibly, a service update is required. **/ 50 | case LoaderCallbackInterface.INCOMPATIBLE_MANAGER_VERSION: 51 | { 52 | Log.d(TAG, "OpenCV Manager Service is uncompatible with this app!"); 53 | AlertDialog IncomatibilityMessage = new AlertDialog.Builder(mAppContext).create(); 54 | IncomatibilityMessage.setTitle("OpenCV Manager"); 55 | IncomatibilityMessage.setMessage("OpenCV Manager service is incompatible with this app. Try to update it via Google Play."); 56 | IncomatibilityMessage.setCancelable(false); // This blocks the 'BACK' button 57 | IncomatibilityMessage.setButton(AlertDialog.BUTTON_POSITIVE, "OK", new OnClickListener() { 58 | public void onClick(DialogInterface dialog, int which) { 59 | finish(); 60 | } 61 | }); 62 | IncomatibilityMessage.show(); 63 | } break; 64 | /** Other status, i.e. INIT_FAILED. **/ 65 | default: 66 | { 67 | Log.e(TAG, "OpenCV loading failed!"); 68 | AlertDialog InitFailedDialog = new AlertDialog.Builder(mAppContext).create(); 69 | InitFailedDialog.setTitle("OpenCV error"); 70 | InitFailedDialog.setMessage("OpenCV was not initialised correctly. Application will be shut down"); 71 | InitFailedDialog.setCancelable(false); // This blocks the 'BACK' button 72 | InitFailedDialog.setButton(AlertDialog.BUTTON_POSITIVE, "OK", new OnClickListener() { 73 | 74 | public void onClick(DialogInterface dialog, int which) { 75 | finish(); 76 | } 77 | }); 78 | 79 | InitFailedDialog.show(); 80 | } break; 81 | } 82 | } 83 | 84 | public void onPackageInstall(final int operation, final InstallCallbackInterface callback) 85 | { 86 | switch (operation) 87 | { 88 | case InstallCallbackInterface.NEW_INSTALLATION: 89 | { 90 | AlertDialog InstallMessage = new AlertDialog.Builder(mAppContext).create(); 91 | InstallMessage.setTitle("Package not found"); 92 | InstallMessage.setMessage(callback.getPackageName() + " package was not found! Try to install it?"); 93 | InstallMessage.setCancelable(false); // This blocks the 'BACK' button 94 | InstallMessage.setButton(AlertDialog.BUTTON_POSITIVE, "Yes", new OnClickListener() 95 | { 96 | public void onClick(DialogInterface dialog, int which) 97 | { 98 | callback.install(); 99 | } 100 | }); 101 | 102 | InstallMessage.setButton(AlertDialog.BUTTON_NEGATIVE, "No", new OnClickListener() { 103 | 104 | public void onClick(DialogInterface dialog, int which) 105 | { 106 | callback.cancel(); 107 | } 108 | }); 109 | 110 | InstallMessage.show(); 111 | } break; 112 | case InstallCallbackInterface.INSTALLATION_PROGRESS: 113 | { 114 | AlertDialog WaitMessage = new AlertDialog.Builder(mAppContext).create(); 115 | WaitMessage.setTitle("OpenCV is not ready"); 116 | WaitMessage.setMessage("Installation is in progress. Wait or exit?"); 117 | WaitMessage.setCancelable(false); // This blocks the 'BACK' button 118 | WaitMessage.setButton(AlertDialog.BUTTON_POSITIVE, "Wait", new OnClickListener() { 119 | public void onClick(DialogInterface dialog, int which) { 120 | callback.wait_install(); 121 | } 122 | }); 123 | WaitMessage.setButton(AlertDialog.BUTTON_NEGATIVE, "Exit", new OnClickListener() { 124 | public void onClick(DialogInterface dialog, int which) { 125 | callback.cancel(); 126 | } 127 | }); 128 | 129 | WaitMessage.show(); 130 | } break; 131 | } 132 | } 133 | 134 | void finish() 135 | { 136 | ((Activity) mAppContext).finish(); 137 | } 138 | 139 | protected Context mAppContext; 140 | private final static String TAG = "OpenCVLoader/BaseLoaderCallback"; 141 | } 142 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/android/FpsMeter.java: -------------------------------------------------------------------------------- 1 | package org.opencv.android; 2 | 3 | import java.text.DecimalFormat; 4 | 5 | import org.opencv.core.Core; 6 | 7 | import android.graphics.Canvas; 8 | import android.graphics.Color; 9 | import android.graphics.Paint; 10 | import android.util.Log; 11 | 12 | public class FpsMeter { 13 | private static final String TAG = "FpsMeter"; 14 | private static final int STEP = 20; 15 | private static final DecimalFormat FPS_FORMAT = new DecimalFormat("0.00"); 16 | 17 | private int mFramesCouner; 18 | private double mFrequency; 19 | private long mprevFrameTime; 20 | private String mStrfps; 21 | Paint mPaint; 22 | boolean mIsInitialized = false; 23 | int mWidth = 0; 24 | int mHeight = 0; 25 | 26 | public void init() { 27 | mFramesCouner = 0; 28 | mFrequency = Core.getTickFrequency(); 29 | mprevFrameTime = Core.getTickCount(); 30 | mStrfps = ""; 31 | 32 | mPaint = new Paint(); 33 | mPaint.setColor(Color.BLUE); 34 | mPaint.setTextSize(20); 35 | } 36 | 37 | public void measure() { 38 | if (!mIsInitialized) { 39 | init(); 40 | mIsInitialized = true; 41 | } else { 42 | mFramesCouner++; 43 | if (mFramesCouner % STEP == 0) { 44 | long time = Core.getTickCount(); 45 | double fps = STEP * mFrequency / (time - mprevFrameTime); 46 | mprevFrameTime = time; 47 | if (mWidth != 0 && mHeight != 0) 48 | mStrfps = FPS_FORMAT.format(fps) + " FPS@" + Integer.valueOf(mWidth) + "x" + Integer.valueOf(mHeight); 49 | else 50 | mStrfps = FPS_FORMAT.format(fps) + " FPS"; 51 | Log.i(TAG, mStrfps); 52 | } 53 | } 54 | } 55 | 56 | public void setResolution(int width, int height) { 57 | mWidth = width; 58 | mHeight = height; 59 | } 60 | 61 | public void draw(Canvas canvas, float offsetx, float offsety) { 62 | Log.d(TAG, mStrfps); 63 | canvas.drawText(mStrfps, offsetx, offsety, mPaint); 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/android/InstallCallbackInterface.java: -------------------------------------------------------------------------------- 1 | package org.opencv.android; 2 | 3 | /** 4 | * Installation callback interface. 5 | */ 6 | public interface InstallCallbackInterface 7 | { 8 | /** 9 | * New package installation is required. 10 | */ 11 | static final int NEW_INSTALLATION = 0; 12 | /** 13 | * Current package installation is in progress. 14 | */ 15 | static final int INSTALLATION_PROGRESS = 1; 16 | 17 | /** 18 | * Target package name. 19 | * @return Return target package name. 20 | */ 21 | public String getPackageName(); 22 | /** 23 | * Installation is approved. 24 | */ 25 | public void install(); 26 | /** 27 | * Installation is canceled. 28 | */ 29 | public void cancel(); 30 | /** 31 | * Wait for package installation. 32 | */ 33 | public void wait_install(); 34 | }; 35 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/android/LoaderCallbackInterface.java: -------------------------------------------------------------------------------- 1 | package org.opencv.android; 2 | 3 | /** 4 | * Interface for callback object in case of asynchronous initialization of OpenCV. 5 | */ 6 | public interface LoaderCallbackInterface 7 | { 8 | /** 9 | * OpenCV initialization finished successfully. 10 | */ 11 | static final int SUCCESS = 0; 12 | /** 13 | * Google Play Market cannot be invoked. 14 | */ 15 | static final int MARKET_ERROR = 2; 16 | /** 17 | * OpenCV library installation has been canceled by the user. 18 | */ 19 | static final int INSTALL_CANCELED = 3; 20 | /** 21 | * This version of OpenCV Manager Service is incompatible with the app. Possibly, a service update is required. 22 | */ 23 | static final int INCOMPATIBLE_MANAGER_VERSION = 4; 24 | /** 25 | * OpenCV library initialization has failed. 26 | */ 27 | static final int INIT_FAILED = 0xff; 28 | 29 | /** 30 | * Callback method, called after OpenCV library initialization. 31 | * @param status status of initialization (see initialization status constants). 32 | */ 33 | public void onManagerConnected(int status); 34 | 35 | /** 36 | * Callback method, called in case the package installation is needed. 37 | * @param callback answer object with approve and cancel methods and the package description. 38 | */ 39 | public void onPackageInstall(final int operation, InstallCallbackInterface callback); 40 | }; 41 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/android/NativeCameraView.java: -------------------------------------------------------------------------------- 1 | package org.opencv.android; 2 | 3 | import org.opencv.core.Mat; 4 | import org.opencv.core.Size; 5 | import org.opencv.highgui.Highgui; 6 | import org.opencv.highgui.VideoCapture; 7 | 8 | import android.content.Context; 9 | import android.util.AttributeSet; 10 | import android.util.Log; 11 | import android.view.ViewGroup.LayoutParams; 12 | 13 | /** 14 | * This class is an implementation of a bridge between SurfaceView and native OpenCV camera. 15 | * Due to the big amount of work done, by the base class this child is only responsible 16 | * for creating camera, destroying camera and delivering frames while camera is enabled 17 | */ 18 | public class NativeCameraView extends CameraBridgeViewBase { 19 | 20 | public static final String TAG = "NativeCameraView"; 21 | private boolean mStopThread; 22 | private Thread mThread; 23 | 24 | protected VideoCapture mCamera; 25 | protected NativeCameraFrame mFrame; 26 | 27 | public NativeCameraView(Context context, int cameraId) { 28 | super(context, cameraId); 29 | } 30 | 31 | public NativeCameraView(Context context, AttributeSet attrs) { 32 | super(context, attrs); 33 | } 34 | 35 | @Override 36 | protected boolean connectCamera(int width, int height) { 37 | 38 | /* 1. We need to instantiate camera 39 | * 2. We need to start thread which will be getting frames 40 | */ 41 | /* First step - initialize camera connection */ 42 | if (!initializeCamera(width, height)) 43 | return false; 44 | 45 | /* now we can start update thread */ 46 | mThread = new Thread(new CameraWorker()); 47 | mThread.start(); 48 | 49 | return true; 50 | } 51 | 52 | @Override 53 | protected void disconnectCamera() { 54 | /* 1. We need to stop thread which updating the frames 55 | * 2. Stop camera and release it 56 | */ 57 | if (mThread != null) { 58 | try { 59 | mStopThread = true; 60 | mThread.join(); 61 | } catch (InterruptedException e) { 62 | e.printStackTrace(); 63 | } finally { 64 | mThread = null; 65 | mStopThread = false; 66 | } 67 | } 68 | 69 | /* Now release camera */ 70 | releaseCamera(); 71 | } 72 | 73 | public static class OpenCvSizeAccessor implements ListItemAccessor { 74 | 75 | public int getWidth(Object obj) { 76 | Size size = (Size)obj; 77 | return (int)size.width; 78 | } 79 | 80 | public int getHeight(Object obj) { 81 | Size size = (Size)obj; 82 | return (int)size.height; 83 | } 84 | 85 | } 86 | 87 | private boolean initializeCamera(int width, int height) { 88 | synchronized (this) { 89 | 90 | if (mCameraIndex == -1) 91 | mCamera = new VideoCapture(Highgui.CV_CAP_ANDROID); 92 | else 93 | mCamera = new VideoCapture(Highgui.CV_CAP_ANDROID + mCameraIndex); 94 | 95 | if (mCamera == null) 96 | return false; 97 | 98 | if (mCamera.isOpened() == false) 99 | return false; 100 | 101 | mFrame = new NativeCameraFrame(mCamera); 102 | 103 | java.util.List sizes = mCamera.getSupportedPreviewSizes(); 104 | 105 | /* Select the size that fits surface considering maximum size allowed */ 106 | Size frameSize = calculateCameraFrameSize(sizes, new OpenCvSizeAccessor(), width, height); 107 | 108 | mFrameWidth = (int)frameSize.width; 109 | mFrameHeight = (int)frameSize.height; 110 | 111 | if ((getLayoutParams().width == LayoutParams.MATCH_PARENT) && (getLayoutParams().height == LayoutParams.MATCH_PARENT)) 112 | mScale = Math.min(((float)height)/mFrameHeight, ((float)width)/mFrameWidth); 113 | else 114 | mScale = 0; 115 | 116 | if (mFpsMeter != null) { 117 | mFpsMeter.setResolution(mFrameWidth, mFrameHeight); 118 | } 119 | 120 | AllocateCache(); 121 | 122 | mCamera.set(Highgui.CV_CAP_PROP_FRAME_WIDTH, frameSize.width); 123 | mCamera.set(Highgui.CV_CAP_PROP_FRAME_HEIGHT, frameSize.height); 124 | } 125 | 126 | Log.i(TAG, "Selected camera frame size = (" + mFrameWidth + ", " + mFrameHeight + ")"); 127 | 128 | return true; 129 | } 130 | 131 | private void releaseCamera() { 132 | synchronized (this) { 133 | if (mFrame != null) mFrame.release(); 134 | if (mCamera != null) mCamera.release(); 135 | } 136 | } 137 | 138 | private static class NativeCameraFrame implements CvCameraViewFrame { 139 | 140 | @Override 141 | public Mat rgba() { 142 | mCapture.retrieve(mRgba, Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA); 143 | return mRgba; 144 | } 145 | 146 | @Override 147 | public Mat gray() { 148 | mCapture.retrieve(mGray, Highgui.CV_CAP_ANDROID_GREY_FRAME); 149 | return mGray; 150 | } 151 | 152 | public NativeCameraFrame(VideoCapture capture) { 153 | mCapture = capture; 154 | mGray = new Mat(); 155 | mRgba = new Mat(); 156 | } 157 | 158 | public void release() { 159 | if (mGray != null) mGray.release(); 160 | if (mRgba != null) mRgba.release(); 161 | } 162 | 163 | private VideoCapture mCapture; 164 | private Mat mRgba; 165 | private Mat mGray; 166 | }; 167 | 168 | private class CameraWorker implements Runnable { 169 | 170 | public void run() { 171 | do { 172 | if (!mCamera.grab()) { 173 | Log.e(TAG, "Camera frame grab failed"); 174 | break; 175 | } 176 | 177 | deliverAndDrawFrame(mFrame); 178 | } while (!mStopThread); 179 | } 180 | } 181 | 182 | } 183 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/android/OpenCVLoader.java: -------------------------------------------------------------------------------- 1 | package org.opencv.android; 2 | 3 | import android.content.Context; 4 | 5 | /** 6 | * Helper class provides common initialization methods for OpenCV library. 7 | */ 8 | public class OpenCVLoader 9 | { 10 | /** 11 | * OpenCV Library version 2.4.2. 12 | */ 13 | public static final String OPENCV_VERSION_2_4_2 = "2.4.2"; 14 | 15 | /** 16 | * OpenCV Library version 2.4.3. 17 | */ 18 | public static final String OPENCV_VERSION_2_4_3 = "2.4.3"; 19 | 20 | /** 21 | * OpenCV Library version 2.4.4. 22 | */ 23 | public static final String OPENCV_VERSION_2_4_4 = "2.4.4"; 24 | 25 | /** 26 | * OpenCV Library version 2.4.5. 27 | */ 28 | public static final String OPENCV_VERSION_2_4_5 = "2.4.5"; 29 | 30 | /** 31 | * OpenCV Library version 2.4.6. 32 | */ 33 | public static final String OPENCV_VERSION_2_4_6 = "2.4.6"; 34 | 35 | /** 36 | * OpenCV Library version 2.4.7. 37 | */ 38 | public static final String OPENCV_VERSION_2_4_7 = "2.4.7"; 39 | 40 | /** 41 | * OpenCV Library version 2.4.8. 42 | */ 43 | public static final String OPENCV_VERSION_2_4_8 = "2.4.8"; 44 | 45 | /** 46 | * OpenCV Library version 2.4.9. 47 | */ 48 | public static final String OPENCV_VERSION_2_4_9 = "2.4.9"; 49 | 50 | /** 51 | * OpenCV Library version 2.4.10. 52 | */ 53 | public static final String OPENCV_VERSION_2_4_10 = "2.4.10"; 54 | 55 | 56 | /** 57 | * Loads and initializes OpenCV library from current application package. Roughly, it's an analog of system.loadLibrary("opencv_java"). 58 | * @return Returns true is initialization of OpenCV was successful. 59 | */ 60 | public static boolean initDebug() 61 | { 62 | return StaticHelper.initOpenCV(false); 63 | } 64 | 65 | /** 66 | * Loads and initializes OpenCV library from current application package. Roughly, it's an analog of system.loadLibrary("opencv_java"). 67 | * @param InitCuda load and initialize CUDA runtime libraries. 68 | * @return Returns true is initialization of OpenCV was successful. 69 | */ 70 | public static boolean initDebug(boolean InitCuda) 71 | { 72 | return StaticHelper.initOpenCV(InitCuda); 73 | } 74 | 75 | /** 76 | * Loads and initializes OpenCV library using OpenCV Engine service. 77 | * @param Version OpenCV library version. 78 | * @param AppContext application context for connecting to the service. 79 | * @param Callback object, that implements LoaderCallbackInterface for handling the connection status. 80 | * @return Returns true if initialization of OpenCV is successful. 81 | */ 82 | public static boolean initAsync(String Version, Context AppContext, 83 | LoaderCallbackInterface Callback) 84 | { 85 | return AsyncServiceHelper.initOpenCV(Version, AppContext, Callback); 86 | } 87 | } 88 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/android/StaticHelper.java: -------------------------------------------------------------------------------- 1 | package org.opencv.android; 2 | 3 | import org.opencv.core.Core; 4 | 5 | import java.util.StringTokenizer; 6 | import android.util.Log; 7 | 8 | class StaticHelper { 9 | 10 | public static boolean initOpenCV(boolean InitCuda) 11 | { 12 | boolean result; 13 | String libs = ""; 14 | 15 | if(InitCuda) 16 | { 17 | loadLibrary("cudart"); 18 | loadLibrary("nppc"); 19 | loadLibrary("nppi"); 20 | loadLibrary("npps"); 21 | loadLibrary("cufft"); 22 | loadLibrary("cublas"); 23 | } 24 | 25 | Log.d(TAG, "Trying to get library list"); 26 | 27 | try 28 | { 29 | System.loadLibrary("opencv_info"); 30 | libs = getLibraryList(); 31 | } 32 | catch(UnsatisfiedLinkError e) 33 | { 34 | Log.e(TAG, "OpenCV error: Cannot load info library for OpenCV"); 35 | } 36 | 37 | Log.d(TAG, "Library list: \"" + libs + "\""); 38 | Log.d(TAG, "First attempt to load libs"); 39 | if (initOpenCVLibs(libs)) 40 | { 41 | Log.d(TAG, "First attempt to load libs is OK"); 42 | String eol = System.getProperty("line.separator"); 43 | for (String str : Core.getBuildInformation().split(eol)) 44 | Log.i(TAG, str); 45 | 46 | result = true; 47 | } 48 | else 49 | { 50 | Log.d(TAG, "First attempt to load libs fails"); 51 | result = false; 52 | } 53 | 54 | return result; 55 | } 56 | 57 | private static boolean loadLibrary(String Name) 58 | { 59 | boolean result = true; 60 | 61 | Log.d(TAG, "Trying to load library " + Name); 62 | try 63 | { 64 | System.loadLibrary(Name); 65 | Log.d(TAG, "Library " + Name + " loaded"); 66 | } 67 | catch(UnsatisfiedLinkError e) 68 | { 69 | Log.d(TAG, "Cannot load library \"" + Name + "\""); 70 | e.printStackTrace(); 71 | result &= false; 72 | } 73 | 74 | return result; 75 | } 76 | 77 | private static boolean initOpenCVLibs(String Libs) 78 | { 79 | Log.d(TAG, "Trying to init OpenCV libs"); 80 | 81 | boolean result = true; 82 | 83 | if ((null != Libs) && (Libs.length() != 0)) 84 | { 85 | Log.d(TAG, "Trying to load libs by dependency list"); 86 | StringTokenizer splitter = new StringTokenizer(Libs, ";"); 87 | while(splitter.hasMoreTokens()) 88 | { 89 | result &= loadLibrary(splitter.nextToken()); 90 | } 91 | } 92 | else 93 | { 94 | // If dependencies list is not defined or empty. 95 | result &= loadLibrary("opencv_java"); 96 | } 97 | 98 | return result; 99 | } 100 | 101 | private static final String TAG = "OpenCV/StaticHelper"; 102 | 103 | private static native String getLibraryList(); 104 | } 105 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/android/Utils.java: -------------------------------------------------------------------------------- 1 | package org.opencv.android; 2 | 3 | import android.content.Context; 4 | import android.graphics.Bitmap; 5 | 6 | import org.opencv.core.CvException; 7 | import org.opencv.core.CvType; 8 | import org.opencv.core.Mat; 9 | import org.opencv.highgui.Highgui; 10 | 11 | import java.io.ByteArrayOutputStream; 12 | import java.io.File; 13 | import java.io.FileOutputStream; 14 | import java.io.IOException; 15 | import java.io.InputStream; 16 | 17 | public class Utils { 18 | 19 | public static String exportResource(Context context, int resourceId) { 20 | return exportResource(context, resourceId, "OpenCV_data"); 21 | } 22 | 23 | public static String exportResource(Context context, int resourceId, String dirname) { 24 | String fullname = context.getResources().getString(resourceId); 25 | String resName = fullname.substring(fullname.lastIndexOf("/") + 1); 26 | try { 27 | InputStream is = context.getResources().openRawResource(resourceId); 28 | File resDir = context.getDir(dirname, Context.MODE_PRIVATE); 29 | File resFile = new File(resDir, resName); 30 | 31 | FileOutputStream os = new FileOutputStream(resFile); 32 | 33 | byte[] buffer = new byte[4096]; 34 | int bytesRead; 35 | while ((bytesRead = is.read(buffer)) != -1) { 36 | os.write(buffer, 0, bytesRead); 37 | } 38 | is.close(); 39 | os.close(); 40 | 41 | return resFile.getAbsolutePath(); 42 | } catch (IOException e) { 43 | e.printStackTrace(); 44 | throw new CvException("Failed to export resource " + resName 45 | + ". Exception thrown: " + e); 46 | } 47 | } 48 | 49 | public static Mat loadResource(Context context, int resourceId) throws IOException 50 | { 51 | return loadResource(context, resourceId, -1); 52 | } 53 | 54 | public static Mat loadResource(Context context, int resourceId, int flags) throws IOException 55 | { 56 | InputStream is = context.getResources().openRawResource(resourceId); 57 | ByteArrayOutputStream os = new ByteArrayOutputStream(is.available()); 58 | 59 | byte[] buffer = new byte[4096]; 60 | int bytesRead; 61 | while ((bytesRead = is.read(buffer)) != -1) { 62 | os.write(buffer, 0, bytesRead); 63 | } 64 | is.close(); 65 | 66 | Mat encoded = new Mat(1, os.size(), CvType.CV_8U); 67 | encoded.put(0, 0, os.toByteArray()); 68 | os.close(); 69 | 70 | Mat decoded = Highgui.imdecode(encoded, flags); 71 | encoded.release(); 72 | 73 | return decoded; 74 | } 75 | 76 | /** 77 | * Converts Android Bitmap to OpenCV Mat. 78 | *

79 | * This function converts an Android Bitmap image to the OpenCV Mat. 80 | *
'ARGB_8888' and 'RGB_565' input Bitmap formats are supported. 81 | *
The output Mat is always created of the same size as the input Bitmap and of the 'CV_8UC4' type, 82 | * it keeps the image in RGBA format. 83 | *
This function throws an exception if the conversion fails. 84 | * @param bmp is a valid input Bitmap object of the type 'ARGB_8888' or 'RGB_565'. 85 | * @param mat is a valid output Mat object, it will be reallocated if needed, so it may be empty. 86 | * @param unPremultiplyAlpha is a flag, that determines, whether the bitmap needs to be converted from alpha premultiplied format (like Android keeps 'ARGB_8888' ones) to regular one; this flag is ignored for 'RGB_565' bitmaps. 87 | */ 88 | public static void bitmapToMat(Bitmap bmp, Mat mat, boolean unPremultiplyAlpha) { 89 | if (bmp == null) 90 | throw new java.lang.IllegalArgumentException("bmp == null"); 91 | if (mat == null) 92 | throw new java.lang.IllegalArgumentException("mat == null"); 93 | nBitmapToMat2(bmp, mat.nativeObj, unPremultiplyAlpha); 94 | } 95 | 96 | /** 97 | * Short form of the bitmapToMat(bmp, mat, unPremultiplyAlpha=false). 98 | * @param bmp is a valid input Bitmap object of the type 'ARGB_8888' or 'RGB_565'. 99 | * @param mat is a valid output Mat object, it will be reallocated if needed, so Mat may be empty. 100 | */ 101 | public static void bitmapToMat(Bitmap bmp, Mat mat) { 102 | bitmapToMat(bmp, mat, false); 103 | } 104 | 105 | 106 | /** 107 | * Converts OpenCV Mat to Android Bitmap. 108 | *

109 | *
This function converts an image in the OpenCV Mat representation to the Android Bitmap. 110 | *
The input Mat object has to be of the types 'CV_8UC1' (gray-scale), 'CV_8UC3' (RGB) or 'CV_8UC4' (RGBA). 111 | *
The output Bitmap object has to be of the same size as the input Mat and of the types 'ARGB_8888' or 'RGB_565'. 112 | *
This function throws an exception if the conversion fails. 113 | * 114 | * @param mat is a valid input Mat object of types 'CV_8UC1', 'CV_8UC3' or 'CV_8UC4'. 115 | * @param bmp is a valid Bitmap object of the same size as the Mat and of type 'ARGB_8888' or 'RGB_565'. 116 | * @param premultiplyAlpha is a flag, that determines, whether the Mat needs to be converted to alpha premultiplied format (like Android keeps 'ARGB_8888' bitmaps); the flag is ignored for 'RGB_565' bitmaps. 117 | */ 118 | public static void matToBitmap(Mat mat, Bitmap bmp, boolean premultiplyAlpha) { 119 | if (mat == null) 120 | throw new java.lang.IllegalArgumentException("mat == null"); 121 | if (bmp == null) 122 | throw new java.lang.IllegalArgumentException("bmp == null"); 123 | nMatToBitmap2(mat.nativeObj, bmp, premultiplyAlpha); 124 | } 125 | 126 | /** 127 | * Short form of the matToBitmap(mat, bmp, premultiplyAlpha=false) 128 | * @param mat is a valid input Mat object of the types 'CV_8UC1', 'CV_8UC3' or 'CV_8UC4'. 129 | * @param bmp is a valid Bitmap object of the same size as the Mat and of type 'ARGB_8888' or 'RGB_565'. 130 | */ 131 | public static void matToBitmap(Mat mat, Bitmap bmp) { 132 | matToBitmap(mat, bmp, false); 133 | } 134 | 135 | 136 | private static native void nBitmapToMat2(Bitmap b, long m_addr, boolean unPremultiplyAlpha); 137 | 138 | private static native void nMatToBitmap2(long m_addr, Bitmap b, boolean premultiplyAlpha); 139 | } 140 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/contrib/Contrib.java: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // This file is auto-generated. Please don't modify it! 4 | // 5 | package org.opencv.contrib; 6 | 7 | import java.util.List; 8 | import org.opencv.core.Mat; 9 | import org.opencv.core.MatOfFloat; 10 | import org.opencv.core.MatOfPoint; 11 | import org.opencv.utils.Converters; 12 | 13 | public class Contrib { 14 | 15 | public static final int 16 | ROTATION = 1, 17 | TRANSLATION = 2, 18 | RIGID_BODY_MOTION = 4, 19 | COLORMAP_AUTUMN = 0, 20 | COLORMAP_BONE = 1, 21 | COLORMAP_JET = 2, 22 | COLORMAP_WINTER = 3, 23 | COLORMAP_RAINBOW = 4, 24 | COLORMAP_OCEAN = 5, 25 | COLORMAP_SUMMER = 6, 26 | COLORMAP_SPRING = 7, 27 | COLORMAP_COOL = 8, 28 | COLORMAP_HSV = 9, 29 | COLORMAP_PINK = 10, 30 | COLORMAP_HOT = 11, 31 | RETINA_COLOR_RANDOM = 0, 32 | RETINA_COLOR_DIAGONAL = 1, 33 | RETINA_COLOR_BAYER = 2; 34 | 35 | 36 | // 37 | // C++: void applyColorMap(Mat src, Mat& dst, int colormap) 38 | // 39 | 40 | /** 41 | *

Applies a GNU Octave/MATLAB equivalent colormap on a given image.

42 | * 43 | *

Currently the following GNU Octave/MATLAB equivalent colormaps are 44 | * implemented: enum

45 | * 46 | *

// C++ code:

47 | * 48 | * 49 | *

COLORMAP_AUTUMN = 0,

50 | * 51 | *

COLORMAP_BONE = 1,

52 | * 53 | *

COLORMAP_JET = 2,

54 | * 55 | *

COLORMAP_WINTER = 3,

56 | * 57 | *

COLORMAP_RAINBOW = 4,

58 | * 59 | *

COLORMAP_OCEAN = 5,

60 | * 61 | *

COLORMAP_SUMMER = 6,

62 | * 63 | *

COLORMAP_SPRING = 7,

64 | * 65 | *

COLORMAP_COOL = 8,

66 | * 67 | *

COLORMAP_HSV = 9,

68 | * 69 | *

COLORMAP_PINK = 10,

70 | * 71 | *

COLORMAP_HOT = 11

72 | * 73 | * 74 | * @param src The source image, grayscale or colored does not matter. 75 | * @param dst The result is the colormapped source image. Note: "Mat.create" is 76 | * called on dst. 77 | * @param colormap The colormap to apply, see the list of available colormaps 78 | * below. 79 | * 80 | * @see org.opencv.contrib.Contrib.applyColorMap 81 | */ 82 | public static void applyColorMap(Mat src, Mat dst, int colormap) 83 | { 84 | 85 | applyColorMap_0(src.nativeObj, dst.nativeObj, colormap); 86 | 87 | return; 88 | } 89 | 90 | 91 | // 92 | // C++: int chamerMatching(Mat img, Mat templ, vector_vector_Point& results, vector_float& cost, double templScale = 1, int maxMatches = 20, double minMatchDistance = 1.0, int padX = 3, int padY = 3, int scales = 5, double minScale = 0.6, double maxScale = 1.6, double orientationWeight = 0.5, double truncate = 20) 93 | // 94 | 95 | public static int chamerMatching(Mat img, Mat templ, List results, MatOfFloat cost, double templScale, int maxMatches, double minMatchDistance, int padX, int padY, int scales, double minScale, double maxScale, double orientationWeight, double truncate) 96 | { 97 | Mat results_mat = new Mat(); 98 | Mat cost_mat = cost; 99 | int retVal = chamerMatching_0(img.nativeObj, templ.nativeObj, results_mat.nativeObj, cost_mat.nativeObj, templScale, maxMatches, minMatchDistance, padX, padY, scales, minScale, maxScale, orientationWeight, truncate); 100 | Converters.Mat_to_vector_vector_Point(results_mat, results); 101 | return retVal; 102 | } 103 | 104 | public static int chamerMatching(Mat img, Mat templ, List results, MatOfFloat cost) 105 | { 106 | Mat results_mat = new Mat(); 107 | Mat cost_mat = cost; 108 | int retVal = chamerMatching_1(img.nativeObj, templ.nativeObj, results_mat.nativeObj, cost_mat.nativeObj); 109 | Converters.Mat_to_vector_vector_Point(results_mat, results); 110 | return retVal; 111 | } 112 | 113 | 114 | // 115 | // C++: Ptr_FaceRecognizer createEigenFaceRecognizer(int num_components = 0, double threshold = DBL_MAX) 116 | // 117 | 118 | // Return type 'Ptr_FaceRecognizer' is not supported, skipping the function 119 | 120 | 121 | // 122 | // C++: Ptr_FaceRecognizer createFisherFaceRecognizer(int num_components = 0, double threshold = DBL_MAX) 123 | // 124 | 125 | // Return type 'Ptr_FaceRecognizer' is not supported, skipping the function 126 | 127 | 128 | // 129 | // C++: Ptr_FaceRecognizer createLBPHFaceRecognizer(int radius = 1, int neighbors = 8, int grid_x = 8, int grid_y = 8, double threshold = DBL_MAX) 130 | // 131 | 132 | // Return type 'Ptr_FaceRecognizer' is not supported, skipping the function 133 | 134 | 135 | 136 | 137 | // C++: void applyColorMap(Mat src, Mat& dst, int colormap) 138 | private static native void applyColorMap_0(long src_nativeObj, long dst_nativeObj, int colormap); 139 | 140 | // C++: int chamerMatching(Mat img, Mat templ, vector_vector_Point& results, vector_float& cost, double templScale = 1, int maxMatches = 20, double minMatchDistance = 1.0, int padX = 3, int padY = 3, int scales = 5, double minScale = 0.6, double maxScale = 1.6, double orientationWeight = 0.5, double truncate = 20) 141 | private static native int chamerMatching_0(long img_nativeObj, long templ_nativeObj, long results_mat_nativeObj, long cost_mat_nativeObj, double templScale, int maxMatches, double minMatchDistance, int padX, int padY, int scales, double minScale, double maxScale, double orientationWeight, double truncate); 142 | private static native int chamerMatching_1(long img_nativeObj, long templ_nativeObj, long results_mat_nativeObj, long cost_mat_nativeObj); 143 | 144 | } 145 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/core/CvException.java: -------------------------------------------------------------------------------- 1 | package org.opencv.core; 2 | 3 | public class CvException extends RuntimeException { 4 | 5 | private static final long serialVersionUID = 1L; 6 | 7 | public CvException(String msg) { 8 | super(msg); 9 | } 10 | 11 | @Override 12 | public String toString() { 13 | return "CvException [" + super.toString() + "]"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/core/CvType.java: -------------------------------------------------------------------------------- 1 | package org.opencv.core; 2 | 3 | public final class CvType { 4 | 5 | // type depth constants 6 | public static final int 7 | CV_8U = 0, CV_8S = 1, 8 | CV_16U = 2, CV_16S = 3, 9 | CV_32S = 4, 10 | CV_32F = 5, 11 | CV_64F = 6, 12 | CV_USRTYPE1 = 7; 13 | 14 | // predefined type constants 15 | public static final int 16 | CV_8UC1 = CV_8UC(1), CV_8UC2 = CV_8UC(2), CV_8UC3 = CV_8UC(3), CV_8UC4 = CV_8UC(4), 17 | CV_8SC1 = CV_8SC(1), CV_8SC2 = CV_8SC(2), CV_8SC3 = CV_8SC(3), CV_8SC4 = CV_8SC(4), 18 | CV_16UC1 = CV_16UC(1), CV_16UC2 = CV_16UC(2), CV_16UC3 = CV_16UC(3), CV_16UC4 = CV_16UC(4), 19 | CV_16SC1 = CV_16SC(1), CV_16SC2 = CV_16SC(2), CV_16SC3 = CV_16SC(3), CV_16SC4 = CV_16SC(4), 20 | CV_32SC1 = CV_32SC(1), CV_32SC2 = CV_32SC(2), CV_32SC3 = CV_32SC(3), CV_32SC4 = CV_32SC(4), 21 | CV_32FC1 = CV_32FC(1), CV_32FC2 = CV_32FC(2), CV_32FC3 = CV_32FC(3), CV_32FC4 = CV_32FC(4), 22 | CV_64FC1 = CV_64FC(1), CV_64FC2 = CV_64FC(2), CV_64FC3 = CV_64FC(3), CV_64FC4 = CV_64FC(4); 23 | 24 | private static final int CV_CN_MAX = 512, CV_CN_SHIFT = 3, CV_DEPTH_MAX = (1 << CV_CN_SHIFT); 25 | 26 | public static final int makeType(int depth, int channels) { 27 | if (channels <= 0 || channels >= CV_CN_MAX) { 28 | throw new java.lang.UnsupportedOperationException( 29 | "Channels count should be 1.." + (CV_CN_MAX - 1)); 30 | } 31 | if (depth < 0 || depth >= CV_DEPTH_MAX) { 32 | throw new java.lang.UnsupportedOperationException( 33 | "Data type depth should be 0.." + (CV_DEPTH_MAX - 1)); 34 | } 35 | return (depth & (CV_DEPTH_MAX - 1)) + ((channels - 1) << CV_CN_SHIFT); 36 | } 37 | 38 | public static final int CV_8UC(int ch) { 39 | return makeType(CV_8U, ch); 40 | } 41 | 42 | public static final int CV_8SC(int ch) { 43 | return makeType(CV_8S, ch); 44 | } 45 | 46 | public static final int CV_16UC(int ch) { 47 | return makeType(CV_16U, ch); 48 | } 49 | 50 | public static final int CV_16SC(int ch) { 51 | return makeType(CV_16S, ch); 52 | } 53 | 54 | public static final int CV_32SC(int ch) { 55 | return makeType(CV_32S, ch); 56 | } 57 | 58 | public static final int CV_32FC(int ch) { 59 | return makeType(CV_32F, ch); 60 | } 61 | 62 | public static final int CV_64FC(int ch) { 63 | return makeType(CV_64F, ch); 64 | } 65 | 66 | public static final int channels(int type) { 67 | return (type >> CV_CN_SHIFT) + 1; 68 | } 69 | 70 | public static final int depth(int type) { 71 | return type & (CV_DEPTH_MAX - 1); 72 | } 73 | 74 | public static final boolean isInteger(int type) { 75 | return depth(type) < CV_32F; 76 | } 77 | 78 | public static final int ELEM_SIZE(int type) { 79 | switch (depth(type)) { 80 | case CV_8U: 81 | case CV_8S: 82 | return channels(type); 83 | case CV_16U: 84 | case CV_16S: 85 | return 2 * channels(type); 86 | case CV_32S: 87 | case CV_32F: 88 | return 4 * channels(type); 89 | case CV_64F: 90 | return 8 * channels(type); 91 | default: 92 | throw new java.lang.UnsupportedOperationException( 93 | "Unsupported CvType value: " + type); 94 | } 95 | } 96 | 97 | public static final String typeToString(int type) { 98 | String s; 99 | switch (depth(type)) { 100 | case CV_8U: 101 | s = "CV_8U"; 102 | break; 103 | case CV_8S: 104 | s = "CV_8S"; 105 | break; 106 | case CV_16U: 107 | s = "CV_16U"; 108 | break; 109 | case CV_16S: 110 | s = "CV_16S"; 111 | break; 112 | case CV_32S: 113 | s = "CV_32S"; 114 | break; 115 | case CV_32F: 116 | s = "CV_32F"; 117 | break; 118 | case CV_64F: 119 | s = "CV_64F"; 120 | break; 121 | case CV_USRTYPE1: 122 | s = "CV_USRTYPE1"; 123 | break; 124 | default: 125 | throw new java.lang.UnsupportedOperationException( 126 | "Unsupported CvType value: " + type); 127 | } 128 | 129 | int ch = channels(type); 130 | if (ch <= 4) 131 | return s + "C" + ch; 132 | else 133 | return s + "C(" + ch + ")"; 134 | } 135 | 136 | } 137 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/core/MatOfByte.java: -------------------------------------------------------------------------------- 1 | package org.opencv.core; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | 6 | public class MatOfByte extends Mat { 7 | // 8UC(x) 8 | private static final int _depth = CvType.CV_8U; 9 | private static final int _channels = 1; 10 | 11 | public MatOfByte() { 12 | super(); 13 | } 14 | 15 | protected MatOfByte(long addr) { 16 | super(addr); 17 | if( !empty() && checkVector(_channels, _depth) < 0 ) 18 | throw new IllegalArgumentException("Incompatible Mat"); 19 | //FIXME: do we need release() here? 20 | } 21 | 22 | public static MatOfByte fromNativeAddr(long addr) { 23 | return new MatOfByte(addr); 24 | } 25 | 26 | public MatOfByte(Mat m) { 27 | super(m, Range.all()); 28 | if( !empty() && checkVector(_channels, _depth) < 0 ) 29 | throw new IllegalArgumentException("Incompatible Mat"); 30 | //FIXME: do we need release() here? 31 | } 32 | 33 | public MatOfByte(byte...a) { 34 | super(); 35 | fromArray(a); 36 | } 37 | 38 | public void alloc(int elemNumber) { 39 | if(elemNumber>0) 40 | super.create(elemNumber, 1, CvType.makeType(_depth, _channels)); 41 | } 42 | 43 | public void fromArray(byte...a) { 44 | if(a==null || a.length==0) 45 | return; 46 | int num = a.length / _channels; 47 | alloc(num); 48 | put(0, 0, a); //TODO: check ret val! 49 | } 50 | 51 | public byte[] toArray() { 52 | int num = checkVector(_channels, _depth); 53 | if(num < 0) 54 | throw new RuntimeException("Native Mat has unexpected type or size: " + toString()); 55 | byte[] a = new byte[num * _channels]; 56 | if(num == 0) 57 | return a; 58 | get(0, 0, a); //TODO: check ret val! 59 | return a; 60 | } 61 | 62 | public void fromList(List lb) { 63 | if(lb==null || lb.size()==0) 64 | return; 65 | Byte ab[] = lb.toArray(new Byte[0]); 66 | byte a[] = new byte[ab.length]; 67 | for(int i=0; i toList() { 73 | byte[] a = toArray(); 74 | Byte ab[] = new Byte[a.length]; 75 | for(int i=0; i0) 42 | super.create(elemNumber, 1, CvType.makeType(_depth, _channels)); 43 | } 44 | 45 | 46 | public void fromArray(DMatch...a) { 47 | if(a==null || a.length==0) 48 | return; 49 | int num = a.length; 50 | alloc(num); 51 | float buff[] = new float[num * _channels]; 52 | for(int i=0; i ldm) { 75 | DMatch adm[] = ldm.toArray(new DMatch[0]); 76 | fromArray(adm); 77 | } 78 | 79 | public List toList() { 80 | DMatch[] adm = toArray(); 81 | return Arrays.asList(adm); 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/core/MatOfDouble.java: -------------------------------------------------------------------------------- 1 | package org.opencv.core; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | 6 | public class MatOfDouble extends Mat { 7 | // 64FC(x) 8 | private static final int _depth = CvType.CV_64F; 9 | private static final int _channels = 1; 10 | 11 | public MatOfDouble() { 12 | super(); 13 | } 14 | 15 | protected MatOfDouble(long addr) { 16 | super(addr); 17 | if( !empty() && checkVector(_channels, _depth) < 0 ) 18 | throw new IllegalArgumentException("Incompatible Mat"); 19 | //FIXME: do we need release() here? 20 | } 21 | 22 | public static MatOfDouble fromNativeAddr(long addr) { 23 | return new MatOfDouble(addr); 24 | } 25 | 26 | public MatOfDouble(Mat m) { 27 | super(m, Range.all()); 28 | if( !empty() && checkVector(_channels, _depth) < 0 ) 29 | throw new IllegalArgumentException("Incompatible Mat"); 30 | //FIXME: do we need release() here? 31 | } 32 | 33 | public MatOfDouble(double...a) { 34 | super(); 35 | fromArray(a); 36 | } 37 | 38 | public void alloc(int elemNumber) { 39 | if(elemNumber>0) 40 | super.create(elemNumber, 1, CvType.makeType(_depth, _channels)); 41 | } 42 | 43 | public void fromArray(double...a) { 44 | if(a==null || a.length==0) 45 | return; 46 | int num = a.length / _channels; 47 | alloc(num); 48 | put(0, 0, a); //TODO: check ret val! 49 | } 50 | 51 | public double[] toArray() { 52 | int num = checkVector(_channels, _depth); 53 | if(num < 0) 54 | throw new RuntimeException("Native Mat has unexpected type or size: " + toString()); 55 | double[] a = new double[num * _channels]; 56 | if(num == 0) 57 | return a; 58 | get(0, 0, a); //TODO: check ret val! 59 | return a; 60 | } 61 | 62 | public void fromList(List lb) { 63 | if(lb==null || lb.size()==0) 64 | return; 65 | Double ab[] = lb.toArray(new Double[0]); 66 | double a[] = new double[ab.length]; 67 | for(int i=0; i toList() { 73 | double[] a = toArray(); 74 | Double ab[] = new Double[a.length]; 75 | for(int i=0; i0) 40 | super.create(elemNumber, 1, CvType.makeType(_depth, _channels)); 41 | } 42 | 43 | public void fromArray(float...a) { 44 | if(a==null || a.length==0) 45 | return; 46 | int num = a.length / _channels; 47 | alloc(num); 48 | put(0, 0, a); //TODO: check ret val! 49 | } 50 | 51 | public float[] toArray() { 52 | int num = checkVector(_channels, _depth); 53 | if(num < 0) 54 | throw new RuntimeException("Native Mat has unexpected type or size: " + toString()); 55 | float[] a = new float[num * _channels]; 56 | if(num == 0) 57 | return a; 58 | get(0, 0, a); //TODO: check ret val! 59 | return a; 60 | } 61 | 62 | public void fromList(List lb) { 63 | if(lb==null || lb.size()==0) 64 | return; 65 | Float ab[] = lb.toArray(new Float[0]); 66 | float a[] = new float[ab.length]; 67 | for(int i=0; i toList() { 73 | float[] a = toArray(); 74 | Float ab[] = new Float[a.length]; 75 | for(int i=0; i0) 40 | super.create(elemNumber, 1, CvType.makeType(_depth, _channels)); 41 | } 42 | 43 | public void fromArray(float...a) { 44 | if(a==null || a.length==0) 45 | return; 46 | int num = a.length / _channels; 47 | alloc(num); 48 | put(0, 0, a); //TODO: check ret val! 49 | } 50 | 51 | public float[] toArray() { 52 | int num = checkVector(_channels, _depth); 53 | if(num < 0) 54 | throw new RuntimeException("Native Mat has unexpected type or size: " + toString()); 55 | float[] a = new float[num * _channels]; 56 | if(num == 0) 57 | return a; 58 | get(0, 0, a); //TODO: check ret val! 59 | return a; 60 | } 61 | 62 | public void fromList(List lb) { 63 | if(lb==null || lb.size()==0) 64 | return; 65 | Float ab[] = lb.toArray(new Float[0]); 66 | float a[] = new float[ab.length]; 67 | for(int i=0; i toList() { 73 | float[] a = toArray(); 74 | Float ab[] = new Float[a.length]; 75 | for(int i=0; i0) 40 | super.create(elemNumber, 1, CvType.makeType(_depth, _channels)); 41 | } 42 | 43 | public void fromArray(float...a) { 44 | if(a==null || a.length==0) 45 | return; 46 | int num = a.length / _channels; 47 | alloc(num); 48 | put(0, 0, a); //TODO: check ret val! 49 | } 50 | 51 | public float[] toArray() { 52 | int num = checkVector(_channels, _depth); 53 | if(num < 0) 54 | throw new RuntimeException("Native Mat has unexpected type or size: " + toString()); 55 | float[] a = new float[num * _channels]; 56 | if(num == 0) 57 | return a; 58 | get(0, 0, a); //TODO: check ret val! 59 | return a; 60 | } 61 | 62 | public void fromList(List lb) { 63 | if(lb==null || lb.size()==0) 64 | return; 65 | Float ab[] = lb.toArray(new Float[0]); 66 | float a[] = new float[ab.length]; 67 | for(int i=0; i toList() { 73 | float[] a = toArray(); 74 | Float ab[] = new Float[a.length]; 75 | for(int i=0; i0) 41 | super.create(elemNumber, 1, CvType.makeType(_depth, _channels)); 42 | } 43 | 44 | public void fromArray(int...a) { 45 | if(a==null || a.length==0) 46 | return; 47 | int num = a.length / _channels; 48 | alloc(num); 49 | put(0, 0, a); //TODO: check ret val! 50 | } 51 | 52 | public int[] toArray() { 53 | int num = checkVector(_channels, _depth); 54 | if(num < 0) 55 | throw new RuntimeException("Native Mat has unexpected type or size: " + toString()); 56 | int[] a = new int[num * _channels]; 57 | if(num == 0) 58 | return a; 59 | get(0, 0, a); //TODO: check ret val! 60 | return a; 61 | } 62 | 63 | public void fromList(List lb) { 64 | if(lb==null || lb.size()==0) 65 | return; 66 | Integer ab[] = lb.toArray(new Integer[0]); 67 | int a[] = new int[ab.length]; 68 | for(int i=0; i toList() { 74 | int[] a = toArray(); 75 | Integer ab[] = new Integer[a.length]; 76 | for(int i=0; i0) 41 | super.create(elemNumber, 1, CvType.makeType(_depth, _channels)); 42 | } 43 | 44 | public void fromArray(int...a) { 45 | if(a==null || a.length==0) 46 | return; 47 | int num = a.length / _channels; 48 | alloc(num); 49 | put(0, 0, a); //TODO: check ret val! 50 | } 51 | 52 | public int[] toArray() { 53 | int num = checkVector(_channels, _depth); 54 | if(num < 0) 55 | throw new RuntimeException("Native Mat has unexpected type or size: " + toString()); 56 | int[] a = new int[num * _channels]; 57 | if(num == 0) 58 | return a; 59 | get(0, 0, a); //TODO: check ret val! 60 | return a; 61 | } 62 | 63 | public void fromList(List lb) { 64 | if(lb==null || lb.size()==0) 65 | return; 66 | Integer ab[] = lb.toArray(new Integer[0]); 67 | int a[] = new int[ab.length]; 68 | for(int i=0; i toList() { 74 | int[] a = toArray(); 75 | Integer ab[] = new Integer[a.length]; 76 | for(int i=0; i0) 42 | super.create(elemNumber, 1, CvType.makeType(_depth, _channels)); 43 | } 44 | 45 | public void fromArray(KeyPoint...a) { 46 | if(a==null || a.length==0) 47 | return; 48 | int num = a.length; 49 | alloc(num); 50 | float buff[] = new float[num * _channels]; 51 | for(int i=0; i lkp) { 78 | KeyPoint akp[] = lkp.toArray(new KeyPoint[0]); 79 | fromArray(akp); 80 | } 81 | 82 | public List toList() { 83 | KeyPoint[] akp = toArray(); 84 | return Arrays.asList(akp); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/core/MatOfPoint.java: -------------------------------------------------------------------------------- 1 | package org.opencv.core; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | 6 | public class MatOfPoint extends Mat { 7 | // 32SC2 8 | private static final int _depth = CvType.CV_32S; 9 | private static final int _channels = 2; 10 | 11 | public MatOfPoint() { 12 | super(); 13 | } 14 | 15 | protected MatOfPoint(long addr) { 16 | super(addr); 17 | if( !empty() && checkVector(_channels, _depth) < 0 ) 18 | throw new IllegalArgumentException("Incompatible Mat"); 19 | //FIXME: do we need release() here? 20 | } 21 | 22 | public static MatOfPoint fromNativeAddr(long addr) { 23 | return new MatOfPoint(addr); 24 | } 25 | 26 | public MatOfPoint(Mat m) { 27 | super(m, Range.all()); 28 | if( !empty() && checkVector(_channels, _depth) < 0 ) 29 | throw new IllegalArgumentException("Incompatible Mat"); 30 | //FIXME: do we need release() here? 31 | } 32 | 33 | public MatOfPoint(Point...a) { 34 | super(); 35 | fromArray(a); 36 | } 37 | 38 | public void alloc(int elemNumber) { 39 | if(elemNumber>0) 40 | super.create(elemNumber, 1, CvType.makeType(_depth, _channels)); 41 | } 42 | 43 | public void fromArray(Point...a) { 44 | if(a==null || a.length==0) 45 | return; 46 | int num = a.length; 47 | alloc(num); 48 | int buff[] = new int[num * _channels]; 49 | for(int i=0; i lp) { 70 | Point ap[] = lp.toArray(new Point[0]); 71 | fromArray(ap); 72 | } 73 | 74 | public List toList() { 75 | Point[] ap = toArray(); 76 | return Arrays.asList(ap); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/core/MatOfPoint2f.java: -------------------------------------------------------------------------------- 1 | package org.opencv.core; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | 6 | public class MatOfPoint2f extends Mat { 7 | // 32FC2 8 | private static final int _depth = CvType.CV_32F; 9 | private static final int _channels = 2; 10 | 11 | public MatOfPoint2f() { 12 | super(); 13 | } 14 | 15 | protected MatOfPoint2f(long addr) { 16 | super(addr); 17 | if( !empty() && checkVector(_channels, _depth) < 0 ) 18 | throw new IllegalArgumentException("Incompatible Mat"); 19 | //FIXME: do we need release() here? 20 | } 21 | 22 | public static MatOfPoint2f fromNativeAddr(long addr) { 23 | return new MatOfPoint2f(addr); 24 | } 25 | 26 | public MatOfPoint2f(Mat m) { 27 | super(m, Range.all()); 28 | if( !empty() && checkVector(_channels, _depth) < 0 ) 29 | throw new IllegalArgumentException("Incompatible Mat"); 30 | //FIXME: do we need release() here? 31 | } 32 | 33 | public MatOfPoint2f(Point...a) { 34 | super(); 35 | fromArray(a); 36 | } 37 | 38 | public void alloc(int elemNumber) { 39 | if(elemNumber>0) 40 | super.create(elemNumber, 1, CvType.makeType(_depth, _channels)); 41 | } 42 | 43 | public void fromArray(Point...a) { 44 | if(a==null || a.length==0) 45 | return; 46 | int num = a.length; 47 | alloc(num); 48 | float buff[] = new float[num * _channels]; 49 | for(int i=0; i lp) { 70 | Point ap[] = lp.toArray(new Point[0]); 71 | fromArray(ap); 72 | } 73 | 74 | public List toList() { 75 | Point[] ap = toArray(); 76 | return Arrays.asList(ap); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/core/MatOfPoint3.java: -------------------------------------------------------------------------------- 1 | package org.opencv.core; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | 6 | public class MatOfPoint3 extends Mat { 7 | // 32SC3 8 | private static final int _depth = CvType.CV_32S; 9 | private static final int _channels = 3; 10 | 11 | public MatOfPoint3() { 12 | super(); 13 | } 14 | 15 | protected MatOfPoint3(long addr) { 16 | super(addr); 17 | if( !empty() && checkVector(_channels, _depth) < 0 ) 18 | throw new IllegalArgumentException("Incompatible Mat"); 19 | //FIXME: do we need release() here? 20 | } 21 | 22 | public static MatOfPoint3 fromNativeAddr(long addr) { 23 | return new MatOfPoint3(addr); 24 | } 25 | 26 | public MatOfPoint3(Mat m) { 27 | super(m, Range.all()); 28 | if( !empty() && checkVector(_channels, _depth) < 0 ) 29 | throw new IllegalArgumentException("Incompatible Mat"); 30 | //FIXME: do we need release() here? 31 | } 32 | 33 | public MatOfPoint3(Point3...a) { 34 | super(); 35 | fromArray(a); 36 | } 37 | 38 | public void alloc(int elemNumber) { 39 | if(elemNumber>0) 40 | super.create(elemNumber, 1, CvType.makeType(_depth, _channels)); 41 | } 42 | 43 | public void fromArray(Point3...a) { 44 | if(a==null || a.length==0) 45 | return; 46 | int num = a.length; 47 | alloc(num); 48 | int buff[] = new int[num * _channels]; 49 | for(int i=0; i lp) { 71 | Point3 ap[] = lp.toArray(new Point3[0]); 72 | fromArray(ap); 73 | } 74 | 75 | public List toList() { 76 | Point3[] ap = toArray(); 77 | return Arrays.asList(ap); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/core/MatOfPoint3f.java: -------------------------------------------------------------------------------- 1 | package org.opencv.core; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | 6 | public class MatOfPoint3f extends Mat { 7 | // 32FC3 8 | private static final int _depth = CvType.CV_32F; 9 | private static final int _channels = 3; 10 | 11 | public MatOfPoint3f() { 12 | super(); 13 | } 14 | 15 | protected MatOfPoint3f(long addr) { 16 | super(addr); 17 | if( !empty() && checkVector(_channels, _depth) < 0 ) 18 | throw new IllegalArgumentException("Incompatible Mat"); 19 | //FIXME: do we need release() here? 20 | } 21 | 22 | public static MatOfPoint3f fromNativeAddr(long addr) { 23 | return new MatOfPoint3f(addr); 24 | } 25 | 26 | public MatOfPoint3f(Mat m) { 27 | super(m, Range.all()); 28 | if( !empty() && checkVector(_channels, _depth) < 0 ) 29 | throw new IllegalArgumentException("Incompatible Mat"); 30 | //FIXME: do we need release() here? 31 | } 32 | 33 | public MatOfPoint3f(Point3...a) { 34 | super(); 35 | fromArray(a); 36 | } 37 | 38 | public void alloc(int elemNumber) { 39 | if(elemNumber>0) 40 | super.create(elemNumber, 1, CvType.makeType(_depth, _channels)); 41 | } 42 | 43 | public void fromArray(Point3...a) { 44 | if(a==null || a.length==0) 45 | return; 46 | int num = a.length; 47 | alloc(num); 48 | float buff[] = new float[num * _channels]; 49 | for(int i=0; i lp) { 71 | Point3 ap[] = lp.toArray(new Point3[0]); 72 | fromArray(ap); 73 | } 74 | 75 | public List toList() { 76 | Point3[] ap = toArray(); 77 | return Arrays.asList(ap); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/core/MatOfRect.java: -------------------------------------------------------------------------------- 1 | package org.opencv.core; 2 | 3 | import java.util.Arrays; 4 | import java.util.List; 5 | 6 | 7 | public class MatOfRect extends Mat { 8 | // 32SC4 9 | private static final int _depth = CvType.CV_32S; 10 | private static final int _channels = 4; 11 | 12 | public MatOfRect() { 13 | super(); 14 | } 15 | 16 | protected MatOfRect(long addr) { 17 | super(addr); 18 | if( !empty() && checkVector(_channels, _depth) < 0 ) 19 | throw new IllegalArgumentException("Incompatible Mat"); 20 | //FIXME: do we need release() here? 21 | } 22 | 23 | public static MatOfRect fromNativeAddr(long addr) { 24 | return new MatOfRect(addr); 25 | } 26 | 27 | public MatOfRect(Mat m) { 28 | super(m, Range.all()); 29 | if( !empty() && checkVector(_channels, _depth) < 0 ) 30 | throw new IllegalArgumentException("Incompatible Mat"); 31 | //FIXME: do we need release() here? 32 | } 33 | 34 | public MatOfRect(Rect...a) { 35 | super(); 36 | fromArray(a); 37 | } 38 | 39 | public void alloc(int elemNumber) { 40 | if(elemNumber>0) 41 | super.create(elemNumber, 1, CvType.makeType(_depth, _channels)); 42 | } 43 | 44 | public void fromArray(Rect...a) { 45 | if(a==null || a.length==0) 46 | return; 47 | int num = a.length; 48 | alloc(num); 49 | int buff[] = new int[num * _channels]; 50 | for(int i=0; i lr) { 73 | Rect ap[] = lr.toArray(new Rect[0]); 74 | fromArray(ap); 75 | } 76 | 77 | public List toList() { 78 | Rect[] ar = toArray(); 79 | return Arrays.asList(ar); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/core/Point.java: -------------------------------------------------------------------------------- 1 | package org.opencv.core; 2 | 3 | /** 4 | *

template class CV_EXPORTS Point_

5 | * 6 | *

// C++ code:

7 | * 8 | * 9 | *

public:

10 | * 11 | *

typedef _Tp value_type;

12 | * 13 | *

// various constructors

14 | * 15 | *

Point_();

16 | * 17 | *

Point_(_Tp _x, _Tp _y);

18 | * 19 | *

Point_(const Point_& pt);

20 | * 21 | *

Point_(const CvPoint& pt);

22 | * 23 | *

Point_(const CvPoint2D32f& pt);

24 | * 25 | *

Point_(const Size_<_Tp>& sz);

26 | * 27 | *

Point_(const Vec<_Tp, 2>& v);

28 | * 29 | *

Point_& operator = (const Point_& pt);

30 | * 31 | *

//! conversion to another data type

32 | * 33 | *

template operator Point_<_Tp2>() const;

34 | * 35 | *

//! conversion to the old-style C structures

36 | * 37 | *

operator CvPoint() const;

38 | * 39 | *

operator CvPoint2D32f() const;

40 | * 41 | *

operator Vec<_Tp, 2>() const;

42 | * 43 | *

//! dot product

44 | * 45 | *

_Tp dot(const Point_& pt) const;

46 | * 47 | *

//! dot product computed in double-precision arithmetics

48 | * 49 | *

double ddot(const Point_& pt) const;

50 | * 51 | *

//! cross-product

52 | * 53 | *

double cross(const Point_& pt) const;

54 | * 55 | *

//! checks whether the point is inside the specified rectangle

56 | * 57 | *

bool inside(const Rect_<_Tp>& r) const;

58 | * 59 | *

_Tp x, y; //< the point coordinates

60 | * 61 | *

};

62 | * 63 | *

Template class for 2D points specified by its coordinates

64 | * 65 | *

x and y. 66 | * An instance of the class is interchangeable with C structures, 67 | * CvPoint and CvPoint2D32f. There is also a cast 68 | * operator to convert point coordinates to the specified type. The conversion 69 | * from floating-point coordinates to integer coordinates is done by rounding. 70 | * Commonly, the conversion uses thisoperation for each of the coordinates. 71 | * Besides the class members listed in the declaration above, the following 72 | * operations on points are implemented:

73 | * 74 | *

// C++ code:

75 | * 76 | *

pt1 = pt2 + pt3;

77 | * 78 | *

pt1 = pt2 - pt3;

79 | * 80 | *

pt1 = pt2 * a;

81 | * 82 | *

pt1 = a * pt2;

83 | * 84 | *

pt1 += pt2;

85 | * 86 | *

pt1 -= pt2;

87 | * 88 | *

pt1 *= a;

89 | * 90 | *

double value = norm(pt); // L2 norm

91 | * 92 | *

pt1 == pt2;

93 | * 94 | *

pt1 != pt2;

95 | * 96 | *

For your convenience, the following type aliases are defined:

97 | * 98 | *

typedef Point_ Point2i;

99 | * 100 | *

typedef Point2i Point;

101 | * 102 | *

typedef Point_ Point2f;

103 | * 104 | *

typedef Point_ Point2d;

105 | * 106 | *

Example:

107 | * 108 | *

Point2f a(0.3f, 0.f), b(0.f, 0.4f);

109 | * 110 | *

Point pt = (a + b)*10.f;

111 | * 112 | *

cout << pt.x << ", " << pt.y << endl;

113 | * 114 | * @see org.opencv.core.Point_ 115 | */ 116 | public class Point { 117 | 118 | public double x, y; 119 | 120 | public Point(double x, double y) { 121 | this.x = x; 122 | this.y = y; 123 | } 124 | 125 | public Point() { 126 | this(0, 0); 127 | } 128 | 129 | public Point(double[] vals) { 130 | this(); 131 | set(vals); 132 | } 133 | 134 | public void set(double[] vals) { 135 | if (vals != null) { 136 | x = vals.length > 0 ? vals[0] : 0; 137 | y = vals.length > 1 ? vals[1] : 0; 138 | } else { 139 | x = 0; 140 | y = 0; 141 | } 142 | } 143 | 144 | public Point clone() { 145 | return new Point(x, y); 146 | } 147 | 148 | public double dot(Point p) { 149 | return x * p.x + y * p.y; 150 | } 151 | 152 | @Override 153 | public int hashCode() { 154 | final int prime = 31; 155 | int result = 1; 156 | long temp; 157 | temp = Double.doubleToLongBits(x); 158 | result = prime * result + (int) (temp ^ (temp >>> 32)); 159 | temp = Double.doubleToLongBits(y); 160 | result = prime * result + (int) (temp ^ (temp >>> 32)); 161 | return result; 162 | } 163 | 164 | @Override 165 | public boolean equals(Object obj) { 166 | if (this == obj) return true; 167 | if (!(obj instanceof Point)) return false; 168 | Point it = (Point) obj; 169 | return x == it.x && y == it.y; 170 | } 171 | 172 | public boolean inside(Rect r) { 173 | return r.contains(this); 174 | } 175 | 176 | @Override 177 | public String toString() { 178 | return "{" + x + ", " + y + "}"; 179 | } 180 | } 181 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/core/Point3.java: -------------------------------------------------------------------------------- 1 | package org.opencv.core; 2 | 3 | /** 4 | *

template class CV_EXPORTS Point3_

5 | * 6 | *

// C++ code:

7 | * 8 | * 9 | *

public:

10 | * 11 | *

typedef _Tp value_type;

12 | * 13 | *

// various constructors

14 | * 15 | *

Point3_();

16 | * 17 | *

Point3_(_Tp _x, _Tp _y, _Tp _z);

18 | * 19 | *

Point3_(const Point3_& pt);

20 | * 21 | *

explicit Point3_(const Point_<_Tp>& pt);

22 | * 23 | *

Point3_(const CvPoint3D32f& pt);

24 | * 25 | *

Point3_(const Vec<_Tp, 3>& v);

26 | * 27 | *

Point3_& operator = (const Point3_& pt);

28 | * 29 | *

//! conversion to another data type

30 | * 31 | *

template operator Point3_<_Tp2>() const;

32 | * 33 | *

//! conversion to the old-style CvPoint...

34 | * 35 | *

operator CvPoint3D32f() const;

36 | * 37 | *

//! conversion to cv.Vec<>

38 | * 39 | *

operator Vec<_Tp, 3>() const;

40 | * 41 | *

//! dot product

42 | * 43 | *

_Tp dot(const Point3_& pt) const;

44 | * 45 | *

//! dot product computed in double-precision arithmetics

46 | * 47 | *

double ddot(const Point3_& pt) const;

48 | * 49 | *

//! cross product of the 2 3D points

50 | * 51 | *

Point3_ cross(const Point3_& pt) const;

52 | * 53 | *

_Tp x, y, z; //< the point coordinates

54 | * 55 | *

};

56 | * 57 | *

Template class for 3D points specified by its coordinates

58 | * 59 | *

x, y and z. 60 | * An instance of the class is interchangeable with the C structure 61 | * CvPoint2D32f. Similarly to Point_, the coordinates 62 | * of 3D points can be converted to another type. The vector arithmetic and 63 | * comparison operations are also supported. 64 | * The following Point3_<> aliases are available:

65 | * 66 | *

// C++ code:

67 | * 68 | *

typedef Point3_ Point3i;

69 | * 70 | *

typedef Point3_ Point3f;

71 | * 72 | *

typedef Point3_ Point3d;

73 | * 74 | * @see org.opencv.core.Point3_ 75 | */ 76 | public class Point3 { 77 | 78 | public double x, y, z; 79 | 80 | public Point3(double x, double y, double z) { 81 | this.x = x; 82 | this.y = y; 83 | this.z = z; 84 | } 85 | 86 | public Point3() { 87 | this(0, 0, 0); 88 | } 89 | 90 | public Point3(Point p) { 91 | x = p.x; 92 | y = p.y; 93 | z = 0; 94 | } 95 | 96 | public Point3(double[] vals) { 97 | this(); 98 | set(vals); 99 | } 100 | 101 | public void set(double[] vals) { 102 | if (vals != null) { 103 | x = vals.length > 0 ? vals[0] : 0; 104 | y = vals.length > 1 ? vals[1] : 0; 105 | z = vals.length > 2 ? vals[2] : 0; 106 | } else { 107 | x = 0; 108 | y = 0; 109 | z = 0; 110 | } 111 | } 112 | 113 | public Point3 clone() { 114 | return new Point3(x, y, z); 115 | } 116 | 117 | public double dot(Point3 p) { 118 | return x * p.x + y * p.y + z * p.z; 119 | } 120 | 121 | public Point3 cross(Point3 p) { 122 | return new Point3(y * p.z - z * p.y, z * p.x - x * p.z, x * p.y - y * p.x); 123 | } 124 | 125 | @Override 126 | public int hashCode() { 127 | final int prime = 31; 128 | int result = 1; 129 | long temp; 130 | temp = Double.doubleToLongBits(x); 131 | result = prime * result + (int) (temp ^ (temp >>> 32)); 132 | temp = Double.doubleToLongBits(y); 133 | result = prime * result + (int) (temp ^ (temp >>> 32)); 134 | temp = Double.doubleToLongBits(z); 135 | result = prime * result + (int) (temp ^ (temp >>> 32)); 136 | return result; 137 | } 138 | 139 | @Override 140 | public boolean equals(Object obj) { 141 | if (this == obj) return true; 142 | if (!(obj instanceof Point3)) return false; 143 | Point3 it = (Point3) obj; 144 | return x == it.x && y == it.y && z == it.z; 145 | } 146 | 147 | @Override 148 | public String toString() { 149 | return "{" + x + ", " + y + ", " + z + "}"; 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/core/Range.java: -------------------------------------------------------------------------------- 1 | package org.opencv.core; 2 | 3 | /** 4 | *

Template class specifying a continuous subsequence (slice) of a sequence.

5 | * 6 | *

class CV_EXPORTS Range

7 | * 8 | *

// C++ code:

9 | * 10 | * 11 | *

public:

12 | * 13 | *

Range();

14 | * 15 | *

Range(int _start, int _end);

16 | * 17 | *

Range(const CvSlice& slice);

18 | * 19 | *

int size() const;

20 | * 21 | *

bool empty() const;

22 | * 23 | *

static Range all();

24 | * 25 | *

operator CvSlice() const;

26 | * 27 | *

int start, end;

28 | * 29 | *

};

30 | * 31 | *

The class is used to specify a row or a column span in a matrix (

32 | * 33 | *

"Mat") and for many other purposes. Range(a,b) is basically the 34 | * same as a:b in Matlab or a..b in Python. As in 35 | * Python, start is an inclusive left boundary of the range and 36 | * end is an exclusive right boundary of the range. Such a 37 | * half-opened interval is usually denoted as [start,end). 38 | * The static method Range.all() returns a special variable that 39 | * means "the whole sequence" or "the whole range", just like " : " 40 | * in Matlab or " ... " in Python. All the methods and functions in 41 | * OpenCV that take Range support this special Range.all() 42 | * value. But, of course, in case of your own custom processing, you will 43 | * probably have to check and handle it explicitly:

44 | * 45 | *

// C++ code:

46 | * 47 | *

void my_function(..., const Range& r,....)

48 | * 49 | * 50 | *

if(r == Range.all()) {

51 | * 52 | *

// process all the data

53 | * 54 | * 55 | *

else {

56 | * 57 | *

// process [r.start, r.end)

58 | * 59 | * 60 | * 61 | *

62 | * 63 | * @see org.opencv.core.Range 64 | */ 65 | public class Range { 66 | 67 | public int start, end; 68 | 69 | public Range(int s, int e) { 70 | this.start = s; 71 | this.end = e; 72 | } 73 | 74 | public Range() { 75 | this(0, 0); 76 | } 77 | 78 | public Range(double[] vals) { 79 | set(vals); 80 | } 81 | 82 | public void set(double[] vals) { 83 | if (vals != null) { 84 | start = vals.length > 0 ? (int) vals[0] : 0; 85 | end = vals.length > 1 ? (int) vals[1] : 0; 86 | } else { 87 | start = 0; 88 | end = 0; 89 | } 90 | 91 | } 92 | 93 | public int size() { 94 | return empty() ? 0 : end - start; 95 | } 96 | 97 | public boolean empty() { 98 | return end <= start; 99 | } 100 | 101 | public static Range all() { 102 | return new Range(Integer.MIN_VALUE, Integer.MAX_VALUE); 103 | } 104 | 105 | public Range intersection(Range r1) { 106 | Range r = new Range(Math.max(r1.start, this.start), Math.min(r1.end, this.end)); 107 | r.end = Math.max(r.end, r.start); 108 | return r; 109 | } 110 | 111 | public Range shift(int delta) { 112 | return new Range(start + delta, end + delta); 113 | } 114 | 115 | public Range clone() { 116 | return new Range(start, end); 117 | } 118 | 119 | @Override 120 | public int hashCode() { 121 | final int prime = 31; 122 | int result = 1; 123 | long temp; 124 | temp = Double.doubleToLongBits(start); 125 | result = prime * result + (int) (temp ^ (temp >>> 32)); 126 | temp = Double.doubleToLongBits(end); 127 | result = prime * result + (int) (temp ^ (temp >>> 32)); 128 | return result; 129 | } 130 | 131 | @Override 132 | public boolean equals(Object obj) { 133 | if (this == obj) return true; 134 | if (!(obj instanceof Range)) return false; 135 | Range it = (Range) obj; 136 | return start == it.start && end == it.end; 137 | } 138 | 139 | @Override 140 | public String toString() { 141 | return "[" + start + ", " + end + ")"; 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/core/RotatedRect.java: -------------------------------------------------------------------------------- 1 | package org.opencv.core; 2 | 3 | public class RotatedRect { 4 | 5 | public Point center; 6 | public Size size; 7 | public double angle; 8 | 9 | public RotatedRect() { 10 | this.center = new Point(); 11 | this.size = new Size(); 12 | this.angle = 0; 13 | } 14 | 15 | public RotatedRect(Point c, Size s, double a) { 16 | this.center = c.clone(); 17 | this.size = s.clone(); 18 | this.angle = a; 19 | } 20 | 21 | public RotatedRect(double[] vals) { 22 | this(); 23 | set(vals); 24 | } 25 | 26 | public void set(double[] vals) { 27 | if (vals != null) { 28 | center.x = vals.length > 0 ? (double) vals[0] : 0; 29 | center.y = vals.length > 1 ? (double) vals[1] : 0; 30 | size.width = vals.length > 2 ? (double) vals[2] : 0; 31 | size.height = vals.length > 3 ? (double) vals[3] : 0; 32 | angle = vals.length > 4 ? (double) vals[4] : 0; 33 | } else { 34 | center.x = 0; 35 | center.x = 0; 36 | size.width = 0; 37 | size.height = 0; 38 | angle = 0; 39 | } 40 | } 41 | 42 | public void points(Point pt[]) 43 | { 44 | double _angle = angle * Math.PI / 180.0; 45 | double b = (double) Math.cos(_angle) * 0.5f; 46 | double a = (double) Math.sin(_angle) * 0.5f; 47 | 48 | pt[0] = new Point( 49 | center.x - a * size.height - b * size.width, 50 | center.y + b * size.height - a * size.width); 51 | 52 | pt[1] = new Point( 53 | center.x + a * size.height - b * size.width, 54 | center.y - b * size.height - a * size.width); 55 | 56 | pt[2] = new Point( 57 | 2 * center.x - pt[0].x, 58 | 2 * center.y - pt[0].y); 59 | 60 | pt[3] = new Point( 61 | 2 * center.x - pt[1].x, 62 | 2 * center.y - pt[1].y); 63 | } 64 | 65 | public Rect boundingRect() 66 | { 67 | Point pt[] = new Point[4]; 68 | points(pt); 69 | Rect r = new Rect((int) Math.floor(Math.min(Math.min(Math.min(pt[0].x, pt[1].x), pt[2].x), pt[3].x)), 70 | (int) Math.floor(Math.min(Math.min(Math.min(pt[0].y, pt[1].y), pt[2].y), pt[3].y)), 71 | (int) Math.ceil(Math.max(Math.max(Math.max(pt[0].x, pt[1].x), pt[2].x), pt[3].x)), 72 | (int) Math.ceil(Math.max(Math.max(Math.max(pt[0].y, pt[1].y), pt[2].y), pt[3].y))); 73 | r.width -= r.x - 1; 74 | r.height -= r.y - 1; 75 | return r; 76 | } 77 | 78 | public RotatedRect clone() { 79 | return new RotatedRect(center, size, angle); 80 | } 81 | 82 | @Override 83 | public int hashCode() { 84 | final int prime = 31; 85 | int result = 1; 86 | long temp; 87 | temp = Double.doubleToLongBits(center.x); 88 | result = prime * result + (int) (temp ^ (temp >>> 32)); 89 | temp = Double.doubleToLongBits(center.y); 90 | result = prime * result + (int) (temp ^ (temp >>> 32)); 91 | temp = Double.doubleToLongBits(size.width); 92 | result = prime * result + (int) (temp ^ (temp >>> 32)); 93 | temp = Double.doubleToLongBits(size.height); 94 | result = prime * result + (int) (temp ^ (temp >>> 32)); 95 | temp = Double.doubleToLongBits(angle); 96 | result = prime * result + (int) (temp ^ (temp >>> 32)); 97 | return result; 98 | } 99 | 100 | @Override 101 | public boolean equals(Object obj) { 102 | if (this == obj) return true; 103 | if (!(obj instanceof RotatedRect)) return false; 104 | RotatedRect it = (RotatedRect) obj; 105 | return center.equals(it.center) && size.equals(it.size) && angle == it.angle; 106 | } 107 | 108 | @Override 109 | public String toString() { 110 | return "{ " + center + " " + size + " * " + angle + " }"; 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/core/Scalar.java: -------------------------------------------------------------------------------- 1 | package org.opencv.core; 2 | 3 | /** 4 | *

Template class for a 4-element vector derived from Vec.

5 | * 6 | *

template class CV_EXPORTS Scalar_ : public Vec<_Tp, 4>

7 | * 8 | *

// C++ code:

9 | * 10 | * 11 | *

public:

12 | * 13 | *

//! various constructors

14 | * 15 | *

Scalar_();

16 | * 17 | *

Scalar_(_Tp v0, _Tp v1, _Tp v2=0, _Tp v3=0);

18 | * 19 | *

Scalar_(const CvScalar& s);

20 | * 21 | *

Scalar_(_Tp v0);

22 | * 23 | *

//! returns a scalar with all elements set to v0

24 | * 25 | *

static Scalar_<_Tp> all(_Tp v0);

26 | * 27 | *

//! conversion to the old-style CvScalar

28 | * 29 | *

operator CvScalar() const;

30 | * 31 | *

//! conversion to another data type

32 | * 33 | *

template operator Scalar_() const;

34 | * 35 | *

//! per-element product

36 | * 37 | *

Scalar_<_Tp> mul(const Scalar_<_Tp>& t, double scale=1) const;

38 | * 39 | *

// returns (v0, -v1, -v2, -v3)

40 | * 41 | *

Scalar_<_Tp> conj() const;

42 | * 43 | *

// returns true iff v1 == v2 == v3 == 0

44 | * 45 | *

bool isReal() const;

46 | * 47 | *

};

48 | * 49 | *

typedef Scalar_ Scalar;

50 | * 51 | *

Being derived from Vec<_Tp, 4>, Scalar_ and 52 | * Scalar can be used just as typical 4-element vectors. In 53 | * addition, they can be converted to/from CvScalar. The type 54 | * Scalar is widely used in OpenCV to pass pixel values. 55 | *

56 | * 57 | * @see org.opencv.core.Scalar_ 58 | */ 59 | public class Scalar { 60 | 61 | public double val[]; 62 | 63 | public Scalar(double v0, double v1, double v2, double v3) { 64 | val = new double[] { v0, v1, v2, v3 }; 65 | } 66 | 67 | public Scalar(double v0, double v1, double v2) { 68 | val = new double[] { v0, v1, v2, 0 }; 69 | } 70 | 71 | public Scalar(double v0, double v1) { 72 | val = new double[] { v0, v1, 0, 0 }; 73 | } 74 | 75 | public Scalar(double v0) { 76 | val = new double[] { v0, 0, 0, 0 }; 77 | } 78 | 79 | public Scalar(double[] vals) { 80 | if (vals != null && vals.length == 4) 81 | val = vals.clone(); 82 | else { 83 | val = new double[4]; 84 | set(vals); 85 | } 86 | } 87 | 88 | public void set(double[] vals) { 89 | if (vals != null) { 90 | val[0] = vals.length > 0 ? vals[0] : 0; 91 | val[1] = vals.length > 1 ? vals[1] : 0; 92 | val[2] = vals.length > 2 ? vals[2] : 0; 93 | val[3] = vals.length > 3 ? vals[3] : 0; 94 | } else 95 | val[0] = val[1] = val[2] = val[3] = 0; 96 | } 97 | 98 | public static Scalar all(double v) { 99 | return new Scalar(v, v, v, v); 100 | } 101 | 102 | public Scalar clone() { 103 | return new Scalar(val); 104 | } 105 | 106 | public Scalar mul(Scalar it, double scale) { 107 | return new Scalar(val[0] * it.val[0] * scale, val[1] * it.val[1] * scale, 108 | val[2] * it.val[2] * scale, val[3] * it.val[3] * scale); 109 | } 110 | 111 | public Scalar mul(Scalar it) { 112 | return mul(it, 1); 113 | } 114 | 115 | public Scalar conj() { 116 | return new Scalar(val[0], -val[1], -val[2], -val[3]); 117 | } 118 | 119 | public boolean isReal() { 120 | return val[1] == 0 && val[2] == 0 && val[3] == 0; 121 | } 122 | 123 | @Override 124 | public int hashCode() { 125 | final int prime = 31; 126 | int result = 1; 127 | result = prime * result + java.util.Arrays.hashCode(val); 128 | return result; 129 | } 130 | 131 | @Override 132 | public boolean equals(Object obj) { 133 | if (this == obj) return true; 134 | if (!(obj instanceof Scalar)) return false; 135 | Scalar it = (Scalar) obj; 136 | if (!java.util.Arrays.equals(val, it.val)) return false; 137 | return true; 138 | } 139 | 140 | @Override 141 | public String toString() { 142 | return "[" + val[0] + ", " + val[1] + ", " + val[2] + ", " + val[3] + "]"; 143 | } 144 | 145 | } 146 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/core/Size.java: -------------------------------------------------------------------------------- 1 | package org.opencv.core; 2 | 3 | /** 4 | *

template class CV_EXPORTS Size_

5 | * 6 | *

// C++ code:

7 | * 8 | * 9 | *

public:

10 | * 11 | *

typedef _Tp value_type;

12 | * 13 | *

//! various constructors

14 | * 15 | *

Size_();

16 | * 17 | *

Size_(_Tp _width, _Tp _height);

18 | * 19 | *

Size_(const Size_& sz);

20 | * 21 | *

Size_(const CvSize& sz);

22 | * 23 | *

Size_(const CvSize2D32f& sz);

24 | * 25 | *

Size_(const Point_<_Tp>& pt);

26 | * 27 | *

Size_& operator = (const Size_& sz);

28 | * 29 | *

//! the area (width*height)

30 | * 31 | *

_Tp area() const;

32 | * 33 | *

//! conversion of another data type.

34 | * 35 | *

template operator Size_<_Tp2>() const;

36 | * 37 | *

//! conversion to the old-style OpenCV types

38 | * 39 | *

operator CvSize() const;

40 | * 41 | *

operator CvSize2D32f() const;

42 | * 43 | *

_Tp width, height; // the width and the height

44 | * 45 | *

};

46 | * 47 | *

Template class for specifying the size of an image or rectangle. The class 48 | * includes two members called width and height. The 49 | * structure can be converted to and from the old OpenCV structures

50 | * 51 | *

CvSize and CvSize2D32f. The same set of arithmetic 52 | * and comparison operations as for Point_ is available. 53 | * OpenCV defines the following Size_<> aliases:

54 | * 55 | *

// C++ code:

56 | * 57 | *

typedef Size_ Size2i;

58 | * 59 | *

typedef Size2i Size;

60 | * 61 | *

typedef Size_ Size2f;

62 | * 63 | * @see org.opencv.core.Size_ 64 | */ 65 | public class Size { 66 | 67 | public double width, height; 68 | 69 | public Size(double width, double height) { 70 | this.width = width; 71 | this.height = height; 72 | } 73 | 74 | public Size() { 75 | this(0, 0); 76 | } 77 | 78 | public Size(Point p) { 79 | width = p.x; 80 | height = p.y; 81 | } 82 | 83 | public Size(double[] vals) { 84 | set(vals); 85 | } 86 | 87 | public void set(double[] vals) { 88 | if (vals != null) { 89 | width = vals.length > 0 ? vals[0] : 0; 90 | height = vals.length > 1 ? vals[1] : 0; 91 | } else { 92 | width = 0; 93 | height = 0; 94 | } 95 | } 96 | 97 | public double area() { 98 | return width * height; 99 | } 100 | 101 | public Size clone() { 102 | return new Size(width, height); 103 | } 104 | 105 | @Override 106 | public int hashCode() { 107 | final int prime = 31; 108 | int result = 1; 109 | long temp; 110 | temp = Double.doubleToLongBits(height); 111 | result = prime * result + (int) (temp ^ (temp >>> 32)); 112 | temp = Double.doubleToLongBits(width); 113 | result = prime * result + (int) (temp ^ (temp >>> 32)); 114 | return result; 115 | } 116 | 117 | @Override 118 | public boolean equals(Object obj) { 119 | if (this == obj) return true; 120 | if (!(obj instanceof Size)) return false; 121 | Size it = (Size) obj; 122 | return width == it.width && height == it.height; 123 | } 124 | 125 | @Override 126 | public String toString() { 127 | return (int)width + "x" + (int)height; 128 | } 129 | 130 | } 131 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/core/TermCriteria.java: -------------------------------------------------------------------------------- 1 | package org.opencv.core; 2 | 3 | /** 4 | *

class CV_EXPORTS TermCriteria

5 | * 6 | *

// C++ code:

7 | * 8 | * 9 | *

public:

10 | * 11 | *

enum

12 | * 13 | * 14 | *

COUNT=1, //!< the maximum number of iterations or elements to compute

15 | * 16 | *

MAX_ITER=COUNT, //!< ditto

17 | * 18 | *

EPS=2 //!< the desired accuracy or change in parameters at which the 19 | * iterative algorithm stops

20 | * 21 | *

};

22 | * 23 | *

//! default constructor

24 | * 25 | *

TermCriteria();

26 | * 27 | *

//! full constructor

28 | * 29 | *

TermCriteria(int type, int maxCount, double epsilon);

30 | * 31 | *

//! conversion from CvTermCriteria

32 | * 33 | *

TermCriteria(const CvTermCriteria& criteria);

34 | * 35 | *

//! conversion to CvTermCriteria

36 | * 37 | *

operator CvTermCriteria() const;

38 | * 39 | *

int type; //!< the type of termination criteria: COUNT, EPS or COUNT + EPS

40 | * 41 | *

int maxCount; // the maximum number of iterations/elements

42 | * 43 | *

double epsilon; // the desired accuracy

44 | * 45 | *

};

46 | * 47 | *

The class defining termination criteria for iterative algorithms. You can 48 | * initialize it by default constructor and then override any parameters, or the 49 | * structure may be fully initialized using the advanced variant of the 50 | * constructor. 51 | *

52 | * 53 | * @see org.opencv.core.TermCriteria 54 | */ 55 | public class TermCriteria { 56 | 57 | /** 58 | * The maximum number of iterations or elements to compute 59 | */ 60 | public static final int COUNT = 1; 61 | /** 62 | * The maximum number of iterations or elements to compute 63 | */ 64 | public static final int MAX_ITER = COUNT; 65 | /** 66 | * The desired accuracy threshold or change in parameters at which the iterative algorithm is terminated. 67 | */ 68 | public static final int EPS = 2; 69 | 70 | public int type; 71 | public int maxCount; 72 | public double epsilon; 73 | 74 | /** 75 | * Termination criteria for iterative algorithms. 76 | * 77 | * @param type 78 | * the type of termination criteria: COUNT, EPS or COUNT + EPS. 79 | * @param maxCount 80 | * the maximum number of iterations/elements. 81 | * @param epsilon 82 | * the desired accuracy. 83 | */ 84 | public TermCriteria(int type, int maxCount, double epsilon) { 85 | this.type = type; 86 | this.maxCount = maxCount; 87 | this.epsilon = epsilon; 88 | } 89 | 90 | /** 91 | * Termination criteria for iterative algorithms. 92 | */ 93 | public TermCriteria() { 94 | this(0, 0, 0.0); 95 | } 96 | 97 | public TermCriteria(double[] vals) { 98 | set(vals); 99 | } 100 | 101 | public void set(double[] vals) { 102 | if (vals != null) { 103 | type = vals.length > 0 ? (int) vals[0] : 0; 104 | maxCount = vals.length > 1 ? (int) vals[1] : 0; 105 | epsilon = vals.length > 2 ? (double) vals[2] : 0; 106 | } else { 107 | type = 0; 108 | maxCount = 0; 109 | epsilon = 0; 110 | } 111 | } 112 | 113 | public TermCriteria clone() { 114 | return new TermCriteria(type, maxCount, epsilon); 115 | } 116 | 117 | @Override 118 | public int hashCode() { 119 | final int prime = 31; 120 | int result = 1; 121 | long temp; 122 | temp = Double.doubleToLongBits(type); 123 | result = prime * result + (int) (temp ^ (temp >>> 32)); 124 | temp = Double.doubleToLongBits(maxCount); 125 | result = prime * result + (int) (temp ^ (temp >>> 32)); 126 | temp = Double.doubleToLongBits(epsilon); 127 | result = prime * result + (int) (temp ^ (temp >>> 32)); 128 | return result; 129 | } 130 | 131 | @Override 132 | public boolean equals(Object obj) { 133 | if (this == obj) return true; 134 | if (!(obj instanceof TermCriteria)) return false; 135 | TermCriteria it = (TermCriteria) obj; 136 | return type == it.type && maxCount == it.maxCount && epsilon == it.epsilon; 137 | } 138 | 139 | @Override 140 | public String toString() { 141 | return "{ type: " + type + ", maxCount: " + maxCount + ", epsilon: " + epsilon + "}"; 142 | } 143 | } 144 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/features2d/DMatch.java: -------------------------------------------------------------------------------- 1 | package org.opencv.features2d; 2 | 3 | //C++: class DMatch 4 | 5 | /** 6 | * Structure for matching: query descriptor index, train descriptor index, train 7 | * image index and distance between descriptors. 8 | */ 9 | public class DMatch { 10 | 11 | /** 12 | * Query descriptor index. 13 | */ 14 | public int queryIdx; 15 | /** 16 | * Train descriptor index. 17 | */ 18 | public int trainIdx; 19 | /** 20 | * Train image index. 21 | */ 22 | public int imgIdx; 23 | 24 | public float distance; 25 | 26 | public DMatch() { 27 | this(-1, -1, Float.MAX_VALUE); 28 | } 29 | 30 | public DMatch(int _queryIdx, int _trainIdx, float _distance) { 31 | queryIdx = _queryIdx; 32 | trainIdx = _trainIdx; 33 | imgIdx = -1; 34 | distance = _distance; 35 | } 36 | 37 | public DMatch(int _queryIdx, int _trainIdx, int _imgIdx, float _distance) { 38 | queryIdx = _queryIdx; 39 | trainIdx = _trainIdx; 40 | imgIdx = _imgIdx; 41 | distance = _distance; 42 | } 43 | 44 | /** 45 | * Less is better. 46 | */ 47 | public boolean lessThan(DMatch it) { 48 | return distance < it.distance; 49 | } 50 | 51 | @Override 52 | public String toString() { 53 | return "DMatch [queryIdx=" + queryIdx + ", trainIdx=" + trainIdx 54 | + ", imgIdx=" + imgIdx + ", distance=" + distance + "]"; 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/features2d/KeyPoint.java: -------------------------------------------------------------------------------- 1 | package org.opencv.features2d; 2 | 3 | import org.opencv.core.Point; 4 | 5 | /** 6 | *

Data structure for salient point detectors.

7 | * 8 | *

coordinates of the keypoint

9 | * 10 | *

diameter of the meaningful keypoint neighborhood

11 | * 12 | *

// C++ code:

13 | * 14 | *

computed orientation of the keypoint (-1 if not applicable). Its possible 15 | * values are in a range [0,360) degrees. It is measured relative to image 16 | * coordinate system (y-axis is directed downward), ie in clockwise.

17 | * 18 | *

the response by which the most strong keypoints have been selected. Can be 19 | * used for further sorting or subsampling

20 | * 21 | *

octave (pyramid layer) from which the keypoint has been extracted

22 | * 23 | *

object id that can be used to clustered keypoints by an object they belong to

24 | * 25 | * @see org.opencv.features2d.KeyPoint 26 | */ 27 | public class KeyPoint { 28 | 29 | /** 30 | * Coordinates of the keypoint. 31 | */ 32 | public Point pt; 33 | /** 34 | * Diameter of the useful keypoint adjacent area. 35 | */ 36 | public float size; 37 | /** 38 | * Computed orientation of the keypoint (-1 if not applicable). 39 | */ 40 | public float angle; 41 | /** 42 | * The response, by which the strongest keypoints have been selected. Can 43 | * be used for further sorting or subsampling. 44 | */ 45 | public float response; 46 | /** 47 | * Octave (pyramid layer), from which the keypoint has been extracted. 48 | */ 49 | public int octave; 50 | /** 51 | * Object ID, that can be used to cluster keypoints by an object they 52 | * belong to. 53 | */ 54 | public int class_id; 55 | 56 | /** 57 | *

The keypoint constructors

58 | * 59 | * @param x x-coordinate of the keypoint 60 | * @param y y-coordinate of the keypoint 61 | * @param _size keypoint diameter 62 | * @param _angle keypoint orientation 63 | * @param _response keypoint detector response on the keypoint (that is, 64 | * strength of the keypoint) 65 | * @param _octave pyramid octave in which the keypoint has been detected 66 | * @param _class_id object id 67 | * 68 | * @see org.opencv.features2d.KeyPoint.KeyPoint 69 | */ 70 | public KeyPoint(float x, float y, float _size, float _angle, float _response, int _octave, int _class_id) 71 | { 72 | pt = new Point(x, y); 73 | size = _size; 74 | angle = _angle; 75 | response = _response; 76 | octave = _octave; 77 | class_id = _class_id; 78 | } 79 | 80 | /** 81 | *

The keypoint constructors

82 | * 83 | * @see org.opencv.features2d.KeyPoint.KeyPoint 84 | */ 85 | public KeyPoint() 86 | { 87 | this(0, 0, 0, -1, 0, 0, -1); 88 | } 89 | 90 | /** 91 | *

The keypoint constructors

92 | * 93 | * @param x x-coordinate of the keypoint 94 | * @param y y-coordinate of the keypoint 95 | * @param _size keypoint diameter 96 | * @param _angle keypoint orientation 97 | * @param _response keypoint detector response on the keypoint (that is, 98 | * strength of the keypoint) 99 | * @param _octave pyramid octave in which the keypoint has been detected 100 | * 101 | * @see org.opencv.features2d.KeyPoint.KeyPoint 102 | */ 103 | public KeyPoint(float x, float y, float _size, float _angle, float _response, int _octave) 104 | { 105 | this(x, y, _size, _angle, _response, _octave, -1); 106 | } 107 | 108 | /** 109 | *

The keypoint constructors

110 | * 111 | * @param x x-coordinate of the keypoint 112 | * @param y y-coordinate of the keypoint 113 | * @param _size keypoint diameter 114 | * @param _angle keypoint orientation 115 | * @param _response keypoint detector response on the keypoint (that is, 116 | * strength of the keypoint) 117 | * 118 | * @see org.opencv.features2d.KeyPoint.KeyPoint 119 | */ 120 | public KeyPoint(float x, float y, float _size, float _angle, float _response) 121 | { 122 | this(x, y, _size, _angle, _response, 0, -1); 123 | } 124 | 125 | /** 126 | *

The keypoint constructors

127 | * 128 | * @param x x-coordinate of the keypoint 129 | * @param y y-coordinate of the keypoint 130 | * @param _size keypoint diameter 131 | * @param _angle keypoint orientation 132 | * 133 | * @see org.opencv.features2d.KeyPoint.KeyPoint 134 | */ 135 | public KeyPoint(float x, float y, float _size, float _angle) 136 | { 137 | this(x, y, _size, _angle, 0, 0, -1); 138 | } 139 | 140 | /** 141 | *

The keypoint constructors

142 | * 143 | * @param x x-coordinate of the keypoint 144 | * @param y y-coordinate of the keypoint 145 | * @param _size keypoint diameter 146 | * 147 | * @see org.opencv.features2d.KeyPoint.KeyPoint 148 | */ 149 | public KeyPoint(float x, float y, float _size) 150 | { 151 | this(x, y, _size, -1, 0, 0, -1); 152 | } 153 | 154 | @Override 155 | public String toString() { 156 | return "KeyPoint [pt=" + pt + ", size=" + size + ", angle=" + angle 157 | + ", response=" + response + ", octave=" + octave 158 | + ", class_id=" + class_id + "]"; 159 | } 160 | 161 | } 162 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/gpu/DeviceInfo.java: -------------------------------------------------------------------------------- 1 | package org.opencv.gpu; 2 | 3 | import java.lang.String; 4 | 5 | // C++: class DeviceInfo 6 | public class DeviceInfo { 7 | 8 | protected final long nativeObj; 9 | protected DeviceInfo(long addr) { nativeObj = addr; } 10 | 11 | 12 | // 13 | // C++: DeviceInfo::DeviceInfo() 14 | // 15 | 16 | public DeviceInfo() 17 | { 18 | 19 | nativeObj = DeviceInfo_0(); 20 | 21 | return; 22 | } 23 | 24 | 25 | // 26 | // C++: DeviceInfo::DeviceInfo(int device_id) 27 | // 28 | 29 | public DeviceInfo(int device_id) 30 | { 31 | 32 | nativeObj = DeviceInfo_1(device_id); 33 | 34 | return; 35 | } 36 | 37 | 38 | // 39 | // C++: int DeviceInfo::deviceID() 40 | // 41 | 42 | public int deviceID() 43 | { 44 | 45 | int retVal = deviceID_0(nativeObj); 46 | 47 | return retVal; 48 | } 49 | 50 | 51 | // 52 | // C++: size_t DeviceInfo::freeMemory() 53 | // 54 | 55 | public long freeMemory() 56 | { 57 | 58 | long retVal = freeMemory_0(nativeObj); 59 | 60 | return retVal; 61 | } 62 | 63 | 64 | // 65 | // C++: bool DeviceInfo::isCompatible() 66 | // 67 | 68 | public boolean isCompatible() 69 | { 70 | 71 | boolean retVal = isCompatible_0(nativeObj); 72 | 73 | return retVal; 74 | } 75 | 76 | 77 | // 78 | // C++: int DeviceInfo::majorVersion() 79 | // 80 | 81 | public int majorVersion() 82 | { 83 | 84 | int retVal = majorVersion_0(nativeObj); 85 | 86 | return retVal; 87 | } 88 | 89 | 90 | // 91 | // C++: int DeviceInfo::minorVersion() 92 | // 93 | 94 | public int minorVersion() 95 | { 96 | 97 | int retVal = minorVersion_0(nativeObj); 98 | 99 | return retVal; 100 | } 101 | 102 | 103 | // 104 | // C++: int DeviceInfo::multiProcessorCount() 105 | // 106 | 107 | public int multiProcessorCount() 108 | { 109 | 110 | int retVal = multiProcessorCount_0(nativeObj); 111 | 112 | return retVal; 113 | } 114 | 115 | 116 | // 117 | // C++: string DeviceInfo::name() 118 | // 119 | 120 | public String name() 121 | { 122 | 123 | String retVal = name_0(nativeObj); 124 | 125 | return retVal; 126 | } 127 | 128 | 129 | // 130 | // C++: void DeviceInfo::queryMemory(size_t& totalMemory, size_t& freeMemory) 131 | // 132 | 133 | public void queryMemory(long totalMemory, long freeMemory) 134 | { 135 | double[] totalMemory_out = new double[1]; 136 | double[] freeMemory_out = new double[1]; 137 | queryMemory_0(nativeObj, totalMemory_out, freeMemory_out); 138 | totalMemory = (long)totalMemory_out[0]; 139 | freeMemory = (long)freeMemory_out[0]; 140 | } 141 | 142 | 143 | // 144 | // C++: size_t DeviceInfo::sharedMemPerBlock() 145 | // 146 | 147 | public long sharedMemPerBlock() 148 | { 149 | 150 | long retVal = sharedMemPerBlock_0(nativeObj); 151 | 152 | return retVal; 153 | } 154 | 155 | 156 | // 157 | // C++: bool DeviceInfo::supports(int feature_set) 158 | // 159 | 160 | public boolean supports(int feature_set) 161 | { 162 | 163 | boolean retVal = supports_0(nativeObj, feature_set); 164 | 165 | return retVal; 166 | } 167 | 168 | 169 | // 170 | // C++: size_t DeviceInfo::totalMemory() 171 | // 172 | 173 | public long totalMemory() 174 | { 175 | 176 | long retVal = totalMemory_0(nativeObj); 177 | 178 | return retVal; 179 | } 180 | 181 | 182 | @Override 183 | protected void finalize() throws Throwable { 184 | delete(nativeObj); 185 | } 186 | 187 | 188 | 189 | // C++: DeviceInfo::DeviceInfo() 190 | private static native long DeviceInfo_0(); 191 | 192 | // C++: DeviceInfo::DeviceInfo(int device_id) 193 | private static native long DeviceInfo_1(int device_id); 194 | 195 | // C++: int DeviceInfo::deviceID() 196 | private static native int deviceID_0(long nativeObj); 197 | 198 | // C++: size_t DeviceInfo::freeMemory() 199 | private static native long freeMemory_0(long nativeObj); 200 | 201 | // C++: bool DeviceInfo::isCompatible() 202 | private static native boolean isCompatible_0(long nativeObj); 203 | 204 | // C++: int DeviceInfo::majorVersion() 205 | private static native int majorVersion_0(long nativeObj); 206 | 207 | // C++: int DeviceInfo::minorVersion() 208 | private static native int minorVersion_0(long nativeObj); 209 | 210 | // C++: int DeviceInfo::multiProcessorCount() 211 | private static native int multiProcessorCount_0(long nativeObj); 212 | 213 | // C++: string DeviceInfo::name() 214 | private static native String name_0(long nativeObj); 215 | 216 | // C++: void DeviceInfo::queryMemory(size_t& totalMemory, size_t& freeMemory) 217 | private static native void queryMemory_0(long nativeObj, double[] totalMemory_out, double[] freeMemory_out); 218 | 219 | // C++: size_t DeviceInfo::sharedMemPerBlock() 220 | private static native long sharedMemPerBlock_0(long nativeObj); 221 | 222 | // C++: bool DeviceInfo::supports(int feature_set) 223 | private static native boolean supports_0(long nativeObj, int feature_set); 224 | 225 | // C++: size_t DeviceInfo::totalMemory() 226 | private static native long totalMemory_0(long nativeObj); 227 | 228 | // native support for java finalize() 229 | private static native void delete(long nativeObj); 230 | 231 | } 232 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/gpu/Gpu.java: -------------------------------------------------------------------------------- 1 | package org.opencv.gpu; 2 | 3 | public class Gpu { 4 | 5 | public static final int 6 | FEATURE_SET_COMPUTE_10 = 10, 7 | FEATURE_SET_COMPUTE_11 = 11, 8 | FEATURE_SET_COMPUTE_12 = 12, 9 | FEATURE_SET_COMPUTE_13 = 13, 10 | FEATURE_SET_COMPUTE_20 = 20, 11 | FEATURE_SET_COMPUTE_21 = 21, 12 | FEATURE_SET_COMPUTE_30 = 30, 13 | FEATURE_SET_COMPUTE_35 = 35, 14 | GLOBAL_ATOMICS = FEATURE_SET_COMPUTE_11, 15 | SHARED_ATOMICS = FEATURE_SET_COMPUTE_12, 16 | NATIVE_DOUBLE = FEATURE_SET_COMPUTE_13, 17 | WARP_SHUFFLE_FUNCTIONS = FEATURE_SET_COMPUTE_30, 18 | DYNAMIC_PARALLELISM = FEATURE_SET_COMPUTE_35; 19 | 20 | 21 | // 22 | // C++: bool deviceSupports(int feature_set) 23 | // 24 | 25 | public static boolean deviceSupports(int feature_set) 26 | { 27 | boolean retVal = deviceSupports_0(feature_set); 28 | return retVal; 29 | } 30 | 31 | 32 | // 33 | // C++: int getCudaEnabledDeviceCount() 34 | // 35 | 36 | public static int getCudaEnabledDeviceCount() 37 | { 38 | int retVal = getCudaEnabledDeviceCount_0(); 39 | return retVal; 40 | } 41 | 42 | 43 | // 44 | // C++: int getDevice() 45 | // 46 | 47 | public static int getDevice() 48 | { 49 | int retVal = getDevice_0(); 50 | return retVal; 51 | } 52 | 53 | 54 | // 55 | // C++: void printCudaDeviceInfo(int device) 56 | // 57 | 58 | public static void printCudaDeviceInfo(int device) 59 | { 60 | printCudaDeviceInfo_0(device); 61 | return; 62 | } 63 | 64 | 65 | // 66 | // C++: void printShortCudaDeviceInfo(int device) 67 | // 68 | 69 | public static void printShortCudaDeviceInfo(int device) 70 | { 71 | printShortCudaDeviceInfo_0(device); 72 | return; 73 | } 74 | 75 | 76 | // 77 | // C++: void resetDevice() 78 | // 79 | 80 | public static void resetDevice() 81 | { 82 | resetDevice_0(); 83 | return; 84 | } 85 | 86 | 87 | // 88 | // C++: void setDevice(int device) 89 | // 90 | 91 | public static void setDevice(int device) 92 | { 93 | setDevice_0(device); 94 | return; 95 | } 96 | 97 | 98 | 99 | 100 | // C++: bool deviceSupports(int feature_set) 101 | private static native boolean deviceSupports_0(int feature_set); 102 | 103 | // C++: int getCudaEnabledDeviceCount() 104 | private static native int getCudaEnabledDeviceCount_0(); 105 | 106 | // C++: int getDevice() 107 | private static native int getDevice_0(); 108 | 109 | // C++: void printCudaDeviceInfo(int device) 110 | private static native void printCudaDeviceInfo_0(int device); 111 | 112 | // C++: void printShortCudaDeviceInfo(int device) 113 | private static native void printShortCudaDeviceInfo_0(int device); 114 | 115 | // C++: void resetDevice() 116 | private static native void resetDevice_0(); 117 | 118 | // C++: void setDevice(int device) 119 | private static native void setDevice_0(int device); 120 | 121 | } 122 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/gpu/TargetArchs.java: -------------------------------------------------------------------------------- 1 | package org.opencv.gpu; 2 | 3 | // C++: class TargetArchs 4 | public class TargetArchs { 5 | 6 | protected final long nativeObj; 7 | protected TargetArchs(long addr) { nativeObj = addr; } 8 | 9 | 10 | // 11 | // C++: static bool TargetArchs::builtWith(int feature_set) 12 | // 13 | 14 | public static boolean builtWith(int feature_set) 15 | { 16 | boolean retVal = builtWith_0(feature_set); 17 | return retVal; 18 | } 19 | 20 | 21 | // 22 | // C++: static bool TargetArchs::has(int major, int minor) 23 | // 24 | 25 | public static boolean has(int major, int minor) 26 | { 27 | boolean retVal = has_0(major, minor); 28 | return retVal; 29 | } 30 | 31 | 32 | // 33 | // C++: static bool TargetArchs::hasBin(int major, int minor) 34 | // 35 | 36 | public static boolean hasBin(int major, int minor) 37 | { 38 | boolean retVal = hasBin_0(major, minor); 39 | return retVal; 40 | } 41 | 42 | 43 | // 44 | // C++: static bool TargetArchs::hasEqualOrGreater(int major, int minor) 45 | // 46 | 47 | public static boolean hasEqualOrGreater(int major, int minor) 48 | { 49 | boolean retVal = hasEqualOrGreater_0(major, minor); 50 | return retVal; 51 | } 52 | 53 | 54 | // 55 | // C++: static bool TargetArchs::hasEqualOrGreaterBin(int major, int minor) 56 | // 57 | 58 | public static boolean hasEqualOrGreaterBin(int major, int minor) 59 | { 60 | boolean retVal = hasEqualOrGreaterBin_0(major, minor); 61 | return retVal; 62 | } 63 | 64 | 65 | // 66 | // C++: static bool TargetArchs::hasEqualOrGreaterPtx(int major, int minor) 67 | // 68 | 69 | public static boolean hasEqualOrGreaterPtx(int major, int minor) 70 | { 71 | boolean retVal = hasEqualOrGreaterPtx_0(major, minor); 72 | return retVal; 73 | } 74 | 75 | 76 | // 77 | // C++: static bool TargetArchs::hasEqualOrLessPtx(int major, int minor) 78 | // 79 | 80 | public static boolean hasEqualOrLessPtx(int major, int minor) 81 | { 82 | boolean retVal = hasEqualOrLessPtx_0(major, minor); 83 | return retVal; 84 | } 85 | 86 | 87 | // 88 | // C++: static bool TargetArchs::hasPtx(int major, int minor) 89 | // 90 | 91 | public static boolean hasPtx(int major, int minor) 92 | { 93 | boolean retVal = hasPtx_0(major, minor); 94 | return retVal; 95 | } 96 | 97 | 98 | @Override 99 | protected void finalize() throws Throwable { 100 | delete(nativeObj); 101 | } 102 | 103 | 104 | 105 | // C++: static bool TargetArchs::builtWith(int feature_set) 106 | private static native boolean builtWith_0(int feature_set); 107 | 108 | // C++: static bool TargetArchs::has(int major, int minor) 109 | private static native boolean has_0(int major, int minor); 110 | 111 | // C++: static bool TargetArchs::hasBin(int major, int minor) 112 | private static native boolean hasBin_0(int major, int minor); 113 | 114 | // C++: static bool TargetArchs::hasEqualOrGreater(int major, int minor) 115 | private static native boolean hasEqualOrGreater_0(int major, int minor); 116 | 117 | // C++: static bool TargetArchs::hasEqualOrGreaterBin(int major, int minor) 118 | private static native boolean hasEqualOrGreaterBin_0(int major, int minor); 119 | 120 | // C++: static bool TargetArchs::hasEqualOrGreaterPtx(int major, int minor) 121 | private static native boolean hasEqualOrGreaterPtx_0(int major, int minor); 122 | 123 | // C++: static bool TargetArchs::hasEqualOrLessPtx(int major, int minor) 124 | private static native boolean hasEqualOrLessPtx_0(int major, int minor); 125 | 126 | // C++: static bool TargetArchs::hasPtx(int major, int minor) 127 | private static native boolean hasPtx_0(int major, int minor); 128 | 129 | // native support for java finalize() 130 | private static native void delete(long nativeObj); 131 | 132 | } 133 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/imgproc/CLAHE.java: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // This file is auto-generated. Please don't modify it! 4 | // 5 | package org.opencv.imgproc; 6 | 7 | import org.opencv.core.Algorithm; 8 | import org.opencv.core.Mat; 9 | import org.opencv.core.Size; 10 | 11 | // C++: class CLAHE 12 | public class CLAHE extends Algorithm { 13 | 14 | protected CLAHE(long addr) { super(addr); } 15 | 16 | 17 | // 18 | // C++: void CLAHE::apply(Mat src, Mat& dst) 19 | // 20 | 21 | public void apply(Mat src, Mat dst) 22 | { 23 | 24 | apply_0(nativeObj, src.nativeObj, dst.nativeObj); 25 | 26 | return; 27 | } 28 | 29 | 30 | // 31 | // C++: void CLAHE::setClipLimit(double clipLimit) 32 | // 33 | 34 | public void setClipLimit(double clipLimit) 35 | { 36 | 37 | setClipLimit_0(nativeObj, clipLimit); 38 | 39 | return; 40 | } 41 | 42 | 43 | // 44 | // C++: void CLAHE::setTilesGridSize(Size tileGridSize) 45 | // 46 | 47 | public void setTilesGridSize(Size tileGridSize) 48 | { 49 | 50 | setTilesGridSize_0(nativeObj, tileGridSize.width, tileGridSize.height); 51 | 52 | return; 53 | } 54 | 55 | 56 | @Override 57 | protected void finalize() throws Throwable { 58 | delete(nativeObj); 59 | } 60 | 61 | 62 | 63 | // C++: void CLAHE::apply(Mat src, Mat& dst) 64 | private static native void apply_0(long nativeObj, long src_nativeObj, long dst_nativeObj); 65 | 66 | // C++: void CLAHE::setClipLimit(double clipLimit) 67 | private static native void setClipLimit_0(long nativeObj, double clipLimit); 68 | 69 | // C++: void CLAHE::setTilesGridSize(Size tileGridSize) 70 | private static native void setTilesGridSize_0(long nativeObj, double tileGridSize_width, double tileGridSize_height); 71 | 72 | // native support for java finalize() 73 | private static native void delete(long nativeObj); 74 | 75 | } 76 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/ml/CvBoostParams.java: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // This file is auto-generated. Please don't modify it! 4 | // 5 | package org.opencv.ml; 6 | 7 | 8 | 9 | // C++: class CvBoostParams 10 | /** 11 | *

Boosting training parameters.

12 | * 13 | *

There is one structure member that you can set directly:

14 | * 15 | *

Splitting criteria used to choose optimal splits during a weak tree 16 | * construction. Possible values are:

17 | * 18 | *
    19 | *
  • CvBoost.DEFAULT Use the default for the particular boosting method, 20 | * see below. 21 | *
22 | *

23 | * 24 | *

// C++ code:

25 | *
    26 | *
  • CvBoost.GINI Use Gini index. This is default option for Real 27 | * AdaBoost; may be also used for Discrete AdaBoost. 28 | *
  • CvBoost.MISCLASS Use misclassification rate. This is default option 29 | * for Discrete AdaBoost; may be also used for Real AdaBoost. 30 | *
  • CvBoost.SQERR Use least squares criteria. This is default and the 31 | * only option for LogitBoost and Gentle AdaBoost. 32 | *
33 | * 34 | *

The structure is derived from "CvDTreeParams" but not all of the decision 35 | * tree parameters are supported. In particular, cross-validation is not 36 | * supported. 37 | *

38 | * 39 | *

All parameters are public. You can initialize them by a constructor and then 40 | * override some of them directly if you want.

41 | * 42 | * @see org.opencv.ml.CvBoostParams : public CvDTreeParams 43 | */ 44 | public class CvBoostParams extends CvDTreeParams { 45 | 46 | protected CvBoostParams(long addr) { super(addr); } 47 | 48 | 49 | // 50 | // C++: CvBoostParams::CvBoostParams() 51 | // 52 | 53 | /** 54 | *

The constructors.

55 | * 56 | *

See "CvDTreeParams.CvDTreeParams" for description of other parameters.

57 | * 58 | *

Default parameters are:

59 | * 60 | *

61 | * 62 | *

// C++ code:

63 | * 64 | *

CvBoostParams.CvBoostParams()

65 | * 66 | * 67 | *

boost_type = CvBoost.REAL;

68 | * 69 | *

weak_count = 100;

70 | * 71 | *

weight_trim_rate = 0.95;

72 | * 73 | *

cv_folds = 0;

74 | * 75 | *

max_depth = 1;

76 | * 77 | * 78 | * @see org.opencv.ml.CvBoostParams.CvBoostParams 79 | */ 80 | public CvBoostParams() 81 | { 82 | 83 | super( CvBoostParams_0() ); 84 | 85 | return; 86 | } 87 | 88 | 89 | // 90 | // C++: int CvBoostParams::boost_type 91 | // 92 | 93 | public int get_boost_type() 94 | { 95 | 96 | int retVal = get_boost_type_0(nativeObj); 97 | 98 | return retVal; 99 | } 100 | 101 | 102 | // 103 | // C++: void CvBoostParams::boost_type 104 | // 105 | 106 | public void set_boost_type(int boost_type) 107 | { 108 | 109 | set_boost_type_0(nativeObj, boost_type); 110 | 111 | return; 112 | } 113 | 114 | 115 | // 116 | // C++: int CvBoostParams::weak_count 117 | // 118 | 119 | public int get_weak_count() 120 | { 121 | 122 | int retVal = get_weak_count_0(nativeObj); 123 | 124 | return retVal; 125 | } 126 | 127 | 128 | // 129 | // C++: void CvBoostParams::weak_count 130 | // 131 | 132 | public void set_weak_count(int weak_count) 133 | { 134 | 135 | set_weak_count_0(nativeObj, weak_count); 136 | 137 | return; 138 | } 139 | 140 | 141 | // 142 | // C++: int CvBoostParams::split_criteria 143 | // 144 | 145 | public int get_split_criteria() 146 | { 147 | 148 | int retVal = get_split_criteria_0(nativeObj); 149 | 150 | return retVal; 151 | } 152 | 153 | 154 | // 155 | // C++: void CvBoostParams::split_criteria 156 | // 157 | 158 | public void set_split_criteria(int split_criteria) 159 | { 160 | 161 | set_split_criteria_0(nativeObj, split_criteria); 162 | 163 | return; 164 | } 165 | 166 | 167 | // 168 | // C++: double CvBoostParams::weight_trim_rate 169 | // 170 | 171 | public double get_weight_trim_rate() 172 | { 173 | 174 | double retVal = get_weight_trim_rate_0(nativeObj); 175 | 176 | return retVal; 177 | } 178 | 179 | 180 | // 181 | // C++: void CvBoostParams::weight_trim_rate 182 | // 183 | 184 | public void set_weight_trim_rate(double weight_trim_rate) 185 | { 186 | 187 | set_weight_trim_rate_0(nativeObj, weight_trim_rate); 188 | 189 | return; 190 | } 191 | 192 | 193 | @Override 194 | protected void finalize() throws Throwable { 195 | delete(nativeObj); 196 | } 197 | 198 | 199 | 200 | // C++: CvBoostParams::CvBoostParams() 201 | private static native long CvBoostParams_0(); 202 | 203 | // C++: int CvBoostParams::boost_type 204 | private static native int get_boost_type_0(long nativeObj); 205 | 206 | // C++: void CvBoostParams::boost_type 207 | private static native void set_boost_type_0(long nativeObj, int boost_type); 208 | 209 | // C++: int CvBoostParams::weak_count 210 | private static native int get_weak_count_0(long nativeObj); 211 | 212 | // C++: void CvBoostParams::weak_count 213 | private static native void set_weak_count_0(long nativeObj, int weak_count); 214 | 215 | // C++: int CvBoostParams::split_criteria 216 | private static native int get_split_criteria_0(long nativeObj); 217 | 218 | // C++: void CvBoostParams::split_criteria 219 | private static native void set_split_criteria_0(long nativeObj, int split_criteria); 220 | 221 | // C++: double CvBoostParams::weight_trim_rate 222 | private static native double get_weight_trim_rate_0(long nativeObj); 223 | 224 | // C++: void CvBoostParams::weight_trim_rate 225 | private static native void set_weight_trim_rate_0(long nativeObj, double weight_trim_rate); 226 | 227 | // native support for java finalize() 228 | private static native void delete(long nativeObj); 229 | 230 | } 231 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/ml/CvERTrees.java: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // This file is auto-generated. Please don't modify it! 4 | // 5 | package org.opencv.ml; 6 | 7 | import org.opencv.core.Mat; 8 | 9 | // C++: class CvERTrees 10 | /** 11 | *

The class implements the Extremely randomized trees algorithm. 12 | * CvERTrees is inherited from "CvRTrees" and has the same 13 | * interface, so see description of "CvRTrees" class to get details. To set the 14 | * training parameters of Extremely randomized trees the same class "CvRTParams" 15 | * is used.

16 | * 17 | * @see org.opencv.ml.CvERTrees : public CvRTrees 18 | */ 19 | public class CvERTrees extends CvRTrees { 20 | 21 | protected CvERTrees(long addr) { super(addr); } 22 | 23 | 24 | // 25 | // C++: CvERTrees::CvERTrees() 26 | // 27 | 28 | public CvERTrees() 29 | { 30 | 31 | super( CvERTrees_0() ); 32 | 33 | return; 34 | } 35 | 36 | 37 | // 38 | // C++: bool CvERTrees::train(Mat trainData, int tflag, Mat responses, Mat varIdx = cv::Mat(), Mat sampleIdx = cv::Mat(), Mat varType = cv::Mat(), Mat missingDataMask = cv::Mat(), CvRTParams params = CvRTParams()) 39 | // 40 | 41 | public boolean train(Mat trainData, int tflag, Mat responses, Mat varIdx, Mat sampleIdx, Mat varType, Mat missingDataMask, CvRTParams params) 42 | { 43 | 44 | boolean retVal = train_0(nativeObj, trainData.nativeObj, tflag, responses.nativeObj, varIdx.nativeObj, sampleIdx.nativeObj, varType.nativeObj, missingDataMask.nativeObj, params.nativeObj); 45 | 46 | return retVal; 47 | } 48 | 49 | public boolean train(Mat trainData, int tflag, Mat responses) 50 | { 51 | 52 | boolean retVal = train_1(nativeObj, trainData.nativeObj, tflag, responses.nativeObj); 53 | 54 | return retVal; 55 | } 56 | 57 | 58 | @Override 59 | protected void finalize() throws Throwable { 60 | delete(nativeObj); 61 | } 62 | 63 | 64 | 65 | // C++: CvERTrees::CvERTrees() 66 | private static native long CvERTrees_0(); 67 | 68 | // C++: bool CvERTrees::train(Mat trainData, int tflag, Mat responses, Mat varIdx = cv::Mat(), Mat sampleIdx = cv::Mat(), Mat varType = cv::Mat(), Mat missingDataMask = cv::Mat(), CvRTParams params = CvRTParams()) 69 | private static native boolean train_0(long nativeObj, long trainData_nativeObj, int tflag, long responses_nativeObj, long varIdx_nativeObj, long sampleIdx_nativeObj, long varType_nativeObj, long missingDataMask_nativeObj, long params_nativeObj); 70 | private static native boolean train_1(long nativeObj, long trainData_nativeObj, int tflag, long responses_nativeObj); 71 | 72 | // native support for java finalize() 73 | private static native void delete(long nativeObj); 74 | 75 | } 76 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/ml/CvGBTreesParams.java: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // This file is auto-generated. Please don't modify it! 4 | // 5 | package org.opencv.ml; 6 | 7 | 8 | 9 | // C++: class CvGBTreesParams 10 | /** 11 | *

GBT training parameters.

12 | * 13 | *

The structure contains parameters for each single decision tree in the 14 | * ensemble, as well as the whole model characteristics. The structure is 15 | * derived from "CvDTreeParams" but not all of the decision tree parameters are 16 | * supported: cross-validation, pruning, and class priorities are not used.

17 | * 18 | * @see org.opencv.ml.CvGBTreesParams : public CvDTreeParams 19 | */ 20 | public class CvGBTreesParams extends CvDTreeParams { 21 | 22 | protected CvGBTreesParams(long addr) { super(addr); } 23 | 24 | 25 | // 26 | // C++: CvGBTreesParams::CvGBTreesParams() 27 | // 28 | 29 | /** 30 | *

By default the following constructor is used: CvGBTreesParams(CvGBTrees.SQUARED_LOSS, 31 | * 200, 0.8f, 0.01f, 3, false)

32 | * 33 | *

// C++ code:

34 | * 35 | *

: CvDTreeParams(3, 10, 0, false, 10, 0, false, false, 0)

36 | * 37 | * @see org.opencv.ml.CvGBTreesParams.CvGBTreesParams 38 | */ 39 | public CvGBTreesParams() 40 | { 41 | 42 | super( CvGBTreesParams_0() ); 43 | 44 | return; 45 | } 46 | 47 | 48 | // 49 | // C++: int CvGBTreesParams::weak_count 50 | // 51 | 52 | public int get_weak_count() 53 | { 54 | 55 | int retVal = get_weak_count_0(nativeObj); 56 | 57 | return retVal; 58 | } 59 | 60 | 61 | // 62 | // C++: void CvGBTreesParams::weak_count 63 | // 64 | 65 | public void set_weak_count(int weak_count) 66 | { 67 | 68 | set_weak_count_0(nativeObj, weak_count); 69 | 70 | return; 71 | } 72 | 73 | 74 | // 75 | // C++: int CvGBTreesParams::loss_function_type 76 | // 77 | 78 | public int get_loss_function_type() 79 | { 80 | 81 | int retVal = get_loss_function_type_0(nativeObj); 82 | 83 | return retVal; 84 | } 85 | 86 | 87 | // 88 | // C++: void CvGBTreesParams::loss_function_type 89 | // 90 | 91 | public void set_loss_function_type(int loss_function_type) 92 | { 93 | 94 | set_loss_function_type_0(nativeObj, loss_function_type); 95 | 96 | return; 97 | } 98 | 99 | 100 | // 101 | // C++: float CvGBTreesParams::subsample_portion 102 | // 103 | 104 | public float get_subsample_portion() 105 | { 106 | 107 | float retVal = get_subsample_portion_0(nativeObj); 108 | 109 | return retVal; 110 | } 111 | 112 | 113 | // 114 | // C++: void CvGBTreesParams::subsample_portion 115 | // 116 | 117 | public void set_subsample_portion(float subsample_portion) 118 | { 119 | 120 | set_subsample_portion_0(nativeObj, subsample_portion); 121 | 122 | return; 123 | } 124 | 125 | 126 | // 127 | // C++: float CvGBTreesParams::shrinkage 128 | // 129 | 130 | public float get_shrinkage() 131 | { 132 | 133 | float retVal = get_shrinkage_0(nativeObj); 134 | 135 | return retVal; 136 | } 137 | 138 | 139 | // 140 | // C++: void CvGBTreesParams::shrinkage 141 | // 142 | 143 | public void set_shrinkage(float shrinkage) 144 | { 145 | 146 | set_shrinkage_0(nativeObj, shrinkage); 147 | 148 | return; 149 | } 150 | 151 | 152 | @Override 153 | protected void finalize() throws Throwable { 154 | delete(nativeObj); 155 | } 156 | 157 | 158 | 159 | // C++: CvGBTreesParams::CvGBTreesParams() 160 | private static native long CvGBTreesParams_0(); 161 | 162 | // C++: int CvGBTreesParams::weak_count 163 | private static native int get_weak_count_0(long nativeObj); 164 | 165 | // C++: void CvGBTreesParams::weak_count 166 | private static native void set_weak_count_0(long nativeObj, int weak_count); 167 | 168 | // C++: int CvGBTreesParams::loss_function_type 169 | private static native int get_loss_function_type_0(long nativeObj); 170 | 171 | // C++: void CvGBTreesParams::loss_function_type 172 | private static native void set_loss_function_type_0(long nativeObj, int loss_function_type); 173 | 174 | // C++: float CvGBTreesParams::subsample_portion 175 | private static native float get_subsample_portion_0(long nativeObj); 176 | 177 | // C++: void CvGBTreesParams::subsample_portion 178 | private static native void set_subsample_portion_0(long nativeObj, float subsample_portion); 179 | 180 | // C++: float CvGBTreesParams::shrinkage 181 | private static native float get_shrinkage_0(long nativeObj); 182 | 183 | // C++: void CvGBTreesParams::shrinkage 184 | private static native void set_shrinkage_0(long nativeObj, float shrinkage); 185 | 186 | // native support for java finalize() 187 | private static native void delete(long nativeObj); 188 | 189 | } 190 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/ml/CvParamGrid.java: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // This file is auto-generated. Please don't modify it! 4 | // 5 | package org.opencv.ml; 6 | 7 | 8 | 9 | // C++: class CvParamGrid 10 | /** 11 | *

The structure represents the logarithmic grid range of statmodel parameters. 12 | * It is used for optimizing statmodel accuracy by varying model parameters, the 13 | * accuracy estimate being computed by cross-validation.

14 | * 15 | *

Minimum value of the statmodel parameter.

16 | * 17 | *

Maximum value of the statmodel parameter. 18 | *

19 | * 20 | *

// C++ code:

21 | * 22 | *

Logarithmic step for iterating the statmodel parameter.

23 | * 24 | *

The grid determines the following iteration sequence of the statmodel 25 | * parameter values:

26 | * 27 | *

(min_val, min_val*step, min_val*(step)^2, dots, min_val*(step)^n),

28 | * 29 | *

where n is the maximal index satisfying

30 | * 31 | *

min_val * step ^n < max_val

32 | * 33 | *

The grid is logarithmic, so step must always be greater then 1.

34 | * 35 | * @see org.opencv.ml.CvParamGrid 36 | */ 37 | public class CvParamGrid { 38 | 39 | protected final long nativeObj; 40 | protected CvParamGrid(long addr) { nativeObj = addr; } 41 | 42 | 43 | public static final int 44 | SVM_C = 0, 45 | SVM_GAMMA = 1, 46 | SVM_P = 2, 47 | SVM_NU = 3, 48 | SVM_COEF = 4, 49 | SVM_DEGREE = 5; 50 | 51 | 52 | // 53 | // C++: CvParamGrid::CvParamGrid() 54 | // 55 | 56 | /** 57 | *

The constructors.

58 | * 59 | *

The full constructor initializes corresponding members. The default 60 | * constructor creates a dummy grid:

61 | * 62 | *

63 | * 64 | *

// C++ code:

65 | * 66 | *

CvParamGrid.CvParamGrid()

67 | * 68 | * 69 | *

min_val = max_val = step = 0;

70 | * 71 | * 72 | * @see org.opencv.ml.CvParamGrid.CvParamGrid 73 | */ 74 | public CvParamGrid() 75 | { 76 | 77 | nativeObj = CvParamGrid_0(); 78 | 79 | return; 80 | } 81 | 82 | 83 | // 84 | // C++: double CvParamGrid::min_val 85 | // 86 | 87 | public double get_min_val() 88 | { 89 | 90 | double retVal = get_min_val_0(nativeObj); 91 | 92 | return retVal; 93 | } 94 | 95 | 96 | // 97 | // C++: void CvParamGrid::min_val 98 | // 99 | 100 | public void set_min_val(double min_val) 101 | { 102 | 103 | set_min_val_0(nativeObj, min_val); 104 | 105 | return; 106 | } 107 | 108 | 109 | // 110 | // C++: double CvParamGrid::max_val 111 | // 112 | 113 | public double get_max_val() 114 | { 115 | 116 | double retVal = get_max_val_0(nativeObj); 117 | 118 | return retVal; 119 | } 120 | 121 | 122 | // 123 | // C++: void CvParamGrid::max_val 124 | // 125 | 126 | public void set_max_val(double max_val) 127 | { 128 | 129 | set_max_val_0(nativeObj, max_val); 130 | 131 | return; 132 | } 133 | 134 | 135 | // 136 | // C++: double CvParamGrid::step 137 | // 138 | 139 | public double get_step() 140 | { 141 | 142 | double retVal = get_step_0(nativeObj); 143 | 144 | return retVal; 145 | } 146 | 147 | 148 | // 149 | // C++: void CvParamGrid::step 150 | // 151 | 152 | public void set_step(double step) 153 | { 154 | 155 | set_step_0(nativeObj, step); 156 | 157 | return; 158 | } 159 | 160 | 161 | @Override 162 | protected void finalize() throws Throwable { 163 | delete(nativeObj); 164 | } 165 | 166 | 167 | 168 | // C++: CvParamGrid::CvParamGrid() 169 | private static native long CvParamGrid_0(); 170 | 171 | // C++: double CvParamGrid::min_val 172 | private static native double get_min_val_0(long nativeObj); 173 | 174 | // C++: void CvParamGrid::min_val 175 | private static native void set_min_val_0(long nativeObj, double min_val); 176 | 177 | // C++: double CvParamGrid::max_val 178 | private static native double get_max_val_0(long nativeObj); 179 | 180 | // C++: void CvParamGrid::max_val 181 | private static native void set_max_val_0(long nativeObj, double max_val); 182 | 183 | // C++: double CvParamGrid::step 184 | private static native double get_step_0(long nativeObj); 185 | 186 | // C++: void CvParamGrid::step 187 | private static native void set_step_0(long nativeObj, double step); 188 | 189 | // native support for java finalize() 190 | private static native void delete(long nativeObj); 191 | 192 | } 193 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/ml/CvRTParams.java: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // This file is auto-generated. Please don't modify it! 4 | // 5 | package org.opencv.ml; 6 | 7 | import org.opencv.core.TermCriteria; 8 | 9 | // C++: class CvRTParams 10 | /** 11 | *

Training parameters of random trees.

12 | * 13 | *

The set of training parameters for the forest is a superset of the training 14 | * parameters for a single tree. However, random trees do not need all the 15 | * functionality/features of decision trees. Most noticeably, the trees are not 16 | * pruned, so the cross-validation parameters are not used.

17 | * 18 | * @see org.opencv.ml.CvRTParams : public CvDTreeParams 19 | */ 20 | public class CvRTParams extends CvDTreeParams { 21 | 22 | protected CvRTParams(long addr) { super(addr); } 23 | 24 | 25 | // 26 | // C++: CvRTParams::CvRTParams() 27 | // 28 | 29 | public CvRTParams() 30 | { 31 | 32 | super( CvRTParams_0() ); 33 | 34 | return; 35 | } 36 | 37 | 38 | // 39 | // C++: bool CvRTParams::calc_var_importance 40 | // 41 | 42 | public boolean get_calc_var_importance() 43 | { 44 | 45 | boolean retVal = get_calc_var_importance_0(nativeObj); 46 | 47 | return retVal; 48 | } 49 | 50 | 51 | // 52 | // C++: void CvRTParams::calc_var_importance 53 | // 54 | 55 | public void set_calc_var_importance(boolean calc_var_importance) 56 | { 57 | 58 | set_calc_var_importance_0(nativeObj, calc_var_importance); 59 | 60 | return; 61 | } 62 | 63 | 64 | // 65 | // C++: int CvRTParams::nactive_vars 66 | // 67 | 68 | public int get_nactive_vars() 69 | { 70 | 71 | int retVal = get_nactive_vars_0(nativeObj); 72 | 73 | return retVal; 74 | } 75 | 76 | 77 | // 78 | // C++: void CvRTParams::nactive_vars 79 | // 80 | 81 | public void set_nactive_vars(int nactive_vars) 82 | { 83 | 84 | set_nactive_vars_0(nativeObj, nactive_vars); 85 | 86 | return; 87 | } 88 | 89 | 90 | // 91 | // C++: TermCriteria CvRTParams::term_crit 92 | // 93 | 94 | public TermCriteria get_term_crit() 95 | { 96 | 97 | TermCriteria retVal = new TermCriteria(get_term_crit_0(nativeObj)); 98 | 99 | return retVal; 100 | } 101 | 102 | 103 | // 104 | // C++: void CvRTParams::term_crit 105 | // 106 | 107 | public void set_term_crit(TermCriteria term_crit) 108 | { 109 | 110 | set_term_crit_0(nativeObj, term_crit.type, term_crit.maxCount, term_crit.epsilon); 111 | 112 | return; 113 | } 114 | 115 | 116 | @Override 117 | protected void finalize() throws Throwable { 118 | delete(nativeObj); 119 | } 120 | 121 | 122 | 123 | // C++: CvRTParams::CvRTParams() 124 | private static native long CvRTParams_0(); 125 | 126 | // C++: bool CvRTParams::calc_var_importance 127 | private static native boolean get_calc_var_importance_0(long nativeObj); 128 | 129 | // C++: void CvRTParams::calc_var_importance 130 | private static native void set_calc_var_importance_0(long nativeObj, boolean calc_var_importance); 131 | 132 | // C++: int CvRTParams::nactive_vars 133 | private static native int get_nactive_vars_0(long nativeObj); 134 | 135 | // C++: void CvRTParams::nactive_vars 136 | private static native void set_nactive_vars_0(long nativeObj, int nactive_vars); 137 | 138 | // C++: TermCriteria CvRTParams::term_crit 139 | private static native double[] get_term_crit_0(long nativeObj); 140 | 141 | // C++: void CvRTParams::term_crit 142 | private static native void set_term_crit_0(long nativeObj, int term_crit_type, int term_crit_maxCount, double term_crit_epsilon); 143 | 144 | // native support for java finalize() 145 | private static native void delete(long nativeObj); 146 | 147 | } 148 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/ml/CvStatModel.java: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // This file is auto-generated. Please don't modify it! 4 | // 5 | package org.opencv.ml; 6 | 7 | import java.lang.String; 8 | 9 | // C++: class CvStatModel 10 | /** 11 | *

Base class for statistical models in ML.

12 | * 13 | *

class CvStatModel

14 | * 15 | *

// C++ code:

16 | * 17 | * 18 | *

public:

19 | * 20 | *

/ * CvStatModel(); * /

21 | * 22 | *

/ * CvStatModel(const Mat& train_data...); * /

23 | * 24 | *

virtual ~CvStatModel();

25 | * 26 | *

virtual void clear()=0;

27 | * 28 | *

/ * virtual bool train(const Mat& train_data, [int tflag,]..., const

29 | * 30 | *

Mat& responses,...,

31 | * 32 | *

[const Mat& var_idx,]..., [const Mat& sample_idx,]...

33 | * 34 | *

[const Mat& var_type,]..., [const Mat& missing_mask,]

35 | * 36 | *

...)=0;

37 | *
    38 | *
  • / 39 | *
40 | * 41 | *

/ * virtual float predict(const Mat& sample...) const=0; * /

42 | * 43 | *

virtual void save(const char* filename, const char* name=0)=0;

44 | * 45 | *

virtual void load(const char* filename, const char* name=0)=0;

46 | * 47 | *

virtual void write(CvFileStorage* storage, const char* name)=0;

48 | * 49 | *

virtual void read(CvFileStorage* storage, CvFileNode* node)=0;

50 | * 51 | *

};

52 | * 53 | *

In this declaration, some methods are commented off. These are methods for 54 | * which there is no unified API (with the exception of the default 55 | * constructor). However, there are many similarities in the syntax and 56 | * semantics that are briefly described below in this section, as if they are 57 | * part of the base class. 58 | *

59 | * 60 | * @see org.opencv.ml.CvStatModel 61 | */ 62 | public class CvStatModel { 63 | 64 | protected final long nativeObj; 65 | protected CvStatModel(long addr) { nativeObj = addr; } 66 | 67 | 68 | // 69 | // C++: void CvStatModel::load(c_string filename, c_string name = 0) 70 | // 71 | 72 | /** 73 | *

Loads the model from a file.

74 | * 75 | *

The method load loads the complete model state with the 76 | * specified name (or default model-dependent name) from the specified XML or 77 | * YAML file. The previous model state is cleared by "CvStatModel.clear".

78 | * 79 | * @param filename a filename 80 | * @param name a name 81 | * 82 | * @see org.opencv.ml.CvStatModel.load 83 | */ 84 | public void load(String filename, String name) 85 | { 86 | 87 | load_0(nativeObj, filename, name); 88 | 89 | return; 90 | } 91 | 92 | /** 93 | *

Loads the model from a file.

94 | * 95 | *

The method load loads the complete model state with the 96 | * specified name (or default model-dependent name) from the specified XML or 97 | * YAML file. The previous model state is cleared by "CvStatModel.clear".

98 | * 99 | * @param filename a filename 100 | * 101 | * @see org.opencv.ml.CvStatModel.load 102 | */ 103 | public void load(String filename) 104 | { 105 | 106 | load_1(nativeObj, filename); 107 | 108 | return; 109 | } 110 | 111 | 112 | // 113 | // C++: void CvStatModel::save(c_string filename, c_string name = 0) 114 | // 115 | 116 | /** 117 | *

Saves the model to a file.

118 | * 119 | *

The method save saves the complete model state to the specified 120 | * XML or YAML file with the specified name or default name (which depends on a 121 | * particular class). *Data persistence* functionality from CxCore 122 | * is used.

123 | * 124 | * @param filename a filename 125 | * @param name a name 126 | * 127 | * @see org.opencv.ml.CvStatModel.save 128 | */ 129 | public void save(String filename, String name) 130 | { 131 | 132 | save_0(nativeObj, filename, name); 133 | 134 | return; 135 | } 136 | 137 | /** 138 | *

Saves the model to a file.

139 | * 140 | *

The method save saves the complete model state to the specified 141 | * XML or YAML file with the specified name or default name (which depends on a 142 | * particular class). *Data persistence* functionality from CxCore 143 | * is used.

144 | * 145 | * @param filename a filename 146 | * 147 | * @see org.opencv.ml.CvStatModel.save 148 | */ 149 | public void save(String filename) 150 | { 151 | 152 | save_1(nativeObj, filename); 153 | 154 | return; 155 | } 156 | 157 | 158 | @Override 159 | protected void finalize() throws Throwable { 160 | delete(nativeObj); 161 | } 162 | 163 | 164 | 165 | // C++: void CvStatModel::load(c_string filename, c_string name = 0) 166 | private static native void load_0(long nativeObj, String filename, String name); 167 | private static native void load_1(long nativeObj, String filename); 168 | 169 | // C++: void CvStatModel::save(c_string filename, c_string name = 0) 170 | private static native void save_0(long nativeObj, String filename, String name); 171 | private static native void save_1(long nativeObj, String filename); 172 | 173 | // native support for java finalize() 174 | private static native void delete(long nativeObj); 175 | 176 | } 177 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/ml/Ml.java: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // This file is auto-generated. Please don't modify it! 4 | // 5 | package org.opencv.ml; 6 | 7 | 8 | 9 | public class Ml { 10 | 11 | 12 | 13 | } 14 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/objdetect/Objdetect.java: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // This file is auto-generated. Please don't modify it! 4 | // 5 | package org.opencv.objdetect; 6 | 7 | import org.opencv.core.Mat; 8 | import org.opencv.core.MatOfInt; 9 | import org.opencv.core.MatOfRect; 10 | 11 | public class Objdetect { 12 | 13 | public static final int 14 | CASCADE_DO_CANNY_PRUNING = 1, 15 | CASCADE_SCALE_IMAGE = 2, 16 | CASCADE_FIND_BIGGEST_OBJECT = 4, 17 | CASCADE_DO_ROUGH_SEARCH = 8; 18 | 19 | 20 | // 21 | // C++: void drawDataMatrixCodes(Mat& image, vector_string codes, Mat corners) 22 | // 23 | 24 | // Unknown type 'vector_string' (I), skipping the function 25 | 26 | 27 | // 28 | // C++: void findDataMatrix(Mat image, vector_string& codes, Mat& corners = Mat(), vector_Mat& dmtx = vector_Mat()) 29 | // 30 | 31 | // Unknown type 'vector_string' (O), skipping the function 32 | 33 | 34 | // 35 | // C++: void groupRectangles(vector_Rect& rectList, vector_int& weights, int groupThreshold, double eps = 0.2) 36 | // 37 | 38 | /** 39 | *

Groups the object candidate rectangles.

40 | * 41 | *

The function is a wrapper for the generic function "partition". It clusters 42 | * all the input rectangles using the rectangle equivalence criteria that 43 | * combines rectangles with similar sizes and similar locations. The similarity 44 | * is defined by eps. When eps=0, no clustering is 45 | * done at all. If eps-> +inf, all the rectangles are put in one 46 | * cluster. Then, the small clusters containing less than or equal to 47 | * groupThreshold rectangles are rejected. In each other cluster, 48 | * the average rectangle is computed and put into the output rectangle list.

49 | * 50 | * @param rectList Input/output vector of rectangles. Output vector includes 51 | * retained and grouped rectangles. (The Python list is not modified in place.) 52 | * @param weights a weights 53 | * @param groupThreshold Minimum possible number of rectangles minus 1. The 54 | * threshold is used in a group of rectangles to retain it. 55 | * @param eps Relative difference between sides of the rectangles to merge them 56 | * into a group. 57 | * 58 | * @see org.opencv.objdetect.Objdetect.groupRectangles 59 | */ 60 | public static void groupRectangles(MatOfRect rectList, MatOfInt weights, int groupThreshold, double eps) 61 | { 62 | Mat rectList_mat = rectList; 63 | Mat weights_mat = weights; 64 | groupRectangles_0(rectList_mat.nativeObj, weights_mat.nativeObj, groupThreshold, eps); 65 | 66 | return; 67 | } 68 | 69 | /** 70 | *

Groups the object candidate rectangles.

71 | * 72 | *

The function is a wrapper for the generic function "partition". It clusters 73 | * all the input rectangles using the rectangle equivalence criteria that 74 | * combines rectangles with similar sizes and similar locations. The similarity 75 | * is defined by eps. When eps=0, no clustering is 76 | * done at all. If eps-> +inf, all the rectangles are put in one 77 | * cluster. Then, the small clusters containing less than or equal to 78 | * groupThreshold rectangles are rejected. In each other cluster, 79 | * the average rectangle is computed and put into the output rectangle list.

80 | * 81 | * @param rectList Input/output vector of rectangles. Output vector includes 82 | * retained and grouped rectangles. (The Python list is not modified in place.) 83 | * @param weights a weights 84 | * @param groupThreshold Minimum possible number of rectangles minus 1. The 85 | * threshold is used in a group of rectangles to retain it. 86 | * 87 | * @see org.opencv.objdetect.Objdetect.groupRectangles 88 | */ 89 | public static void groupRectangles(MatOfRect rectList, MatOfInt weights, int groupThreshold) 90 | { 91 | Mat rectList_mat = rectList; 92 | Mat weights_mat = weights; 93 | groupRectangles_1(rectList_mat.nativeObj, weights_mat.nativeObj, groupThreshold); 94 | 95 | return; 96 | } 97 | 98 | 99 | 100 | 101 | // C++: void groupRectangles(vector_Rect& rectList, vector_int& weights, int groupThreshold, double eps = 0.2) 102 | private static native void groupRectangles_0(long rectList_mat_nativeObj, long weights_mat_nativeObj, int groupThreshold, double eps); 103 | private static native void groupRectangles_1(long rectList_mat_nativeObj, long weights_mat_nativeObj, int groupThreshold); 104 | 105 | } 106 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/video/BackgroundSubtractor.java: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // This file is auto-generated. Please don't modify it! 4 | // 5 | package org.opencv.video; 6 | 7 | import org.opencv.core.Algorithm; 8 | import org.opencv.core.Mat; 9 | 10 | // C++: class BackgroundSubtractor 11 | /** 12 | *

Base class for background/foreground segmentation.

13 | * 14 | *

class BackgroundSubtractor : public Algorithm

15 | * 16 | *

// C++ code:

17 | * 18 | * 19 | *

public:

20 | * 21 | *

virtual ~BackgroundSubtractor();

22 | * 23 | *

virtual void operator()(InputArray image, OutputArray fgmask, double 24 | * learningRate=0);

25 | * 26 | *

virtual void getBackgroundImage(OutputArray backgroundImage) const;

27 | * 28 | *

};

29 | * 30 | *

The class is only used to define the common interface for the whole family of 31 | * background/foreground segmentation algorithms. 32 | *

33 | * 34 | * @see org.opencv.video.BackgroundSubtractor : public Algorithm 35 | */ 36 | public class BackgroundSubtractor extends Algorithm { 37 | 38 | protected BackgroundSubtractor(long addr) { super(addr); } 39 | 40 | 41 | // 42 | // C++: void BackgroundSubtractor::operator ()(Mat image, Mat& fgmask, double learningRate = 0) 43 | // 44 | 45 | /** 46 | *

Computes a foreground mask.

47 | * 48 | * @param image Next video frame. 49 | * @param fgmask The output foreground mask as an 8-bit binary image. 50 | * @param learningRate a learningRate 51 | * 52 | * @see org.opencv.video.BackgroundSubtractor.operator() 53 | */ 54 | public void apply(Mat image, Mat fgmask, double learningRate) 55 | { 56 | 57 | apply_0(nativeObj, image.nativeObj, fgmask.nativeObj, learningRate); 58 | 59 | return; 60 | } 61 | 62 | /** 63 | *

Computes a foreground mask.

64 | * 65 | * @param image Next video frame. 66 | * @param fgmask The output foreground mask as an 8-bit binary image. 67 | * 68 | * @see org.opencv.video.BackgroundSubtractor.operator() 69 | */ 70 | public void apply(Mat image, Mat fgmask) 71 | { 72 | 73 | apply_1(nativeObj, image.nativeObj, fgmask.nativeObj); 74 | 75 | return; 76 | } 77 | 78 | 79 | @Override 80 | protected void finalize() throws Throwable { 81 | delete(nativeObj); 82 | } 83 | 84 | 85 | 86 | // C++: void BackgroundSubtractor::operator ()(Mat image, Mat& fgmask, double learningRate = 0) 87 | private static native void apply_0(long nativeObj, long image_nativeObj, long fgmask_nativeObj, double learningRate); 88 | private static native void apply_1(long nativeObj, long image_nativeObj, long fgmask_nativeObj); 89 | 90 | // native support for java finalize() 91 | private static native void delete(long nativeObj); 92 | 93 | } 94 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/video/BackgroundSubtractorMOG.java: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // This file is auto-generated. Please don't modify it! 4 | // 5 | package org.opencv.video; 6 | 7 | 8 | 9 | // C++: class BackgroundSubtractorMOG 10 | /** 11 | *

Gaussian Mixture-based Background/Foreground Segmentation Algorithm.

12 | * 13 | *

The class implements the algorithm described in P. KadewTraKuPong and R. 14 | * Bowden, *An improved adaptive background mixture model for real-time tracking 15 | * with shadow detection*, Proc. 2nd European Workshop on Advanced Video-Based 16 | * Surveillance Systems, 2001: http://personal.ee.surrey.ac.uk/Personal/R.Bowden/publications/avbs01/avbs01.pdf

17 | * 18 | * @see org.opencv.video.BackgroundSubtractorMOG : public BackgroundSubtractor 19 | */ 20 | public class BackgroundSubtractorMOG extends BackgroundSubtractor { 21 | 22 | protected BackgroundSubtractorMOG(long addr) { super(addr); } 23 | 24 | 25 | // 26 | // C++: BackgroundSubtractorMOG::BackgroundSubtractorMOG() 27 | // 28 | 29 | /** 30 | *

The constructors.

31 | * 32 | *

Default constructor sets all parameters to default values.

33 | * 34 | * @see org.opencv.video.BackgroundSubtractorMOG.BackgroundSubtractorMOG 35 | */ 36 | public BackgroundSubtractorMOG() 37 | { 38 | 39 | super( BackgroundSubtractorMOG_0() ); 40 | 41 | return; 42 | } 43 | 44 | 45 | // 46 | // C++: BackgroundSubtractorMOG::BackgroundSubtractorMOG(int history, int nmixtures, double backgroundRatio, double noiseSigma = 0) 47 | // 48 | 49 | /** 50 | *

The constructors.

51 | * 52 | *

Default constructor sets all parameters to default values.

53 | * 54 | * @param history Length of the history. 55 | * @param nmixtures Number of Gaussian mixtures. 56 | * @param backgroundRatio Background ratio. 57 | * @param noiseSigma Noise strength. 58 | * 59 | * @see org.opencv.video.BackgroundSubtractorMOG.BackgroundSubtractorMOG 60 | */ 61 | public BackgroundSubtractorMOG(int history, int nmixtures, double backgroundRatio, double noiseSigma) 62 | { 63 | 64 | super( BackgroundSubtractorMOG_1(history, nmixtures, backgroundRatio, noiseSigma) ); 65 | 66 | return; 67 | } 68 | 69 | /** 70 | *

The constructors.

71 | * 72 | *

Default constructor sets all parameters to default values.

73 | * 74 | * @param history Length of the history. 75 | * @param nmixtures Number of Gaussian mixtures. 76 | * @param backgroundRatio Background ratio. 77 | * 78 | * @see org.opencv.video.BackgroundSubtractorMOG.BackgroundSubtractorMOG 79 | */ 80 | public BackgroundSubtractorMOG(int history, int nmixtures, double backgroundRatio) 81 | { 82 | 83 | super( BackgroundSubtractorMOG_2(history, nmixtures, backgroundRatio) ); 84 | 85 | return; 86 | } 87 | 88 | 89 | @Override 90 | protected void finalize() throws Throwable { 91 | delete(nativeObj); 92 | } 93 | 94 | 95 | 96 | // C++: BackgroundSubtractorMOG::BackgroundSubtractorMOG() 97 | private static native long BackgroundSubtractorMOG_0(); 98 | 99 | // C++: BackgroundSubtractorMOG::BackgroundSubtractorMOG(int history, int nmixtures, double backgroundRatio, double noiseSigma = 0) 100 | private static native long BackgroundSubtractorMOG_1(int history, int nmixtures, double backgroundRatio, double noiseSigma); 101 | private static native long BackgroundSubtractorMOG_2(int history, int nmixtures, double backgroundRatio); 102 | 103 | // native support for java finalize() 104 | private static native void delete(long nativeObj); 105 | 106 | } 107 | -------------------------------------------------------------------------------- /opencv/src/main/java/org/opencv/video/KalmanFilter.java: -------------------------------------------------------------------------------- 1 | 2 | // 3 | // This file is auto-generated. Please don't modify it! 4 | // 5 | package org.opencv.video; 6 | 7 | import org.opencv.core.Mat; 8 | 9 | // C++: class KalmanFilter 10 | /** 11 | *

Kalman filter class.

12 | * 13 | *

The class implements a standard Kalman filter http://en.wikipedia.org/wiki/Kalman_filter, 14 | * [Welch95]. However, you can modify transitionMatrix, 15 | * controlMatrix, and measurementMatrix to get an 16 | * extended Kalman filter functionality. See the OpenCV sample kalman.cpp.

17 | * 18 | *

Note:

19 | *
    20 | *
  • An example using the standard Kalman filter can be found at 21 | * opencv_source_code/samples/cpp/kalman.cpp 22 | *
23 | * 24 | * @see org.opencv.video.KalmanFilter 25 | */ 26 | public class KalmanFilter { 27 | 28 | protected final long nativeObj; 29 | protected KalmanFilter(long addr) { nativeObj = addr; } 30 | 31 | 32 | // 33 | // C++: KalmanFilter::KalmanFilter() 34 | // 35 | 36 | /** 37 | *

The constructors.

38 | * 39 | *

The full constructor.

40 | * 41 | *

Note: In C API when CvKalman* kalmanFilter structure is not 42 | * needed anymore, it should be released with cvReleaseKalman(&kalmanFilter)

43 | * 44 | * @see org.opencv.video.KalmanFilter.KalmanFilter 45 | */ 46 | public KalmanFilter() 47 | { 48 | 49 | nativeObj = KalmanFilter_0(); 50 | 51 | return; 52 | } 53 | 54 | 55 | // 56 | // C++: KalmanFilter::KalmanFilter(int dynamParams, int measureParams, int controlParams = 0, int type = CV_32F) 57 | // 58 | 59 | /** 60 | *

The constructors.

61 | * 62 | *

The full constructor.

63 | * 64 | *

Note: In C API when CvKalman* kalmanFilter structure is not 65 | * needed anymore, it should be released with cvReleaseKalman(&kalmanFilter)

66 | * 67 | * @param dynamParams Dimensionality of the state. 68 | * @param measureParams Dimensionality of the measurement. 69 | * @param controlParams Dimensionality of the control vector. 70 | * @param type Type of the created matrices that should be CV_32F 71 | * or CV_64F. 72 | * 73 | * @see org.opencv.video.KalmanFilter.KalmanFilter 74 | */ 75 | public KalmanFilter(int dynamParams, int measureParams, int controlParams, int type) 76 | { 77 | 78 | nativeObj = KalmanFilter_1(dynamParams, measureParams, controlParams, type); 79 | 80 | return; 81 | } 82 | 83 | /** 84 | *

The constructors.

85 | * 86 | *

The full constructor.

87 | * 88 | *

Note: In C API when CvKalman* kalmanFilter structure is not 89 | * needed anymore, it should be released with cvReleaseKalman(&kalmanFilter)

90 | * 91 | * @param dynamParams Dimensionality of the state. 92 | * @param measureParams Dimensionality of the measurement. 93 | * 94 | * @see org.opencv.video.KalmanFilter.KalmanFilter 95 | */ 96 | public KalmanFilter(int dynamParams, int measureParams) 97 | { 98 | 99 | nativeObj = KalmanFilter_2(dynamParams, measureParams); 100 | 101 | return; 102 | } 103 | 104 | 105 | // 106 | // C++: Mat KalmanFilter::correct(Mat measurement) 107 | // 108 | 109 | /** 110 | *

Updates the predicted state from the measurement.

111 | * 112 | * @param measurement The measured system parameters 113 | * 114 | * @see org.opencv.video.KalmanFilter.correct 115 | */ 116 | public Mat correct(Mat measurement) 117 | { 118 | 119 | Mat retVal = new Mat(correct_0(nativeObj, measurement.nativeObj)); 120 | 121 | return retVal; 122 | } 123 | 124 | 125 | // 126 | // C++: Mat KalmanFilter::predict(Mat control = Mat()) 127 | // 128 | 129 | /** 130 | *

Computes a predicted state.

131 | * 132 | * @param control The optional input control 133 | * 134 | * @see org.opencv.video.KalmanFilter.predict 135 | */ 136 | public Mat predict(Mat control) 137 | { 138 | 139 | Mat retVal = new Mat(predict_0(nativeObj, control.nativeObj)); 140 | 141 | return retVal; 142 | } 143 | 144 | /** 145 | *

Computes a predicted state.

146 | * 147 | * @see org.opencv.video.KalmanFilter.predict 148 | */ 149 | public Mat predict() 150 | { 151 | 152 | Mat retVal = new Mat(predict_1(nativeObj)); 153 | 154 | return retVal; 155 | } 156 | 157 | 158 | @Override 159 | protected void finalize() throws Throwable { 160 | delete(nativeObj); 161 | } 162 | 163 | 164 | 165 | // C++: KalmanFilter::KalmanFilter() 166 | private static native long KalmanFilter_0(); 167 | 168 | // C++: KalmanFilter::KalmanFilter(int dynamParams, int measureParams, int controlParams = 0, int type = CV_32F) 169 | private static native long KalmanFilter_1(int dynamParams, int measureParams, int controlParams, int type); 170 | private static native long KalmanFilter_2(int dynamParams, int measureParams); 171 | 172 | // C++: Mat KalmanFilter::correct(Mat measurement) 173 | private static native long correct_0(long nativeObj, long measurement_nativeObj); 174 | 175 | // C++: Mat KalmanFilter::predict(Mat control = Mat()) 176 | private static native long predict_0(long nativeObj, long control_nativeObj); 177 | private static native long predict_1(long nativeObj); 178 | 179 | // native support for java finalize() 180 | private static native void delete(long nativeObj); 181 | 182 | } 183 | -------------------------------------------------------------------------------- /opencv/src/main/res/values/attrs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # [android-opencv-template](https://github.com/gowithfloat/android-opencv-template) [![Build Status](https://travis-ci.org/gowithfloat/android-opencv-template.svg?branch=master)](https://travis-ci.org/gowithfloat/android-opencv-template) 2 | 3 | An [Android Studio](http://developer.android.com/sdk/index.html) template configured to use [OpenCV for Android](http://opencv.org/platforms/android.html). 4 | 5 | While researching OpenCV integration in Android, we found that many of the tutorials in place refer to setting up the Eclipse environment. For those using Android Studio, we thought we'd share an project set up to use the OpenCV library, which was converted to use [Gradle](https://www.gradle.org/) build scripts. 6 | 7 | # Usage 8 | 9 | Just [download this repository](https://github.com/floatlearning/android-opencv-template/archive/master.zip) and uncompress it. Open Android Studio and choose `Open an existing Android Studio project`. Navigate to the folder containing this template and the project should open without issue and be ready to build. Requires Android 2.2 SDK (API 8) aka Froyo. 10 | 11 | # License 12 | 13 | © 2014 [Float](http://gowithfloat.com/). Shared under an [MIT license](https://en.wikipedia.org/wiki/MIT_License). See [license.md](./license.md) for details. 14 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | include ':opencv' 3 | --------------------------------------------------------------------------------