1

我已经从GithubJava Vision API下载了项目。

我通过开发人员控制台为我的项目启用了计费,并为我的项目获取了 client_secret。GOOGLE_APPLICATION_CREDENTIALS稍后通过添加指向我的 client_secret 文件的环境变量。我能够执行所有其他操作,例如标签、面部检测和地标检测。当我尝试执行 text_detection 代码时,我收到了这些错误。在此处查看图片

public void indexDirectory(Path inputPath) throws IOException {
List<Path> unprocessedImages =
    Files.walk(inputPath)
        .filter(Files::isRegularFile)
        .filter(index::isDocumentUnprocessed)
        .collect(Collectors.toList());
Lists.<Path>partition(unprocessedImages, BATCH_SIZE)
    .stream()
    .map(this::detectText)
    .flatMap(l -> l.stream())
    .filter(this::successfullyDetectedText)
    .map(this::extractDescriptions)
    .forEach(index::addDocument);}

这是我编写的代码,我收到以下错误。

Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
    Files cannot be resolved to a variable
    Syntax error on tokens, delete these tokens
    Syntax error on tokens, delete these tokens
    Syntax error on token(s), misplaced construct(s)
    Syntax error on tokens, delete these tokens
    Syntax error on token "-", -- expected
    Syntax error on tokens, delete these tokens
    Syntax error on tokens, delete these tokens
    Syntax error on token ":", EnhancedForStatementHeaderInit expected after this token

    at com.google.cloud.vision.samples.text.TextApp.indexDirectory(TextApp.java:158)
    at com.google.cloud.vision.samples.text.TextApp.main(TextApp.java:107)

我知道这些是语法错误,但我仍然无法找到使其工作的任何解决方案。

谁能建议我如何让它工作。

4

0 回答 0