我有32个字母卡,例如OSMO应用程序(https://www.playosmo.com/en/words/)。
我想通过相机的图像或实时识别它们
我想要这个适用于android设备的应用
所以我为此使用了opencv和c ++。
我尝试过的方法是
第一种方法存在一个问题,即关键点可以实时更改并且不是唯一的。
所以匹配关键点是不好的。
第二个方法问题是android设备中xml文件的加载时间过长。
所以现在我需要帮助
有没有快速可靠的方法?我该怎么办?
答案 0 :(得分:0)
最后,我找到了一种检测五月卡中字母的方法
认出我用胡瞬间的卡片中的字母
就像匹配Shape一样,但是它更准确
https://www.learnopencv.com/shape-matching-using-hu-moments-c-python/
下面的代码重新运行一个double,这是两个图像之间的区别
所以我使用其他图片并将其与其他图片进行比较,然后识别图片中的字母。
double HuMatchingShape(double* secondMoments,double* firstMoments)
{
double dif = 0;
int counter = 0;
for (int i = 0; i < 7; i++)
{
dif += (firstMoments[i] - secondMoments[i]) * (firstMoments[i] -secondMoments[i]);
}
return sqrt(dif);
}
double* getHuMoments(Mat img)
{
Moments moments = cv::moments(img,true);
// Calculate Hu Moments
double * huMoments = new double[7];
HuMoments(moments, huMoments);
for (int i = 0; i < 7; i++)
{
huMoments[i] = -1 * copysign(1.0, huMoments[i]) * log10(abs(huMoments[i]));
}
return huMoments;
}
int main()
{
Mat image1 = imread("image path");
Mat image2 = imread("second image path");
// make these two images binary
image1 = makeItBinay(image1);
image2 = makeItBinay(image2);
// calculate different between two image with hu moments
double different = HuMatchingShape(getHuMoments(image1), getHuMoments(image2));
return 0;
}