a9t9 / ocr.space-ocr-api-code-snippets Goto Github PK
View Code? Open in Web Editor NEWMisc. code snippets for calling the OCR API etc
Home Page: https://ocr.space/ocrapi
License: MIT License
Misc. code snippets for calling the OCR API etc
Home Page: https://ocr.space/ocrapi
License: MIT License
When we are picking image from camera. we are getting issue with image size
When the command is pasted on the terminal the following error is returned:
{"ParsedResults":null,"OCRExitCode":3,"IsErroredOnProcessing":true,"ErrorMessage":["Not a valid base64 image. The accepted base64 image format is 'data:image/<content_type>;base64,<base64_image_content>'."],"ErrorDetails":"Not a valid base64 image. The accepted base64 image format is 'data:image/<content_type>;base64,<base64_image_content>'.","ProcessingTimeInMilliseconds":"1","SearchablePDFURL":null}
Hello,
i'm using your php sscript but how i can add post params? as isOverlayRequired=true
Hi,
I'm having an issue with PDF files. I get "Not a valid base64 image. The accepted base64 image format is 'data:image/<content_type>;base64,<base64_image_content>". The strange thing is that it says it requires "data:image/" but PDFs are "application/pdf". What is the solution ?
Cheers,
K.
Hi,
PHP, I am not able to see the result in index.php , this is what i am done before submit:
but show:
Error "Sorry, there was an error uploading your file."
Any help Please.
Thank you.
Default is English. But I need guide on how to toggle between various languages.
Can someone confirm that is ever worked? Thanks
Sorry, please upload a pdf file
but it really PDF file i have uploaded....
It's almost same as Arabic, but we only have few letters difference Can you add it ? or at least give me files so I will add it I been looking for the files but I can't figure out where they are.
how can I change the OCR language ?
After updating your code to swift 4, the request times out. please see code below:
`
static func getImageText(_ imageData: Data, completion: (String) -> ())
{
let url = URL(string: "https://api.ocr.space/parse/image")!
let boundary: String = "randomString"
let session = URLSession.shared
let parametersDictionary = ["4159879d4788957": "apikey", "True": "isOverlayRequired", "eng": "language"]
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.addValue("multipart/form-data; boundary=\(boundary)", forHTTPHeaderField: "Content-Type")
let data: Data = createBodyWithBoundary(boundary, parameters: parametersDictionary as [NSObject : AnyObject], imageData: imageData, filename: "yourImage.jpg")
request.httpBody = data
let task = session.dataTask(with: request)
{ data, response, error in
guard let pageData = data else
{
print("error getting ocr: \(error)")
return
}
do
{
try print(JSONSerialization.jsonObject(with: pageData, options: .allowFragments))
}
catch
{
print("json error: \(error)")
}
}
task.resume()
}
private static func createBodyWithBoundary(_ boundary: String, parameters: [NSObject : AnyObject], imageData data: Data, filename: String) -> Data
{
var body: NSMutableData = NSMutableData()
body.append("--\(boundary)\r\n".data(using: .utf8)!)
body.append("Content-Disposition: form-data; name=\"\("file")\"; filename=\"\(filename)\"\r\n".data(using: .utf8)!)
body.append("Content-Type: image/jpeg\r\n\r\n".data(using: .utf8)!)
body.append(data)
for key in parameters.keys
{
body.append("--\(boundary)\r\n".data(using: .utf8)!)
body.append("Content-Disposition: form-data; name=\"\(key)\"\r\n\r\n".data(using: .utf8)!)
body.append("\(parameters[key])\r\n".data(using: .utf8)!)
}
body.append("--\(boundary)--\r\n".data(using: .utf8)!)
return body as Data
}`
Change Line 48
From: if($response['ErrorMessage'] == "") {
To: if(!isset($response['ErrorMessage'])) {
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.