| 44 | } |
| 45 | |
| 46 | async function detectHandwritingGCS(uri) { |
| 47 | // [START vision_handwritten_ocr_gcs_beta] |
| 48 | // Imports the Google Cloud client libraries |
| 49 | const vision = require('@google-cloud/vision').v1p3beta1; |
| 50 | const fs = require('fs'); |
| 51 | |
| 52 | // Creates a client |
| 53 | const client = new vision.ImageAnnotatorClient(); |
| 54 | |
| 55 | /** |
| 56 | * TODO(developer): Uncomment the following line before running the sample. |
| 57 | */ |
| 58 | // const uri = `gs://bucket/bucketImage.png`; |
| 59 | |
| 60 | const request = { |
| 61 | image: { |
| 62 | content: fs.readFileSync(uri), |
| 63 | }, |
| 64 | feature: { |
| 65 | languageHints: ['en-t-i0-handwrit'], |
| 66 | }, |
| 67 | }; |
| 68 | |
| 69 | const [result] = await client.documentTextDetection(request); |
| 70 | const fullTextAnnotation = result.fullTextAnnotation; |
| 71 | console.log(`Full text: ${fullTextAnnotation.text}`); |
| 72 | // [END vision_handwritten_ocr_gcs_beta] |
| 73 | } |
| 74 | |
| 75 | require('yargs') |
| 76 | .demand(1) |