1

我想SurfFeatureDetector用来检测指定图片区域的关键点:

  1. Train_pic & Source_pic
  2. 使用 检测 Train_pic keypoint_1 SurfFeatureDetector
  3. SurfFeatureDetector使用指定区域检测 Source_pic keypoint_2 。
  4. 计算和匹配。

OpenCVSurfFeatureDetector如下。

void FeatureDetector::detect(const Mat& image, vector<KeyPoint>& keypoints, const Mat& mask=Mat())

mask -- 指定在哪里查找关键点的掩码(可选)。必须是感兴趣区域中具有非零值的 char 矩阵。

任何人都可以帮助解释如何mask=Mat()为 Source_pic 创建?

谢谢杰

4

1 回答 1

4

从技术上讲,您不必指定空矩阵来使用该detect函数,因为它是默认参数。

你可以detect这样调用:

Ptr<FeatureDetector> detector = FeatureDetector::create("SURF");
vector<KeyPoint> keyPoints;
detector->detect(anImage, keyPoints);

或者,通过显式创建空矩阵:

Ptr<FeatureDetector> detector = FeatureDetector::create("SURF");
vector<KeyPoint> keyPoints;
detector->detect(anImage, keyPoints, Mat());

如果你想在感兴趣的区域创建一个蒙版,你可以像这样创建一个:

假设Source_pic是类型CV_8UC3

Mat mask = Mat::zeros(Source_pic.size(), Source_pic.type());

// select a ROI
Mat roi(mask, Rect(10,10,100,100));

// fill the ROI with (255, 255, 255) (which is white in RGB space);
// the original image will be modified
roi = Scalar(255, 255, 255);

编辑:那里有一个复制意大利面错误。设置 的 ROI mask,然后将其传递给detect函数。

希望这能说明问题!

于 2012-03-29T00:58:05.193 回答