= Huawei Cloud Image Recognition Component
:doctitle: Huawei Cloud Image Recognition
:shortname: hwcloud-imagerecognition
:artifactid: camel-huaweicloud-imagerecognition
:description: To identify objects, scenes, and concepts in images on Huawei Cloud
:since: 3.12
:supportlevel: Stable
:tabs-sync-option:
:component-header: Only producer is supported
//Manually maintained attributes
:group: Huawei Cloud
:camel-spring-boot-name: huaweicloud-imagerecognition

*Since Camel {since}*

*{component-header}*

Huawei Cloud Image Recognition component allows you to integrate with https://www.huaweicloud.com/intl/en-us/product/image.html[Image Recognition] provided by Huawei Cloud.

Maven users will need to add the following dependency to their `pom.xml`
for this component:

[source,xml]
------------------------------------------------------------
<dependency>
    <groupId>org.apache.camel</groupId>
    <artifactId>camel-huaweicloud-imagerecognition</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>
------------------------------------------------------------

== URI format

[source,text]
------------------------
hwcloud-imagerecognition:operation[?options]
------------------------

// component-configure options: START

// component-configure options: END

// component options: START
include::partial$component-configure-options.adoc[]
include::partial$component-endpoint-options.adoc[]
// component options: END

// endpoint options: START

// endpoint options: END

[NOTE]
====
When using imageContent option, we suggest you use RAW(image_base64_value) to avoid encoding issue.
====

== Usage

=== Message properties evaluated by the Image Recognition producer

[width="100%",cols="10%,10%,80%",options="header",]
|=======================================================================
|Header |Type |Description

|`CamelHwCloudImageContent` |`String` |The Base64 character string converted from the image

|`CamelHwCloudImageUrl` |`String` |The URL of an image

|`CamelHwCloudImageTagLimit` |`Integer` |The maximum number of the returned tags when the operation is tagRecognition

|`CamelHwCloudImageTagLanguage` |`String` |The language of the returned tags when the operation is tagRecognition

|`CamelHwCloudImageThreshold` |`Integer` |The threshold of confidence.

|=======================================================================

=== List of Supported Image Recognition Operations

- celebrityRecognition - to analyze and identify the political figures, stars and online celebrities contained in the picture, and return the person information and face coordinates
- tagRecognition - to recognize hundreds of scenes and thousands of objects and their properties in natural images

=== Inline Configuration of route

==== celebrityRecognition

Java DSL

[source,java]
----
from("direct:triggerRoute")
  .setProperty(ImageRecognitionProperties.IMAGE_URL, constant("https://xxxx"))
  .setProperty(ImageRecognitionProperties.THRESHOLD,constant(0.5))
  .to("hwcloud-imagerecognition:celebrityRecognition?accessKey=*********&secretKey=********&projectId=9071a38e7f6a4ba7b7bcbeb7d4ea6efc&region=cn-north-4")
----

XML DSL

[source,xml]
----
<route>
   <from uri="direct:triggerRoute" />
   <setProperty name="CamelHwCloudImageUrl">
      <constant>https://xxxx</constant>
   </setProperty>
   <setProperty name="CamelHwCloudImageThreshold">
      <constant>0.5</constant>
   </setProperty>
   <to uri="hwcloud-imagerecognition:celebrityRecognition?accessKey=*********&amp;secretKey=********&amp;projectId=9071a38e7f6a4ba7b7bcbeb7d4ea6efc&amp;region=cn-north-4" />
</route>
----

=== tagRecognition

Java DSL

[source,java]
----
from("direct:triggerRoute")
  .setProperty(ImageRecognitionProperties.IMAGE_CONTENT, constant("/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAA0JCgsKCA0LCgsODg0PEyAVExISEyccHhcgLikxMC4pLSwzOko+MzZGNywtQFdBRkxOUlNSMj5aYVpQYEpRUk//..."))
  .setProperty(ImageRecognitionProperties.THRESHOLD,constant(60))
  .setProperty(ImageRecognitionProperties.TAG_LANGUAGE,constant("en"))
  .setProperty(ImageRecognitionProperties.TAG_LIMIT,constant(50))
  .to("hwcloud-imagerecognition:tagRecognition?accessKey=*********&secretKey=********&projectId=9071a38e7f6a4ba7b7bcbeb7d4ea6efc&region=cn-north-4")
----

XML DSL

[source,xml]
----
<route>
    <from uri="direct:triggerRoute" />
    <setProperty name="CamelHwCloudImageContent">
        <constant>/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAA0JCgsKCA0LCgsODg0PEyAVExISEyccHhcgLikxMC4pLSwzOko+MzZGNywtQFdBRkxOUlNSMj5aYVpQYEpRUk//...</constant>
    </setProperty>
    <setProperty name="CamelHwCloudImageThreshold">
        <constant>60</constant>
    </setProperty>
    <setProperty name="CamelHwCloudImageTagLanguage">
        <constant>en</constant>
    </setProperty>
    <setProperty name="CamelHwCloudImageTagLimit">
        <constant>50</constant>
    </setProperty>
    <to uri="hwcloud-imagerecognition:tagRecognition?accessKey=*********&amp;secretKey=********&amp;projectId=9071a38e7f6a4ba7b7bcbeb7d4ea6efc&amp;region=cn-north-4" />
</route>
----


include::spring-boot:partial$starter.adoc[]
