jni_part.cpp 826 B

123456789101112131415161718192021222324252627
  1. #include <jni.h>
  2. #include <opencv2/core.hpp>
  3. #include <opencv2/imgproc.hpp>
  4. #include <opencv2/features2d.hpp>
  5. #include <vector>
  6. using namespace std;
  7. using namespace cv;
  8. extern "C" {
  9. JNIEXPORT void JNICALL Java_org_opencv_samples_tutorial2_Tutorial2Activity_FindFeatures(JNIEnv*, jobject, jlong addrGray, jlong addrRgba);
  10. JNIEXPORT void JNICALL Java_org_opencv_samples_tutorial2_Tutorial2Activity_FindFeatures(JNIEnv*, jobject, jlong addrGray, jlong addrRgba)
  11. {
  12. Mat& mGr = *(Mat*)addrGray;
  13. Mat& mRgb = *(Mat*)addrRgba;
  14. vector<KeyPoint> v;
  15. Ptr<FeatureDetector> detector = FastFeatureDetector::create(50);
  16. detector->detect(mGr, v);
  17. for( unsigned int i = 0; i < v.size(); i++ )
  18. {
  19. const KeyPoint& kp = v[i];
  20. circle(mRgb, Point(kp.pt.x, kp.pt.y), 10, Scalar(255,0,0,255));
  21. }
  22. }
  23. }