REST Math recognition with image/png, image/jpeg and text/html return image of my strokes, not the converted math.
D
Devteam
started a topic
over 2 years ago
Hello.
I am using iinkjs with the REST protocol with the MATH recognition type and am trying to obtain an image I can insert onto our FabricJS canvas. However, with image/png, image/jpeg and text/html, I get an image of the strokes used for the recognition, not the converted math.
Here is an image of the strokes. I gather points from the strokes and to fill the strokeGroups with.
Here is what I get for the image/png format in the recognize callback:When I ask for mathml or latex, I get what is expected:
Currently, for the REST API, you can create a simple request, referring to our swaggerui page: https://swaggerui.myscript.com/
Simply setting the Accept header to "image/png" will normally return an image.
Best regards,
Olivier
D
Devteam
said
over 2 years ago
Hmm, I thought just setting the mime type in the recognizer configuration would be enough. I can try this as well.
D
Devteam
said
over 2 years ago
Hi,
I forgot to mention that I am using iinkJS to do the rest call as shown in the rest_no_ui.html example. How would I go about setting the accept header using iinkjs' export_ call? I would have thought iinkJS would do that for me.
Thanks.
O
Olivier @MyScript
said
over 2 years ago
Answer
Dear "Devteam",
thank you for the update.
At present, using the iinkJS, the solution would consist in patching the "post" functionof the src/recognizer/rest/networkInterface.js file:
export async function post (recognizerContext, url, data, apiVersion, mimeType) { const configuration = recognizerContext.editor.configuration const recognizerContextRef = recognizerContext if (recognizerContextRef) { recognizerContextRef.idle = true } try { const headers = new Headers() headers.append('Accept', 'application/json,' + mimeType) headers.append('applicationKey', configuration.recognitionParams.server.applicationKey)
Replacing application/json by "image/png" should normally work.
Instead, I would recommend you format the REST request by yourself, setting the "Accept" header as in the above image ; it would be easier and faster.
Devteam
Hello.
I am using iinkjs with the REST protocol with the MATH recognition type and am trying to obtain an image I can insert onto our FabricJS canvas. However, with image/png, image/jpeg and text/html, I get an image of the strokes used for the recognition, not the converted math.
Here is an image of the strokes. I gather points from the strokes and to fill the strokeGroups with.
Here is what I get for the image/png format in the recognize callback:When I ask for mathml or latex, I get what is expected:Should I be getting an image of the converted math or is this as expected.
I have also used MathJax to convert the mathml to an image and that works, but feel it shouldn't be necessary.
Thanks.
Dear "Devteam",
thank you for the update.
At present, using the iinkJS, the solution would consist in patching the "post" functionof the src/recognizer/rest/networkInterface.js file:
export async function post (recognizerContext, url, data, apiVersion, mimeType) {
const configuration = recognizerContext.editor.configuration
const recognizerContextRef = recognizerContext
if (recognizerContextRef) {
recognizerContextRef.idle = true
}
try {
const headers = new Headers()
headers.append('Accept', 'application/json,' + mimeType)
headers.append('applicationKey', configuration.recognitionParams.server.applicationKey)
Replacing application/json by "image/png" should normally work.
Instead, I would recommend you format the REST request by yourself, setting the "Accept" header as in the above image ; it would be easier and faster.
Best regards,
Olivier
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstOlivier @MyScript
Dear "Devteam",
thank you for contacting us.
Currently, for the REST API, you can create a simple request, referring to our swaggerui page: https://swaggerui.myscript.com/
Simply setting the Accept header to "image/png" will normally return an image.
Best regards,
Olivier
Devteam
Hmm, I thought just setting the mime type in the recognizer configuration would be enough. I can try this as well.
Devteam
Hi,
I forgot to mention that I am using iinkJS to do the rest call as shown in the rest_no_ui.html example. How would I go about setting the accept header using iinkjs' export_ call? I would have thought iinkJS would do that for me.
Thanks.
Olivier @MyScript
Dear "Devteam",
thank you for the update.
At present, using the iinkJS, the solution would consist in patching the "post" functionof the src/recognizer/rest/networkInterface.js file:
export async function post (recognizerContext, url, data, apiVersion, mimeType) {
const configuration = recognizerContext.editor.configuration
const recognizerContextRef = recognizerContext
if (recognizerContextRef) {
recognizerContextRef.idle = true
}
try {
const headers = new Headers()
headers.append('Accept', 'application/json,' + mimeType)
headers.append('applicationKey', configuration.recognitionParams.server.applicationKey)
Replacing application/json by "image/png" should normally work.
Instead, I would recommend you format the REST request by yourself, setting the "Accept" header as in the above image ; it would be easier and faster.
Best regards,
Olivier
1 person likes this