Cloud Development Kit

Cloud Request - Unclear on response received

Hi,

I received the following response after making a cloud request following steps provided by Myscript (attached below). What is the expected value of the result as I am not clear on how to interpret this response:

HTTP/1.1 100 Continue


HTTP/1.1 200 

Date: Tue, 30 Oct 2018 05:49:26 GMT

Content-Type: text/plain

Content-Length: 5

Connection: keep-alive

Set-Cookie: JSESSIONID=4FD3B8269D0ED2FE160C9D860F450267; Path=/; HttpOnly

Access-Control-Allow-Origin: *

Access-Control-Allow-Credentials: true

Access-Control-Allow-Headers: Accept, Accept-Encoding, Cache-Control, Pragma, Upgrade, Accept-Language, Cookie, Access-Control-Request-Method, Access-Control-Request-Headers, Authorization, Connection, Content-Type, Host, Origin, Referer, Token-Id, User-Agent, X-Requested-With, applicationKey, hmacTh


The request was as below (replaced by my application key and hmac key)

curl -i -X POST \

   -H "Content-Type:application/json" \

   -H "Accept:application/json,text/plain" \

   -H "applicationKey:your-application-key" \

   -H "hmac:hmac-value" \

   -d \

'{"contentType":"Text","conversionState":"DIGITAL_EDIT",

"strokeGroups":[

   {"strokes": [

 {

      "x":[33,38,44,55,64,77,94,105,119,128,139,142,148,152,153,153,153,153,153,151,147,144,141,138,137,137,137,136,136,136,135,134,133,133,133,131,131,131,131,132,137,140,145,151,154,157,160,161,162,162,162,163,165,170,173,177,184,196,200,203,204,204,204,202,201,197,196,196,196,196,201,206,227,243,253,264,269,278,282,285,285,285,285,280,275,271,268,267,267,267,269,272,274,278,285,293,299,304,311,316,326,332,339,343,343,344,334,318,310,303,300,300,298,300,301,305,309,310,315,321,328,332,339,340,338,338,340,344,347,352,362,367,370,372,367,359,353,342,337,338,343,350,361,402,439,458,472],

      "y":[333,331,329,327,326,322,318,315,310,305,299,293,280,268,260,251,245,236,233,228,223,222,228,240,245,253,259,267,273,285,292,302,312,318,323,327,331,334,330,325,318,315,309,304,302,302,303,308,312,319,323,329,335,339,339,339,339,335,332,327,324,320,317,324,327,335,339,343,346,349,351,351,348,342,336,325,316,296,282,259,243,230,224,226,232,239,249,256,271,280,293,296,302,304,302,299,296,292,286,281,269,259,243,230,216,213,226,250,266,289,303,325,344,363,371,382,389,393,393,388,379,373,363,360,365,371,379,381,381,380,374,366,352,342,333,327,325,324,327,330,331,331,331,317,303,289,275],

      "t":[13161.210000000001,13208.210000000001,13224.210000000001,13240.210000000001,13256.210000000001,13273.210000000001,13289.210000000001,13305.210000000001,13321.210000000001,13337.210000000001,13353.210000000001,13368.210000000001,13385.210000000001,13409.210000000001,13425.210000000001,13441.210000000001,13457.210000000001,13473.210000000001,13489.210000000001,13505.210000000001,13537.210000000001,13561.210000000001,13641.210000000001,13657.210000000001,13673.210000000001,13689.210000000001,13705.210000000001,13720.210000000001,13737.210000000001,13752.210000000001,13769.210000000001,13785.210000000001,13809.210000000003,13825.210000000003,13840.210000000001,13856.210000000001,13872.210000000001,13897.210000000001,14009.210000000001,14025.210000000001,14041.210000000001,14057.210000000001,14072.210000000003,14088.210000000003,14105.210000000001,14121.210000000001,14169.210000000001,14185.210000000001,14209.210000000001,14225.210000000001,14241.210000000001,14257.210000000001,14289.210000000001,14321.210000000001,14337.210000000001,14353.210000000001,14369.210000000001,14393.210000000001,14408.210000000001,14424.210000000001,14441.210000000001,14456.210000000001,14481.210000000001,14553.210000000001,14569.210000000001,14593.210000000001,14609.210000000001,14625.210000000001,14641.210000000001,14665.210000000003,14721.210000000001,14737.210000000001,14761.210000000003,14777.210000000003,14793.210000000003,14809.210000000003,14825.210000000003,14840.210000000001,14857.210000000003,14873.210000000003,14889.210000000003,14905.210000000003,14921.210000000003,14977.210000000001,14993.210000000001,15009.210000000001,15025.210000000001,15041.210000000001,15057.210000000001,15073.210000000001,15088.210000000003,15105.210000000001,15121.210000000001,15160.210000000001,15193.210000000001,15209.210000000001,15225.210000000001,15241.210000000001,15257.210000000001,15273.210000000001,15289.210000000001,15305.210000000001,15321.210000000001,15337.210000000001,15361.210000000001,15377.210000000001,15457.210000000001,15473.210000000001,15489.210000000001,15505.210000000001,15521.210000000001,15537.210000000001,15561.210000000001,15577.210000000001,15593.210000000001,15609.210000000001,15625.210000000001,15641.210000000001,15672.210000000001,15689.210000000001,15705.210000000001,15721.210000000001,15744.210000000001,15761.210000000003,15889.210000000003,15905.210000000003,15928.210000000001,15961.210000000001,15977.210000000001,15993.210000000001,16009.210000000003,16025.210000000001,16041.210000000003,16057.210000000001,16073.21,16089.210000000001,16105.21,16129.210000000001,16161.210000000001,16193.210000000001,16209.210000000003,16225.210000000001,16241.210000000003,16257.210000000001,16273.210000000003,16289.210000000001,16297.21]

    }

     ]

   }

],"configuration":{"lang":"en_US"}}' \

