diff options
| -rw-r--r-- | src/calibration.cpp | 16 | ||||
| -rw-r--r-- | src/camera/innomakerov9281.cpp | 79 | ||||
| -rw-r--r-- | src/constants.h | 10 | ||||
| -rw-r--r-- | src/image.cpp | 1 | ||||
| -rw-r--r-- | src/main.cpp | 28 | ||||
| -rw-r--r-- | src/profile.cpp | 2 |
6 files changed, 80 insertions, 56 deletions
diff --git a/src/calibration.cpp b/src/calibration.cpp index 5caae02..3bc0ba5 100644 --- a/src/calibration.cpp +++ b/src/calibration.cpp @@ -81,16 +81,16 @@ void interpolate( table->end(), [](auto& column) { interpolate(column); }); - for (size_t i = 9471; i < 9472; i++) { - std::cout << __func__ << ": row #" << i << ": "; + // for (size_t i = 9471; i < 9472; i++) { + // std::cout << __func__ << ": row #" << i << ": "; - for (size_t j = 640 - 5; j < 640 + 5; ++j) { - const auto& p = table->at(j).at(i); - std::cout << p << ' '; - } + // for (size_t j = 640 - 5; j < 640 + 5; ++j) { + // const auto& p = table->at(j).at(i); + // std::cout << p << ' '; + // } - std::cout << std::endl; - } + // std::cout << std::endl; + // } // for (size_t i = 0; i < discretesInRage; i++) { // std::cout << "row #" << i << ": "; 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(); } diff --git a/src/constants.h b/src/constants.h index 53e6063..ba17382 100644 --- a/src/constants.h +++ b/src/constants.h @@ -6,8 +6,14 @@ // TODO: get rid of qstring #include <QString> -constexpr size_t img_width = 1280; -constexpr size_t img_height = 800; +// ov9281 +// constexpr size_t img_width = 1280; +// constexpr size_t img_height = 800; + +// imx287llr +constexpr size_t img_width = 704; +constexpr size_t img_height = 544; + constexpr size_t img_size = img_width * img_height; constexpr uint32_t patternSize = 10; diff --git a/src/image.cpp b/src/image.cpp index befcb2b..c2ee5b4 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -16,6 +16,7 @@ uint64_t corr_elapsed_ns = 0; uint64_t max_elapsed_ns = 0; uint64_t value_elapsed_ns = 0; uint64_t rot_elapsed_ns = 0; +uint64_t dropped_count = 0; // float process_column(const uint8_t (&column)[]) // float process_column(const Image::row_t &column) diff --git a/src/main.cpp b/src/main.cpp index d986f91..fd5bd79 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -120,10 +120,10 @@ void onNewPixels(std::shared_ptr<Pixels> pixels) // qDebug() << __func__ << "got empty pixels"; } - for (size_t i = 640 - 5; i < 640 + 5; i++) - { - // std::cout << pixels->pixels[i] << " "; - } + // for (size_t i = 640 - 5; i < 640 + 5; i++) + // { + // // std::cout << pixels->pixels[i] << " "; + // } // std::cout << std::endl @@ -144,7 +144,8 @@ int main(int argc, char* argv[]) std::cout << std::boolalpha; InnoMakerOV9281 innoMakerCam; qDebug() << "init:" << innoMakerCam.init(); - qDebug() << "set exposure:" << innoMakerCam.setExposureTimeUs(3000000); + // qDebug() << "set exposure:" << innoMakerCam.setExposureTimeUs(3000000); + qDebug() << "set exposure:" << innoMakerCam.setExposureTimeUs(10000); qDebug() << "set gain:" << innoMakerCam.setGain(2); innoMakerCam.startStream(); @@ -167,25 +168,22 @@ int main(int argc, char* argv[]) // if (false) qDebug() << "size of raw profile" << sizeof(Pixels); - if (true) - { + if (false) { // open binary calibration table if (true) { initializers << QtConcurrent::run([&]() { - if (!openCalibrationTable( - // "/home/user/dumps/binz.calibration_table", - "/tmp/binz.calibration_table", - ::calibrationTableZ)) { + if (!openCalibrationTable("/home/user/dumps/binz.calibration_table", + // "/tmp/binz.calibration_table", + ::calibrationTableZ)) { exit(EXIT_FAILURE); } }); initializers << QtConcurrent::run([&]() { - if (!openCalibrationTable( - // "/home/user/dumps/binx.calibration_table", - "/tmp/binx.calibration_table", - ::calibrationTableX)) { + if (!openCalibrationTable("/home/user/dumps/binx.calibration_table", + // "/tmp/binx.calibration_table", + ::calibrationTableX)) { exit(EXIT_FAILURE); } }); diff --git a/src/profile.cpp b/src/profile.cpp index 2c7b9a9..64ba091 100644 --- a/src/profile.cpp +++ b/src/profile.cpp @@ -25,7 +25,7 @@ Profile::Profile( for (size_t i = 9471; i < 9472; i++) { std::cout << __func__ << ": row #" << i << ": "; - for (size_t j = 0; j < 1280; ++j) { + for (size_t j = 0; j < img_width; ++j) { const auto& x = calibrationTableX->at(j).at(i); const auto& z = calibrationTableZ->at(j).at(i); std::cout << "Profile: table: " << x << ' ' << z << std::endl; |
