Reshape function problem
When I use the reshape function with ROI then I encounter the following error.
Mat cur_img = imread(fileList.fileNames[i],0);
Mat res_img = cur_img(Rect(0,0,100,100)).reshape(1,1);
Error :Image step is wrong
I made a clone of ROI image then the error is resolved.
Mat cur_img = imread(fileList.fileNames[i],0);
Mat res_img = cur_img(Rect(0,0,100,100)).clone().reshape(1,1);
What is the reason?
Edit:
I realize this topic that the reshape function in this step need to consecutive memory.My question is why the reshape function don't create new image when the Mat data is not consecutive memory and then it does not reshape it .This solution is better than facing the user with an error.
rois don't have consecutive memory. you can't reshape them (without the clone())