-
Notifications
You must be signed in to change notification settings - Fork 0
/
face_detection.go
101 lines (87 loc) · 2.91 KB
/
face_detection.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// Copyright 2021 The Chromium OS Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
package camera
import (
"context"
"chromiumos/tast/common/camera/chart"
"chromiumos/tast/common/media/caps"
"chromiumos/tast/remote/bundles/cros/camera/camerabox"
"chromiumos/tast/remote/bundles/cros/camera/face"
"chromiumos/tast/rpc"
pb "chromiumos/tast/services/cros/camerabox"
"chromiumos/tast/testing"
)
func init() {
testing.AddTest(&testing.Test{
Func: FaceDetection,
LacrosStatus: testing.LacrosVariantUnneeded,
Desc: "Verifies face detection",
Contacts: []string{"mojahsu@chromium.org", "chromeos-camera-eng@google.com"},
Attr: []string{"group:camerabox"},
SoftwareDeps: []string{"arc", "arc_camera3", caps.BuiltinUSBCamera},
ServiceDeps: []string{"tast.cros.camerabox.HAL3Service"},
Data: []string{"its_scene2_c_20210708.png"},
Vars: []string{"chart"},
Params: []testing.Param{
{
Name: "back",
ExtraAttr: []string{"camerabox_facing_back"},
Val: pb.Facing_FACING_BACK,
},
{
Name: "front",
ExtraAttr: []string{"camerabox_facing_front"},
Val: pb.Facing_FACING_FRONT,
},
},
})
}
func FaceDetection(ctx context.Context, s *testing.State) {
d := s.DUT()
facing := s.Param().(pb.Facing)
roiSupport, err := face.CheckRoiSupport(ctx, d, facing)
if err != nil {
s.Fatal("Failed to check ROI support: ", err)
}
if !roiSupport {
s.Log("Skip this DUT, because it doesn't support roi")
return
}
var altAddr string
if chartAddr, ok := s.Var("chart"); ok {
altAddr = chartAddr
}
c, namePaths, err := chart.New(ctx, s.DUT(), altAddr, s.OutDir(), []string{s.DataPath("its_scene2_c_20210708.png")})
if err != nil {
s.Fatal("Failed to prepare chart tablet: ", err)
}
defer c.Close(ctx, s.OutDir())
if err := c.Display(ctx, namePaths[0]); err != nil {
s.Fatal("Failed to display chart on chart tablet: ", err)
}
if err := camerabox.LogTestScene(ctx, d, facing, s.OutDir()); err != nil {
s.Error("Failed to take a photo of test scene: ", err)
}
// Connect to the gRPC server on the DUT.
cl, err := rpc.Dial(ctx, d, s.RPCHint())
if err != nil {
s.Fatal("Failed to connect to the HAL3 service on the DUT: ", err)
}
defer cl.Close(ctx)
// Run remote test on DUT.
hal3Client := pb.NewHAL3ServiceClient(cl.Conn)
runTestRequest := &pb.RunTestRequest{Test: pb.HAL3CameraTest_FACE_DETECTION, Facing: facing, ExtendedParams: "3"}
response, err := hal3Client.RunTest(ctx, runTestRequest)
if err != nil {
s.Fatal("Remote call RunTest() failed: ", err)
}
// Check test result.
switch response.Result {
case pb.TestResult_TEST_RESULT_PASSED:
case pb.TestResult_TEST_RESULT_FAILED:
s.Error("Remote test failed with error message:", response.Error)
case pb.TestResult_TEST_RESULT_UNSET:
s.Error("Remote test result is unset")
}
}