求大神把以下代码转为ios类型代码
privatestringSurfFeatureDetect(){//获取参数boolgetDescriptors=cbSurfGetDescriptors.Checke...
privatestring SurfFeatureDetect()
{
//获取参数
bool getDescriptors = cbSurfGetDescriptors.Checked;
MCvSURFParams surfParam =new MCvSURFParams();
surfParam.extended=rbSurfBasicDescriptor.Checked ?0 : 1;
surfParam.hessianThreshold=double.Parse(txtSurfHessianThreshold.Text);
surfParam.nOctaves=int.Parse(txtSurfNumberOfOctaves.Text);
surfParam.nOctaveLayers=int.Parse(txtSurfNumberOfOctaveLayers.Text);
//计算
SURFFeature[] features =null;
MKeyPoint[] keyPoints =null;
Stopwatch sw =new Stopwatch();
sw.Start();
if (getDescriptors)
features = imageSourceGrayscale.ExtractSURF(ref surfParam);
else
keyPoints = surfParam.DetectKeyPoints(imageSourceGrayscale, null);
sw.Stop();
//显示
bool showDetail = cbSurfShowDetail.Checked;
Image<Bgr, Byte> imageResult = imageSourceGrayscale.Convert<Bgr, Byte>();
StringBuilder sbResult =new StringBuilder();
int idx =0;
if (getDescriptors)
{
foreach (SURFFeature feature in features)
{
imageResult.Draw(new CircleF(feature.Point.pt, 5), new Bgr(255d, 0d, 0d), 2);
if (showDetail)
{
sbResult.AppendFormat("第{0}点(坐标:{1},尺寸:{2},方向:{3}°,hessian值:{4},拉普拉斯标志:{5},描述:[",
idx, feature.Point.pt, feature.Point.size, feature.Point.dir, feature.Point.hessian, feature.Point.laplacian);
foreach (float d in feature.Descriptor)
sbResult.AppendFormat("{0},", d);
sbResult.Append("]),");
}
idx++;
}
}
else
{
foreach (MKeyPoint keypoint in keyPoints)
{
imageResult.Draw(new CircleF(keypoint.Point, 5), new Bgr(255d, 0d, 0d), 2);
if (showDetail)
sbResult.AppendFormat("第{0}点(坐标:{1},尺寸:{2},方向:{3}°,响应:{4},octave:{5}),",
idx, keypoint.Point, keypoint.Size, keypoint.Angle, keypoint.Response, keypoint.Octave);
idx++;
}
}
pbResult.Image = imageResult.Bitmap;
//释放资源
imageResult.Dispose();
//返回
returnstring.Format("·SURF角点,用时{0:F05}毫秒,参数(描述:{1},hessian阀值:{2},octave数目:{3},每个octave的层数:{4},检测到{5}个角点\r\n{6}",
sw.Elapsed.TotalMilliseconds, getDescriptors ? (surfParam.extended ==0?"获取基本描述" : "获取扩展描述") : "不获取描述", surfParam.hessianThreshold,
surfParam.nOctaves, surfParam.nOctaveLayers, getDescriptors ? features.Length : keyPoints.Length, showDetail ? sbResult.ToString() +"\r\n" : "");
} 展开
{
//获取参数
bool getDescriptors = cbSurfGetDescriptors.Checked;
MCvSURFParams surfParam =new MCvSURFParams();
surfParam.extended=rbSurfBasicDescriptor.Checked ?0 : 1;
surfParam.hessianThreshold=double.Parse(txtSurfHessianThreshold.Text);
surfParam.nOctaves=int.Parse(txtSurfNumberOfOctaves.Text);
surfParam.nOctaveLayers=int.Parse(txtSurfNumberOfOctaveLayers.Text);
//计算
SURFFeature[] features =null;
MKeyPoint[] keyPoints =null;
Stopwatch sw =new Stopwatch();
sw.Start();
if (getDescriptors)
features = imageSourceGrayscale.ExtractSURF(ref surfParam);
else
keyPoints = surfParam.DetectKeyPoints(imageSourceGrayscale, null);
sw.Stop();
//显示
bool showDetail = cbSurfShowDetail.Checked;
Image<Bgr, Byte> imageResult = imageSourceGrayscale.Convert<Bgr, Byte>();
StringBuilder sbResult =new StringBuilder();
int idx =0;
if (getDescriptors)
{
foreach (SURFFeature feature in features)
{
imageResult.Draw(new CircleF(feature.Point.pt, 5), new Bgr(255d, 0d, 0d), 2);
if (showDetail)
{
sbResult.AppendFormat("第{0}点(坐标:{1},尺寸:{2},方向:{3}°,hessian值:{4},拉普拉斯标志:{5},描述:[",
idx, feature.Point.pt, feature.Point.size, feature.Point.dir, feature.Point.hessian, feature.Point.laplacian);
foreach (float d in feature.Descriptor)
sbResult.AppendFormat("{0},", d);
sbResult.Append("]),");
}
idx++;
}
}
else
{
foreach (MKeyPoint keypoint in keyPoints)
{
imageResult.Draw(new CircleF(keypoint.Point, 5), new Bgr(255d, 0d, 0d), 2);
if (showDetail)
sbResult.AppendFormat("第{0}点(坐标:{1},尺寸:{2},方向:{3}°,响应:{4},octave:{5}),",
idx, keypoint.Point, keypoint.Size, keypoint.Angle, keypoint.Response, keypoint.Octave);
idx++;
}
}
pbResult.Image = imageResult.Bitmap;
//释放资源
imageResult.Dispose();
//返回
returnstring.Format("·SURF角点,用时{0:F05}毫秒,参数(描述:{1},hessian阀值:{2},octave数目:{3},每个octave的层数:{4},检测到{5}个角点\r\n{6}",
sw.Elapsed.TotalMilliseconds, getDescriptors ? (surfParam.extended ==0?"获取基本描述" : "获取扩展描述") : "不获取描述", surfParam.hessianThreshold,
surfParam.nOctaves, surfParam.nOctaveLayers, getDescriptors ? features.Length : keyPoints.Length, showDetail ? sbResult.ToString() +"\r\n" : "");
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询