OpenCV4Android-FaceRecognition-例程中出现的错误

移动开发 码拜 8年前 (2016-02-02) 1233次浏览
LogCat:贴出的错误:01-06 14:05:13.834: E/(1620): file /data/data/com.nvidia.NvCPLSvc/files/driverlist.txt: not found!
相关的解释很少,有的说是程序退出的提示错误,本人在Android下调用C++的函数,事实证明不调用该函数是正确的,函数是这么写的,

#include "E:/OpenCV/OpenCV-2.4.9-android-sdk/sdk/native/jni/include/opencv2/core/core.hpp"
#include "E:/OpenCV/OpenCV-2.4.9-android-sdk/sdk/native/jni/include/opencv2/contrib/contrib.hpp"
#include "E:/OpenCV/OpenCV-2.4.9-android-sdk/sdk/native/jni/include/opencv2/highgui/highgui.hpp"
#include <E:/AndriodNDK/android_ndk_r9d/sources/cxx-stl/gnu-libstdc++/4.6/include/iostream>
#include <E:/AndriodNDK/android_ndk_r9d/sources/cxx-stl/gnu-libstdc++/4.6/include/fstream>
#include <E:/AndriodNDK/android_ndk_r9d/sources/cxx-stl/gnu-libstdc++/4.6/include/sstream>
#include <facerec_lbph.h>
using namespace cv;
using namespace std;
JNIEXPORT jint JNICALL Java_com_example_FaceRecognitionLBPH_ImageProc_FacePredict() {
	// Get the path to your CSV.
	string fn_csv = "e:/OpenCV/SmallFaceInfo.csv";
	// These vectors hold the images and corresponding labels.
	vector<Mat> images;
	vector<int> labels;
	// Read in the data. This can fail if no valid
	// input filename is given.
	try {
			ifstream file(fn_csv.c_str(), ifstream::in);
			if (!file) {
				string error_message = "No valid input file was given, please check the given filename.";
				CV_Error(CV_StsBadArg, error_message);
			}
			string line, path, classlabel;
			while (getline(file, line)) {
				stringstream liness(line);
				getline(liness, path, "";"");
				getline(liness, classlabel);
				if (!path.empty() && !classlabel.empty()) {
					Mat temp_Image = imread(path,0);
					if(	NULL == temp_Image.data)
					{
						string error_message = "Read Image failed.";
						CV_Error(CV_StsBadArg, error_message);
					}
					images.push_back(temp_Image);
					//images.push_back(cvLoadImageM(path,0));
					labels.push_back(atoi(classlabel.c_str()));
				}
			}
	}
	catch (cv::Exception& e) {
		cerr << "Error opening file "" << fn_csv << "". Reason: " << e.msg << endl;
		// nothing more we can do
		exit(1);
	}
	// Quit if there are not enough images for this demo.
	if (images.size() <= 1) {
		string error_message = "This demo needs at least 2 images to work. Please add more images to your data set!";
		CV_Error(CV_StsError, error_message);
	}
	int height = images[0].rows;
	Mat testSample = images[images.size() - 1];
	int testLabel = labels[labels.size() - 1];
	images.pop_back();
	labels.pop_back();
	Ptr<FaceRecognizer> model = createLBPHFaceRecognizer();
	model->train(images, labels);
	// The following line predicts the label of a given
	// test image:
	jint predictedLabel = (jint)model->predict(testSample);
	return predictedLabel;
}

头文件如下:

#include <E:\AndriodNDK\android_ndk_r9d\platforms\android-8\arch-arm\usr\include\jni.h>
extern "C" {
	JNIEXPORT jint JNICALL Java_com_example_FaceRecognitionLBPH_ImageProc_FacePredict();
}

整个库的编译生成,没有问题。求帮助啊!


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明OpenCV4Android-FaceRecognition-例程中出现的错误
喜欢 (2)
[1034331897@qq.com]
分享 (0)