I have a cv::Mat which is CV_32S type (also tried CV_8SC3), it stores both positive and negative values.
When convert it to tensor, the values are messed up:
cout << in_img << endl;
auto tensor_image = torch::from_blob(in_img.data, {1, in_img.rows, in_img.cols, 3}, at::kByte);
The in_img has negative values, while after print out tensor_image, the values were all totally different than in_img. It somehow seems to be scaled to 255 range
the negative values are gone. how do I keep the negative values? When I do this:
auto tensor_image = torch::from_blob(in_img.data, {1, in_img.rows, in_img.cols, 3}, at::kFloat);
and pass this to the forward of the model, I get seg fault
but, when I originally do:
auto tensor_image = torch::from_blob(in_img.data, {1, in_img.rows, in_img.cols, 3}, at::kByte);
tensor_image = tensor_image.toType(at::kFloat);
it works as expected… which is perplexing to me :((