Detects objects in the given image using a PyTorch model.
49 {
50
52 {
53
54 LOG_ERROR(logging::g_qSharedLogger, "Detect() requires a RGB image.");
55 return {};
56 }
57
58
59 std::vector<objectdetectutils::Object> vDetectedTags;
60
61
63 {
64
65 std::vector<yolomodel::Detection> vOutputTensorTags = trPyTorchDetector.
Inference(cvFrame, fMinObjectConfidence, fNMSThreshold);
66
67
69 {
70
72 stDetectedTag.dConfidence = stTagDetection.fConfidence;
73 stDetectedTag.pBoundingBox = std::make_shared<cv::Rect2d>(stTagDetection.cvBoundingBox);
74 stDetectedTag.szClassName = stTagDetection.szClassName;
75 stDetectedTag.eDetectionMethod = objectdetectutils::ObjectDetectionMethod::eTorch;
76 stDetectedTag.cvImageResolution = cvFrame.
size();
77
78
79 vDetectedTags.emplace_back(stDetectedTag);
80 }
81 }
82 else
83 {
84
85 LOG_WARNING(logging::g_qSharedLogger,
86 "TorchDetect: Unable to detect tags using YOLO torch detection because hardware is not opened or model is not initialized.");
87 }
88
89
90 return vDetectedTags;
91 }
bool IsReadyForInference() const
Check if the model is ready for inference.
Definition YOLOModel.hpp:946
std::vector< Detection > Inference(const cv::Mat &cvInputFrame, const float fMinObjectConfidence=0.85, const float fNMSThreshold=0.6)
Given an input image forward the image through the YOLO model to run inference on the PyTorch model,...
Definition YOLOModel.hpp:859
Represents a single detected object. Combines attributes from TorchObject and TensorflowObject struct...
Definition ObjectDetectionUtility.hpp:73
This struct is used to.
Definition YOLOModel.hpp:45