Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Here's what I would do:

  1. Create a new black image (CV_8U) img
  2. For each matched keypoint, draw a white pixel (where kp is the list of your matched keypoints)
  3. Run a box filter on img with the size of your rectangle
  4. Detect the coordinates of the maximum of the image, and draw a rectangle around it.

Here's the code (untested, so might contain bugs):

    Mat img=zeros(rows,cols,CV_8U);
    for(size_t i=0;i<kp.size();i++)
        img.at<uchar>(kp[i].pt)=255;
    Mat filtimg;
    boxFilter(img,filtimg,Size(100,100),Point(0,0),false);
    Point min_loc, max_loc;double min,max;
    minMaxLoc(your_mat, &min, &max, &min_loc, &max_loc);
    rectangle(original,Rect(max.x,max.y,100,100),Scalar(0,0,255);

Here's what I would do:

  1. Create a new black image (CV_8U) img
  2. For each matched keypoint, draw a white pixel (where kp is the list of your matched keypoints)
  3. Run a box filter on img with the size of your rectanglerectangle (this will count the active pixel in the area)
  4. Detect the coordinates of the maximum of the image, and draw a rectangle around it.

Here's the code (untested, so might contain bugs):

    Mat img=zeros(rows,cols,CV_8U);
    for(size_t i=0;i<kp.size();i++)
        img.at<uchar>(kp[i].pt)=255;
    Mat filtimg;
    boxFilter(img,filtimg,Size(100,100),Point(0,0),false);
    Point min_loc, max_loc;double min,max;
    minMaxLoc(your_mat, &min, &max, &min_loc, &max_loc);
    rectangle(original,Rect(max.x,max.y,100,100),Scalar(0,0,255);

Here's what I would do:

  1. Create a new black image (CV_8U) img
  2. For each matched keypoint, draw a white pixel (where kp is the list of your matched keypoints)
  3. Run a box filter on img with the size of your rectangle (this will count the active pixel in the area)
  4. Detect the coordinates of the maximum of the image, and draw a rectangle around it.

Here's the code (untested, so might contain bugs):

    Mat img=zeros(rows,cols,CV_8U);
    for(size_t i=0;i<kp.size();i++)
        img.at<uchar>(kp[i].pt)=255;
    Mat filtimg;
    boxFilter(img,filtimg,Size(100,100),Point(0,0),false);
    Point min_loc, max_loc;double min,max;
    minMaxLoc(your_mat, minMaxLoc(filtimg, &min, &max, &min_loc, &max_loc);
    rectangle(original,Rect(max.x,max.y,100,100),Scalar(0,0,255);

Here's what I would do:

  1. Create a new black image (CV_8U) img
  2. For each matched keypoint, draw a white pixel (where kp is the list of your matched keypoints)
  3. Run a box filter on img with the size of your rectangle (this will count the active pixel in the area)
  4. Detect the coordinates of the maximum of the image, and draw a rectangle around it.

Here's the code (untested, so might contain bugs):

    Mat img=zeros(rows,cols,CV_8U);
    for(size_t i=0;i<kp.size();i++)
        img.at<uchar>(kp[i].pt)=255;
    Mat filtimg;
    boxFilter(img,filtimg,Size(100,100),Point(0,0),false);
    Point min_loc, max_loc;double min,max;
    minMaxLoc(filtimg, &min, &max, &min_loc, &max_loc);
    rectangle(original,Rect(max.x,max.y,100,100),Scalar(0,0,255);
rectangle(original,Rect(max_loc.x,max_loc.y,100,100),Scalar(0,0,255);

Here's what I would do:

  1. Create a new black image (CV_8U) img
  2. For each matched keypoint, draw a white pixel (where kp is the list of your matched keypoints)
  3. Run a box filter on img with the size of your rectangle (this will count the active pixel in the area)
  4. Detect the coordinates of the maximum of the image, and draw a rectangle around it.

Here's the code (untested, so might contain bugs):

    Mat img=zeros(rows,cols,CV_8U);
img=zeros(original.size(),CV_8U);
    for(size_t i=0;i<kp.size();i++)
        img.at<uchar>(kp[i].pt)=255;
    Mat filtimg;
    boxFilter(img,filtimg,Size(100,100),Point(0,0),false);
    Point min_loc, max_loc;double min,max;
    minMaxLoc(filtimg, &min, &max, &min_loc, &max_loc);
    rectangle(original,Rect(max_loc.x,max_loc.y,100,100),Scalar(0,0,255);