Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9145965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:38:38+00:00 2026-06-17T10:38:38+00:00

I am working on my project and I got a problem is that I

  • 0

I am working on my project and I got a problem is that I have no idea how to only detect the key points from a square area which had been detector before. Below is my demo and as so far, my code would detect key points both outside and inside square: https://www.youtube.com/watch?feature=player_embedded&v=3U8V6PhMnZ8

This is my code to find the square:

       const int threshold_level = 2;
    for (int l = 0; l < threshold_level; l++)
    {

        gray = gray0 >= (l+1) * 255 / threshold_level;

        // Find contours and store them in a list
        findContours(gray, contours, CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE);

        // Test contours
        vector<Point> approx;
        for (size_t i = 0; i < contours.size(); i++)
        {
                // approximate contour with accuracy proportional
                // to the contour perimeter
                approxPolyDP(Mat(contours[i]), approx, arcLength(Mat(contours[i]), true)*0.02, true);

                // Note: absolute value of an area is used because
                // area may be positive or negative - in accordance with the
                // contour orientation
                if (approx.size() == 4 &&
                        fabs(contourArea(Mat(approx))) > 3000 &&
                        isContourConvex(Mat(approx)))
                {
                        double maxCosine = 0;

                        for (int j = 2; j < 5; j++)
                        {
                                double cosine = fabs(angle(approx[j%4], approx[j-2], approx[j-1]));
                                maxCosine = MAX(maxCosine, cosine);
                        }

                        if (maxCosine < 0.3)
                                squares.push_back(approx);
                }
        }
    }

This is my code to draw the square and the corner points:

 const Point* p = &squares[i][0];
        int n = (int)squares[i].size();       
        Point p1 = squares[i][0];
        Point p2 = squares[i][1];
        Point p3 = squares[i][2];
        Point p4 = squares[i][3];
        cout<<"p1 is "<<p1<<" p2 is "<<p2<<" p3 is "<<p3<<" p4 is "<<p4<<endl;
        circle(image, squares[i][0], 3, Scalar(0,0,255), 5, 8, 0);
        circle(image, squares[i][1], 3, Scalar(0,255,255), 5, 8, 0);
        circle(image, squares[i][2], 3, Scalar(255,0,255), 5, 8, 0);
        circle(image, squares[i][3], 3, Scalar(255,255,0), 5, 8, 0);

        polylines(image, &p, &n, 1, true, Scalar(0,255,0), 3, CV_AA);

This is my code to detect key points:

    Mat gray_image;
    vector<KeyPoint> keyPoints; 
    cvtColor(image, gray_image, CV_BGR2GRAY); 
    FastFeatureDetector fast(60); 
    fast.detect(gray_image,keyPoints);  
    drawKeypoints(image, keyPoints,image, Scalar::all(255), DrawMatchesFlags::DRAW_OVER_OUTIMG); 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:38:39+00:00Added an answer on June 17, 2026 at 10:38 am

    You can crop the image using

    Rect r(left,top,width,height); // Part of the image we are interested in

    Mat roi(fullImage, r); // will create a reference to the rectangle r of the original image. Note that it is not a copy.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On a current project which I'm currently working, i have a symfony task that
I've got a django project working on a development server(ubuntu) that we have been
I installed TeamCity and got it working against my project. However, I have since
I am currently working on a project that implements Azure ACS. I got the
I've got some syntax in a project I'm working on that I'm not familiar
In the project I'm working on I have got a list List<Item> with objects
I've got a problem with git and my rails project. I have set up
It seems that I have a problem with Linux IO performance. Working with a
Working on a problem that requires a GA. I have all of that working
I have a project that I could sync with the svn server only at

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.