mirror of
https://github.com/Xevion/paperless-mobile.git
synced 2025-12-08 12:07:54 -06:00
15 lines
451 B
C++
15 lines
451 B
C++
#include "conversion_utils.hpp"
|
|
using namespace cv;
|
|
uint8_t * ConversionUtils::matrix_to_bytearray(Mat mat)
|
|
{
|
|
int size = mat.total() * mat.elemSize();
|
|
uint8_t *bytes = (uint8_t *)malloc(size);
|
|
std::memcpy(bytes, mat.data, size * sizeof(uint8_t));
|
|
return bytes;
|
|
}
|
|
|
|
Mat ConversionUtils::bytearray_to_matrix(uint8_t *bytes, int byteCount)
|
|
{
|
|
std::vector<uint8_t> buf(bytes, bytes + byteCount);
|
|
return imdecode(buf, IMREAD_COLOR);
|
|
} |