| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- #pragma once
- #include <cstdint>
- #include <vector>
- #include "rtsp_capture.h"
- class RgaProcessor {
- public:
- RgaProcessor() = default;
- ~RgaProcessor();
-
- // Initialize with target input size for the model (e.g. 640x640)
- bool init(int target_w, int target_h);
-
- // Convert NV12 to RGB and resize to target size
- // Returns RGB data in NHWC format, normalized to [0,1] as float
- // Also returns the scale factor and padding offsets for coordinate mapping
- bool process(const Nv12Frame& nv12,
- std::vector<float>& output,
- float& scale, int& pad_x, int& pad_y);
-
- // Get the scale factor used in last process() call
- float lastScale() const { return last_scale_; }
- int lastPadX() const { return last_pad_x_; }
- int lastPadY() const { return last_pad_y_; }
-
- // Direct NV12->RGB without normalization (for display/JPEG encoding)
- bool processToRgb(const Nv12Frame& nv12, std::vector<uint8_t>& rgb_out,
- int& out_w, int& out_h);
- private:
- int target_w_ = 640;
- int target_h_ = 640;
- float last_scale_ = 1.0f;
- int last_pad_x_ = 0;
- int last_pad_y_ = 0;
-
- // Software fallback methods
- void softwareNv12ToRgb(const Nv12Frame& nv12, std::vector<uint8_t>& rgb,
- int out_w, int out_h);
- };
|