如何将CGPoint转换为opencv point(cv :: Point)

时间:2017-01-31 06:05:06

标签: ios opencv

我遇到了问题, 我有一个UIView,它将平移UIImageView, 我想将此点的位置转换为opencv mat中相同位置的位置。

这样我就可以缩放那个特定的位置。

我当前的函数接收UIImage和我必须缩放的CGPoint。我在这里想念什么吗?

- (UIImage*) getZoomedImage:(UIImage *)img :(CGPoint) pt :(float) alpha{

cv::Mat backGround = [self cvMatFromUIImage:img];

cv::Point p = cv::Point(pt.x,pt.y);

int r=backGround.rows/40;
int radius = r * 1.5;

float rtXY=(float)backGround.rows/backGround.cols;//h/w



int WW=2*radius;
int HH=2*radius;
cv::Rect lip_rect=cv::Rect(p.x-WW/2,p.y-HH/2,WW,HH);

fixedRectwithImage(lip_rect, backGround);

cv::Mat min_Image=backGround(lip_rect);


cv::Mat image_w;

float fect=2;

resize(min_Image,image_w,cv::Size(min_Image.cols*fect,min_Image.rows*fect));


cv::Point leave_p=cv::Point(p.x,p.y-70);


//circle(backGround, leave_p, image_w.rows/2, Scalar(255, 255, 255),radius/6);



int HH1=image_w.rows;
int WW1=image_w.cols;

cv::Rect large_rect=cv::Rect(leave_p.x-WW1/2,leave_p.y-HH1/2,WW1, HH1);

fixedRectwithImage(large_rect, backGround);




cv::Mat small_lip;



cv::Mat src=backGround(large_rect);

cv::Mat src_Mask1(image_w.rows,image_w.cols, CV_8UC3, 

cv::Scalar(0,0,0));
ellipse(src_Mask1, cv::Point(image_w.cols/2,image_w.rows/2), cv::Size(image_w.cols/2.1,image_w.rows/2.1), 0, 0, 360, Scalar(255, 255, 255), -1, LINE_8);
    small_lip=mixImages(src,src_Mask1,image_w,alpha);
circle(small_lip, cv::Point(image_w.cols/2,image_w.rows/2), image_w.rows/2.1, Scalar(100, 100, 100),radius/8,LINE_8);
    cv::Mat dstROI=backGround(large_rect);
    return [self UIImageFromCVMat:small_lip];

}

0 个答案:

没有答案