Closed nische closed 1 year ago
Hi, After I studied my old university documents i found a perfomant solution:
First I create the tensor in the shape of rgb per layer. After that i "reorganize" the Tensor by Transpose it with the vector {1,2,0}.
int Classifier::Predigt(uint8_t* red, uint8_t* green, uint8_t* blue, int width, int height)
{
int n = (height*width);
std::vector<uint8_t> data;
data.reserve(3*n);
data.insert(data.end(), red, red + n);
data.insert(data.end(), green, green + n);
data.insert(data.end(), blue, blue + n);
auto img_tensor = cppflow::tensor(data, {3, height, width});
img_tensor = cppflow::transpose(img_tensor, cppflow::tensor{1,2,0});
.....
}
Hi, I use cppflow to Predict Images with a Classifier. This works fine with my OpenCV BGR Images. In my new Usecase i get three Pointers (to every Channel of the RGB). In the first Steps i push the data together in one vector and create the tensor. This work but is very slow and not usefull for my Project.
Is it possible to create a tensor from each Channel and stick them together in one tensor?
Here is my function to predict with the single rgb pointer:
This is the slow vector solution:
Maybe something like this is possible or did everybody know some magic tensor tricks to reorganize the tensor after it created with the vector from rrrr...rrrrgggggg....gggggbbbbbb.....bbbbbb type?
BR, Nische