Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

Xojo Plugin Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
Secrets
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(Xojo Plugin) Google Cloud Vision Text Detection

Demonstrates calling the Google Cloud Vision for text detection (performs Optical Character Recognition). "Detects and extracts text within an image with support for a broad range of languages. It also features automatic language identification." See https://cloud.google.com/vision/docs/detecting-text

Chilkat Xojo Plugin Download

Xojo Plugin for Windows, Linux, Mac OS X, and ARM, ARM64

// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

// Build the following request:

// {
//   "requests": [
//     {
//       "image": {
//         "content": "/9j/7QBEUGhvdG9zaG9...base64-encoded-image-content...fXNWzvDEeYxxxzj/Coa6Bax//Z"
//       },
//       "features": [
//         {
//           "type": "TEXT_DETECTION"
//         }
//       ]
//     }
//   ]
// }

// Use this online tool to generate the code from sample JSON: 
// Generate Code to Create JSON

// Load an image file.
Dim imageData As New Chilkat.BinData
// This image file contains some text...
Dim success As Boolean
success = imageData.LoadFile("qa_data/jpg/text.jpg")
If (success <> True) Then
    System.DebugLog("Failed to load image file.")
    Return
End If

// Create the above JSON.
Dim json As New Chilkat.JsonObject
success = json.UpdateBd("requests[0].image.content","base64",imageData)
success = json.UpdateString("requests[0].features[0].type","TEXT_DETECTION")

// Send the following POST with the HTTP request body containing the above JSON.
// POST https://vision.googleapis.com/v1/images:annotate?key=YOUR_API_KEY

Dim http As New Chilkat.Http
Dim sb As New Chilkat.StringBuilder
Dim url As String
url = "https://vision.googleapis.com/v1/images:annotate?key=YOUR_API_KEY"
Dim resp As Chilkat.HttpResponse
resp = http.PostJson3(url,"application/json",json)
If (http.LastMethodSuccess <> True) Then
    System.DebugLog(http.LastErrorText)
    Return
End If

System.DebugLog("status = " + Str(resp.StatusCode))

// A 200 response status indicate success.
If (resp.StatusCode <> 200) Then
    System.DebugLog(resp.BodyStr)
    System.DebugLog("Failed.")

    Return
End If

Dim sbResponseBody As New Chilkat.StringBuilder
success = resp.GetBodySb(sbResponseBody)
success = sbResponseBody.WriteFile("qa_output/textDetectResponse.json","utf-8",False)
success = json.LoadSb(sbResponseBody)

// The response is a JSON document like this:

// Use this online tool to generate parsing code from sample JSON: 
// Generate Parsing Code from JSON

// {
//   "responses": [
//     {
//       "textAnnotations": [
//         {
//           "locale": "en",
//           "description": "Chilkat is a cross-language, cross-platform\nAPl providing 90+ classes for many Internet\nprotocols, formats, and algorithms.\n",
//           "boundingPoly": {
//             "vertices": [
//               {
//                 "x": 17,
//                 "y": 14
//               },
// 	...
//             ]
//           }
//         ],
//         "text": "Chilkat is a cross-language, cross-platform\nAPl providing 90+ classes for many Internet\nprotocols, formats, and algorithms.\n"
//       }
//     }
//   ]
// }

// The parsing code generated from the online tool:

Dim i As Int32
Dim count_i As Int32
Dim fullTextAnnotationText As String
Dim j As Int32
Dim count_j As Int32
Dim locale As String
Dim description As String
Dim k As Int32
Dim count_k As Int32
Dim x As Int32
Dim y As Int32
Dim width As Int32
Dim height As Int32
Dim languageCode As String
Dim blockType As String
Dim i1 As Int32
Dim count_i1 As Int32
Dim json1 As Chilkat.JsonObject
Dim j1 As Int32
Dim count_j1 As Int32
Dim k1 As Int32
Dim count_k1 As Int32
Dim text As String
Dim propertyDetectedBreakType As String
Dim i2 As Int32
Dim count_i2 As Int32
Dim json2 As Chilkat.JsonObject

