Spring Cloud Google Cloud Vision 檢測(cè)圖像標(biāo)簽示例

2024-01-12 09:47 更新

圖像標(biāo)簽是指產(chǎn)生描述圖像內(nèi)容的標(biāo)簽。以下是使用Cloud Vision Spring模板完成此操作的代碼示例。

@Autowired
private ResourceLoader resourceLoader;

@Autowired
private CloudVisionTemplate cloudVisionTemplate;

public void processImage() {
  Resource imageResource = this.resourceLoader.getResource("my_image.jpg");
  AnnotateImageResponse response = this.cloudVisionTemplate.analyzeImage(
      imageResource, Type.LABEL_DETECTION);
  System.out.println("Image Classification results: " + response.getLabelAnnotationsList());
}
以上內(nèi)容是否對(duì)您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號(hào)
微信公眾號(hào)

編程獅公眾號(hào)