This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch 23153 in repository https://gitbox.apache.org/repos/asf/camel.git
commit 804cb1cc8fc57b77bfebc5da12c985c69acdc88d Author: Andrea Cosentino <[email protected]> AuthorDate: Mon Mar 9 09:59:35 2026 +0100 CAMEL-23153 - Camel-Google: Add Google Cloud Vision AI component Signed-off-by: Andrea Cosentino <[email protected]> --- .../component/google/vision/google-vision.json | 2 +- .../src/main/docs/google-vision-component.adoc | 87 ++++++++++------------ .../vision/GoogleCloudVisionConfiguration.java | 16 +++- .../google/vision/GoogleCloudVisionEndpoint.java | 9 +-- .../google/vision/GoogleCloudVisionProducer.java | 2 +- 5 files changed, 61 insertions(+), 55 deletions(-) diff --git a/components/camel-google/camel-google-vision/src/generated/resources/META-INF/org/apache/camel/component/google/vision/google-vision.json b/components/camel-google/camel-google-vision/src/generated/resources/META-INF/org/apache/camel/component/google/vision/google-vision.json index 874952595ccf..8f7a18b77040 100644 --- a/components/camel-google/camel-google-vision/src/generated/resources/META-INF/org/apache/camel/component/google/vision/google-vision.json +++ b/components/camel-google/camel-google-vision/src/generated/resources/META-INF/org/apache/camel/component/google/vision/google-vision.json @@ -3,7 +3,7 @@ "kind": "component", "name": "google-vision", "title": "Google Cloud Vision", - "description": "Analyze images using Google Cloud Vision AI", + "description": "Detect labels, text, faces, logos and more on images through Google Cloud Vision API", "deprecated": false, "firstVersion": "4.19.0", "label": "cloud,ai", diff --git a/components/camel-google/camel-google-vision/src/main/docs/google-vision-component.adoc b/components/camel-google/camel-google-vision/src/main/docs/google-vision-component.adoc index 4d4465f31665..d00bd8824a16 100644 --- a/components/camel-google/camel-google-vision/src/main/docs/google-vision-component.adoc +++ b/components/camel-google/camel-google-vision/src/main/docs/google-vision-component.adoc @@ -2,7 +2,7 @@ :doctitle: Google Cloud Vision :shortname: google-vision :artifactid: camel-google-vision -:description: Analyze images using Google Cloud Vision AI +:description: Detect labels, text, faces, logos and more on images through Google Cloud Vision API :since: 4.19 :supportlevel: Preview :tabs-sync-option: @@ -15,12 +15,9 @@ *{component-header}* -The Google Cloud Vision component provides access to https://cloud.google.com/vision[Google Cloud Vision AI] via +The Google Cloud Vision component provides access to https://cloud.google.com/vision[Google Cloud Vision API] via the https://github.com/googleapis/java-cloud-vision[Google Cloud Vision Client for Java]. -Google Cloud Vision AI enables you to detect objects, text, faces, landmarks, logos, and more within images -using pre-trained machine learning models. - Maven users will need to add the following dependency to their pom.xml for this component: @@ -65,7 +62,7 @@ google-vision://operation[?options] You can append query options to the URI in the following format, `?options=value&option2=value&...` -For example, to perform label detection on an image, use the following snippet: +For example, in order to perform label detection on an image, use the following snippet: [source,java] -------------------------------------------------------------------------------- @@ -86,28 +83,28 @@ include::partial$component-endpoint-headers.adoc[] === Message body -The message body should contain the image data as a `byte[]`. The component will build the Vision API request from this image data. +The message body should contain the image data as a `byte[]`. -When `pojoRequest=true`, the message body should be a `com.google.cloud.vision.v1.AnnotateImageRequest` instance, giving you full control over the request. +When `pojoRequest=true`, the body should be a `com.google.cloud.vision.v1.AnnotateImageRequest` instance instead. -=== Google Cloud Vision operations +=== Google Cloud Vision Producer operations -The Google Cloud Vision component provides the following operations: +Google Cloud Vision component provides the following operation on the producer side: -- `labelDetection` - Detect labels (objects, entities, categories) in images -- `textDetection` - Detect and extract text (OCR) from images -- `documentTextDetection` - Full document text detection optimized for dense text and documents -- `faceDetection` - Detect faces and facial attributes -- `landmarkDetection` - Detect well-known landmarks -- `logoDetection` - Detect company logos -- `safeSearchDetection` - Detect explicit content (adult, violence, etc.) -- `imagePropertiesDetection` - Detect image properties such as dominant colors -- `webDetection` - Detect web references and similar images -- `objectLocalization` - Detect and localize multiple objects with bounding polygons -- `cropHintsDetection` - Suggest crop hints for images +- labelDetection +- textDetection +- documentTextDetection +- faceDetection +- landmarkDetection +- logoDetection +- safeSearchDetection +- imagePropertiesDetection +- webDetection +- objectLocalization +- cropHintsDetection The operation is specified as part of the endpoint URI (e.g., `google-vision://labelDetection`). -It can also be overridden at runtime by setting the `GoogleCloudVisionOperation` message header. +You can override the operation at runtime by setting the `GoogleCloudVisionOperation` message header. === Advanced component configuration @@ -119,9 +116,9 @@ from("direct:start") .to("google-vision://labelDetection?client=#myVisionClient"); -------------------------------------------------------------------------------- -=== Google Cloud Vision operation examples +=== Google Cloud Vision Producer Operation examples -- `labelDetection`: Detect labels in an image +- `labelDetection`: this operation detects labels in an image [source,java] -------------------------------------------------------------------------------- @@ -131,13 +128,13 @@ from("direct:start") exchange.getIn().setBody(imageData); }) .to("google-vision://labelDetection?serviceAccountKey=/home/user/Downloads/my-key.json&maxResults=10") - .log("Labels: ${body}") + .log("body:${body}") .to("mock:result"); -------------------------------------------------------------------------------- -The body will contain a `List<EntityAnnotation>` with the detected labels. +This operation will return a `List<EntityAnnotation>` with the detected labels. -- `textDetection`: Extract text from an image (OCR) +- `textDetection`: this operation extracts text from an image (OCR) [source,java] -------------------------------------------------------------------------------- @@ -147,13 +144,13 @@ from("direct:start") exchange.getIn().setBody(imageData); }) .to("google-vision://textDetection?serviceAccountKey=/home/user/Downloads/my-key.json") - .log("Text: ${body}") + .log("body:${body}") .to("mock:result"); -------------------------------------------------------------------------------- -The body will contain a `List<EntityAnnotation>` with the detected text. +This operation will return a `List<EntityAnnotation>` with the detected text. -- `faceDetection`: Detect faces in an image +- `faceDetection`: this operation detects faces in an image [source,java] -------------------------------------------------------------------------------- @@ -163,13 +160,13 @@ from("direct:start") exchange.getIn().setBody(imageData); }) .to("google-vision://faceDetection?serviceAccountKey=/home/user/Downloads/my-key.json") - .log("Faces: ${body}") + .log("body:${body}") .to("mock:result"); -------------------------------------------------------------------------------- -The body will contain a `List<FaceAnnotation>` with the detected faces and their attributes. +This operation will return a `List<FaceAnnotation>` with the detected faces. -- `safeSearchDetection`: Detect explicit content +- `safeSearchDetection`: this operation detects explicit content [source,java] -------------------------------------------------------------------------------- @@ -179,13 +176,13 @@ from("direct:start") exchange.getIn().setBody(imageData); }) .to("google-vision://safeSearchDetection?serviceAccountKey=/home/user/Downloads/my-key.json") - .log("SafeSearch: ${body}") + .log("body:${body}") .to("mock:result"); -------------------------------------------------------------------------------- -The body will contain a `SafeSearchAnnotation` with likelihood ratings for adult, spoof, medical, violence, and racy content. +This operation will return a `SafeSearchAnnotation` with likelihood ratings for adult, spoof, medical, violence and racy content. -- `objectLocalization`: Detect and localize objects +- `objectLocalization`: this operation detects and localizes objects [source,java] -------------------------------------------------------------------------------- @@ -195,13 +192,13 @@ from("direct:start") exchange.getIn().setBody(imageData); }) .to("google-vision://objectLocalization?serviceAccountKey=/home/user/Downloads/my-key.json") - .log("Objects: ${body}") + .log("body:${body}") .to("mock:result"); -------------------------------------------------------------------------------- -The body will contain a `List<LocalizedObjectAnnotation>` with detected objects and their bounding polygons. +This operation will return a `List<LocalizedObjectAnnotation>` with detected objects and their bounding polygons. -- `webDetection`: Find web references and similar images +- `webDetection`: this operation finds web references and visually similar images [source,java] -------------------------------------------------------------------------------- @@ -211,11 +208,11 @@ from("direct:start") exchange.getIn().setBody(imageData); }) .to("google-vision://webDetection?serviceAccountKey=/home/user/Downloads/my-key.json") - .log("Web detection: ${body}") + .log("body:${body}") .to("mock:result"); -------------------------------------------------------------------------------- -The body will contain a `WebDetection` with matching pages, images, and best guess labels. +This operation will return a `WebDetection` with matching pages, images and best guess labels. - Using POJO request for full control: @@ -237,11 +234,11 @@ from("direct:start") exchange.getIn().setBody(request); }) .to("google-vision://labelDetection?serviceAccountKey=/home/user/Downloads/my-key.json&pojoRequest=true") - .log("Response: ${body}") + .log("body:${body}") .to("mock:result"); -------------------------------------------------------------------------------- -When using `pojoRequest=true`, the body should be a `AnnotateImageRequest` and the full `AnnotateImageResponse` is returned. +When using `pojoRequest=true`, the body should be an `AnnotateImageRequest` and the full `AnnotateImageResponse` is returned. - Overriding the operation at runtime via header: @@ -254,11 +251,9 @@ from("direct:start") exchange.getIn().setHeader(GoogleCloudVisionConstants.OPERATION, GoogleCloudVisionOperations.logoDetection); }) .to("google-vision://labelDetection?serviceAccountKey=/home/user/Downloads/my-key.json") - .log("Logos: ${body}") + .log("body:${body}") .to("mock:result"); -------------------------------------------------------------------------------- -The header `GoogleCloudVisionOperation` overrides the operation specified in the endpoint URI. - include::spring-boot:partial$starter.adoc[] diff --git a/components/camel-google/camel-google-vision/src/main/java/org/apache/camel/component/google/vision/GoogleCloudVisionConfiguration.java b/components/camel-google/camel-google-vision/src/main/java/org/apache/camel/component/google/vision/GoogleCloudVisionConfiguration.java index b5d4f96bd433..a2908d75379e 100644 --- a/components/camel-google/camel-google-vision/src/main/java/org/apache/camel/component/google/vision/GoogleCloudVisionConfiguration.java +++ b/components/camel-google/camel-google-vision/src/main/java/org/apache/camel/component/google/vision/GoogleCloudVisionConfiguration.java @@ -54,7 +54,9 @@ public class GoogleCloudVisionConfiguration implements Cloneable, GoogleCommonCo } /** - * The operation name + * Set the operation name + * + * @param operation */ public void setOperation(String operation) { this.operation = operation; @@ -67,6 +69,8 @@ public class GoogleCloudVisionConfiguration implements Cloneable, GoogleCommonCo /** * Service account key + * + * @param serviceAccountKey */ public void setServiceAccountKey(String serviceAccountKey) { this.serviceAccountKey = serviceAccountKey; @@ -78,6 +82,8 @@ public class GoogleCloudVisionConfiguration implements Cloneable, GoogleCommonCo /** * The operation to perform on the producer. + * + * @param operationType */ public void setOperationType(GoogleCloudVisionOperations operationType) { this.operationType = operationType; @@ -88,7 +94,9 @@ public class GoogleCloudVisionConfiguration implements Cloneable, GoogleCommonCo } /** - * The max number of results to return per feature type. + * Max results to return per feature type. + * + * @param maxResults */ public void setMaxResults(Integer maxResults) { this.maxResults = maxResults; @@ -100,6 +108,8 @@ public class GoogleCloudVisionConfiguration implements Cloneable, GoogleCommonCo /** * The client to use during service invocation. + * + * @param client */ public void setClient(ImageAnnotatorClient client) { this.client = client; @@ -111,6 +121,8 @@ public class GoogleCloudVisionConfiguration implements Cloneable, GoogleCommonCo /** * Configure the input type. If true the message will be POJO type. + * + * @param pojoRequest */ public void setPojoRequest(boolean pojoRequest) { this.pojoRequest = pojoRequest; diff --git a/components/camel-google/camel-google-vision/src/main/java/org/apache/camel/component/google/vision/GoogleCloudVisionEndpoint.java b/components/camel-google/camel-google-vision/src/main/java/org/apache/camel/component/google/vision/GoogleCloudVisionEndpoint.java index ad73dff6befd..d1639ade92dd 100644 --- a/components/camel-google/camel-google-vision/src/main/java/org/apache/camel/component/google/vision/GoogleCloudVisionEndpoint.java +++ b/components/camel-google/camel-google-vision/src/main/java/org/apache/camel/component/google/vision/GoogleCloudVisionEndpoint.java @@ -28,10 +28,7 @@ import org.apache.camel.support.DefaultEndpoint; import org.apache.camel.util.ObjectHelper; /** - * Analyze images using Google Cloud Vision AI - * - * Google Cloud Vision Endpoint definition represents the Vision API and contains configuration to customize the - * behavior of Producer. + * Detect labels, text, faces, logos and more on images through Google Cloud Vision API */ @UriEndpoint(firstVersion = "4.19.0", scheme = "google-vision", title = "Google Cloud Vision", syntax = "google-vision:operation", category = { @@ -66,7 +63,9 @@ public class GoogleCloudVisionEndpoint extends DefaultEndpoint implements Endpoi } /** - * Setup configuration + * Set the endpoint configuration. + * + * @param configuration */ public void setConfiguration(GoogleCloudVisionConfiguration configuration) { this.configuration = configuration; diff --git a/components/camel-google/camel-google-vision/src/main/java/org/apache/camel/component/google/vision/GoogleCloudVisionProducer.java b/components/camel-google/camel-google-vision/src/main/java/org/apache/camel/component/google/vision/GoogleCloudVisionProducer.java index 804c64d14757..0d16bc536fe3 100644 --- a/components/camel-google/camel-google-vision/src/main/java/org/apache/camel/component/google/vision/GoogleCloudVisionProducer.java +++ b/components/camel-google/camel-google-vision/src/main/java/org/apache/camel/component/google/vision/GoogleCloudVisionProducer.java @@ -32,7 +32,7 @@ import org.apache.camel.Message; import org.apache.camel.support.DefaultProducer; /** - * The GoogleCloudVision producer. + * Producer for the Google Cloud Vision component. */ public class GoogleCloudVisionProducer extends DefaultProducer { private GoogleCloudVisionEndpoint endpoint;
