@@ -97,6 +97,22 @@ The high-level steps involved in liveness orchestration are illustrated below:
97
97
98
98
#### [Java](#tab/java)
99
99
```java
100
+ String endpoint = System .getenv (" VISION_ENDPOINT" );
101
+ String accountKey = System .getenv (" VISION_KEY" );
102
+
103
+ FaceSessionClient sessionClient = new FaceSessionClientBuilder ()
104
+ .endpoint (endpoint )
105
+ .credential (new AzureKeyCredential (accountKey ))
106
+ .buildClient ();
107
+
108
+ CreateLivenessSessionContent parameters = new CreateLivenessSessionContent (LivenessOperationMode .PASSIVE )
109
+ .setDeviceCorrelationId (" 723d6d03-ef33-40a8-9682-23a1feb7bccd" )
110
+ .setSendResultsToClient (false );
111
+
112
+ CreateLivenessSessionResult creationResult = sessionClient .createLivenessSession (parameters );
113
+ System .out .println (" Session created." );
114
+ System .out .println (" Session id: " + creationResult .getSessionId ());
115
+ System .out .println (" Auth token: " + creationResult .getAuthToken ());
100
116
```
101
117
102
118
#### [Python](#tab/python)
@@ -195,6 +211,16 @@ The high-level steps involved in liveness orchestration are illustrated below:
195
211
196
212
#### [Java](#tab/java)
197
213
```java
214
+ LivenessSession sessionResult = sessionClient .getLivenessSessionResult (creationResult .getSessionId ());
215
+ System .out .println (" Session id: " + sessionResult .getId ());
216
+ System .out .println (" Session status: " + sessionResult .getStatus ());
217
+ System .out .println (" Liveness detection request id: " + sessionResult .getResult ().getRequestId ());
218
+ System .out .println (" Liveness detection received datetime: " + sessionResult .getResult ().getReceivedDateTime ());
219
+ System .out .println (" Liveness detection decision: " + sessionResult .getResult ().getResponse ().getBody ().getLivenessDecision ());
220
+ System .out .println (" Session created datetime: " + sessionResult .getCreatedDateTime ());
221
+ System .out .println (" Auth token TTL (seconds): " + sessionResult .getAuthTokenTimeToLiveInSeconds ());
222
+ System .out .println (" Session expired: " + sessionResult .isSessionExpired ());
223
+ System .out .println (" Device correlation id: " + sessionResult .getDeviceCorrelationId ());
198
224
```
199
225
200
226
#### [Python](#tab/python)
@@ -284,6 +310,8 @@ The high-level steps involved in liveness orchestration are illustrated below:
284
310
285
311
#### [Java](#tab/java)
286
312
```java
313
+ sessionClient .deleteLivenessSession (creationResult .getSessionId ());
314
+ System .out .println (" The session " + creationResult .getSessionId () + " is deleted." );
287
315
```
288
316
289
317
#### [Python](#tab/python)
@@ -354,6 +382,28 @@ The high-level steps involved in liveness with verification orchestration are il
354
382
355
383
#### [Java](#tab/java)
356
384
```java
385
+ String endpoint = System .getenv (" VISION_ENDPOINT" );
386
+ String accountKey = System .getenv (" VISION_KEY" );
387
+
388
+ FaceSessionClient sessionClient = new FaceSessionClientBuilder ()
389
+ .endpoint (endpoint )
390
+ .credential (new AzureKeyCredential (accountKey ))
391
+ .buildClient ();
392
+
393
+ CreateLivenessSessionContent parameters = new CreateLivenessSessionContent (LivenessOperationMode .PASSIVE )
394
+ .setDeviceCorrelationId (" 723d6d03-ef33-40a8-9682-23a1feb7bccd" )
395
+ .setSendResultsToClient (false );
396
+
397
+ Path path = Paths .get (" test.png" );
398
+ BinaryData data = BinaryData .fromFile (path );
399
+ CreateLivenessWithVerifySessionResult creationResult = sessionClient .createLivenessWithVerifySession (parameters , data );
400
+
401
+ System .out .println (" Session created." );
402
+ System .out .println (" Session id: " + creationResult .getSessionId ());
403
+ System .out .println (" Auth token: " + creationResult .getAuthToken ());
404
+ System .out .println (" The reference image:" );
405
+ System .out .println (" Face rectangle: " + creationResult .getVerifyImage ().getFaceRectangle ().getTop () + " " + creationResult .getVerifyImage ().getFaceRectangle ().getLeft () + " " + creationResult .getVerifyImage ().getFaceRectangle ().getWidth () + " " + creationResult .getVerifyImage ().getFaceRectangle ().getHeight ());
406
+ System .out .println (" The quality for recognition: " + creationResult .getVerifyImage ().getQualityForRecognition ());
357
407
```
358
408
359
409
#### [Python](#tab/python)
@@ -456,6 +506,18 @@ The high-level steps involved in liveness with verification orchestration are il
456
506
457
507
#### [Java](#tab/java)
458
508
```java
509
+ LivenessWithVerifySession sessionResult = sessionClient .getLivenessWithVerifySessionResult (creationResult .getSessionId ());
510
+ System .out .println (" Session id: " + sessionResult .getId ());
511
+ System .out .println (" Session status: " + sessionResult .getStatus ());
512
+ System .out .println (" Liveness detection request id: " + sessionResult .getResult ().getRequestId ());
513
+ System .out .println (" Liveness detection received datetime: " + sessionResult .getResult ().getReceivedDateTime ());
514
+ System .out .println (" Liveness detection decision: " + sessionResult .getResult ().getResponse ().getBody ().getLivenessDecision ());
515
+ System .out .println (" Verification result: " + sessionResult .getResult ().getResponse ().getBody ().getVerifyResult ().isIdentical ());
516
+ System .out .println (" Verification confidence: " + sessionResult .getResult ().getResponse ().getBody ().getVerifyResult ().getMatchConfidence ());
517
+ System .out .println (" Session created datetime: " + sessionResult .getCreatedDateTime ());
518
+ System .out .println (" Auth token TTL (seconds): " + sessionResult .getAuthTokenTimeToLiveInSeconds ());
519
+ System .out .println (" Session expired: " + sessionResult .isSessionExpired ());
520
+ System .out .println (" Device correlation id: " + sessionResult .getDeviceCorrelationId ());
459
521
```
460
522
461
523
#### [Python](#tab/python)
@@ -551,6 +613,8 @@ The high-level steps involved in liveness with verification orchestration are il
551
613
552
614
#### [Java](#tab/java)
553
615
```java
616
+ sessionClient .deleteLivenessWithVerifySession (creationResult .getSessionId ());
617
+ System .out .println (" The session " + creationResult .getSessionId () + " is deleted." );
554
618
```
555
619
556
620
#### [Python](#tab/python)
0 commit comments