Ask Your Question
0

understanding the letter recognition sample of OpenCV

asked 2016-09-29 10:19:31 -0500

BenNG gravatar image

updated 2016-09-30 06:15:32 -0500

Eduardo gravatar image

Hi all,

I try to understand the letter recognition sample of OpenCV and i'm stuck on this line

        int cls_label = responses.at<int>(i) - 'A';

Can somebody explain what this line means ? more precisely what this 'A' is doing here ?

Thank you !

edit retag flag offensive close merge delete

Comments

Ok. I think that the image samples are only 'A'

BenNG gravatar imageBenNG ( 2016-09-29 10:35:31 -0500 )edit

2 answers

Sort by ยป oldest newest most voted
2

answered 2016-09-30 05:58:17 -0500

berak gravatar image

updated 2016-09-30 05:59:06 -0500

data in that example is read from this csv file , which has letters for labels in the 1st column.

subtracting 'A' from those makes 0-based labels again, since:

'A' - 'A' = 0, 'B' - 'A' = 1, 'C' - 'A' = 2, etc.

edit flag offensive delete link more
1

answered 2016-09-29 11:09:41 -0500

'A' means ascii code of A as integer. output of the code below is 35 ( 100 - 65 )

   int a = 100;
   a = a - 'A';
   std::cout << a;
edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-09-29 10:19:31 -0500

Seen: 137 times

Last updated: Sep 30 '16