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

Update colorFlag of cv::imread to UNCHANGED and fix tests on cv::Mat size.

parent b227ffee
No related branches found
No related tags found
2 merge requests!10Update backend_opencv with modifications from aidge_core,!4Change tensorimpl opencv `future_std::span<cv::Mat>` to `cv::Mat`
Pipeline #38933 failed
......@@ -28,12 +28,12 @@ class StimulusImpl_opencv_imread : public StimulusImpl {
private:
/// Stimulus data path
const std::string mDataPath;
const int mColorFlag;
const int mReadMode;
public:
StimulusImpl_opencv_imread(const std::string& dataPath="", std::int32_t colorFlag=cv::IMREAD_COLOR)
StimulusImpl_opencv_imread(const std::string& dataPath="", int readMode=cv::IMREAD_UNCHANGED)
: mDataPath(dataPath),
mColorFlag(colorFlag)
mReadMode(readMode)
{
// ctor
}
......
......@@ -23,7 +23,7 @@
Aidge::StimulusImpl_opencv_imread::~StimulusImpl_opencv_imread() noexcept = default;
std::shared_ptr<Aidge::Tensor> Aidge::StimulusImpl_opencv_imread::load() const {
cv::Mat cvImg = cv::imread(mDataPath, mColorFlag);
cv::Mat cvImg = cv::imread(mDataPath, mReadMode);
if (cvImg.empty()) {
throw std::runtime_error("Could not open images file: " + mDataPath);
}
......
......@@ -39,7 +39,7 @@ 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());
REQUIRE(tImpl_opencv->data().size() == true_mat.size());
REQUIRE((tImpl_opencv->data().total() * tImpl_opencv->data().channels()) == (true_mat.total() * true_mat.channels()));
REQUIRE(cv::countNonZero(tImpl_opencv->data() != true_mat) == 0);
......@@ -50,7 +50,7 @@ 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());
REQUIRE(tImpl_opencv_2->data().size() == true_mat.size());
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);
}
......
......@@ -38,7 +38,7 @@ 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());
REQUIRE(tImpl_opencv->data().size() == true_mat.size());
REQUIRE((tImpl_opencv->data().total() * tImpl_opencv->data().channels()) == (true_mat.total() * true_mat.channels()));
REQUIRE(cv::countNonZero(tImpl_opencv->data() != true_mat) == 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