Skip to content

Commit

Permalink
one total execution time is enough
Browse files Browse the repository at this point in the history
  • Loading branch information
danielchristianschroeter committed Jul 3, 2024
1 parent 7d46de9 commit cb25600
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 21 deletions.
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,14 @@ You can request trial access on https://bwsportal.bioid.com/register
2. Execute following command to perform a photo verify with two images:

```
.\BioIDWebService-PhotoVerify-gRPC-Sample-In-Go.exe -BWSClientID <BWSClientID> -BWSKey <BWSKey> -photo example_images\photo.jpg -image1 example_images\testimage1.jpg -image2 example_images\testimage2.jpg
.\BioIDWebService-PhotoVerify-gRPC-Sample-In-Go -BWSClientID <BWSClientID> -BWSKey <BWSKey> -photo example_images\photo.jpg -image1 example_images\testimage1.jpg -image2 example_images\testimage2.jpg
```

Example Output:

```
Token generation took: 0s
Client creation took: 519.8µs
File reading took: 536.2µs
Photo verification took: 921.5775ms
Total execution time: 954.999ms
Verification Status: SUCCEEDED
Verification Errors: [error_code:"RejectedByPassiveLiveDetection" message:"At least one of the live images seem not to be recorded from a live person." error_code:"RejectedByPassiveLiveDetection" message:"At least one of the live images seem not to be recorded from a live person."]
Verification ImageProperties: [faces:{left_eye:{x:716.6898478956991 y:295.90328987385425} right_eye:{x:583.7671688344084 y:295.6642189519129} texture_liveness_score:0.36677824126349556} faces:{left_eye:{x:493.984682522074 y:253.9819667801256} right_eye:{x:382.02615043197886 y:250.22897896148734} texture_liveness_score:0.46766824192470974}]
Expand All @@ -33,7 +31,6 @@ Verification Level: NOT_RECOGNIZED
Verification Score: 0
Verification Live: false
Verification LivenessScore: 0.46766824192470974
Total execution time: 923.6721ms
```

### Available command line parameter
Expand Down
20 changes: 5 additions & 15 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ func init() {
}

func main() {
startTime := time.Now() // Record the start time of the entire process
log.SetFlags(0)

flag.Usage = func() {
Expand All @@ -101,24 +100,19 @@ func main() {
log.Fatal("Usage: -BWSClientID <BWSClientID> -BWSKey <BWSKey> -photo <photo> -image1 <image1> [-image2 <image2>]")
}

tokenStart := time.Now() // Measure time to generate the token
startTime := time.Now() // Record the start time of the entire process

token, err := generateToken(BWSClientID, BWSKey, 5)
if err != nil {
log.Fatalf("Failed to generate token: %v", err)
}
tokenDuration := time.Since(tokenStart)
fmt.Printf("Token generation took: %v\n", tokenDuration)

clientCreationStart := time.Now() // Measure time to create the authenticated client

conn, client, err := createAuthenticatedClient()
if err != nil {
log.Fatalf("Failed to create client: %v", err)
}
defer conn.Close()
clientCreationDuration := time.Since(clientCreationStart)
fmt.Printf("Client creation took: %v\n", clientCreationDuration)

fileReadStart := time.Now() // Measure time to read all files
var wg sync.WaitGroup
wg.Add(2)
if image2Path != "" {
Expand All @@ -135,7 +129,6 @@ func main() {
}

wg.Wait()
fmt.Printf("File reading took: %v\n", time.Since(fileReadStart))

if err1 != nil {
log.Fatalf("Failed to read live image 1: %v", err1)
Expand All @@ -158,18 +151,17 @@ func main() {
request.LiveImages = append(request.LiveImages, &pb.ImageData{Image: liveImage2})
}

photoVerifyStart := time.Now() // Measure time to verify photo
ctx := context.Background()
ctx = metadata.AppendToOutgoingContext(ctx, "authorization", "Bearer "+token)

response, err := client.PhotoVerify(ctx, request)
if err != nil {
log.Fatalf("Failed to verify photo: %v", err)
}
photoVerifyDuration := time.Since(photoVerifyStart)
fmt.Printf("Photo verification took: %v\n", photoVerifyDuration)

// Print the results
fmt.Printf("Total execution time: %v\n", time.Since(startTime)) // Print the total execution time
fmt.Println()
fmt.Printf("Verification Status: %v\n", response.Status)
fmt.Printf("Verification Errors: %v\n", response.Errors)
fmt.Printf("Verification ImageProperties: %v\n", response.ImageProperties)
Expand All @@ -178,6 +170,4 @@ func main() {
fmt.Printf("Verification Score: %v\n", response.VerificationScore)
fmt.Printf("Verification Live: %v\n", response.Live)
fmt.Printf("Verification LivenessScore: %v\n", response.LivenessScore)

fmt.Printf("Total execution time: %v\n", time.Since(startTime)) // Print the total execution time
}

0 comments on commit cb25600

Please sign in to comment.