Code Monkey home page Code Monkey logo

api-examples's People

Contributors

mathpixsrc avatar nicodjimenez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

api-examples's Issues

error while 'python python/test.py images/algebra.jpg'

{
"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))

Still uses old endpoint

It uses https://api.mathpix.com/v3/latex as endpoint which is outdated. It should be https://api.mathpix.com/v3/text.

bug: -215:Assertion failed)

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"}}

API usage

How can i use API in python for any other image
please mention the required steps

Why I get an error ...

{
"error": "Invalid credentials",
"error_info": {
"id": "http_unauthorized",
"message": "Invalid credentials"
}
}

MathPix-API: PHP sample is missing

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.