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 6074859
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:25:45+00:00 2026-05-23T10:25:45+00:00

I just want to try the openCV function — cvCornerHarris. Here is my c++

  • 0

I just want to try the openCV function — cvCornerHarris. Here is my c++ code:

//image file
    char imagePath[256] = "./images/lena512color.tiff";
    printf("%s\n", imagePath);

    IplImage* srcImg = cvLoadImage(imagePath, 1);
    if(NULL == srcImg){
        printf("Can not open image file(s).\n");
        return -1;
    }
    IplImage* srcImgGry = cvCreateImage(cvGetSize(srcImg), IPL_DEPTH_8U, 1);
    cvCvtColor(srcImg, srcImgGry, CV_RGB2GRAY);
    // Canny and Harris expect grayscale  (8-bit) input.
    // And output of harris image must be 32-bit float .
    IplImage* harrisImg = cvCreateImage(cvGetSize(srcImg), IPL_DEPTH_32F, 1);
    IplImage* cannyImg = cvCreateImage(cvGetSize(srcImg), IPL_DEPTH_8U, 1);

    //// Corner detection using Harris-corner
    cvCornerHarris(srcImgGry, harrisImg, 5, 5, 0.04);
    cvCanny(srcImgGry, cannyImg, 50, 100, 3);

    // (5)Display the result
    cvNamedWindow ("Img", CV_WINDOW_AUTOSIZE);
    cvShowImage ("Img", srcImgGry);
    cvNamedWindow ("Harris", CV_WINDOW_AUTOSIZE);
    cvShowImage ("Harris", harrisImg);
    cvNamedWindow ("Canny", CV_WINDOW_AUTOSIZE);
    cvShowImage ("Canny", cannyImg);
    cvWaitKey (0);

    cvDestroyWindow ("Harris");
    cvDestroyWindow ("Img");
    cvReleaseImage (&srcImg);
    cvReleaseImage (&srcImgGry);
    cvReleaseImage (&harrisImg);
    cvReleaseImage (&cannyImg);

I can get a expected output image of cvCanny (cannyImg) but the output image of cvCornerHarris (harrisImg)is an black image with nothing on it.
Please help to explain how to use this function cvCornerHarris. Thanks!

  • 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-05-23T10:25:46+00:00Added an answer on May 23, 2026 at 10:25 am

    It’s all about parameters! People tend to believe that there are magical parameters that will work for all types of images and scenarios. Unfortunately, this doesn’t happen in the real world.

    The parameters used to process one image may not produce the same level of results when applied to other type of image. Now, consider the following code:

    IplImage* colored = cvLoadImage("house.jpg", CV_LOAD_IMAGE_UNCHANGED);
    if (!colored)
    {
        printf("Can not open image file(s).\n");
        return -1;
    }
    
    IplImage* gray = cvCreateImage(cvGetSize(colored), IPL_DEPTH_8U, 1);
    cvCvtColor(colored, gray, CV_RGB2GRAY);
    
    IplImage* harris = cvCreateImage(cvGetSize(colored), IPL_DEPTH_32F, 1);
    cvCornerHarris(gray, harris, 3, 11, 0.07);
    
    cvNamedWindow("Harris", CV_WINDOW_AUTOSIZE);
    cvShowImage ("Harris", harris);
    

    As you can see below, these parameters produced a decent result (to my point of view). However, keep in mind that they won’t probably work for you. Bad parameters will produce a black image (i.e. will detect nothing) as you have observed on your tests.

    The answer is: take a look at the docs to see what those parameters mean and how they influence the result. Most importantly, play with them until they produce images that satisfy your needs.

    Input image:

    a_house
    (source: 123desenhosparacolorir.com)

    Output:

    harry's_house

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

Sidebar

Related Questions

I just want to learn something new here about my code. I have the
I try to edit ODT-documents programmaticly in PHP. In fact I just want to
Sorry for maybe this is stupid question, I just want download source code form
I just want to try a software which uses tomcat. I added JAVA_HOME to
When you just want to do a try-except without handling the exception, how do
I'm making an android app and since I've just started I want to try
Whenever I try to move a file it does not work and shows Image
Just want to know if there other optional wrapper framework available that generate client
Just want to know how to read an attribute of a parent node from
I just want an ASP.NET DropDownList with no selected item. Setting SelectedIndex to -1

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.