diff options
| author | Nikita Kostovsky <nikita@kostovsky.me> | 2025-02-22 11:37:25 +0100 |
|---|---|---|
| committer | Nikita Kostovsky <nikita@kostovsky.me> | 2025-02-22 11:37:25 +0100 |
| commit | a554cb955012adc51ab0d82af32206fd38a88da8 (patch) | |
| tree | f8df589220e3c2c97a13739faef0a2d32385c342 /src/camera | |
| parent | d12498504c279a0a85bbfb024f7903e34dbe07db (diff) | |
add veye imx287 support: initial commit
Diffstat (limited to 'src/camera')
| -rw-r--r-- | src/camera/innomakerov9281.cpp | 79 |
1 files changed, 49 insertions, 30 deletions
diff --git a/src/camera/innomakerov9281.cpp b/src/camera/innomakerov9281.cpp index 79ae0b4..01f485d 100644 --- a/src/camera/innomakerov9281.cpp +++ b/src/camera/innomakerov9281.cpp @@ -33,6 +33,7 @@ extern uint64_t corr_elapsed_ns; extern uint64_t max_elapsed_ns; extern uint64_t value_elapsed_ns; extern uint64_t rot_elapsed_ns; +extern uint64_t dropped_count; // constexpr char videoDevice[] = "/dev/video0"; @@ -83,7 +84,7 @@ std::vector<std::shared_ptr<ICamera> > InnoMakerOV9281::search() if (!cam->init()) return {}; - if (!cam->setExposureTimeUs(68000)) + if (!cam->setExposureTimeUs(30)) return {}; if (!cam->setLaserLevel(1)) @@ -124,7 +125,7 @@ bool InnoMakerOV9281::startStream() std::cout << "InnoMakerOV9281: start stream" << std::endl; // Image image; - std::shared_ptr<Image> imageCopy = std::make_shared<Image>(); + // std::shared_ptr<Image> imageCopy = std::make_shared<Image>(); while (!stopToken.stop_requested()) { size_t imageIndex{}; @@ -133,31 +134,33 @@ bool InnoMakerOV9281::startStream() if (!getImage(imageIndex)) break; - auto image = m_images[imageIndex]; + continue; + + // auto image = m_images[imageIndex]; - // // FIXME: backup emit value - // #ifdef emit - // #undef emit - // // std::cout << "emit new image" << std::endl << std::flush; - // // newImage.emit(image); - if (newImageCallback) { - // memcpy(imageCopy.get(), &image, sizeof(Image)); - // newImageCallback(imageCopy); - newImageCallback(image); - } + // // // FIXME: backup emit value + // // #ifdef emit + // // #undef emit + // // // std::cout << "emit new image" << std::endl << std::flush; + // // // newImage.emit(image); + // if (newImageCallback) { + // // memcpy(imageCopy.get(), &image, sizeof(Image)); + // // newImageCallback(imageCopy); + // newImageCallback(image); + // } + // // continue; + // // // // newPixels.emit(pixels); + // // auto &img = *image; + // // image->rotate(); + // // img.rotate(); + // image.rotate(); + // // image.rotate(); + // if (newPixelsCallback) { + // // auto pixels = image->pixels(); + // auto pixels = image.pixels(); + // newPixelsCallback(pixels); + // } // continue; - // // // newPixels.emit(pixels); - // auto &img = *image; - // image->rotate(); - // img.rotate(); - image.rotate(); - // image.rotate(); - if (newPixelsCallback) { - // auto pixels = image->pixels(); - auto pixels = image.pixels(); - newPixelsCallback(pixels); - } - continue; } // #define emit // #endif @@ -184,6 +187,7 @@ bool InnoMakerOV9281::init() bool InnoMakerOV9281::setExposureTimeUs(int valueUs) { + return true; std::cout << __func__ << ": " << valueUs << std::endl << std::flush; /* @@ -210,21 +214,28 @@ bool InnoMakerOV9281::setGain(int value) { std::cout << __func__ << ": " << value << std::endl << std::flush; - return setCamParam(V4L2_CID_GAIN, value); + // return setCamParam(V4L2_CID_GAIN, value); + // FIXME: tmp workaround for imx287llr + return true; } bool InnoMakerOV9281::setLaserLevel(int value) { std::cout << __func__ << ": " << value << std::endl << std::flush; - return setCamParam(V4L2_CID_FLASH_TIMEOUT, value); + // return setCamParam(V4L2_CID_FLASH_TIMEOUT, value); + + // FIXME: tmp workaround for imx287llr + return true; } bool InnoMakerOV9281::setSomething(int value) { std::cout << __func__ << ": " << value << std::endl << std::flush; - return setCamParam(V4L2_CID_FLASH_INTENSITY, value); + // return setCamParam(V4L2_CID_FLASH_INTENSITY, value); + // FIXME: tmp workaround for imx287llr + return true; } bool InnoMakerOV9281::setCamParam(unsigned int v4l2controlId, int value) @@ -415,8 +426,10 @@ bool InnoMakerOV9281::getImage(size_t &imageIndex) if (elapsedTime > 1000.) { fprintf(stderr, - "fps: %d\tsec: %d\tdq: %d\tget: %d\trot: %d\tsum: %d,\tcorr: %d,\tval: %d\n", + "fps: %d\tdropped: %d\tsec: %d\tdq: %d\tget: %d\trot: %d\tsum: %d,\tcorr: " + "%d,\tval: %d\n", counter, + dropped_count, curr.tv_sec % 1000, dq_elapsed_ns / 1000 / counter, get_elapsed_ns / 1000 / counter, @@ -433,6 +446,7 @@ bool InnoMakerOV9281::getImage(size_t &imageIndex) max_elapsed_ns = 0; value_elapsed_ns = 0; rot_elapsed_ns = 0; + dropped_count = 0; counter = 0; prev = curr; @@ -472,12 +486,17 @@ bool InnoMakerOV9281::getImage(size_t &imageIndex) // TODO: fill // image.counters.encoderPosition = RotaryEncoder::instance()->position(); image.counters.measurementCounter = buffer.sequence; + + static int64_t prevCounter = buffer.sequence; + dropped_count += buffer.sequence - prevCounter - 1; + prevCounter = buffer.sequence; + image.counters.timestampUs = buffer.timestamp.tv_sec * 1000 * 1000 + buffer.timestamp.tv_usec; { QElapsedTimer t; t.start(); - memcpy(&image.data, video_buffer_ptr[buffer.index], img_size); + // memcpy(&image.data, video_buffer_ptr[buffer.index], img_size); // std::cout << (void *) video_buffer_ptr[buffer.index] << std::endl; get_elapsed_ns += t.nsecsElapsed(); } |
