ndk-build error.opencv2/core/core.hpp: No such file or directory

匿名 (未验证) 提交于 2019-12-03 01:00:01

问题:

I am getting problem in Using OpenCV Nonfree Module in Android. I read this tutorial https://sites.google.com/site/wghsite/technical-notes/sift_surf_opencv_android

But after running ndk-build,it shows following errors..

guru@guru-Aspire-5738:~/Android/OpenCVWorkspace/sift_opencv_android/jni$ ~/Android/android-ndk-r9/ndk-build   Install        : libopencv_java.so => libs/armeabi-v7a/libopencv_java.so   Install        : libnonfree.so => libs/armeabi-v7a/libnonfree.so   Compile++ thumb  : test_sift <= test_sift.cpp /home/guru/Android/OpenCVWorkspace/sift_opencv_android/jni/test_sift.cpp:2:33: fatal error: opencv2/core/core.hpp: No such file or directory compilation terminated.   make: ***[/home/guru/Android/OpenCVWorkspace/sift_opencv_android/obj/local/armeabi-v7a/objs/test_sift/test_sift.o] Error 1 

Here is my code..

#include <iostream> #include <opencv2/core/core.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/nonfree/features2d.hpp> #include <opencv2/nonfree/nonfree.hpp>   using namespace cv; using namespace std;  int main( int argc, char** argv ) {  if( argc != 3)  {  cout <<" Usage: sift input_image output_image" << endl;  return -1;  }   //cv::initModule_nonfree();  //cout <<"initModule_nonfree() called" << endl;   Mat image;  image = imread(argv[1], CV_LOAD_IMAGE_COLOR);  if(! image.data )  {  cout <<  "Could not open or find the image" << std::endl ;  return -1;  }   vector<KeyPoint> keypoints;  Mat descriptors;   // Create a SIFT keypoint detector.  SiftFeatureDetector detector;  detector.detect(image, keypoints);  cout << "Detected " << (int) keypoints.size() << " keypoints" <<endl;   // Compute feature description.  detector.compute(image,keypoints, descriptors);  cout << "Computed feature."<<endl;   // Store description to "descriptors.des".  FileStorage fs;  fs.open("descriptors.des", FileStorage::WRITE);  cout << "Opened file to store the features."<<endl;  fs << "descriptors" << descriptors;  cout << "Finished writing file."<<endl;  fs.release();  cout << "Released file."<<endl;   // Show keypoints in the output image.  Mat outputImg;  Scalar keypointColor = Scalar(0, 0, 255);  drawKeypoints(image, keypoints, outputImg, keypointColor, DrawMatchesFlags::DRAW_RICH_KEYPOINTS);  cout << "Drew keypoints in output image file."<<endl;    namedWindow("Output image", CV_WINDOW_NORMAL );  imshow("Output image", outputImg);  waitKey(0);    cout << "Generate the output image."<<endl;  imwrite(argv[2], outputImg);   cout << "Done."<<endl;  return 0; } 

My Android.mk is ..

LOCAL_PATH := $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE    := sift_prebuilt LOCAL_SRC_FILES := libnonfree.so include $(PREBUILT_SHARED_LIBRARY)    include $(CLEAR_VARS) LOCAL_MODULE    := opencv_java_prebuilt LOCAL_SRC_FILES := libopencv_java.so include $(PREBUILT_SHARED_LIBRARY)   LOCAL_C_INCLUDE:= /home/guru/Android/OpenCV-2.4.6-android-sdk/sdk/native/jni/include LOCAL_MODULE    := test_sift  LOCAL_LDLIBS +=  -llog -ldl LOCAL_SHARED_LIBRARIES := sift_prebuilt opencv_java_prebuilt LOCAL_SRC_FILES := test_sift.cpp  include $(BUILD_EXECUTABLE) 

pls help..

回答1:

I think you forgot to include "opencv2/core/core.hpp". Here is your include:

LOCAL_C_INCLUDE:= /home/guru/Android/OpenCV-2.4.6-android-sdk/sdk/native/jni/include 

add "opencv2/core/core.hpp" to LOCAL_C_INCLUDE.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!