= Huawei Cloud Face Recognition Service (FRS) Component
:doctitle: Huawei Cloud Face Recognition Service (FRS)
:shortname: hwcloud-frs
:artifactid: camel-huaweicloud-frs
:description: Face Recognition Service (FRS) is an intelligent service that uses computers to process, analyze, and understand facial images based on human facial features.
:since: 3.15
:supportlevel: Stable
:tabs-sync-option:
:component-header: Only producer is supported
//Manually maintained attributes
:group: Huawei Cloud
:camel-spring-boot-name: huaweicloud-frs

*Since Camel {since}*

*{component-header}*

Huawei Cloud Face Recognition Service component allows you to integrate with https://support.huaweicloud.com/intl/en-us/productdesc-face/face_01_0001.html[Face Recognition Service] 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-frs</artifactId>
    <version>x.x.x</version>
    <!-- use the same version as your Camel core version -->
</dependency>
------------------------------------------------------------

== URI format

[source,text]
------------------------
hwcloud-frs: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 imageBase64 or videoBase64 option, we suggest you use RAW(base64_value) to avoid encoding issue.
====

== Usage

=== Message properties evaluated by the Face Recognition Service producer

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

|`CamelHwCloudFrsImageBase64` |`String` |The Base64 character string converted from an image. This property can be used when the operation is faceDetection or faceVerification.

|`CamelHwCloudFrsImageUrl` |`String` |The URL of an image. This property can be used when the operation is faceDetection or faceVerification.

|`CamelHwCloudFrsImageFilePath` |`String` |The local file path of an image. This property can be used when the operation is faceDetection or faceVerification.

|`CamelHwCloudFrsAnotherImageBase64` |`String` |The Base64 character string converted from another image. This property can be used when the operation is faceVerification.

|`CamelHwCloudFrsAnotherImageUrl` |`String` |The URL of another image. This property can be used when the operation is faceVerification.

|`CamelHwCloudFrsAnotherImageFilePath` |`String` |The local file path of another image. This property can be used when the operation is faceVerification.

|`CamelHwCloudFrsVideoBase64` |`String` |The Base64 character string converted from a video. This property can be used when the operation is faceLiveDetection.

|`CamelHwCloudFrsVideoUrl` |`String` |The URL of a video. This property can be used when the operation is faceLiveDetection.

|`CamelHwCloudFrsVideoFilePath` |`String` |The local file path of a video. This property can be used when the operation is faceLiveDetection.

|`CamelHwCloudFrsVideoActions` |`String` |The action code sequence list. This property can be used when the operation is faceLiveDetection.

|`CamelHwCloudFrsVideoActionTimes` |`String` |The action time array. This property is used when the operation is faceLiveDetection.

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

=== List of Supported Operations

- faceDetection - detect, locate, and analyze the face in an input image, and output the key facial points and attributes.
- faceVerification - compare two faces to verify whether they belong to the same person and return the confidence level
- faceLiveDetection - determine whether a person in a video is alive by checking whether the person's actions in the video are consistent with those in the input action list

=== Inline Configuration of route

==== faceDetection

Java DSL

[source,java]
----
from("direct:triggerRoute")
  .setProperty(FaceRecognitionProperties.FACE_IMAGE_URL, constant("https://xxxx"))
  .to("hwcloud-frs:faceDetection?accessKey=*********&secretKey=********&projectId=9071a38e7f6a4ba7b7bcbeb7d4ea6efc&region=cn-north-4")
----

XML DSL

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

=== faceVerification

Java DSL

[source,java]
----
from("direct:triggerRoute")
  .setProperty(FaceRecognitionProperties.FACE_IMAGE_BASE64, constant("/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAA0JCgsKCA0LCgsODg0PEyAVExISEyccHhcgLikxMC4pLSwzOko+MzZGNywtQFdBRkxOUlNSMj5aYVpQYEpRUk..."))
  .setProperty(FaceRecognitionProperties.ANOTHER_FACE_IMAGE_BASE64, constant("/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgFBgcGBQgHBgcJCAgJDBMMDAsLDBgREg4THBgdHRsYGxofIywlHyEqIRobJjQnKi4vMTIxHiU2Os..."))
  .to("hwcloud-frs:faceVerification?accessKey=*********&secretKey=********&projectId=9071a38e7f6a4ba7b7bcbeb7d4ea6efc&region=cn-north-4")
----

XML DSL

[source,xml]
----
<route>
    <from uri="direct:triggerRoute" />
    <setProperty name="CamelHwCloudFrsImageBase64">
        <constant>/9j/4AAQSkZJRgABAQEASABIAAD/2wBDAA0JCgsKCA0LCgsODg0PEyAVExISEyccHhcgLikxMC4pLSwzOko+MzZGNywtQFdBRkxOUlNSMj5aYVpQYEpRUk...</constant>
    </setProperty>
    <setProperty name="CamelHwCloudFrsAnotherImageBase64">
        <constant>/9j/4AAQSkZJRgABAQAAAQABAAD/2wBDAAgFBgcGBQgHBgcJCAgJDBMMDAsLDBgREg4THBgdHRsYGxofIywlHyEqIRobJjQnKi4vMTIxHiU2Os...</constant>
    </setProperty>
    <to uri="hwcloud-frs:faceVerification?accessKey=*********&amp;secretKey=********&amp;projectId=9071a38e7f6a4ba7b7bcbeb7d4ea6efc&amp;region=cn-north-4" />
</route>
----

=== faceLiveDetection

Java DSL

[source,java]
----
from("direct:triggerRoute")
  .setProperty(FaceRecognitionProperties.FACE_VIDEO_FILE_PATH, constant("/tmp/video.mp4"))
  .setProperty(FaceRecognitionProperties.FACE_VIDEO_ACTIONS, constant("1,3,2"))
  .to("hwcloud-frs:faceLiveDetection?accessKey=*********&secretKey=********&projectId=9071a38e7f6a4ba7b7bcbeb7d4ea6efc&region=cn-north-4")
----

XML DSL

[source,xml]
----
<route>
    <from uri="direct:triggerRoute" />
    <setProperty name="CamelHwCloudFrsVideoFilePath">
        <constant>/tmp/video.mp4</constant>
    </setProperty>
    <setProperty name="CamelHwCloudFrsVideoActions">
        <constant>1,3,2</constant>
    </setProperty>
    <to uri="hwcloud-frs:faceLiveDetection?accessKey=*********&amp;secretKey=********&amp;projectId=9071a38e7f6a4ba7b7bcbeb7d4ea6efc&amp;region=cn-north-4" />
</route>
----

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