'http://webdemoapi.myscript.com/api/v4.0/iink/batch'

"


I am enclosing the original mail I received for running this:

-----

Dear Prithvi Narayanan,

I am Olivier Rocher, from the technical support team at MyScript.

Please note in order to get a faster support, we recommend you submit any question you may have on our developer forum: https://developer-support.myscript.com/support/discussions.

To answer your question, it is not possible to use swagger-ui to test our endpoint because of the way we do authentication (via applicationKey and hmac).

You can test it for example using this curl command (please visit https://developer.myscript.com/support/account/registering-myscript-cloud/#computing-the-hmac-value to see how to produce your hmac value) :

curl -i -X POST \

   -H "Content-Type:application/json" \

   -H "Accept:application/json,text/plain" \

   -H "applicationKey:your-application-key" \

   -H "hmac:hmac-value" \

   -d \

'{"contentType":"Text","conversionState":"DIGITAL_EDIT",

"strokeGroups":[

   {"strokes": [

 {

      "x":[33,38,44,55,64,77,94,105,119,128,139,142,148,152,153,153,153,153,153,151,147,144,141,138,137,137,137,136,136,136,135,134,133,133,133,131,131,131,131,132,137,140,145,151,154,157,160,161,162,162,162,163,165,170,173,177,184,196,200,203,204,204,204,202,201,197,196,196,196,196,201,206,227,243,253,264,269,278,282,285,285,285,285,280,275,271,268,267,267,267,269,272,274,278,285,293,299,304,311,316,326,332,339,343,343,344,334,318,310,303,300,300,298,300,301,305,309,310,315,321,328,332,339,340,338,338,340,344,347,352,362,367,370,372,367,359,353,342,337,338,343,350,361,402,439,458,472],

      "y":[333,331,329,327,326,322,318,315,310,305,299,293,280,268,260,251,245,236,233,228,223,222,228,240,245,253,259,267,273,285,292,302,312,318,323,327,331,334,330,325,318,315,309,304,302,302,303,308,312,319,323,329,335,339,339,339,339,335,332,327,324,320,317,324,327,335,339,343,346,349,351,351,348,342,336,325,316,296,282,259,243,230,224,226,232,239,249,256,271,280,293,296,302,304,302,299,296,292,286,281,269,259,243,230,216,213,226,250,266,289,303,325,344,363,371,382,389,393,393,388,379,373,363,360,365,371,379,381,381,380,374,366,352,342,333,327,325,324,327,330,331,331,331,317,303,289,275],

      "t":[13161.210000000001,13208.210000000001,13224.210000000001,13240.210000000001,13256.210000000001,13273.210000000001,13289.210000000001,13305.210000000001,13321.210000000001,13337.210000000001,13353.210000000001,13368.210000000001,13385.210000000001,13409.210000000001,13425.210000000001,13441.210000000001,13457.210000000001,13473.210000000001,13489.210000000001,13505.210000000001,13537.210000000001,13561.210000000001,13641.210000000001,13657.210000000001,13673.210000000001,13689.210000000001,13705.210000000001,13720.210000000001,13737.210000000001,13752.210000000001,13769.210000000001,13785.210000000001,13809.210000000003,13825.210000000003,13840.210000000001,13856.210000000001,13872.210000000001,13897.210000000001,14009.210000000001,14025.210000000001,14041.210000000001,14057.210000000001,14072.210000000003,14088.210000000003,14105.210000000001,14121.210000000001,14169.210000000001,14185.210000000001,14209.210000000001,14225.210000000001,14241.210000000001,14257.210000000001,14289.210000000001,14321.210000000001,14337.210000000001,14353.210000000001,14369.210000000001,14393.210000000001,14408.210000000001,14424.210000000001,14441.210000000001,14456.210000000001,14481.210000000001,14553.210000000001,14569.210000000001,14593.210000000001,14609.210000000001,14625.210000000001,14641.210000000001,14665.210000000003,14721.210000000001,14737.210000000001,14761.210000000003,14777.210000000003,14793.210000000003,14809.210000000003,14825.210000000003,14840.210000000001,14857.210000000003,14873.210000000003,14889.210000000003,14905.210000000003,14921.210000000003,14977.210000000001,14993.210000000001,15009.210000000001,15025.210000000001,15041.210000000001,15057.210000000001,15073.210000000001,15088.210000000003,15105.210000000001,15121.210000000001,15160.210000000001,15193.210000000001,15209.210000000001,15225.210000000001,15241.210000000001,15257.210000000001,15273.210000000001,15289.210000000001,15305.210000000001,15321.210000000001,15337.210000000001,15361.210000000001,15377.210000000001,15457.210000000001,15473.210000000001,15489.210000000001,15505.210000000001,15521.210000000001,15537.210000000001,15561.210000000001,15577.210000000001,15593.210000000001,15609.210000000001,15625.210000000001,15641.210000000001,15672.210000000001,15689.210000000001,15705.210000000001,15721.210000000001,15744.210000000001,15761.210000000003,15889.210000000003,15905.210000000003,15928.210000000001,15961.210000000001,15977.210000000001,15993.210000000001,16009.210000000003,16025.210000000001,16041.210000000003,16057.210000000001,16073.21,16089.210000000001,16105.21,16129.210000000001,16161.210000000001,16193.210000000001,16209.210000000003,16225.210000000001,16241.210000000003,16257.210000000001,16273.210000000003,16289.210000000001,16297.21]

    }

     ]

   }

],"configuration":{"lang":"en_US"}}' \

