6#include <neoapi/neoapi.hpp>
7#include <opencv2/opencv.hpp>
14 const size_t width = image.GetWidth();
15 const size_t height = image.GetHeight();
16 const size_t numPixels = width * height;
19 image.GetPixelFormat() == NeoAPI::NeoString(
"Mono12"),
20 "Only 'Mono12' pixel format are supported, got '%s'",
21 image.GetPixelFormat().c_str());
25 image.GetSize() == numPixels * 2,
"Invalid image size for Mono12 unpacked format");
28 const uint8_t* rawData =
reinterpret_cast<const uint8_t*
>(image.GetImageData());
31 cv::Mat output(height, width, CV_16UC1);
34 for(
size_t i = 0; i < numPixels; ++i) {
71 cv::Mat mat(rows, cols, CV_16UC1);
72 size_t expectedSize = rows * cols * 2;
79 memcpy(mat.data, data, expectedSize);
Assertion macros and utilities based on the PPK_ASSERT library.
#define IRSOL_ASSERT_ERROR
Error-level assertion macro.
cv::Mat createCvMatFromIrsolServerBuffer(unsigned char *data, size_t rows, size_t cols)
Creates an OpenCV cv::Mat from a raw buffer received from the IRSOL server.
cv::Mat convertNeoImageToCvMat(const NeoAPI::Image &image)
Converts a NeoAPI::Image (Mono12, non-packed) into an OpenCV cv::Mat.
Provides utilities for interoperability between NeoAPI and OpenCV.
OpenCV integration utilities for NeoAPI image handling.
Utility for swapping pixel bytes in a buffer.
Helper to convert pixel values from one bit depth to another with scaling.
static Pixel< TargetBitDepth >::representation scale(typename Pixel< SourceBitDepth >::representation value)
Scales a pixel value from source bit depth to target bit depth.
typename PixelRepresentation< BitDepth >::type representation
The integral type used to represent pixel values at this bit depth.