欢迎光临
我们一直在努力

OpenCV C++基于CNN模型的场景文本检测(OCR)

这个程序使用OpenCV text模块检测场景中的文本。

输入图片:

程序运行后会显示用红色矩形框标注文本的图片:

代码:

int main()
{
Mat image = imread("scenetext_segmented_word02.jpg");

Ptr<TextDetectorCNN> textSpotter =
TextDetectorCNN::create("textbox.prototxt","TextBoxes_icdar13.caffemodel");

vector<Rect> bbox;
vector<float> outProbabillities;
textSpotter->detect(image, bbox, outProbabillities);

vector<int> indexes;
NMSBoxes(bbox, outProbabillities, 0.3f, 0.4f, indexes);

for (int i = 0; i < indexes.size(); i++)
{
rectangle(image, bbox[indexes[i]], Scalar(0, 0, 255), 3, 8);
}

imshow("TextBox",image);
waitKey();
}

赞(0)
未经允许不得转载:171主机测评 » OpenCV C++基于CNN模型的场景文本检测(OCR)
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址