New sample for CUDA on Android added.
This commit is contained in:
13
samples/android/tutorial-4-cuda/jni/Android.mk
Normal file
13
samples/android/tutorial-4-cuda/jni/Android.mk
Normal file
@@ -0,0 +1,13 @@
|
||||
LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
CUDA_TOOLKIT_DIR=$(CUDA_TOOLKIT_ROOT)
|
||||
include ../../sdk/native/jni/OpenCV.mk
|
||||
|
||||
LOCAL_MODULE := cuda_sample
|
||||
LOCAL_SRC_FILES := jni_part.cpp
|
||||
LOCAL_LDLIBS += -llog -ldl
|
||||
LOCAL_LDFLAGS += -Os
|
||||
|
||||
include $(BUILD_SHARED_LIBRARY)
|
4
samples/android/tutorial-4-cuda/jni/Application.mk
Normal file
4
samples/android/tutorial-4-cuda/jni/Application.mk
Normal file
@@ -0,0 +1,4 @@
|
||||
APP_STL := gnustl_static
|
||||
APP_CPPFLAGS := -frtti -fexceptions
|
||||
APP_ABI := armeabi-v7a
|
||||
APP_PLATFORM := android-8
|
35
samples/android/tutorial-4-cuda/jni/jni_part.cpp
Normal file
35
samples/android/tutorial-4-cuda/jni/jni_part.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#include <jni.h>
|
||||
#include <opencv2/core/core.hpp>
|
||||
#include <opencv2/imgproc/imgproc.hpp>
|
||||
#include <opencv2/features2d/features2d.hpp>
|
||||
#include <opencv2/gpu/gpu.hpp>
|
||||
#include <vector>
|
||||
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
using namespace cv::gpu;
|
||||
|
||||
#include <android/log.h>
|
||||
|
||||
#define LOG_TAG "Cuda"
|
||||
#define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
|
||||
|
||||
extern "C" {
|
||||
JNIEXPORT void JNICALL Java_org_opencv_samples_tutorial4_Tutorial4Activity_FindFeatures(JNIEnv*, jobject, jlong addrGray, jlong addrRgba);
|
||||
|
||||
JNIEXPORT void JNICALL Java_org_opencv_samples_tutorial4_Tutorial4Activity_FindFeatures(JNIEnv*, jobject, jlong addrGray, jlong addrRgba)
|
||||
{
|
||||
Mat& mGr = *(Mat*)addrGray;
|
||||
Mat& mRgb = *(Mat*)addrRgba;
|
||||
vector<KeyPoint> keypoints;
|
||||
GpuMat grGpu(mGr);
|
||||
|
||||
FAST_GPU fast(50);
|
||||
fast(grGpu, GpuMat(), keypoints);
|
||||
for( unsigned int i = 0; i < keypoints.size(); i++ )
|
||||
{
|
||||
const KeyPoint& kp = keypoints[i];
|
||||
circle(mRgb, Point(kp.pt.x, kp.pt.y), 10, Scalar(255,0,0,255));
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user