diff options
| author | Nikita Kostovsky <luntik2012@gmail.com> | 2025-01-12 17:57:45 +0100 |
|---|---|---|
| committer | Nikita Kostovsky <luntik2012@gmail.com> | 2025-01-12 17:57:45 +0100 |
| commit | 201d98f63131242bb8871ed0c4a3ae9ebd4ef030 (patch) | |
| tree | 763a52710b3c8021c62b93535692b53de90265e5 /src/camera/ov9281.h | |
| parent | 4782e81c32392c78025aae1acb4b2ed1d1395908 (diff) | |
start refactoring. non-working commit
Diffstat (limited to 'src/camera/ov9281.h')
| -rw-r--r-- | src/camera/ov9281.h | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/src/camera/ov9281.h b/src/camera/ov9281.h new file mode 100644 index 0000000..f70db2f --- /dev/null +++ b/src/camera/ov9281.h @@ -0,0 +1,68 @@ +#pragma once + +#include <map> +#include <memory> +#include <vector> + +#include <libcamera/base/signal.h> +#include <libcamera/formats.h> + +namespace libcamera { +class Camera; +class CameraConfiguration; +class CameraManager; +class FrameBufferAllocator; +class Request; +} // namespace libcamera + +class Image; +class Pixels; + +class OV9281 +{ +public: + ~OV9281(); + +public: + static std::vector<std::shared_ptr<OV9281>> search( + std::unique_ptr<libcamera::CameraManager> &manager); + + // public functions +public: + bool startStream(); + void printControls(); + + // signals +public: + // TODO: image->pixels in separate thread + // TODO: respect sender/receiver threads + libcamera::Signal<std::shared_ptr<Pixels>> newPixels; + +private: + explicit OV9281(const std::shared_ptr<libcamera::Camera> &camera); + + // private functions +private: + bool init(); + bool validateConfig(); + bool applyConfig(); + + void onRequestCompleted(libcamera::Request *completed_request); + + // constants +private: + static inline constexpr auto pixelFormat{libcamera::formats::R16}; + static inline constexpr unsigned int bufferCount{2}; + static inline constexpr size_t desiredFPS{144}; + + // member variables +private: + std::shared_ptr<libcamera::Camera> m_camera{nullptr}; + std::unique_ptr<libcamera::CameraConfiguration> m_config{nullptr}; + std::map<int, std::pair<void *, unsigned int>> m_mappedBuffers; + std::vector<std::unique_ptr<libcamera::Request>> m_requests; + std::unique_ptr<libcamera::FrameBufferAllocator> m_allocator{nullptr}; + + // TODO: set exposureTime from outside + int32_t m_exposureTime{1000}; +}; |
