Text

Answered

How can I get the exact coordinates of a string ?

The obtained coordinates do not match the actual coordinates.

Current log: 

{

     "type": "Text",

     "bounding-box": {

      "x": 9.51567459,

      "y": 38.902504,

      "width": 183.969711,

      "height": 9.97500229

     },

     "label": "6",

     "words": [ {

       "label": "6",

       "candidates": [ "6", "G", "°", "•", "5" ],

       "bounding-box": {

        "x": 180.79657,

        "y": 38.8113518,

        "width": 3.86470032,

        "height": 5.35850143

       }

      } ],

     "id": "1",

     "version": "3"

    }

The actual screen resolution is 1200 * 1400

Best regards.


Best Answer

Dear Olivier,

Thank you for your reply.

I have tried the way mentioned in your latest reply, but  still repeat the problems I encountered before.So I decided to convert the coordinates in another way, after testing, the accuracy is more than 90%. Anyway, thank you for your help.

Best regards,

Shiftsand


Answer

Dear Olivier,

Thank you for your reply.

I have tried the way mentioned in your latest reply, but  still repeat the problems I encountered before.So I decided to convert the coordinates in another way, after testing, the accuracy is more than 90%. Anyway, thank you for your help.

Best regards,

Shiftsand

Dear Shiftsand,


the reason is that you are using the batch mode, which by definition is off-screen.


If you want to have the coordinates of the converted text, the solution is that you add the strokes using the incremental API: https://developer.myscript.com/docs/interactive-ink/1.4/android/fundamentals/editing/#incremental-input


As the incremental API is the deafult way strokes are added, the easier is that you refer to the handleOnTouchForPointer function you can find in the InputController.java file.


Best regards,


Olivier

Dear Olivier,

Thank you for your reply.

At present, I need to get the coordinate information of the recognition result. The problem now is that the coordinates of the recognition results are not correct. In any case, the value of the X coordinate does not change, and the value of the Y coordinate is not correct.

Here is my code:

image


image

image

Best regards,

Shiftsand


Dear Shiftingsand,


thank you for the update.


Currently, I do not see anything wrong in your above code? What is the exact behavior?  The point doesn't correspond to the one of the ink? Or the converted result?


Also, please note you have to ensure you provide with the proper resolution (in DPI) when creating the renderer (createRenderer(240, 240, nullptr);) ; the resolution shall be the one of the writing device (e.g. touch screen).


Best regards,


Olivier

Dear Olivier,

Thank you for your reply.

According to your suggestion, the converted coordinates are still wrong, I don't know what the problem is.

Here is my code:

   Transform transform = editor.getRenderer().getViewTransform();

   for (JixDefinitions.ChildrenBean child : children) {

      Point childPoint = transform.apply(child.getBoundingbox().getX(), child.getBoundingbox().getY());

      ELog.e("MyScript -----> childPoint ---->",childPoint.x + "-------" + childPoint.y);

   }

Look forward to your reply.

Best regards,

Shiftsand

Dear Shiftingsand,


thank you for contacting us.?


Currently, the reason is that the JIIX coordinates are in milimeters.


To convert milimeters to pixels, you shall use the transform Matrix: https://developer.myscript.com/refguides/interactive-ink/android/1.5/


If you want to convert a point from milimeters to pixels, this is done as follows:
Transform tr= editor->getRenderer()->getViewTransform();
Point myPoint(x,y); //coordinates in milimeters
tr.apply(myPoint); //coordinates in pixels


see https://developer-support.myscript.com/support/discussions/topics/16000031216


Best regards,


Olivier