OpenCV on Android - Headers; No such file/directory(Android 上的 OpenCV - 标头;没有这样的文件/目录)
问题描述
so I am new to using the JNI for Android so sorry in advance if this is something silly. I have installed the SDK and in Eclipse have added it as a library for the project. After finishing up everything, I have tried to run the ndk-build function but get this error:
Compile++ thumb : face_detect_rec <= jni_part.cpp
In file included from jni/face_detect_rec.h:11:0,
from jni/jni_part.cpp:3:
/Users/Justin/Documents/Android/opencv-2.4.3.2-android-sdk/sdk/native/jni/include/opencv2/core/core.hpp:56:21: fatal error: algorithm: No such file or directory
compilation terminated.
make: *** [obj/local/armeabi/objs/face_detect_rec/jni_part.o] Error 1
That file location is where the core.hpp is so I am not sure why this is a problem. I'll post my code below for reference, thanks guys!
jni_part.cpp:
#include <jni.h>
#include "face_detect_rec.h"
using namespace std;
using namespace cv;
extern "C" {
JNIEXPORT void JNICALL Java_com_example_opencvandroidtest_MainActivity_detectFaces(
JNIEnv* env, jclass mClass, jstring filePath)
{
detectFaces(filePath);
}
}
face_detect_rec.h
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <math.h>
#include <float.h>
#include <limits.h>
#include <time.h>
#include <ctype.h>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/contrib/contrib.hpp>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
using namespace cv;
using namespace std;
static void detectFaces(string filePath);
face_detect_rec.cpp:
#include "face_detect_rec.h"
// Create a string that contains the exact cascade name
string faceCascade_name =
"/Users/Justin/Documents/OpenCV/data/haarcascades/haarcascade_frontalface_alt2.xml";
/* "haarcascade_profileface.xml";*/
string eyeCascade_name =
"/Users/Justin/Documents/OpenCV/data/haarcascades/haarcascade_mcs_lefteye.xml";
//string rightEyeCascade_name =
// "/Users/Justin/Documents/OpenCV/data/haarcascades/haarcascade_mcs_righteye.xml";
// Function to detect and draw any faces that is present in an image
static void detectFaces(string filePath)
{
// Create a new Haar classifier
CascadeClassifier faceCascade;
Mat img = imread(filePath);
//int scale = 1;
// Load the HaarClassifierCascade
faceCascade.load(faceCascade_name);
// Check whether the cascade has loaded successfully. Else report and error and quit
if( faceCascade.empty() )
{
cout << "ERROR: Could not load classifier cascade
";
return;
}
// There can be more than one face in an image. So create a growable sequence of faces.
// Detect the objects and store them in the sequence
vector<Rect> faces;
faceCascade.detectMultiScale(img, faces, 1.1, 2, CV_HAAR_SCALE_IMAGE, cvSize(70, 70));
// Loop the number of faces found.
for( int i=0; i<faces.size(); i++ )
{
//save image
Mat faceROI = img(faces[i]);
stringstream s;
s << "/mnt/sdcard/Pictures/TagSense" << i << ".jpg";
imwrite(s.str(), faceROI);
}
}
}
Do you have a so-called "Application.mk" file in your "jni" directory? If you don't, try to create it with, for instance, the following code:
Application.mk:
APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_ABI := armeabi-v7a
APP_PLATFORM := android-8
Hope this will help.
这篇关于Android 上的 OpenCV - 标头;没有这样的文件/目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Android 上的 OpenCV - 标头;没有这样的文件/目录
基础教程推荐
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01