OpenCV IOS 调整垫子大小
OpenCV IOS Resize a Mat
我正在尝试动态调整要叠加到另一张图片上的垫子的大小。图像存储在 Assets.xcassets 文件夹中的 IOS 设备上,我将它传递给我的函数,然后使用 UIImageToMat 将其转换为 cv::Mat.
作为测试,我希望能够调整它的大小以使其大小减半,但我 运行 遇到了问题。
当我尝试时 overlay->resize(overlay->rows/2);
结果叠加层只显示了它的上半部分。
然后当我尝试 cvResize(overlay, destPointer, CV_INTER_LINEAR);
我收到错误:
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;
如有任何帮助,我们将不胜感激,图像处理还很陌生,不确定如何处理这些 cv::Mat,因为它们是矩阵。
使用以下方法使其工作:
cv::resize(*overlay, destination, cv::Size(), 0.5, 0.5);
如果其他人遇到了这个问题,那你就去:)
我正在尝试动态调整要叠加到另一张图片上的垫子的大小。图像存储在 Assets.xcassets 文件夹中的 IOS 设备上,我将它传递给我的函数,然后使用 UIImageToMat 将其转换为 cv::Mat.
作为测试,我希望能够调整它的大小以使其大小减半,但我 运行 遇到了问题。
当我尝试时 overlay->resize(overlay->rows/2);
结果叠加层只显示了它的上半部分。
然后当我尝试 cvResize(overlay, destPointer, CV_INTER_LINEAR);
我收到错误:
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;
如有任何帮助,我们将不胜感激,图像处理还很陌生,不确定如何处理这些 cv::Mat,因为它们是矩阵。
使用以下方法使其工作:
cv::resize(*overlay, destination, cv::Size(), 0.5, 0.5);
如果其他人遇到了这个问题,那你就去:)