'http://webdemoapi.myscript.com/api/v4.0/iink/batch'

"

Best regards,

Olivier





Dear Prithvi,


thank you for the update.


Currently, we can't see the entire response you are getting as it is truncated but based on the content-type=text/plain, the response code=200 and the content-length = 5, it is likely the body of the response contains "hello", that is text/plain result of the recognition.

Please take a look at the documentation (https://developer.myscript.com/docs/interactive-ink/1.2/web/rest/architecture/) for more information about how to use the REST recognition.


In the case of a text result (if exported in JIIX), you get a body response such as in the following example: https://developer.myscript.com/docs/interactive-ink/1.2/web/rest/text-example/


You can then parse it by yourself.


Best regards,


Olivier



Thanks. Any reason it's getting truncated? I'm running from the command line of a MAC, and is there a way I can capture the entire output?

My specific use case is that I've got x, y co-ordinates normalized to a value between [0,1] that displays well in a plot on Matlab. Is there a conversion needed to make this amenable for recognition at myscript?

Separately, if I take your x-y co-ordinates and plot these in matlab - the results are interpretable. Is there a way to take your x/y co-ordinates and plot these somehow?


thx

Prithvi

Sorry above should read as " if I take your x-y co-ordinates and plot these in matlab - the results are NOT  interpretable."


Ok, I did some manipulation (multiplying your 'y' coordinates with -1, and I do believe it looks like a 'hello' in a vague way. How do I attach a screenshot of this to make sure this may have been the original shape? Separately, can you also respond on the other question I had earlier.


 

"Thanks. Any reason it's getting truncated? I'm running from the command line of a MAC, and is there a way I can capture the entire output?"

 

P

 


Dear Prithvi,


Can you please check again the return of your request? Using CURL, the result was displayed at the bottom line (hidden next to the login) :-)



Best regards,


Olivier


1 person likes this

Thanks - just noticed this! :) - good observation


Is there a limit on the length of the x and y vectors, and can these be sent without the time parameter?

Dear Pritvhi,


to answer your questions:

-Using the REST API, you can indeed remove the time information (you can either provide with an empty array, or even with not "t" parameter)

-The limit of a REST request is 700KB


Best regards,


Olivier

image

This is a matlab plot of the x/y co-ordinates - did the original image look like this, and this is what was interpreted?


Dear Pritvhi,


Based on the X and Y coordinates, I am also getting the same image and result:


Where is this ink coming from? Indeed, we recommend having a good quality to ensure the best accuracy.


Best regards,


Olivier