i = 0
count_i = json.SizeOfArray("responses")
While i < count_i
    json.I = i
    fullTextAnnotationText = json.StringOf("responses[i].fullTextAnnotation.text")
    j = 0
    count_j = json.SizeOfArray("responses[i].textAnnotations")
    While j < count_j
        json.J = j
        locale = json.StringOf("responses[i].textAnnotations[j].locale")
        description = json.StringOf("responses[i].textAnnotations[j].description")
        k = 0
        count_k = json.SizeOfArray("responses[i].textAnnotations[j].boundingPoly.vertices")
        While k < count_k
            json.K = k
            x = json.IntOf("responses[i].textAnnotations[j].boundingPoly.vertices[k].x")
            y = json.IntOf("responses[i].textAnnotations[j].boundingPoly.vertices[k].y")
            k = k + 1
        Wend
        j = j + 1
    Wend
    j = 0
    count_j = json.SizeOfArray("responses[i].fullTextAnnotation.pages")
    While j < count_j
        json.J = j
        width = json.IntOf("responses[i].fullTextAnnotation.pages[j].width")
        height = json.IntOf("responses[i].fullTextAnnotation.pages[j].height")
        k = 0
        count_k = json.SizeOfArray("responses[i].fullTextAnnotation.pages[j].property.detectedLanguages")
        While k < count_k
            json.K = k
            languageCode = json.StringOf("responses[i].fullTextAnnotation.pages[j].property.detectedLanguages[k].languageCode")
            k = k + 1
        Wend
        k = 0
        count_k = json.SizeOfArray("responses[i].fullTextAnnotation.pages[j].blocks")
        While k < count_k
            json.K = k
            blockType = json.StringOf("responses[i].fullTextAnnotation.pages[j].blocks[k].blockType")

            json1 = json.ObjectOf("responses[i].fullTextAnnotation.pages[j].blocks[k]")
            i1 = 0
            count_i1 = json1.SizeOfArray("property.detectedLanguages")
            While i1 < count_i1
                json1.I = i1
                languageCode = json1.StringOf("property.detectedLanguages[i].languageCode")
                i1 = i1 + 1
            Wend

            json1 = json.ObjectOf("responses[i].fullTextAnnotation.pages[j].blocks[k]")
            i1 = 0
            count_i1 = json1.SizeOfArray("boundingBox.vertices")
            While i1 < count_i1
                json1.I = i1
                x = json1.IntOf("boundingBox.vertices[i].x")
                y = json1.IntOf("boundingBox.vertices[i].y")
                i1 = i1 + 1
            Wend

            json1 = json.ObjectOf("responses[i].fullTextAnnotation.pages[j].blocks[k]")
            i1 = 0
            count_i1 = json1.SizeOfArray("paragraphs")
            While i1 < count_i1
                json1.I = i1
                j1 = 0
                count_j1 = json1.SizeOfArray("paragraphs[i].property.detectedLanguages")
                While j1 < count_j1
                    json1.J = j1
                    languageCode = json1.StringOf("paragraphs[i].property.detectedLanguages[j].languageCode")
                    j1 = j1 + 1
                Wend
                j1 = 0
                count_j1 = json1.SizeOfArray("paragraphs[i].boundingBox.vertices")
                While j1 < count_j1
                    json1.J = j1
                    x = json1.IntOf("paragraphs[i].boundingBox.vertices[j].x")
                    y = json1.IntOf("paragraphs[i].boundingBox.vertices[j].y")
                    j1 = j1 + 1
                Wend
                j1 = 0
                count_j1 = json1.SizeOfArray("paragraphs[i].words")
                While j1 < count_j1
                    json1.J = j1
                    k1 = 0
                    count_k1 = json1.SizeOfArray("paragraphs[i].words[j].property.detectedLanguages")
                    While k1 < count_k1
                        json1.K = k1
                        languageCode = json1.StringOf("paragraphs[i].words[j].property.detectedLanguages[k].languageCode")
                        k1 = k1 + 1
                    Wend
                    k1 = 0
                    count_k1 = json1.SizeOfArray("paragraphs[i].words[j].boundingBox.vertices")
                    While k1 < count_k1
                        json1.K = k1
                        x = json1.IntOf("paragraphs[i].words[j].boundingBox.vertices[k].x")
                        y = json1.IntOf("paragraphs[i].words[j].boundingBox.vertices[k].y")
                        k1 = k1 + 1
                    Wend
                    k1 = 0
                    count_k1 = json1.SizeOfArray("paragraphs[i].words[j].symbols")
                    While k1 < count_k1
                        json1.K = k1
                        text = json1.StringOf("paragraphs[i].words[j].symbols[k].text")
                        propertyDetectedBreakType = json1.StringOf("paragraphs[i].words[j].symbols[k].property.detectedBreak.type")

                        json2 = json1.ObjectOf("paragraphs[i].words[j].symbols[k]")
                        i2 = 0
                        count_i2 = json2.SizeOfArray("property.detectedLanguages")
                        While i2 < count_i2
                            json2.I = i2
                            languageCode = json2.StringOf("property.detectedLanguages[i].languageCode")
                            i2 = i2 + 1
                        Wend

                        json2 = json1.ObjectOf("paragraphs[i].words[j].symbols[k]")
                        i2 = 0
                        count_i2 = json2.SizeOfArray("boundingBox.vertices")
                        While i2 < count_i2
                            json2.I = i2
                            x = json2.IntOf("boundingBox.vertices[i].x")
                            y = json2.IntOf("boundingBox.vertices[i].y")
                            i2 = i2 + 1
                        Wend

                        k1 = k1 + 1
                    Wend
                    j1 = j1 + 1
                Wend
                i1 = i1 + 1
            Wend

            k = k + 1
        Wend
        j = j + 1
    Wend
    i = i + 1
Wend

System.DebugLog("Success.")

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.