android file headers,OpenCV on Android - Headers; No such file/director

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

#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

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

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\n";

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 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

{

//save image

Mat faceROI = img(faces[i]);

stringstream s;

s << "/mnt/sdcard/Pictures/TagSense" << i << ".jpg";

imwrite(s.str(), faceROI);

}

}

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值