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)
55 lines
2.1 KiB
C++
55 lines
2.1 KiB
C++
// Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
|
|
|
|
#ifndef INFERENCE_H
|
|
#define INFERENCE_H
|
|
|
|
// Cpp native
|
|
#include <fstream>
|
|
#include <vector>
|
|
#include <string>
|
|
#include <random>
|
|
|
|
// OpenCV / DNN / Inference
|
|
#include <opencv2/imgproc.hpp>
|
|
#include <opencv2/opencv.hpp>
|
|
#include <opencv2/dnn.hpp>
|
|
|
|
struct Detection
|
|
{
|
|
int class_id{0};
|
|
std::string className{};
|
|
float confidence{0.0};
|
|
cv::Scalar color{};
|
|
cv::Rect box{};
|
|
};
|
|
|
|
class Inference
|
|
{
|
|
public:
|
|
Inference(const std::string &onnxModelPath, const cv::Size &modelInputShape = {640, 640}, const std::string &classesTxtFile = "", const bool &runWithCuda = true);
|
|
std::vector<Detection> runInference(const cv::Mat &input);
|
|
|
|
private:
|
|
void loadClassesFromFile();
|
|
void loadOnnxNetwork();
|
|
cv::Mat formatToSquare(const cv::Mat &source, int *pad_x, int *pad_y, float *scale);
|
|
|
|
std::string modelPath{};
|
|
std::string classesPath{};
|
|
bool cudaEnabled{};
|
|
|
|
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"};
|
|
|
|
cv::Size2f modelShape{};
|
|
|
|
float modelConfidenceThreshold {0.25};
|
|
float modelScoreThreshold {0.45};
|
|
float modelNMSThreshold {0.50};
|
|
|
|
bool letterBoxForSquare = true;
|
|
|
|
cv::dnn::Net net;
|
|
};
|
|
|
|
#endif // INFERENCE_H
|