FastDeploy  latest
Fast & Easy to Deploy!
Public Member Functions | List of all members
fastdeploy::pipeline::PPOCRv2 Class Reference

PPOCRv2 is used to load PP-OCRv2 series models provided by PaddleOCR. More...

#include <ppocr_v2.h>

Inheritance diagram for fastdeploy::pipeline::PPOCRv2:
Inheritance graph
[legend]
Collaboration diagram for fastdeploy::pipeline::PPOCRv2:
Collaboration graph
[legend]

Public Member Functions

 PPOCRv2 (fastdeploy::vision::ocr::DBDetector *det_model, fastdeploy::vision::ocr::Classifier *cls_model, fastdeploy::vision::ocr::Recognizer *rec_model)
 Set up the detection model path, classification model path and recognition model path respectively. More...
 
 PPOCRv2 (fastdeploy::vision::ocr::DBDetector *det_model, fastdeploy::vision::ocr::Recognizer *rec_model)
 Classification model is optional, so this function is set up the detection model path and recognition model path respectively. More...
 
std::unique_ptr< PPOCRv2Clone () const
 Clone a new PPOCRv2 with less memory usage when multiple instances of the same model are created. More...
 
virtual bool Predict (cv::Mat *img, fastdeploy::vision::OCRResult *result)
 Predict the input image and get OCR result. More...
 
virtual bool BatchPredict (const std::vector< cv::Mat > &images, std::vector< fastdeploy::vision::OCRResult > *batch_result)
 BatchPredict the input image and get OCR result. More...
 
bool Initialized () const override
 Check if the model is initialized successfully.
 
- Public Member Functions inherited from fastdeploy::FastDeployModel
virtual std::string ModelName () const
 Get model's name.
 
virtual bool Infer (std::vector< FDTensor > &input_tensors, std::vector< FDTensor > *output_tensors)
 Inference the model by the runtime. This interface is included in the Predict() function, so we don't call Infer() directly in most common situation.
 
virtual bool Infer ()
 Inference the model by the runtime. This interface is using class member reused_input_tensors_ to do inference and writing results to reused_output_tensors_.
 
virtual int NumInputsOfRuntime ()
 Get number of inputs for this model.
 
virtual int NumOutputsOfRuntime ()
 Get number of outputs for this model.
 
virtual TensorInfo InputInfoOfRuntime (int index)
 Get input information for this model.
 
virtual TensorInfo OutputInfoOfRuntime (int index)
 Get output information for this model.
 
virtual void EnableRecordTimeOfRuntime ()
 This is a debug interface, used to record the time of runtime (backend + h2d + d2h) More...
 
virtual void DisableRecordTimeOfRuntime ()
 Disable to record the time of runtime, see EnableRecordTimeOfRuntime() for more detail.
 
virtual std::map< std::string, float > PrintStatisInfoOfRuntime ()
 Print the statistic information of runtime in the console, see function EnableRecordTimeOfRuntime() for more detail.
 
virtual bool EnabledRecordTimeOfRuntime ()
 Check if the EnableRecordTimeOfRuntime() method is enabled.
 
virtual double GetProfileTime ()
 Get profile time of Runtime after the profile process is done.
 
virtual void ReleaseReusedBuffer ()
 Release reused input/output buffers.
 

Additional Inherited Members

- Public Attributes inherited from fastdeploy::FastDeployModel
std::vector< Backendvalid_cpu_backends = {Backend::ORT}
 Model's valid cpu backends. This member defined all the cpu backends have successfully tested for the model.
 
std::vector< Backendvalid_gpu_backends = {Backend::ORT}
 
std::vector< Backendvalid_ipu_backends = {}
 
std::vector< Backendvalid_timvx_backends = {}
 
std::vector< Backendvalid_directml_backends = {}
 
std::vector< Backendvalid_ascend_backends = {}
 
std::vector< Backendvalid_kunlunxin_backends = {}
 
std::vector< Backendvalid_rknpu_backends = {}
 
std::vector< Backendvalid_sophgonpu_backends = {}
 

Detailed Description

PPOCRv2 is used to load PP-OCRv2 series models provided by PaddleOCR.

Constructor & Destructor Documentation

◆ PPOCRv2() [1/2]

fastdeploy::pipeline::PPOCRv2::PPOCRv2 ( fastdeploy::vision::ocr::DBDetector det_model,
fastdeploy::vision::ocr::Classifier cls_model,
fastdeploy::vision::ocr::Recognizer rec_model 
)

Set up the detection model path, classification model path and recognition model path respectively.

Parameters
[in]det_modelPath of detection model, e.g ./ch_PP-OCRv2_det_infer
[in]cls_modelPath of classification model, e.g ./ch_ppocr_mobile_v2.0_cls_infer
[in]rec_modelPath of recognition model, e.g ./ch_PP-OCRv2_rec_infer

◆ PPOCRv2() [2/2]

fastdeploy::pipeline::PPOCRv2::PPOCRv2 ( fastdeploy::vision::ocr::DBDetector det_model,
fastdeploy::vision::ocr::Recognizer rec_model 
)

Classification model is optional, so this function is set up the detection model path and recognition model path respectively.

Parameters
[in]det_modelPath of detection model, e.g ./ch_PP-OCRv2_det_infer
[in]rec_modelPath of recognition model, e.g ./ch_PP-OCRv2_rec_infer

Member Function Documentation

◆ BatchPredict()

bool fastdeploy::pipeline::PPOCRv2::BatchPredict ( const std::vector< cv::Mat > &  images,
std::vector< fastdeploy::vision::OCRResult > *  batch_result 
)
virtual

BatchPredict the input image and get OCR result.

Parameters
[in]imagesThe list of input image data, comes from cv::imread(), is a 3-D array with layout HWC, BGR format.
[in]batch_resultThe output list of OCR result will be writen to this structure.
Returns
true if the prediction successed, otherwise false.

◆ Clone()

std::unique_ptr< PPOCRv2 > fastdeploy::pipeline::PPOCRv2::Clone ( ) const

Clone a new PPOCRv2 with less memory usage when multiple instances of the same model are created.

Returns
new PPOCRv2* type unique pointer

◆ Predict()

bool fastdeploy::pipeline::PPOCRv2::Predict ( cv::Mat *  img,
fastdeploy::vision::OCRResult *  result 
)
virtual

Predict the input image and get OCR result.

Parameters
[in]imThe input image data, comes from cv::imread(), is a 3-D array with layout HWC, BGR format.
[in]resultThe output OCR result will be writen to this structure.
Returns
true if the prediction successed, otherwise false.

The documentation for this class was generated from the following files: