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 5f6cd7103c1afaa673898d71db6c5c05fdfd1bfe..28a697b57aa3fea21c78c8e3e5fc719afcb60e3d 100644 --- a/unit_tests/Tests_Utils.cpp +++ b/unit_tests/Tests_Utils.cpp @@ -61,9 +61,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]); + //Get the matrix inside the tensor TensorImpl_opencv_* tImpl_opencv = dynamic_cast<TensorImpl_opencv_*>(tensorOcv->getImpl().get());