The problem is in int type of vector elements, they shuld be unsigned char.
But when you print it use cout << (int)your_value << endl;
문제
I want to save my grayscale image of type Mat
into a list of vectors. They greyscale image contains values such as 110
, 123
, 150
, etc... and when I use my code to transfer the data into a list of vectors and after I have transfered the data, I print the items in the list of vectors and they are values such as -155552323
or 75694920
. Where have my nice 110
, 123
, 150
from before gone??
cv::Mat grayscaleFrame;
cv::Mat image;
image = cv::imread(fullPath);
cvtColor(image, grayscaleFrame, CV_BGR2GRAY);
equalizeHist(grayscaleFrame, grayscaleFrame);
cout << grayscaleFrame << endl;
vector<int> **vectorList = new vector<int>*[grayscaleFrame.rows];
for(size_t i=0; i<grayscaleFrame.rows;i++)
{
int *p = grayscaleFrame.ptr<int>(i); // pointer to row 0
std::vector<int> row(p, p+grayscaleFrame.cols);
vectorList[i]=&row;
for(int a =0; a<vectorList[i]->size();a++)
{
cout << vectorList[i]->at(a) << endl;
}
}
If my mistake is to use &row
then how can I accomplish this without addressing the address, because when I remove the &
I get the error: "No suitable conversion function from ...."
해결책
The problem is in int type of vector elements, they shuld be unsigned char.
But when you print it use cout << (int)your_value << endl;