C++ 如何在OpenCV中计算图像中的提示数?

C++ 如何在OpenCV中计算图像中的提示数?,c++,image,opencv,convex-hull,corner-detection,C++,Image,Opencv,Convex Hull,Corner Detection,我有一组平假名字符,我想数一数字符的端点/提示数 例如: 输入图像: 所需输出图像: 我试过使用凸包 代码:(基于opencv教程) findContours(阈值输出、轮廓、层次、CV树、CV链近似、点(0,0)); 向量壳(contours.size()); 对于(int i=0;i

我有一组平假名字符,我想数一数字符的端点/提示数

例如: 输入图像:

所需输出图像:

我试过使用凸包

代码:(基于opencv教程)

findContours(阈值输出、轮廓、层次、CV树、CV链近似、点(0,0));
向量壳(contours.size());
对于(int i=0;i
然后是conrnerHarris(),但它返回了太多不需要的角点

代码:(基于opencv教程)

int blockSize=2;
int-apertureSize=3;
///检测角点
绘图=二值化图像(绘图);//大津
cornerHarris(图形、dst、块大小、光圈大小、0.04、默认边框);
///规范化
标准化(dst,dst_norm,0,255,norm_MINMAX,CV_32FC1,Mat());
可转换标度(dst_norm,dst_norm_scaled);
int countCorner=0;
///在拐角处画一个圆
对于(int j=0;j50)
{
圆(输出,点(i,j),2,标量::全部(255),-1,8,0);
countCorner++;
}
}
}
它检测到11个角

我想这可能和指尖检测一样,但我不知道怎么做


[我正在使用OpenCV 2.4.9.]

我不打算使用OpenCV,因为我可以通过
ImageMagick
获得我所需要的,它是免费的,安装在大多数Linux发行版上,也可用于OSX和Windows。因此,我尝试了ImageMagick,也许您可以调整我的方法-这只是在命令行中完成的

# Thin input image down to a skeleton
convert char.jpg -threshold 50% -negate -morphology Thinning:-1 Skeleton skeleton.jpg

现在,在线条端点附近有一个红色点和两个绿色点,在交叉点附近只有红色点,但没有匹配的绿色点。因此,您将计算附近有绿点的红点

我将只显示叠加了点的骨架,以便您可以看到它们之间的关系:

composite -blend 30% skeleton.jpg result.jpg z.jpg

# Thin input image down to a skeleton
convert char.jpg -threshold 50% -negate -morphology Thinning:-1 Skeleton skeleton.jpg
# Find line-ends, using Hit-or-Miss morphology, and make them green (lime). Save as "lineends.jpg"
convert skeleton.jpg -morphology HMT LineEnds -threshold 50% -fill lime -opaque white lineends.jpg
# Find line-junctions, using Hit-or-Miss morphology, and make them red. Save as "line junctions.jpg"
convert skeleton.jpg -morphology HMT LineJunctions -threshold 50% -fill red -opaque white linejunctions.jpg
# Superpose the line-ends and line junctions into a result
convert lineends.jpg linejunctions.jpg -compose lighten -composite result.jpg
composite -blend 30% skeleton.jpg result.jpg z.jpg