#pragma once #include "pipeline_types.hpp" #include "trt_engine.hpp" #include #include #include #include #include #include namespace fangjia { class BoxTracker { public: std::vector update(std::vector& boxes, int frameIndex, int width, int height); private: struct Track { Box box; int lastFrame{}; }; int nextId_{1}; std::unordered_map tracks_; }; class RtmwEngine { public: RtmwEngine( std::filesystem::path const& enginePath, TrtLogger& logger, int maxSourceWidth, int maxSourceHeight, int maxPeople = 3); ~RtmwEngine(); RtmwEngine(RtmwEngine const&) = delete; RtmwEngine& operator=(RtmwEngine const&) = delete; std::vector infer( cv::Mat const& frame, std::vector const& boxes, cudaStream_t stream, float* preprocessMs = nullptr, float* inferenceMs = nullptr, float* postprocessMs = nullptr); void warmup(cudaStream_t stream); private: TrtEngine engine_; int maxSourceWidth_{}; int maxSourceHeight_{}; int maxPeople_{}; std::uint8_t* sourceDevice_{}; std::uint8_t* cropsDevice_{}; float* networkDevice_{}; std::vector centersHost_; std::vector scalesHost_; std::vector simccXHost_; std::vector simccYHost_; }; class PoseFusionTracker { public: PoseFrameResult update( std::vector const& raw, std::vector const& isolated, int frameIndex); private: struct Vec2 { double x{}; double y{}; }; struct SideFusion { std::array limbPrevious{}; std::array limbVelocity{}; std::array handPrevious{}; std::array handVelocity{}; bool hasLimbPrevious{}; bool hasLimbVelocity{}; bool hasHandPrevious{}; bool hasHandVelocity{}; std::string limbSource; std::string handSource; }; struct Endpoint { bool hasWrist{}; Vec2 wrist{}; Vec2 velocity{}; std::array handShape{}; bool hasHandShape{}; int lastObservedFrame{-1}; int missedFrames{}; bool hasLastElbow{}; Vec2 lastElbow{}; bool hasLastDirection{}; Vec2 lastDirection{}; }; struct PersonState { std::array fusion; std::array endpoints; std::array>, 2> boneSamples; std::array smoothed{}; bool hasSmoothed{}; int lastFrame{-1}; }; std::unordered_map states_; }; } // namespace fangjia