diff options
Diffstat (limited to 'src/camera/innomakerov9281.cpp')
| -rw-r--r-- | src/camera/innomakerov9281.cpp | 49 |
1 files changed, 48 insertions, 1 deletions
diff --git a/src/camera/innomakerov9281.cpp b/src/camera/innomakerov9281.cpp index 6d7aa4a..a2d3136 100644 --- a/src/camera/innomakerov9281.cpp +++ b/src/camera/innomakerov9281.cpp @@ -9,6 +9,8 @@ #include <sys/mman.h> #include <unistd.h> +#include <iostream> + #include "constants.h" // #include "rotaryencoder.h" @@ -25,12 +27,15 @@ extern uint64_t corr_elapsed_ns; extern uint64_t max_elapsed_ns; extern uint64_t value_elapsed_ns; -constexpr char videoDevice[] = "/dev/video0"; +// constexpr char videoDevice[] = "/dev/video0"; InnoMakerOV9281::InnoMakerOV9281() {} InnoMakerOV9281::~InnoMakerOV9281() { + m_streamThread.request_stop(); + m_streamThread.join(); + int ret{-1}; for (int i = 0; i < BUFFER_COUNT; ++i) { @@ -55,6 +60,48 @@ InnoMakerOV9281::~InnoMakerOV9281() // std::cout << __func__ << ": success" << std::endl; } +std::vector<std::shared_ptr<ICamera> > InnoMakerOV9281::search() +{ + // return only one camera for now + std::cout << std::boolalpha; + auto cam = std::make_shared<InnoMakerOV9281>(); + + if (!cam->init()) + return {}; + + if (!cam->setExposureTimeMs(3000)) + return {}; + + if (!cam->setGain(3000)) + return {}; + + return {cam}; +} + +bool InnoMakerOV9281::startStream() +{ + m_streamThread = std::jthread{[&](std::stop_token stopToken) { + std::cout << "InnoMakerOV9281: start stream" << std::endl; + + while (!stopToken.stop_requested()) { + std::shared_ptr<Image> image = std::make_shared<Image>(); + getImage(*image); +// FIXME: backup emit value +#ifdef emit +#undef emit + std::cout << "emit new image" << std::endl << std::flush; + newImage.emit(image); + auto pixels = image->pixels(); + newPixels.emit(pixels); + } +#define emit +#endif + std::cout << "InnoMakerOV9281: stream interruption requested" << std::endl; + }}; + + return true; +} + bool InnoMakerOV9281::init() { if (!openCam()) |
