Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在特征脸识别器中找不到捕捉人脸?_Java_Opencv - Fatal编程技术网

Java 在特征脸识别器中找不到捕捉人脸?

Java 在特征脸识别器中找不到捕捉人脸?,java,opencv,Java,Opencv,我需要捕捉训练图像集中人脸不可用时的异常。我使用EigenFaceRecognizer进行识别,当我运行此程序时,如果图像可用,它将正确预测,但如果图像不可用,它不会做任何事情,它将预测训练图像集中的最后一幅图像。当人脸在图像集中不可用时,如何实现给我错误的代码 FaceRecognizer faceRecognizer = createEigenFaceRecognizer(); faceRecognizer.train(images, labels); int predictedLabel

我需要捕捉训练图像集中人脸不可用时的异常。我使用EigenFaceRecognizer进行识别,当我运行此程序时,如果图像可用,它将正确预测,但如果图像不可用,它不会做任何事情,它将预测训练图像集中的最后一幅图像。当人脸在图像集中不可用时,如何实现给我错误的代码

FaceRecognizer faceRecognizer = createEigenFaceRecognizer();
faceRecognizer.train(images, labels);
int predictedLabel = faceRecognizer.predict(testImage);
System.out.println("Predicted label: " + predictedLabel);    
return predictedLabel;

我想你想做这样的事情:

final double MIN_CONFIDENCE = 0.01; // experiment with this.
int labela[] = new int[1];
double confidence[] = new double[1];
faceRecognizer.predict(testImage,labela, confidence);
int predictedLabel = (confidence[0] > MIN_CONFIDENCE)?labela[0]:-1; 
System.out.println("Predicted label: " + predictedLabel);

您将需要尝试您重新获得的信心值,以找到一个良好的值,该值拒绝失败,而不拒绝某些合法案例。

我认为您希望这样做:

final double MIN_CONFIDENCE = 0.01; // experiment with this.
int labela[] = new int[1];
double confidence[] = new double[1];
faceRecognizer.predict(testImage,labela, confidence);
int predictedLabel = (confidence[0] > MIN_CONFIDENCE)?labela[0]:-1; 
System.out.println("Predicted label: " + predictedLabel);

你需要尝试你重新获得的信心的价值,找到一个好的价值,它拒绝失败,而不拒绝一些合法的案例。

你离正确的目标不远了。你可以这样做

FaceRecognizer faceRecognizer = createEigenFaceRecognizer();
faceRecognizer.train(images, labels);
int predictedLabel = -1;
predictedLabel = faceRecognizer.predict(testImage);
System.out.println("Predicted label: " + predictedLabel);    
return predictedLabel;
这样,如果预测后和predictedLabel仍然为-1,则您知道图像不是从训练图像集中预测的


如果predictedLabel返回1,则知道该图像是从训练图像集中预测的。我假设您为添加到培训集中的图像输入了1作为标签。

您离正确输入还不远。你可以这样做

FaceRecognizer faceRecognizer = createEigenFaceRecognizer();
faceRecognizer.train(images, labels);
int predictedLabel = -1;
predictedLabel = faceRecognizer.predict(testImage);
System.out.println("Predicted label: " + predictedLabel);    
return predictedLabel;
这样,如果预测后和predictedLabel仍然为-1,则您知道图像不是从训练图像集中预测的


如果predictedLabel返回1,则知道该图像是从训练图像集中预测的。我假设您输入了1作为添加到培训集中的图像的标签。

谢谢,先生bt没有,仍然得到相同的结果它打印了-1它打印了什么?predictedLabel仅在测试图像被预测时才应更改,否则,如果图像未被预测,即在您的训练集中找到,则它将保持为-1。它打印训练图像集中最后一个图像的标签,但不打印-1 Hanku sir bt不工作仍然得到相同的结果它打印-1打印什么?predictedLabel只有在测试图像被预测时才会更改,否则,如果图像未被预测,即在您的培训集中找到,它将保持为-1。它打印培训图像集中最后一个图像的标签,但不打印-1您使用的是哪种java包和opencv版本?@WillShackleford JDK 1.8.031和opencv2.4.10您是从源代码构建OpenCV还是下载了预构建的二进制文件,如?您使用的是哪个java包和版本的OpenCV?@WillShackleford JDK 1.8.031和OpenCV 2.4.10您是从源代码构建OpenCV还是下载了预构建的二进制文件,如?