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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T19:58:51+00:00 2026-06-02T19:58:51+00:00

How can I convert a cv::Mat to a gray scale? I am trying to

  • 0

How can I convert a cv::Mat to a gray scale?

I am trying to run drawKeyPoints func from opencv, however I have been getting an Assertion Filed error. My guess is that it needs to receive a gray scale image rather than a color image in the parameter.

void SurfDetector(cv::Mat img){
vector<cv::KeyPoint> keypoints;
cv::Mat featureImage;

cv::drawKeypoints(img, keypoints, featureImage, cv::Scalar(255,255,255) ,cv::DrawMatchesFlags::DRAW_RICH_KEYPOINTS);

cv::namedWindow("Picture");
cv::imshow("Picture", featureImage);

}

  • 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-02T19:58:53+00:00Added an answer on June 2, 2026 at 7:58 pm

    Using the C++ API, the function name has slightly changed and it writes now:

    #include <opencv2/imgproc/imgproc.hpp>
    
    cv::Mat greyMat, colorMat;
    cv::cvtColor(colorMat, greyMat, CV_BGR2GRAY);
    

    The main difficulties are that the function is in the imgproc module (not in the core), and by default cv::Mat are in the Blue Green Red (BGR) order instead of the more common RGB.

    OpenCV 3

    Starting with OpenCV 3.0, there is yet another convention.
    Conversion codes are embedded in the namespace cv:: and are prefixed with COLOR.
    So, the example becomes then:

    #include <opencv2/imgproc/imgproc.hpp>
    
    cv::Mat greyMat, colorMat;
    cv::cvtColor(colorMat, greyMat, cv::COLOR_BGR2GRAY);
    

    As far as I have seen, the included file path hasn’t changed (this is not a typo).

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

Sidebar

Related Questions

I was wondering how can convert CGcolorRef to UIColor ? I have created a
If I do the following I can convert from a time_struct object to a
How can I convert an 8 bit mat to a 32 bit mat to
I'm trying to convert this SQL into a Linq2SQL query, however, I'm at the
How can I convert a number contained in a string from any base to
Is there can convert the stuff read from input port to some specific type
I trying to convert an old exercise i made in matlab to OpenCV. Code
I'm trying to capture an image from the camera preview and convert it to
I can convert html files to pdfs with iTextSharp using code from Kyle in
I am trying to detect solid circles using opencv. The example code from the

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.