samples/dnn/text_detection.cpp
Примеры с cv2.imshow требуют сборки OpenCV с GUI. В ноутбуке с headless-версией используйте вывод изображений через Matplotlib.
Loading...
Searching...
No Matches
samples/dnn/text_detection.cpp
/*
Text detection model: https://github.com/argman/EAST
Download link: https://www.dropbox.com/s/r2ingd0l3zt8hxs/frozen_east_text_detection.tar.gz?dl=1
Text recognition models can be downloaded directly here:
Download link: https://drive.google.com/drive/folders/1cTbQ3nuZG-EKWak6emD_s8_hHXWz7lAr?usp=sharing
and doc/tutorials/dnn/dnn_text_spotting/dnn_text_spotting.markdown
How to convert from pb to onnx:
Using classes from here: https://github.com/meijieru/crnn.pytorch/blob/master/models/crnn.py
import torch
from models.crnn import CRNN
model = CRNN(32, 1, 37, 256)
model.load_state_dict(torch.load('crnn.pth'))
dummy_input = torch.randn(1, 1, 32, 100)
torch.onnx.export(model, dummy_input, "crnn.onnx", verbose=True)
For more information, please refer to doc/tutorials/dnn/dnn_text_spotting/dnn_text_spotting.markdown and doc/tutorials/dnn/dnn_OCR/dnn_OCR.markdown
*/
#include <iostream>
#include <fstream>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui.hpp>
# </.>
;
::;
* =
;
( & , [], & );
( , ** )
{
(, , );
.(
);
( == || .())
{
.();
;
}
= .<>();
= .<>();
= .<>();
= .<>();
= .<>();
= .<>();
= .<>();
= .<>();
(!.())
{
.();
;
}
(!.() && !.());
();
.()
.();
();
(!.());
:: ;
.(::());
(.());
;
::<> ;
(::(, )) {
.();
}
.();
.();
= / ;
= (, , );
= (, );
.(, , );
= ;
= (, );
= (, , );
= ;
.(, , , );
;
= .() ? .(.<>()) : .();
();
:: = ;
;
(() < )
{
>> ;
(.())
{
();
;
}
:: << . << ::;
::< ::<> > ;
.(, );
= .();
(.() > ) {
;
(!) {
(, , ::);
} {
= ;
}
::< ::<> > ;
( = ; < .(); ++)
{
& = [];
(.(), (), );
.();
::<> ;
( = ; < ; ++)
.([]);
;
(, &[], );
:: = .();
:: << << << << << ::;
(, , [], , , (, , ), );
}
(, , , (, , ), );
}
(, );
}
;
}
( & , [], & )
{
= (, );
[] = {
(, . - ),
(, ), (. - , ),
(. - , . - )
};
= (, );
(, , , );
}