Files
HSAP/algorithms/dms_yolo/code.embedded.bak/examples/YOLOv8-OpenVINO-CPP-Inference/inference.h
Chengfang Lu e72bc061c5 feat: HSAP platform v2 — modular navigation, quality review, audit log, world model simulation
Major changes:
- New frontend (platform/web/): Vite + React 18 + TypeScript + Tailwind
- 4-module navigation: 数据送标 / 模型管理 / 车队管理 / 系统管理
- Data catalog with charts (DMS/ADAS/Lane 3-tab view)
- Quality review workflow (标注质检): Good/Fine/Bad scoring with auto-advance
- Audit enhancements: batch operations, rejection categories, Feishu notifications
- Operation audit log (操作日志)
- World model simulation studio (仿真工坊)
- Dataset version management with snapshots and diff
- ADAS 7-class dataset integration (138K images organized + compressed)
- User management with Feishu integration and pagination
- CRUD/search/filter on all pages, card layout redesign
- PIL-optimized image overlay rendering
- Auto-snapshot on build, in_review workflow stage
- Removed embedded algorithm code (now in workspace)
2026-06-03 11:40:21 +08:00

62 lines
2.5 KiB
C++

// Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
#ifndef YOLO_INFERENCE_H_
#define YOLO_INFERENCE_H_
#include <string>
#include <vector>
#include <opencv2/imgproc.hpp>
#include <openvino/openvino.hpp>
namespace yolo {
struct Detection {
short class_id;
float confidence;
cv::Rect box;
};
class Inference {
public:
Inference() {}
// Constructor to initialize the model with default input shape
Inference(const std::string &model_path, const float &model_confidence_threshold, const float &model_NMS_threshold);
// Constructor to initialize the model with specified input shape
Inference(const std::string &model_path, const cv::Size model_input_shape, const float &model_confidence_threshold, const float &model_NMS_threshold);
void RunInference(cv::Mat &frame);
private:
void InitializeModel(const std::string &model_path);
void Preprocessing(const cv::Mat &frame);
void PostProcessing(cv::Mat &frame);
cv::Rect GetBoundingBox(const cv::Rect &src) const;
void DrawDetectedObject(cv::Mat &frame, const Detection &detections) const;
cv::Point2f scale_factor_; // Scaling factor for the input frame
cv::Size2f model_input_shape_; // Input shape of the model
cv::Size model_output_shape_; // Output shape of the model
ov::InferRequest inference_request_; // OpenVINO inference request
ov::CompiledModel compiled_model_; // OpenVINO compiled model
float model_confidence_threshold_; // Confidence threshold for detections
float model_NMS_threshold_; // Non-Maximum Suppression threshold
std::vector<std::string> classes_ {
"person", "bicycle", "car", "motorcycle", "airplane", "bus", "train", "truck", "boat", "traffic light",
"fire hydrant", "stop sign", "parking meter", "bench", "bird", "cat", "dog", "horse", "sheep", "cow",
"elephant", "bear", "zebra", "giraffe", "backpack", "umbrella", "handbag", "tie", "suitcase", "frisbee",
"skis", "snowboard", "sports ball", "kite", "baseball bat", "baseball glove", "skateboard", "surfboard",
"tennis racket", "bottle", "wine glass", "cup", "fork", "knife", "spoon", "bowl", "banana", "apple",
"sandwich", "orange", "broccoli", "carrot", "hot dog", "pizza", "donut", "cake", "chair", "couch",
"potted plant", "bed", "dining table", "toilet", "tv", "laptop", "mouse", "remote", "keyboard",
"cell phone", "microwave", "oven", "toaster", "sink", "refrigerator", "book", "clock", "vase",
"scissors", "teddy bear", "hair drier", "toothbrush"
};
};
} // namespace yolo
#endif // YOLO_INFERENCE_H_