Hi, this ink is basically a plot of the strokes you provided in your request as a sample to try with curl. I wanted to see what the image represents. I have my samples that plot similarly and wanted to see if these are recognized (they don't :( )./


 I'm a bit confused on the co-ordinate axes and what needs to be used - if I normalize your sample values in the [0,1] range these don't work - my ink samples belong in this range- 


Can you point me on how the scaling needs to be setup to make this work? I did see some on the site, but don't think am too clear.. if you've any easy writeup on this, it'd help greatly.


Thanks

Prithvi

Dear Prithvi,

Is it possible that you attach a sample of your ink?

I will then check it carefully and update you.

Best regards,

Olivier

 

I am enclosing the same x/y co-ordinates normalized to a range between 0 and 1. The plot in matlab is identical to the original. However, the curl command return 'w' instead of 'hello'


curl -i -X POST \

   -H "Content-Type:application/json" \

   -H "Accept:application/json,text/plain" \

  -H "applicationKey:your-application-key" \

   -H "hmac:hmac-value" \

   -d \

'{"contentType":"Text","conversionState":"DIGITAL_EDIT",

"strokeGroups":[

   {"strokes": [

    {



"x":[0,0.01139,0.025057,0.050114,0.070615,0.10023,0.13895,0.16401,0.1959,0.2164,0.24146,0.24829,0.26196,0.27107,0.27335,0.27335,0.27335,0.27335,0.27335,0.26879,0.25968,0.25285,0.24601,0.23918,0.2369,0.2369,0.2369,0.23462,0.23462,0.23462,0.23235,0.23007,0.22779,0.22779,0.22779,0.22323,0.22323,0.22323,0.22323,0.22551,0.2369,0.24374,0.25513,0.26879,0.27563,0.28246,0.28929,0.29157,0.29385,0.29385,0.29385,0.29613,0.30068,0.31207,0.31891,0.32802,0.34396,0.3713,0.38041,0.38724,0.38952,0.38952,0.38952,0.38497,0.38269,0.37358,0.3713,0.3713,0.3713,0.3713,0.38269,0.39408,0.44191,0.47836,0.50114,0.5262,0.53759,0.55809,0.5672,0.57403,0.57403,0.57403,0.57403,0.56264,0.55125,0.54214,0.53531,0.53303,0.53303,0.53303,0.53759,0.54442,0.54897,0.55809,0.57403,0.59226,0.60592,0.61731,0.63326,0.64465,0.66743,0.68109,0.69704,0.70615,0.70615,0.70843,0.68565,0.6492,0.63098,0.61503,0.6082,0.6082,0.60364,0.6082,0.61048,0.61959,0.6287,0.63098,0.64237,0.65604,0.67198,0.68109,0.69704,0.69932,0.69476,0.69476,0.69932,0.70843,0.71526,0.72665,0.74943,0.76082,0.76765,0.77221,0.76082,0.7426,0.72893,0.70387,0.69248,0.69476,0.70615,0.7221,0.74715,0.84055,0.92483,0.96811,1],


"y":[0.66667,0.65556,0.64444,0.63333,0.62778,0.60556,0.58333,0.56667,0.53889,0.51111,0.47778,0.44444,0.37222,0.30556,0.26111,0.21111,0.17778,0.12778,0.11111,0.083333,0.055556,0.05,0.083333,0.15,0.17778,0.22222,0.25556,0.3,0.33333,0.4,0.43889,0.49444,0.55,0.58333,0.61111,0.63333,0.65556,0.67222,0.65,0.62222,0.58333,0.56667,0.53333,0.50556,0.49444,0.49444,0.5,0.52778,0.55,0.58889,0.61111,0.64444,0.67778,0.7,0.7,0.7,0.7,0.67778,0.66111,0.63333,0.61667,0.59444,0.57778,0.61667,0.63333,0.67778,0.7,0.72222,0.73889,0.75556,0.76667,0.76667,0.75,0.71667,0.68333,0.62222,0.57222,0.46111,0.38333,0.25556,0.16667,0.094444,0.061111,0.072222,0.10556,0.14444,0.2,0.23889,0.32222,0.37222,0.44444,0.46111,0.49444,0.50556,0.49444,0.47778,0.46111,0.43889,0.40556,0.37778,0.31111,0.25556,0.16667,0.094444,0.016667,0,0.072222,0.20556,0.29444,0.42222,0.5,0.62222,0.72778,0.83333,0.87778,0.93889,0.97778,1,1,0.97222,0.92222,0.88889,0.83333,0.81667,0.84444,0.87778,0.92222,0.93333,0.93333,0.92778,0.89444,0.85,0.77222,0.71667,0.66667,0.63333,0.62222,0.61667,0.63333,0.65,0.65556,0.65556,0.65556,0.57778,0.5,0.42222,0.34444],



      "t":[]

    }

     ]

   }

],"configuration":{"lang":"en_US"}}' \

'http://webdemoapi.myscript.com/api/v4.0/iink/batch'


Dear Prithvi,


currently, you should indeed tune the resolution accordingly, setting the xDPI and yDPI parameters: https://developer.myscript.com/docs/interactive-ink/1.2/web/rest/architecture/#overview-of-the-request


You can try with values such as 5 DPI based on the ink you send.


Best regards,


Olivier

Login or Signup to post a comment