2011-06-29 21:17:02 +08:00
|
|
|
#include <jni.h>
|
|
|
|
#include <opencv2/core/core.hpp>
|
|
|
|
#include <opencv2/imgproc/imgproc.hpp>
|
|
|
|
#include <opencv2/features2d/features2d.hpp>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace cv;
|
|
|
|
|
|
|
|
extern "C" {
|
2013-04-05 16:17:45 +08:00
|
|
|
JNIEXPORT void JNICALL Java_org_opencv_samples_tutorial2_Tutorial2Activity_FindFeatures(JNIEnv*, jobject, jlong addrGray, jlong addrRgba);
|
2012-11-19 19:16:13 +08:00
|
|
|
|
2013-02-11 15:36:12 +08:00
|
|
|
JNIEXPORT void JNICALL Java_org_opencv_samples_tutorial2_Tutorial2Activity_FindFeatures(JNIEnv*, jobject, jlong addrGray, jlong addrRgba)
|
2011-06-29 21:17:02 +08:00
|
|
|
{
|
2012-11-26 16:13:33 +08:00
|
|
|
Mat& mGr = *(Mat*)addrGray;
|
|
|
|
Mat& mRgb = *(Mat*)addrRgba;
|
2011-06-29 21:17:02 +08:00
|
|
|
vector<KeyPoint> v;
|
|
|
|
|
2014-10-17 18:22:02 +08:00
|
|
|
Ptr<FeatureDetector> detector = FastFeatureDetector::create(50);
|
|
|
|
detector->detect(mGr, v);
|
2012-11-26 16:13:33 +08:00
|
|
|
for( unsigned int i = 0; i < v.size(); i++ )
|
|
|
|
{
|
|
|
|
const KeyPoint& kp = v[i];
|
|
|
|
circle(mRgb, Point(kp.pt.x, kp.pt.y), 10, Scalar(255,0,0,255));
|
|
|
|
}
|
2011-06-29 21:17:02 +08:00
|
|
|
}
|
|
|
|
}
|