- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
这是我在这里的第一篇文章,如果我的问题不清楚或没有提供足够的信息,我很抱歉。
我目前正在开发一个可以从图片中识别人脸的 Android 应用程序。
我的第一个方法是使用 JavaCV,一切正常,除了面部检测需要太多时间才能完成!
之后,我尝试使用 FaceDetector.Face 检测人脸。然后我使用检测到的人脸来训练我的人脸识别器模型。目前没有发现错误。
我的问题是我的模型无法识别 FaceDetector.Face 提供的任何检测到的人脸。我总是从预测函数中得到 -1。谁能告诉我可能出了什么问题?提前致谢!
这是我在检测后裁剪人脸的方式:
for(int count=0;count<NUMBER_OF_FACE_DETECTED;count++)
{
Face face=detectedFaces[count];
PointF midPoint=new PointF();
face.getMidPoint(midPoint);
eyeDistance=face.eyesDistance();
left = midPoint.x - (float)(1.4 * eyeDistance);
top = midPoint.y - (float)(1.8 * eyeDistance);
bmFace = Bitmap.createBitmap(origiImage, (int) left, (int) top, (int) (2.8 * eyeDistance), (int) (3.6 * eyeDistance));
bmFaces.add(bmFace);
}
这是训练模型的主要部分。
MatVector images = new MatVector(imageFiles.length);
int[] labels = new int[imageFiles.length];
IplImage img;
IplImage grayImage;
FaceRecognizer faceRecognizer = createLBPHFaceRecognizer(1, 8, 8, 8, binaryTreshold);
try
{
FileInputStream fstream = new FileInputStream(working_Dir.getAbsolutePath()+"/csv.txt");
BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
String imgInfo;
for (int i = 0; (imgInfo = br.readLine()) != null; i++)
{
String info[] = imgInfo.split(";");
String imagePath = info[0];
img = cvLoadImage(imagePath);
grayImage = IplImage.create(img.width(),img.height(), IPL_DEPTH_8U, 1);
cvCvtColor(img, grayImage, CV_BGR2GRAY);
images.put(i, grayImage);
labels[i] = Integer.parseInt(info[1]);;
}
in.close();
//train the FaceRecognizer model
faceRecognizer.train(images, labels);
}catch (Exception e)
{
System.err.println("Error: " + e.getMessage());
}
最后我用下面的代码识别了人脸:
public static String identifyFace(IplImage grayImg)
{
String predictedName = "";
//identify face from the image
int predictedLabel = faceRecognizer.predict(grayImg);
if(predictedLabel != -1 )
{
predictedName = new String(idToName.get(predictedLabel));
}
return predictedName;
}
最佳答案
这只有在您没有正确设置阈值时才会发生,请参阅文档:
创建LBPHFaceRecognizer
的方法是:
Ptr<FaceRecognizer> createLBPHFaceRecognizer(int radius=1, int neighbors=8, int grid_x=8, int grid_y=8, double threshold=DBL_MAX)
,其中:
因此,在上面的方法签名中,您会看到阈值默认设置为 DBL_MAX
。因此,如果您只是将阈值排除在外,那么它永远不会产生 -1
。另一方面,如果您将阈值设置得太低,FaceRecognizer 总是会产生 -1
。也就是说,检查您在代码中将 binaryTreshold
设置为什么。为您的数据找到合适的决策阈值是一个经典的优化问题,您必须根据给定标准(例如,基于错误接受率/错误拒绝率)优化最佳阈值。
关于android - 如何在Android上使用FaceDetector.Face进行人脸识别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14207485/
大家好,我正在使用 OpenCV(Python)开发人脸识别程序。我有两个文件,一个可以捕捉新用户的脸并按用户提供的名称存储它。第二个文件识别使用网络摄像头的用户。现在,我担心的是用户被正确识别,但名
一般来说,我的字体工作正常,但我偶尔会看到一些奇怪的情况,例如从另一个应用程序切换回浏览器,有时当从另一个选项卡切换回时,我的字体似乎已经卸载并正在使用后备字体。 我正在努力始终如一地复制它,当我看到
我经常在我开发的网站中嵌入 webfont (@font-face),直到今天我才遇到过重大问题。 其实我觉得line-height有很大的问题,我英文不是特别好所以我尽量用图来说明。我已经联系了 f
屏幕截图很棒,但没有呈现自定义 @font-face 字体。是否有可能纠正这一点? 最佳答案 在做了一些研究之后,我发现了这个 http://code.google.com/p/phantomjs/i
所以我有一个字体,我最近在几个网站上使用了它,叫做 Kondolar。这是一种可爱的字体,我实际上使用了 4 种字体粗细,所以在我的样式表中实际上有 4 个 @font-face 定义,每个定义都有自
非常感谢:)请找到完整的代码 导入boto3 s3_client = boto3.client('s3', aws_access_key_id='xxxxxxxxxxxxxxx', aws_secre
这不是以下的骗局:Can we test Face ID in simulator? 我想知道如何测试用户何时接受下面的 Face ID 警告,上面写着“你想允许“应用程序”使用 Face ID”,然
我需要检测 iPhone 朝向哪个方向,以便在掉落时从无障碍摄像头(正面或背面)进行录制。 这将在紧急情况下使用,手机掉落或放置在事件摄像头没有记录任何有值(value)内容的情况下。 我可以使用什么
我有一个需要 Trade Gothic 的网站。我想知道将 @font-face 或 cufon 与看起来类似于 Trade Gothic 的字体一起使用还是只是使用图像路线是更好的做法。显然,使用图
我在使用 Microsoft Face API 时遇到问题。以下是我的示例请求: curl -v -X POST "https://westus.api.cognitive.microsoft.com
我有一个在图像上运行并识别人脸并返回如下列表的脚本: [('Mike', (142, 464, 365, 241)),('Garry', (42, 364, 65, 141)),('unknown',
我有一个网络服务,可以重写 css 文件中的 url,以便可以通过 CDN 提供它们。 css 文件可以包含图像或字体的 url。 我目前有以下正则表达式来匹配 css 文件中的所有 url: (ur
我在乱用 @font-face 并且得到了一些奇怪的结果。我下载并安装了字体,它像它应该的那样安装在/Users/myuser/Library/Fonts 中(我想!?)。奇怪的是,无论我在 CSS
JSF 2 的 Mojarra 实现具有以下上下文参数: com.sun.faces.numberOfViewsInSession(默认为 15) com.sun.faces.numberOfLogi
jsf-api.jar 包含各种本地化的 Messages.properties 文件,这些文件一方面包含 javax.faces.component.UIInput.CONVERSION 键,另一方
谁能介绍一下 Liferay Faces 和 JSF 连接。就像我无法理解 Liferay 人脸在以下场景中的作用。 JSF ----> Model View Controller Spr
我正在尝试使用我的字体的“较轻”版本,但在 firefox 和 chrome 中它仍然显示为“正常”粗细。 这是我的 font.css: @font-face { font-family: Aveni
尝试访问应用程序时出现以下JavaScript错误。 Uncaught SyntaxError: Unexpected token 和的正常运行是必需的)。 您可能已经知道HTML文档通常通常以<和J
在我的应用程序中,我想对 UIImage 使用人脸检测,所以我使用库中的 CoreImage 构建(我知道 Vision Library 也是最新的人脸检测库。但它仅支持 ios 11.0 及以上)。
我需要从 Stylus 获得以下 CSS 输出(这是一种落后的方式,但 Stylus 将使该元素的许多其他部分变得更容易)。我已经尝试了很多东西,但无法编译,当它说它已经编译时,这部分输出没有任何显示
我是一名优秀的程序员,十分优秀!