diff options
| author | Nikita Kostovsky <luntik2012@gmail.com> | 2025-01-23 13:41:27 +0100 |
|---|---|---|
| committer | Nikita Kostovsky <luntik2012@gmail.com> | 2025-01-23 13:41:27 +0100 |
| commit | 80949709a1132b5198bb8006963f177fcde2e991 (patch) | |
| tree | 5d797ecfd761df3ac9968c696eba3abfd50852fa | |
| parent | 3fa8f19daf8b36b0703002d78a84e5bb7919849b (diff) | |
fix CMakeLists.txt, add some debug info and prototypes
| -rw-r--r-- | CMakeLists.txt | 17 | ||||
| -rw-r--r-- | macro.h | 2 | ||||
| -rw-r--r-- | main.cpp | 2 | ||||
| -rw-r--r-- | src/camera/ov9281.cpp | 16 | ||||
| -rw-r--r-- | src/image.cpp | 17 | ||||
| -rw-r--r-- | src/image.h | 2 |
6 files changed, 47 insertions, 9 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 32fdfaa..4e08791 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,4 @@ cmake_minimum_required(VERSION 3.16) -project(orpheus LANGUAGES CXX) set(CMAKE_CXX_STANDARD 23) cmake_minimum_required(VERSION 3.18) @@ -26,13 +25,7 @@ set(ENV{PKG_CONFIG_SYSROOT_DIR} ${CMAKE_SYSROOT}) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -I${TARGET_SYSROOT}/usr/include") set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}") -find_package(OpenMP) -if (OPENMP_FOUND) - message("found openmp") - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") - set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") -endif() + # NOTE: on your rpi you'll need to install # libcamera-dev, libcamera-ipa (TODO: check if ipa is needed) @@ -83,6 +76,14 @@ message(STATUS ${LIBCAMERA_LIBRARY}) message(STATUS ${LIBCAMERA_BASE_LIBRARY}) pkg_check_modules(CAMERA REQUIRED libcamera) set(LIBCAMERA_LIBRARIES "${LIBCAMERA_LIBRARY}" "${LIBCAMERA_BASE_LIBRARY}") +project(orpheus LANGUAGES CXX) +find_package(OpenMP) +if (OPENMP_FOUND) + message("found openmp") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") + set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}") +endif() set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD 23) @@ -13,3 +13,5 @@ // << std::endl; #define INIT_FIELD(name) m_##name(name) + +#define INNO_MAKER @@ -119,6 +119,7 @@ int main(int argc, char* argv[]) { QCoreApplication app(argc, argv); +#ifdef INNO_MAKER { std::cout << std::boolalpha; InnoMakerOV9281 innoMakerCam; @@ -139,6 +140,7 @@ int main(int argc, char* argv[]) } qDebug() << "ok"; exit(EXIT_SUCCESS); +#endif // if (false) qDebug() << "size of raw profile" << sizeof(Pixels); diff --git a/src/camera/ov9281.cpp b/src/camera/ov9281.cpp index 012eab6..b76ecdd 100644 --- a/src/camera/ov9281.cpp +++ b/src/camera/ov9281.cpp @@ -64,6 +64,18 @@ bool OV9281::init() libcamera::StreamConfiguration &streamConfig = m_config->at(0); + std::cout << "supported pixel formats:\n"; + + for (const auto &pixelFormat : streamConfig.formats().pixelformats()) + { + std::cout << "\t" << pixelFormat.toString() << std::endl; + + for (const auto &size : streamConfig.formats().sizes(pixelFormat)) + { + std::cout << "\t\t" << size.toString() << std::endl; + } + } + streamConfig.pixelFormat = OV9281::pixelFormat; streamConfig.bufferCount = OV9281::bufferCount; @@ -177,6 +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; void *data = m_mappedBuffers[plane.fd.get()].first; auto img = std::make_shared<Image>(); @@ -184,13 +197,14 @@ void OV9281::onRequestCompleted(libcamera::Request *completed_request) img->width = imageSize.width; img->height = imageSize.height; - memcpy(img->data, data, size); // img->dataSize = size; // img->stride = stride; img->pixelFormat = pixelFormat; img->counters.measurementCounter = metadata.sequence; img->counters.timestampUs = metadata.timestamp / 1000; img->counters.encoderPosition = RotaryEncoder::instance()->position(); + + memcpy(img->data, data, size); img->rotate(); auto pixels = img->pixels(); diff --git a/src/image.cpp b/src/image.cpp index ce814da..000ca2d 100644 --- a/src/image.cpp +++ b/src/image.cpp @@ -1,7 +1,11 @@ #include "image.h" +// #include <format> + #include <QElapsedTimer> +#include <libcamera/formats.h> + #include "macro.h" #include "pixels.h" @@ -125,3 +129,16 @@ std::shared_ptr<Pixels> Image::pixels() const return result; } + +void Image::copyFromData(const void *src, size_t size) +{ + if (size > sizeof(data)) + { + // throw std::logic_error(std::format) + } + + if (pixelFormat == libcamera::formats::R8) + { + memcpy(data, src, size); + } +} diff --git a/src/image.h b/src/image.h index 1ec1b93..934aa40 100644 --- a/src/image.h +++ b/src/image.h @@ -5,6 +5,7 @@ class Pixels; +// TODO: template struct Image { int width{0}; @@ -18,4 +19,5 @@ struct Image void rotate(); std::shared_ptr<Pixels> pixels() const; + void copyFromData(const void* src, size_t size); }; |
