#include "aidge/backend/opencv/stimuli/StimuliImpl_opencv_imread.hpp" std::shared_ptr<Aidge::Tensor> Aidge::StimuliImpl_opencv_imread::load() { cv::Mat cv_img = cv::imread(mDataPath, mColorFlag); if (cv_img.empty()) { throw std::runtime_error("Could not open images file: " + mDataPath); } // Get Mat dims std::vector<DimSize_t> matDims = std::vector<DimSize_t>({static_cast<DimSize_t>(cv_img.cols), static_cast<DimSize_t>(cv_img.rows), static_cast<DimSize_t>(cv_img.channels())}); // Create tensor from the dims of the Cv::Mat std::shared_ptr<Tensor> img = std::make_shared<Tensor>(matDims); // Set beackend opencv img->setBackend("opencv"); // Set Data Type img->setDataType(DataType::UInt8); // Cast the tensorImpl to access setCvMat function TensorImpl_opencv_* tImpl_opencv = dynamic_cast<TensorImpl_opencv_*>(img->getImpl().get()); tImpl_opencv->setCvMat(cv_img); return img; }