diff --git a/src/utils/Utils.cpp b/src/utils/Utils.cpp index 09df5ec5d95c2e48200706969a4aa2ec58ef3213..3be0ab365730ca8ea57a3eb63e0a5a2083c5b589 100644 --- a/src/utils/Utils.cpp +++ b/src/utils/Utils.cpp @@ -61,9 +61,9 @@ static Aidge::DataType CVtoAidge(const int matDepth) { std::shared_ptr<Aidge::Tensor> Aidge::tensorOpencv(cv::Mat mat) { // 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.channels())}); + static_cast<DimSize_t>(mat.cols)}); // Get the correct Data Type Aidge::DataType type; type = CVtoAidge(mat.depth()); diff --git a/unit_tests/Tests_Utils.cpp b/unit_tests/Tests_Utils.cpp index bd01df9b9f51c53e68135c554ab3497d3e5a19c1..a623e1b9499753939710a519954cab3d141850df 100644 --- a/unit_tests/Tests_Utils.cpp +++ b/unit_tests/Tests_Utils.cpp @@ -69,9 +69,10 @@ TEMPLATE_TEST_CASE("Opencv Utils", "[Utils][OpenCV]", signed char, unsigned char auto tensorOcv = tensorOpencv(mat); // Check the size of the tensor + REQUIRE(mat.channels() == tensorOcv->dims()[0]); REQUIRE(mat.rows == tensorOcv->dims()[1]); - REQUIRE(mat.cols == tensorOcv->dims()[0]); - REQUIRE(mat.channels() == tensorOcv->dims()[2]); + REQUIRE(mat.cols == tensorOcv->dims()[2]); + // Check the matrix inside the tensor coorresponds to the matrix TensorImpl_opencv_* tImpl_opencv = dynamic_cast<TensorImpl_opencv_*>(tensorOcv->getImpl().get());