From 459fe70f53b2f3a7dc33c3833210f60840a23204 Mon Sep 17 00:00:00 2001 From: Nikita Kostovsky Date: Thu, 23 Jan 2025 15:49:39 +0100 Subject: change img data type to uint8_t, fix loading of bin calibration table --- src/camera/innomakerov9281.h | 13 ++++++++++--- src/camera/ov9281.cpp | 5 +++-- src/camera/ov9281.h | 2 +- 3 files changed, 14 insertions(+), 6 deletions(-) (limited to 'src/camera') diff --git a/src/camera/innomakerov9281.h b/src/camera/innomakerov9281.h index bcafc12..51485cb 100644 --- a/src/camera/innomakerov9281.h +++ b/src/camera/innomakerov9281.h @@ -5,7 +5,14 @@ #include "constants.h" #include "image.h" -class InnoMakerOV9281 +class ICamera +{ +public: + virtual bool setExposureTimeMs(int value) = 0; + virtual bool setGain(int value) = 0; +}; + +class InnoMakerOV9281 : public ICamera { public: using buffer_t = std::array; @@ -17,8 +24,8 @@ public: public: bool init(); - bool setExposureTimeMs(int value); - bool setGain(int value); + bool setExposureTimeMs(int value) override; + bool setGain(int value) override; bool getImage(Image &image); diff --git a/src/camera/ov9281.cpp b/src/camera/ov9281.cpp index b76ecdd..48f445f 100644 --- a/src/camera/ov9281.cpp +++ b/src/camera/ov9281.cpp @@ -189,7 +189,7 @@ void OV9281::onRequestCompleted(libcamera::Request *completed_request) .planes()[i]; size_t size = std::min(metaplane.bytesused, plane.length); - std::cout << "size is: " << size << std::endl; + // std::cout << "size is: " << size << std::endl; void *data = m_mappedBuffers[plane.fd.get()].first; auto img = std::make_shared(); @@ -204,7 +204,8 @@ void OV9281::onRequestCompleted(libcamera::Request *completed_request) img->counters.timestampUs = metadata.timestamp / 1000; img->counters.encoderPosition = RotaryEncoder::instance()->position(); - memcpy(img->data, data, size); + img->copyFromData(data, size); + // memcpy(img->data, data, size); img->rotate(); auto pixels = img->pixels(); diff --git a/src/camera/ov9281.h b/src/camera/ov9281.h index e989d96..1f2011a 100644 --- a/src/camera/ov9281.h +++ b/src/camera/ov9281.h @@ -65,5 +65,5 @@ private: std::unique_ptr m_allocator{nullptr}; // TODO: set exposureTime from outside - int32_t m_exposureTime{100}; + int32_t m_exposureTime{3000}; }; -- cgit v1.2.3-70-g09d2