ndk-build error.opencv2/core/core.hpp:没有这样的文件或目录 [英] ndk-build error.opencv2/core/core.hpp: No such file or directory

查看:561
本文介绍了ndk-build error.opencv2/core/core.hpp:没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Android中使用OpenCV Nonfree模块时遇到问题.我读了本教程 https://sites.google.com/site/wghsite/technical-notes/sift_surf_opencv_android

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

但是运行ndk-build后,它显示以下错误.

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

这是我的代码.

#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;
}

我的Android.mk是..

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)

请帮助.

推荐答案

我认为您忘记了包含"opencv2/core/core.hpp".这是您的包含项:

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

将"opencv2/core/core.hpp"添加到LOCAL_C_INCLUDE.

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

这篇关于ndk-build error.opencv2/core/core.hpp:没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