Skip to content
Snippets Groups Projects
Unverified Commit 57230090 authored by Maxence Naud's avatar Maxence Naud
Browse files

[upd] functions to follow Tensor member function updated names

parent 248415ba
No related branches found
No related tags found
No related merge requests found
Pipeline #77409 failed
......@@ -72,7 +72,7 @@ std::shared_ptr<Aidge::Tensor> Aidge::tensorOpencv(cv::Mat mat) {
tensor->setDataType(CVtoAidge(mat.depth()));
// Cast the tensorImpl to access setCvMat function
TensorImpl_opencv_* tImpl_opencv = dynamic_cast<TensorImpl_opencv_*>(tensor->getImpl().get());
TensorImpl_opencv_* tImpl_opencv = dynamic_cast<TensorImpl_opencv_*>(tensor->impl().get());
tImpl_opencv->setCvMat(mat);
return tensor;
}
......@@ -32,7 +32,7 @@ TEST_CASE("Stimulus creation", "[Stimulus][OpenCV]") {
// // Create Stimulus
// Stimulus stimg("/data1/is156025/tb256203/dev/eclipse_aidge/aidge/user_tests/train-images-idx3-ubyte[00001].pgm", true);
// stimg.setBackend("opencv");
// Generate random matrix and save it
std::vector<cv::Mat> channels;
cv::Mat true_mat;
......@@ -57,7 +57,7 @@ TEST_CASE("Stimulus creation", "[Stimulus][OpenCV]") {
tensor_load = stimg.load();
// Access the cv::Mat with the tensor
TensorImpl_opencv_* tImpl_opencv = dynamic_cast<TensorImpl_opencv_*>(tensor_load->getImpl().get());
TensorImpl_opencv_* tImpl_opencv = dynamic_cast<TensorImpl_opencv_*>(tensor_load->impl().get());
auto mat_tensor = tImpl_opencv->data();
// Check the dimensions
......@@ -71,7 +71,7 @@ TEST_CASE("Stimulus creation", "[Stimulus][OpenCV]") {
// Check the elements
for (size_t i = 0; i < channels_tensor.size(); ++i) {
REQUIRE(cv::countNonZero(channels_tensor[i] != channels[i]) == 0);
REQUIRE(cv::countNonZero(channels_tensor[i] != channels[i]) == 0);
}
// This time the tensor is already loaded in memory
......@@ -79,7 +79,7 @@ TEST_CASE("Stimulus creation", "[Stimulus][OpenCV]") {
tensor_load_2 = stimg.load();
// Access the cv::Mat with the tensor
TensorImpl_opencv_* tImpl_opencv_2 = dynamic_cast<TensorImpl_opencv_*>(tensor_load_2->getImpl().get());
TensorImpl_opencv_* tImpl_opencv_2 = dynamic_cast<TensorImpl_opencv_*>(tensor_load_2->impl().get());
auto mat_tensor_2 = tImpl_opencv_2->data();
// Check the dimensions
......@@ -93,7 +93,7 @@ TEST_CASE("Stimulus creation", "[Stimulus][OpenCV]") {
// Check the elements
for (size_t i = 0; i < channels_tensor_2.size(); ++i) {
REQUIRE(cv::countNonZero(channels_tensor_2[i] != channels[i]) == 0);
REQUIRE(cv::countNonZero(channels_tensor_2[i] != channels[i]) == 0);
}
}
}
......@@ -33,7 +33,7 @@ TEST_CASE("StimulusImpl_opencv_imread creation", "[StimulusImpl_opencv_imread][O
// // Create StimulusImpl_opencv_imread
// // StimulusImpl_opencv_imread stImpl("/data1/is156025/tb256203/dev/eclipse_aidge/aidge/user_tests/Lenna.png");
// StimulusImpl_opencv_imread stImpl("/data1/is156025/tb256203/dev/eclipse_aidge/aidge/user_tests/train-images-idx3-ubyte[00001].pgm");
// Generate random matrix and save it
std::vector<cv::Mat> channels;
cv::Mat true_mat;
......@@ -58,7 +58,7 @@ TEST_CASE("StimulusImpl_opencv_imread creation", "[StimulusImpl_opencv_imread][O
tensor_load = stImpl.load();
// Access the cv::Mat with the tensor
TensorImpl_opencv_* tImpl_opencv = dynamic_cast<TensorImpl_opencv_*>(tensor_load->getImpl().get());
TensorImpl_opencv_* tImpl_opencv = dynamic_cast<TensorImpl_opencv_*>(tensor_load->impl().get());
auto mat_tensor = tImpl_opencv->data();
// Check the dimensions
......@@ -72,7 +72,7 @@ TEST_CASE("StimulusImpl_opencv_imread creation", "[StimulusImpl_opencv_imread][O
// Check the elements
for (size_t i = 0; i < channels_tensor.size(); ++i) {
REQUIRE(cv::countNonZero(channels_tensor[i] != channels[i]) == 0);
REQUIRE(cv::countNonZero(channels_tensor[i] != channels[i]) == 0);
}
}
}
......@@ -70,16 +70,16 @@ TEST_CASE("Tensor creation opencv", "[Tensor][OpenCV]") {
}
SECTION("OpenCV tensor features") {
REQUIRE(static_cast<TensorImpl_opencv<int>*>(x.getImpl().get())->data().rows == 2);
REQUIRE(static_cast<TensorImpl_opencv<int>*>(x.getImpl().get())->data().cols == 2);
REQUIRE(static_cast<TensorImpl_opencv<int>*>(x.getImpl().get())->data().dims == 2);
REQUIRE(static_cast<TensorImpl_opencv<int>*>(x.getImpl().get())->data().total() == 4);
REQUIRE(static_cast<TensorImpl_opencv<int>*>(x.getImpl().get())->data().channels() == 2);
REQUIRE(static_cast<TensorImpl_opencv<int>*>(x.impl().get())->data().rows == 2);
REQUIRE(static_cast<TensorImpl_opencv<int>*>(x.impl().get())->data().cols == 2);
REQUIRE(static_cast<TensorImpl_opencv<int>*>(x.impl().get())->data().dims == 2);
REQUIRE(static_cast<TensorImpl_opencv<int>*>(x.impl().get())->data().total() == 4);
REQUIRE(static_cast<TensorImpl_opencv<int>*>(x.impl().get())->data().channels() == 2);
}
SECTION("Access to array") {
REQUIRE(static_cast<int*>(x.getImpl()->rawPtr())[0] == 1);
REQUIRE(static_cast<int*>(x.getImpl()->rawPtr())[7] == 8);
REQUIRE(static_cast<int*>(x.impl()->rawPtr())[0] == 1);
REQUIRE(static_cast<int*>(x.impl()->rawPtr())[7] == 8);
}
SECTION("get function") {
......
......@@ -64,10 +64,10 @@ TEMPLATE_TEST_CASE("Opencv Utils", "[Utils][OpenCV]", signed char, unsigned char
REQUIRE(mat.rows == tensorOcv->dims()[0]);
REQUIRE(mat.cols == tensorOcv->dims()[1]);
REQUIRE(mat.channels() == tensorOcv->dims()[2]);
//Get the matrix inside the tensor
TensorImpl_opencv_* tImpl_opencv = dynamic_cast<TensorImpl_opencv_*>(tensorOcv->getImpl().get());
TensorImpl_opencv_* tImpl_opencv = dynamic_cast<TensorImpl_opencv_*>(tensorOcv->impl().get());
auto mat_tensor = tImpl_opencv->data();
// Split the mat from tensor opencv into channels
std::vector<cv::Mat> channels_split;
......@@ -79,7 +79,7 @@ TEMPLATE_TEST_CASE("Opencv Utils", "[Utils][OpenCV]", signed char, unsigned char
tensorCpu.setDataFormat(DataFormat::CHW);
// Get the cpu ptr of the converted tensor
auto cpu_ptr = static_cast<TestType*>(tensorCpu.getImpl()->rawPtr());
auto cpu_ptr = static_cast<TestType*>(tensorCpu.impl()->rawPtr());
// Compare the tensor cpu values with the cv mat in an elementwise fashion
// Loop over channels
......
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