目前我正在开发适用于Android手机的应用.我们想要检测脸部的特征.该程序应该能够检测眼睛,鼻子,嘴巴和脸部边缘的位置.
准确性应该很好,但不一定要完美.可以放松一些准确性以加快速度.所有的面都是正面的,我们之前会知道这些特征的大致位置.我们不需要实时检测.应从保存的图像中提取要素.检测时间应该只要不影响用户体验.所以即使2或3秒也可以.
有了这个假设,找到一个能让我们实现这个目标的库不应该太难.但我的问题是,最好的方法是什么?你的建议是什么?这是我第一次为Android开发,我不想跑错方向.对我们来说这是一个好主意,还是我自己实现一些现有算法更好(更快/更高精度)?
我google了很多,我发现了很多有趣的东西.Android API中还有面部检测功能.但返回的face class(http://developer.android.com/reference/android/media/FaceDetector.Face.html)仅包含眼睛的位置.这对我们的应用来说更少.然后还有适用于Android或JavaCV的OpenCV.您认为合作的好主意是什么?对于哪个库有好的文档,教程?
android opencv computer-vision face-detection feature-detection
features2D课堂上我到处都看到术语query和train.例如matches有 trainIdx和queryIdx,并且Matchers有train()方法.
我知道单词train和query英语的定义,但我无法理解这个属性或方法的含义.
PS我明白,这是一个非常愚蠢的问题,但也许是因为英语不是我的母语.
我从各个角度都有一个汽车图像文件夹.我想用一袋文字的方法训练系统识别汽车.一旦完成训练,我希望如果给出该车的图像,它应该能够识别它.
我一直在尝试在opencv中学习BOW功能,以便完成这项工作并达到我现在不知道该做什么的水平,并且一些指导将不胜感激.
这是我用来制作文字包的代码:
Ptr<FeatureDetector> features = FeatureDetector::create("SIFT");
Ptr<DescriptorExtractor> descriptors = DescriptorExtractor::create("SIFT");
Ptr<DescriptorMatcher> matcher = DescriptorMatcher::create("FlannBased");
//defining terms for bowkmeans trainer
TermCriteria tc(MAX_ITER + EPS, 10, 0.001);
int dictionarySize = 1000;
int retries = 1;
int flags = KMEANS_PP_CENTERS;
BOWKMeansTrainer bowTrainer(dictionarySize, tc, retries, flags);
BOWImgDescriptorExtractor bowDE(descriptors, matcher);
//training data now
Mat features;
Mat img = imread("c:\\1.jpg", 0);
Mat img2 = imread("c:\\2.jpg", 0);
vector<KeyPoint> keypoints, keypoints2;
features->detect(img, keypoints);
features->detect(img2,keypoints2);
descriptor->compute(img, keypoints, features);
Mat features2;
descripto->compute(img2, keypoints2, features2);
bowTrainer.add(features);
bowTrainer.add(features2);
Mat dictionary = …Run Code Online (Sandbox Code Playgroud) 使用OpenCV查找二进制图像中最大blob的边界框的最有效方法是什么?不幸的是,OpenCV没有特定的blob检测功能.我应该只使用findContours()并搜索列表中最大的?
我正试图在P/Invoking之前找到一种检测特征是否存在的好方法.例如,调用本机StrCmpLogicalW函数:
[SuppressUnmanagedCodeSecurity]
internal static class SafeNativeMethods
{
[DllImport("shlwapi.dll", CharSet = CharSet.Unicode)]
public static extern int StrCmpLogicalW(string psz1, string psz2);
}
Run Code Online (Sandbox Code Playgroud)
将在某些没有此功能的系统上崩溃.
我不想执行版本检查,因为这是不好的做法,有时可能只是错误(例如,当功能被反向移植时,或者可以卸载功能时).
正确的方法是检查导出的存在shlwapi.dll:
private static _StrCmpLogicalW: function(String psz1, String psz2): Integer;
private Boolean _StrCmpLogicalWInitialized;
public int StrCmpLogicalW(String psz1, psz2)
{
if (!_StrCmpLogialInitialized)
{
_StrCmpLogicalW = GetProcedure("shlwapi.dll", "StrCmpLogicalW");
_StrCmpLogicalWInitialized = true;
}
if (_StrCmpLogicalW)
return _StrCmpLogicalW(psz1, psz2)
else
return String.Compare(psz1, psz2, StringComparison.CurrentCultureIgnoreCase);
}
Run Code Online (Sandbox Code Playgroud)
当然,问题是C#不支持函数指针,即:
_StrCmpLogicalW = GetProcedure("shlwapi.dll", "StrCmpLogicalW");
Run Code Online (Sandbox Code Playgroud)
无法做到.
所以我试图找到替代语法来在.NET中执行相同的逻辑.到目前为止我有以下伪代码,但我受到了阻碍:
[SuppressUnmanagedCodeSecurity]
internal static class SafeNativeMethods …Run Code Online (Sandbox Code Playgroud) 我使用OpenCV C++ Lib的HOGDescriptor来计算图像的特征向量.我想要想象源图像中的功能.谁能帮我?
我在Mac OS X 10.8上运行OpenCV 2.4.3.我正在尝试使用cv :: HOGDescriptor来获取视频序列中的行人.
这是我用来执行检测并绘制边界框的代码.
cv::VideoCapture input("file.avi");
assert(input.isOpened());
cv::HOGDescriptor body;
assert(body.load("hogcascade_pedestrians.xml"));
cv::Mat frame, gray;
cv::namedWindow("video");
while (input.read(frame)) {
vector<cv::Rect> rects;
cv::cvtColor(frame, gray, cv::COLOR_RGB2GRAY);
cv::equalizeHist(gray, gray);
body.detectMultiScale(gray, rects);
for (unsigned int i=0;i<rects.size();i++) {
cv::rectangle(frame, cv::Point(rects[i].x, rects[i].y),
cv::Point(rects[i].x+rects[i].width, rects[i].y+rects[i].height),
cv::Scalar(255, 0, 255));
}
cv::imshow("video", frame);
}
Run Code Online (Sandbox Code Playgroud)
但是,当执行到达该行时body.detectMultiScale(gray, rects);,我得到一个错误,整个应用程序崩溃
libc++abi.dylib: terminate called throwing an exception
[1] 92156 abort ../bin/DetectPedestrians
Run Code Online (Sandbox Code Playgroud)
出了什么问题?我似乎无法得到来自任何新的信息gdb或lldb输出.我正在使用CMake构建编译代码,所以我猜这不是链接的问题.
这是崩溃线程的堆栈跟踪 -
Thread 0 Crashed:: Dispatch queue: com.apple.root.default-priority
0 libsystem_kernel.dylib 0x00007fff8c001212 __pthread_kill + 10 …Run Code Online (Sandbox Code Playgroud) 我有一个视频输入.此视频源包含几个以不同速率闪烁的灯.所有灯都是相同的颜色(它们都是红外LED).如何检测这些闪烁灯的位置和频率?
免责声明:我是非常新的OpenCV.我有一份学习OpenCV的副本,但我发现它有点压倒性.如果有人能用OpenCV术语解释解决方案,我们将不胜感激.我不希望为我编写代码.
我试图使用Opencv在Python中实现FREAK描述符.这是我正在使用的代码:
def surf_freak_detect(image,hessianThreshold):
surfDetector = cv2.SURF(hessianThreshold)
surfDetector=cv2.GridAdaptedFeatureDetector(surfDetector,50)
keypoints = surfDetector.detect(image,None)
freakExtractor = cv2.DescriptorExtractor_create('FREAK')
keypoints,descriptors= freakExtractor.compute(image,keypoints)
del freakExtractor
return keypoints,descriptors
Run Code Online (Sandbox Code Playgroud)
这是初始化怪胎描述符的正确方法吗?通过一些调试,我发现解释器需要花费很长时间来计算描述符然后最终崩溃.正确检测关键点.奇怪的是,它有时有效,有时只是崩溃!