Skip to content
Snippets Groups Projects
Commit d0b35714 authored by Thibault Allenet's avatar Thibault Allenet
Browse files

Fix layout from [H,W,C] to [C,H,W]

parent ab2fbc0f
No related branches found
No related tags found
2 merge requests!10Update backend_opencv with modifications from aidge_core,!8Fix layout from [H,W,C] to [C,H,W]
Pipeline #39351 failed
...@@ -61,9 +61,9 @@ static Aidge::DataType CVtoAidge(const int matDepth) { ...@@ -61,9 +61,9 @@ static Aidge::DataType CVtoAidge(const int matDepth) {
std::shared_ptr<Aidge::Tensor> Aidge::tensorOpencv(cv::Mat mat) { std::shared_ptr<Aidge::Tensor> Aidge::tensorOpencv(cv::Mat mat) {
// Get Mat dims // Get Mat dims
const std::vector<DimSize_t> matDims = std::vector<DimSize_t>({static_cast<DimSize_t>(mat.cols), const std::vector<DimSize_t> matDims = std::vector<DimSize_t>({static_cast<DimSize_t>(mat.channels()),
static_cast<DimSize_t>(mat.rows), static_cast<DimSize_t>(mat.rows),
static_cast<DimSize_t>(mat.channels())}); static_cast<DimSize_t>(mat.cols)});
// Get the correct Data Type // Get the correct Data Type
Aidge::DataType type; Aidge::DataType type;
type = CVtoAidge(mat.depth()); type = CVtoAidge(mat.depth());
......
...@@ -69,9 +69,10 @@ TEMPLATE_TEST_CASE("Opencv Utils", "[Utils][OpenCV]", signed char, unsigned char ...@@ -69,9 +69,10 @@ TEMPLATE_TEST_CASE("Opencv Utils", "[Utils][OpenCV]", signed char, unsigned char
auto tensorOcv = tensorOpencv(mat); auto tensorOcv = tensorOpencv(mat);
// Check the size of the tensor // Check the size of the tensor
REQUIRE(mat.channels() == tensorOcv->dims()[0]);
REQUIRE(mat.rows == tensorOcv->dims()[1]); REQUIRE(mat.rows == tensorOcv->dims()[1]);
REQUIRE(mat.cols == tensorOcv->dims()[0]); REQUIRE(mat.cols == tensorOcv->dims()[2]);
REQUIRE(mat.channels() == tensorOcv->dims()[2]);
// Check the matrix inside the tensor coorresponds to the matrix // Check the matrix inside the tensor coorresponds to the matrix
TensorImpl_opencv_* tImpl_opencv = dynamic_cast<TensorImpl_opencv_*>(tensorOcv->getImpl().get()); TensorImpl_opencv_* tImpl_opencv = dynamic_cast<TensorImpl_opencv_*>(tensorOcv->getImpl().get());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment