CNNNetwork read() override {
std::cout << "[ INFO ] Loading network files for Licence Plate Recognition (LPR)" << std::endl;
CNNNetReader netReader;
/** Read network model **/
netReader.ReadNetwork(FLAGS_m_lpr);
std::cout << "[ INFO ] Batch size is forced to 1 for LPR Network" << std::endl;
netReader.getNetwork().setBatchSize(1);
/** Extract model name and load it's weights **/
std::string binFileName = fileNameNoExt(FLAGS_m_lpr) + ".bin";
netReader.ReadWeights(binFileName);
/** LPR network should have 2 inputs (and second is just a stub) and one output **/
// ---------------------------Check inputs
std::cout << "[ INFO ] Checking LPR Network inputs" << std::endl;
InputsDataMap inputInfo(netReader.getNetwork().getInputsInfo());
if (inputInfo.size() != 2) {
throw std::logic_error("LPR should have 2 inputs");
}
InputInfo::Ptr& inputInfoFirst = inputInfo.begin()->second;
inputInfoFirst->setInputPrecision(Precision::U8);
inputInfoFirst->getInputData()->setLayout(Layout::NCHW);
inputImageName = inputInfo.begin()->first;
auto sequenceInput = (++inputInfo.begin());
inputSeqName = sequenceInput->first;
if (sequenceInput->second->getTensorDesc().getDims()[0] != maxSequenceSizePerPlate) {
throw std::logic_error("LPR post-processing assumes certain maximum sequences");
}
// ---------------------------Check outputs
std::cout << "[ INFO ] Checking LPR Network outputs" << std::endl;
OutputsDataMap outputInfo(netReader.getNetwork().getOutputsInfo());
if (outputInfo.size() != 1) {
throw std::logic_error("LPR should have 1 output");
}
outputName = outputInfo.begin()->first;
std::cout << "[ INFO ] Loading LPR model to the "<< FLAGS_d_lpr << " plugin" << std::endl;
_enabled = true;
return netReader.getNetwork();
}