Declaration
TIEVisionNNet = interface(TIEVisionNNetBase)
Description
The
TIEVisionNNet class provides functionilty related to neural networks and deep learning. The following functions are supported:
◼Recognizing (classifying) a single object within an image,
◼Detecting the position of one or more objects within an image
◼Detecting the position of one or more text blocks within an image.
This class is responsible for loading the model, preparing the input, running the neural network, and post-processing the output.
More information on Deep Learning is available at:
learnopencv.com/deep-learning-with-opencvs-dnn-module-a-definitive-guide/ | Demos\IEVision\NeuralNet\NeuralNet.dpr |
// Recognize the object inside TImageEnView1 using a pretrained BLVC GoogLeNet model
var
nnet: TIEVisionNNet;
classId: integer;
confidence: single;
begin
nnet := IEVisionLib.createNNet('bvlc_googlenet.caffemodel', 'bvlc_googlenet.prototxt');
nnet.classifyObject(ImageEnView1.IEBitmap.GetIEVisionImage(), classId, confidence);
ShowMessage(Format('Object index %d (%d%%)', [classId, trunc(confidence * 100)]));
end;
// Detect all text blocks inside TImageEnView using DB_IC15_resnet18.onnx pretrained model
var
nnet: TIEVisionNNet;
rrects: TIEVisionVectorRotatedRect;
confidences: TIEVisionVectorDouble;
i: integer;
begin
nnet := IEVisionLib.createNNet('models\DB\DB_IC15_resnet18.onnx');
nnet.setInputSize(1280, 736);
nnet.setInputScale(1.0/255);
nnet.detectTexts(1, ImageEnView1.IEBitmap.GetIEVisionImage(), confidences, rrects);
for i := 0 to rrects.size() - 1 do
begin
// Do something with the detected text blocks, e.g. use TIEVisionOCR to recognize the text
end;
end;
See Also
◼createNNet◼TIEVisionNNetSuperRes