I am trying to resize a Mat on the fly which I am overlaying on to another image. The image is stored on the IOS device in the Assets.xcassets folder and I am passing it to my function then using UIImageToMat to convert it to a cv::Mat.
As a test I want to be able to resize it to make it half the size, but I am running into problems.
When I tried overlay->resize(overlay->rows/2);
The result overlay just shows the top half of what it was.
Then when I tried cvResize(overlay, destPointer, CV_INTER_LINEAR);
I get the error:
error: (-5) Unknown array type in function cvarrToMat
C++:
cv::Point center;
int radius;
double NewRadius;
cv::Mat originphoto;
UIImageToMat(overlay, originphoto, 1);
cv::Mat *overlay = &originphoto;
center.x = cv::saturate_cast<int>((r->x + r->width*0.5) - overlay->size().width*0.5);
center.y = cv::saturate_cast<int>((r->y + r->height*0.5 - overlay->size().height*0.5));
radius = cv::saturate_cast<int>((r->width + r->height) / 2);
printf("%d",radius);
NewRadius = radius/1;
cv::Mat destination(overlay->rows/2, overlay->cols/2, 1);
cv::Mat *destPointer = &destination;
cvResize(overlay, destPointer, CV_INTER_LINEAR);
overlay = destPointer;
Any help here would be greatly appreciated, still very new to image processing and not sure how to deal with these cv::Mats since they are matrices.
Got it working using:
cv::resize(*overlay, destination, cv::Size(), 0.5, 0.5);
If anyone else runs into this problem, there you go :)