mathpix / api-examples Goto Github PK
View Code? Open in Web Editor NEWMathpix API examples - converts image to latex
Mathpix API examples - converts image to latex
Could you add an example for PHP, I am stuck with this custom code:
$uploadedFile = file_get_contents('ztest.jpg');
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_RETURNTRANSFER => true, // receive server response
CURLOPT_URL => "https://api.mathpix.com/v3/latex",
CURLOPT_POST => 1,
CURLOPT_HTTPHEADER => array('Content-Type:application/json'),
CURLOPT_POSTFIELDS => array(
"app_id" => "trial",
"app_key" => "34f1a4cea0eaca8540c95908b4dc84ab",
"src" => "data:image/jpeg;base64,".base64_encode($uploadedFile), // data
)
));
$result = curl_exec($ch);
curl_close($ch);
// further processing
if($result == "OK")
{
// **** how to access the latex results?!
var_dump('Okay');
}
else
{
var_dump($result);
}
I guess the data should not be sent by "src"
but differently using CURL.
It uses https://api.mathpix.com/v3/latex
as endpoint which is outdated. It should be https://api.mathpix.com/v3/text
.
{
"error": "Invalid credentials",
"error_info": {
"id": "http_unauthorized",
"message": "Invalid credentials"
}
}
{
"error": "Invalid credentials",
"error_info": {
"id": "http_unauthorized",
"message": "Invalid credentials"
}
}
what does this means?
I use python3.6, so my code is
#!/usr/bin/env python
import sys
import base64
import requests
import json
file_path = sys.argv[1]
image_uri = "data:image/jpg;base64," + base64.b64encode(open(file_path, "rb").read()).decode()
r = requests.post("https://api.mathpix.com/v3/latex",
data=json.dumps({'src': image_uri,
'formats': ['latex_normal', 'latex_styled']}),
headers={"app_id": "trial", "app_key": "34f1a4cea0eaca8540c95908b4dc84ab",
"Content-type": "application/json"})
print(json.dumps(json.loads(r.text), indent=4, sort_keys=True))
Maybe helpful for others: https://github.com/jonocarroll/mathpix
You might want to add this to your examples / docs.
Description
Hello,
I have encountered an issue while using Mathpix to recognize text in a Japanese PDF book where the text is vertically aligned. The recognition quality is poor, and many characters are not recognized correctly. Here are the details:
Text Alignment: Japanese text is arranged vertically from top to bottom and right to left.
File Type: PDF
Issue Observed: The recognition results show missing characters, incorrect characters, and some characters that are not recognized at all.
Attachments
https://drive.google.com/file/d/1Z1LcEuuuqGOyTgyjckdvzN_DSd0JFsmo/view?usp=sharing
Dear Mathpix Support Team,
I hope this message is helpful to you. I am a member of the Immersive Translate team, and we have been utilizing Mathpix for our translation projects with great enthusiasm. We deeply appreciate the innovative solutions your product offers, which have significantly enhanced our workflow. At the same time, we also encountered some problems when using Mathpix, I will explain them separately in this issue, hoping to get your help, thanks!
How can i use API in python for any other image
please mention the required steps
latex {'request_id': 'c590d176a336a9eaa488383fcd8f78c4', 'error': "OpenCV(4.2.0) /io/opencv/modules/imgproc/src/resize.cpp:4048: error: (-215:Assertion failed) inv_scale_x > 0 in function 'resize'\n", 'error_info': {'id': 'sys_exception', 'message': "OpenCV(4.2.0) /io/opencv/modules/imgproc/src/resize.cpp:4048: error: (-215:Assertion failed) inv_scale_x > 0 in function 'resize'\n"}}
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.