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

Update tests for opencv version compatibility with function countNonZero

parent 3fdb6589
No related branches found
No related tags found
2 merge requests!10Update backend_opencv with modifications from aidge_core,!9Remove dependency of backend CPU and fix CI
Pipeline #39416 passed
......@@ -58,10 +58,21 @@ TEST_CASE("Stimulus creation", "[Stimulus][OpenCV]") {
// Access the cv::Mat with the tensor
TensorImpl_opencv_* tImpl_opencv = dynamic_cast<TensorImpl_opencv_*>(tensor_load->getImpl().get());
auto mat_tensor = tImpl_opencv->data();
REQUIRE((tImpl_opencv->data().total() * tImpl_opencv->data().channels()) == (true_mat.total() * true_mat.channels()));
REQUIRE(cv::countNonZero(tImpl_opencv->data() != true_mat) == 0);
// Check the dimensions
REQUIRE((mat_tensor.total() * mat_tensor.channels()) == (true_mat.total() * true_mat.channels()));
// Split it in channels
std::vector<cv::Mat> channels_tensor;
cv::split(mat_tensor, channels_tensor);
REQUIRE(channels_tensor.size() == channels.size());
// Check the elements
for (size_t i = 0; i < channels_tensor.size(); ++i) {
REQUIRE(cv::countNonZero(channels_tensor[i] != channels[i]) == 0);
}
// This time the tensor is already loaded in memory
std::shared_ptr<Tensor> tensor_load_2;
......@@ -69,9 +80,20 @@ TEST_CASE("Stimulus creation", "[Stimulus][OpenCV]") {
// Access the cv::Mat with the tensor
TensorImpl_opencv_* tImpl_opencv_2 = dynamic_cast<TensorImpl_opencv_*>(tensor_load_2->getImpl().get());
auto mat_tensor_2 = tImpl_opencv_2->data();
REQUIRE((tImpl_opencv_2->data().total() * tImpl_opencv_2->data().channels()) == (true_mat.total() * true_mat.channels()));
REQUIRE(cv::countNonZero(tImpl_opencv_2->data() != true_mat) == 0);
// Check the dimensions
REQUIRE((mat_tensor_2.total() * mat_tensor_2.channels()) == (true_mat.total() * true_mat.channels()));
// Split it in channels
std::vector<cv::Mat> channels_tensor_2;
cv::split(mat_tensor_2, channels_tensor_2);
REQUIRE(channels_tensor_2.size() == channels.size());
// Check the elements
for (size_t i = 0; i < channels_tensor_2.size(); ++i) {
REQUIRE(cv::countNonZero(channels_tensor_2[i] != channels[i]) == 0);
}
}
}
......@@ -59,9 +59,20 @@ TEST_CASE("StimulusImpl_opencv_imread creation", "[StimulusImpl_opencv_imread][O
// Access the cv::Mat with the tensor
TensorImpl_opencv_* tImpl_opencv = dynamic_cast<TensorImpl_opencv_*>(tensor_load->getImpl().get());
auto mat_tensor = tImpl_opencv->data();
REQUIRE((tImpl_opencv->data().total() * tImpl_opencv->data().channels()) == (true_mat.total() * true_mat.channels()));
REQUIRE(cv::countNonZero(tImpl_opencv->data() != true_mat) == 0);
// Check the dimensions
REQUIRE((mat_tensor.total() * mat_tensor.channels()) == (true_mat.total() * true_mat.channels()));
// Split it in channels
std::vector<cv::Mat> channels_tensor;
cv::split(mat_tensor, channels_tensor);
REQUIRE(channels_tensor.size() == channels.size());
// Check the elements
for (size_t i = 0; i < channels_tensor.size(); ++i) {
REQUIRE(cv::countNonZero(channels_tensor[i] != channels[i]) == 0);
}
}
}
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