2

Firebase Cloud 기능에서 Cloud Vision API를 사용하여 Firebase Storage에 저장된 이미지를 OCR하려고 시도합니다.Firebase Cloud 기능 및 Cloud Vision API : TypeError : vision.detectText가 함수가 아닙니다.

const vision = require('@google-cloud/vision'); 

을 따를

본인은 Google 클라우드 비전 클라이언트 라이브러리를 가져오고 내가

이 형식 오류 오류 얻을 그러나 그때

vision.detectText({ source: { imageUri: 'gs://xxxx.appspot.com/yyyy.JPG' } }) 

전화 : vision.detectText는 함수가 아닙니다에게

처음에는 내가 사용했습니다

vision.textDetection({ source: { imageUri: ... } }) 

이 예제에서 https://cloud.google.com/vision/docs/reference/libraries#client-libraries-install-nodejs하지만 정확히 같은 오류가 발생했습니다. 나는 그 textDetection가 detectText로 대체되었지만 설명 된대로 당신이 API를 호출하지 않는 것처럼 미리

답변

1

에서 더 이상 성공

감사 그것은 보이는 없음을 읽어 보시기 바랍니다. 첫째, 문서에서 제공되는 sample code에서 살펴 :

const vision = require('@google-cloud/vision'); 

// Creates a client 
const client = new vision.ImageAnnotatorClient(); 

/** 
* TODO(developer): Uncomment the following line before running the sample. 
*/ 
// const fileName = 'Local image file, e.g. /path/to/image.png'; 

// Performs text detection on the local file 
client 
    .textDetection(fileName) 
    .then(results => { 
    const detections = results[0].textAnnotations; 
    console.log('Text:'); 
    detections.forEach(text => console.log(text)); 
    }) 
    .catch(err => { 
    console.error('ERROR:', err); 
    }); 

당신은 먼저 textDetection() 방법으로 전화 할 수있는 ImageAnnotatorClient 객체를 생성해야합니다.

+0

@ RenenaT이 답변이 맞으면 정답으로 사용하십시오. –