From cf87257fc3b7132eccf305f3eca9ee56c151d913 Mon Sep 17 00:00:00 2001 From: Nikita Kostovsky Date: Sun, 30 Nov 2025 01:19:33 +0100 Subject: don't waste memory --- src/camera/veyeimx287m.h | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/camera/veyeimx287m.h') diff --git a/src/camera/veyeimx287m.h b/src/camera/veyeimx287m.h index d65b00d..3f591f7 100644 --- a/src/camera/veyeimx287m.h +++ b/src/camera/veyeimx287m.h @@ -44,8 +44,9 @@ public: [[nodiscard]] bool dequeueImageBuffer(size_t &image); // bool getImage(Image &image); - [[nodiscard]] bool getImage(Image *image) override; - [[nodiscard]] std::shared_ptr getImage() override; + // [[nodiscard]] bool getImage(Image *image) override; + [[nodiscard]] Image *getImage() override; + // [[nodiscard]] std::shared_ptr getImage() override; bool init(); @@ -66,7 +67,7 @@ public: public: /*! * \brief processedCounter - count of images processed in current second. - * Used for performance measurement and bottlenecks analysing + * Used for performance measurement and bottlenecks analysis */ uint32_t processedCounter{0}; @@ -76,6 +77,11 @@ private: [[nodiscard]] bool initI2C(); + /*! + * \brief getFramesLoop - get frames from camera and manage futher processing + * \note to be started in a soparate thread + * \param stopToken - asks to break the loop + */ void getFramesLoop(std::stop_token stopToken); private: @@ -96,21 +102,19 @@ private: */ std::array m_imageMutexes; - // TODO: split this - // there should be no chance of changing image by ioctl during futher processing struct buffer { void *mem{nullptr}; - std::shared_ptr image{std::make_shared()}; }; std::vector m_rawBuffers; - // std::array m_images; + std::array m_images; + // std::optional> m_lastImageIdx; + std::optional m_lastImageIdx; std::mutex m_camMtx; std::jthread m_streamThread; std::jthread m_getThreads[1]; - std::mutex m_lastImageMtx; std::shared_ptr m_lastProcessedImage{}; std::shared_ptr m_i2c; -- cgit v1.2.3-70-g09d2