我正在使用霍夫圆变换(https://docs.opencv.org/2.4/doc/tutorials/imgproc/imgtrans/hough_circle/hough_circle.html)在UVC视频供稿中查找单个圆。 然后,我使用此处Cropping circle from image using opencv python所述的方法创建圆形的蒙版。
我现在正在尝试缩放视频,以使圆圈在视图中居中,圆圈的顶部和底部触摸视图的顶部和底部。
我曾经尝试过使用调整大小功能,但是我一直在努力使宽高比正常工作,否则最终会出现怪异的效果,即图像被复制/镜像/一分为二。
cv::cvtColor(frame,src,cv::COLOR_RGBA2GRAY,1);
cv::GaussianBlur( src,cv::Size(9,9),2,2 );
std::vector<cv::Vec3f> circles;
cv::HoughCircles( src,circles,CV_HOUGH_GRADIENT,1,10000,50,40,100,0 );
center = cv::Point(cvRound(circles[0][0]),cvRound(circles[0][1]));
int radius = cvRound(circles[0][2]);
//Draw black filled rectangle
rectangle(result,cv::Point(0,0),cv::Point(640,480),cv::Scalar(0,255),-1); //-1 means filled
// Draw the circle center
circle( frame,center,3,255,-1,8,0 );
// Draw tge circle outline
circle( frame,radius,0 );
//Create the mask
cv::Mat1b mask(frame.size(),uchar(0));
circle( mask,cv::Scalar(255,0 ); //-1 means filled
//Copy the frame to the result using the mask
frame.copyTo( result,mask );
//Send result frame back to java
callJavaCallback(env,result,last_queued_time_ms);
如何自动缩放视频并使其在圈子中居中?