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

Update with Tensor constructor from dimensions in aidge_core

parent 0d83f3d4
No related branches found
No related tags found
1 merge request!10Update backend_opencv with modifications from aidge_core
Pipeline #42953 passed
......@@ -16,6 +16,8 @@
#include <memory>
#include <tuple>
#include <vector>
#include <cstring>
#include <string>
#include "aidge/data/Data.hpp"
#include "aidge/data/Tensor.hpp"
......
......@@ -68,9 +68,11 @@ std::shared_ptr<Aidge::Tensor> Aidge::tensorOpencv(cv::Mat mat) {
Aidge::DataType type;
type = CVtoAidge(mat.depth());
// Create tensor from the dims of the Cv::Mat
std::shared_ptr<Tensor> tensor = std::make_shared<Tensor>(matDims,type);
std::shared_ptr<Tensor> tensor = std::make_shared<Tensor>(matDims);
// Set beackend opencv
tensor->setBackend("opencv");
// Set datatype
tensor->setDataType(type);
// Cast the tensorImpl to access setCvMat function
TensorImpl_opencv_* tImpl_opencv = dynamic_cast<TensorImpl_opencv_*>(tensor->getImpl().get());
......@@ -94,7 +96,7 @@ void Aidge::convert(const cv::Mat& mat, void* data, std::size_t offset)
std::shared_ptr<Aidge::Tensor> Aidge::convertCpu(std::shared_ptr<Aidge::Tensor> tensorOpencv){
// Assert the tensorOpencv is backend Opencv
assert(std::strcmp(tensorOpencv->getImpl()->backend(), "opencv") == 0 && "Cannot convert tensor backend from opencv to cpu : tensor is not backend opencv.");
assert(std::strcmp(tensorOpencv->getImpl()->backend().c_str(), "opencv") == 0 && "Cannot convert tensor backend from opencv to cpu : tensor is not backend opencv.");
// Create a tensor backend cpu from the dimensions of the tensor backend opencv
std::shared_ptr<Aidge::Tensor> tensorCpu = std::make_shared<Aidge::Tensor>(tensorOpencv->dims());
......
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