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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:18:26+00:00 2026-06-03T08:18:26+00:00

I’m having some trouble printing the values of the descriptor matrix obtained through the

  • 0

I’m having some trouble printing the values of the descriptor matrix obtained through the use of the ‘compute’ method of any opencv descriptor extractor. I want to print the descriptor of a feature to a file one by one, but always when I access some element of the descriptor matrix with ‘at’, I receive a different value for that element. The following is a ‘for’ loop I used to test the output value of the descriptor matrix when using ‘at’:

for(int i=0; i<nF; i++){

    if(lpx != keypoints[i].pt.x && lpy != keypoints[i].pt.y){
        usedFeatures++;
        cerr << descriptors.row(i) << endl << endl; // printing row of descriptor matrix
        fileS << keypoints[i].pt.y << " " << keypoints[i].pt.x << " ";
        fileS << keypoints[i].size << " " << keypoints[i].angle << endl;

        if(i == nF - 2){
            //printing subvector of descriptor matrix made of the element at row i and col 0
            cerr << "get row i, col 0 " << descriptors.row(i).col(0) << endl;

            //same as before just inverting the order of access
            cerr << "get col 0, row i: " << descriptors.col(0).row(i) << endl;


            //printing the value of the element with 'at'
            cerr << (int)descriptors.at<uchar>(i, 0);

            //creating a new int and giving it the value of element (i, 0) of descriptor matrix. Should be the same
            //value shown on the subvector before
            int test = descriptors.at<uchar>(i, 0);

            //printing value of element
            cerr << "i, 0: " << test << endl;
        }

The second ‘if’ is a test ‘if’ I made to see the values printed when accessing the elements of the descriptors. Now, printed by the

cerr << descriptors.row(i) << endl << endl;

at the nF – 2 iteraction, I have the following result:

[20, 11, 0, 18, 51, 3, 0, 3, 133, 50, 0, 0, 0, 0, 0, 11, 133, 18, 0, 0, 0, 0, 0, 3,
119, 2, 0, 0, 0, 0, 0, 2, 19, 5, 0, 4, 55, 27, 1, 1, 133, 25, 0, 1, 4, 1, 0, 22, 133,
18, 0, 0, 0, 0, 0, 14, 131, 13, 1, 0, 0, 0, 0, 1, 12, 1, 0, 1, 56, 133, 25, 13, 133,
14, 0, 0, 3, 8, 20, 80, 133, 38, 0, 0, 0, 0, 0, 51, 106, 11, 1, 0, 0, 0, 0, 23, 0, 0,
0, 0, 19, 126, 70, 11, 23, 0, 0, 0, 0, 9, 83, 133, 53, 1, 0, 0, 0, 0, 2, 133, 26, 
3, 2, 0, 0, 0, 0, 28]

And as expected, the first two prints inside the second ‘if’:

cerr << "get row i, col 0 " << descriptors.row(i).col(0) << endl;

cerr << "get col 0, row i: " << descriptors.col(0).row(i) << endl;

give me [20]

But the other two prints

cerr << (int)descriptors.at<uchar>(i, 0);

and

int test = descriptors.at<uchar>(i, 0);
cerr << "i, 0: " << test << endl;

give me 0 instead of 20. The complete result I had for line nF-2 I showed before, when accessing the elements with ‘at’ and printing them was:

 0 0 160 65 0 0 48 65 0 0 0 0 0 0 144 65 0 0 76 66
 0 0 64 64 0 0 0 0 0 0 64 64 0 0 5 67 0 0 72 66
 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 0 0 48 65 0 0 5 67 0 0 144 65 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 0 0 0 0 0 0 0 64 64 0 0 238 66
 0 0 0 64 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
 0 0 0 0 0 0 0 64

Which is completely different from what I was expecting. I’ve tried a lot of things already: casting with float, double, unsigned int instead of only int, and assigning to variables of those types as well; converting the matrix before printing it, copying the matrix then converting, creating the descriptors matrix with a different type…but none of them worked. I suspect it has something to do with the type of the descriptors matrix, although I’m almost sure it has the uchar type (I checked with elemSize)

Thanks in advance, and sorry for my english and the size of the question.

  • 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-03T08:18:28+00:00Added an answer on June 3, 2026 at 8:18 am

    Found the answer. It was indeed a type problem. The type of descriptor matrix returned by isn’t uchar like I thought, it is actually float. Getting the value with

    (float)descriptors.at<float>(i, 0);
    

    gives me the right value. Funny thing is I could swear I tried it for float before, and it didn’t work. I must’ve tried it only for int, double and unsigned int.

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm having trouble keeping the paragraph square between the quote marks. In firefox the
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka

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.