Topic locked

help getting coordinates textreco

March 15, 2014 - 6:04am #1

I am using the wordreco sample android. 

I need to get specific coordinates (x,y) of an area within a text's bounding box where there is no text.

I had a look at 

QCAR::Word::getMask (   ) const

which shows areas coverd by text but i cannot get the coordinates to use for further processing. Please help me on how to obtain them.

 

Thank you,

B.B

help getting coordinates textreco

March 26, 2014 - 1:42am #11

Great :-)

help getting coordinates textreco

March 26, 2014 - 1:14am #10

That works okay :)

help getting coordinates textreco

March 26, 2014 - 12:18am #9
 
try this:
const unsigned char *pixels = (const unsigned char *)mask->getPixels();
 

help getting coordinates textreco

March 25, 2014 - 11:22pm #8

I modified the code and i get an error at his assignment:

 
    const unsigned char *pixels = mask->getPixels();
 
It says invalid conversion from 'void const*' to 'unsigned char const'

help getting coordinates textreco

March 25, 2014 - 1:24pm #7
Try adjusting the code as follows:
const QCAR::Image *mask = word.getMask();

int num_rows = mask->getBufferHeight();
int num_cols = mask->getBufferWidth();

const unsigned char *pixels = mask->getPixels();

int xCoord = 0;
int yCoord = 0;

for (int row = 0; row < num_rows; ++row)
{
    for (int column = 0; column < num_cols; ++column)
    {
        unsigned char byte = pixels[row*num_cols + column]; // Get byte from mask
        if (byte == 255)
        {
            xCoord = row;
            yCoord = column;

            break;
        }
    }
}

 

 

help getting coordinates textreco

March 25, 2014 - 10:27am #6
const QCAR::Image *p_bitmask = word.getMask();
    const unsigned bytes_per_row = 5U; // You need to change this according to the bitmask size.
    const unsigned row_quantity = 10;   // Change per bitmask dimensions.
    for (unsigned int row = 0; row < row_quantity; ++row)
    {
       for (unsigned int column = 0; column < bytes_per_row; ++column)
       {
           uint8_t byte = *p_bitmask++; // Get byte from bitmask
           if (byte == 255)
           {
                   xCoord = row;
                       yCoord = column;
 
                       break;
           }
       }
    }
 
Currently i am trying this out in c++but i get an error could i get any further help?

help getting coordinates textreco

March 25, 2014 - 5:28am #5

Could i get  more help on the maths as stated? How do i get the coordinates of the area with pixel value 255 from the bitmask and convert the coordinates to match those of the original image? (im assuming the bitmask size is no the same as the original one).

 

I hope this is the right forum.

help getting coordinates textreco

March 18, 2014 - 1:45am #4

Ok, I understand it now :-)

I think the getMask() method is the right one to use in this case; as the documention says, this function: 

Returns an image representing the bit mask of the letters in the word.
Each pixel in the image is represented by a byte (8-bit value).
A value of 255 represents an empty area, i.e. a pixel not covered 
by any letter of the word.
If a pixel is covered by a letter, then the pixel value represents 
the position of that letter in the word, i.e. 0 for the first character,
1 for the second, 2 for the third, and so on. 

So, you could iterate over the pixels of the image and based on the position (row and column) of the pixel in the image, you should be able to compute the coordinates that you are looking for...  it's just about maths :-)

 

help getting coordinates textreco

March 17, 2014 - 2:04pm #3

Sory for not being so clear.

In the textreco sample, when text is detected a tectangular box is drawn around it. I need to select any area from within this box that is not coverd by text. i therefore need coordinates of any area that is not coverd by text but lies within this box.

help getting coordinates textreco

March 15, 2014 - 9:31am #2

Hi, 

could you explain this a bit better?

what do you mean with:

 a text's bounding box where there is no text

?

 

Topic locked