@@ -19,7 +19,70 @@ import (
19
19
segment "go.viam.com/rdk/vision/segmentation"
20
20
)
21
21
22
- func TestTransformSegmenter (t * testing.T ) {
22
+ func TestTransformSegmenterProps (t * testing.T ) {
23
+ r := & inject.Robot {}
24
+ cam := & inject.Camera {}
25
+ vizServ := & inject.VisionService {}
26
+
27
+ cam .StreamFunc = func (ctx context.Context ,
28
+ errHandlers ... gostream.ErrorHandler ,
29
+ ) (gostream.MediaStream [image.Image ], error ) {
30
+ return & streamTest {}, nil
31
+ }
32
+ cam .PropertiesFunc = func (ctx context.Context ) (camera.Properties , error ) {
33
+ return camera.Properties {}, nil
34
+ }
35
+
36
+ r .ResourceByNameFunc = func (n resource.Name ) (resource.Resource , error ) {
37
+ switch n .Name {
38
+ case "fakeCamera" :
39
+ return cam , nil
40
+ case "fakeVizService" :
41
+ return vizServ , nil
42
+ default :
43
+ return nil , resource .NewNotFoundError (n )
44
+ }
45
+ }
46
+
47
+ transformConf := & transformConfig {
48
+ Source : "fakeCamera" ,
49
+ Pipeline : []Transformation {
50
+ {
51
+ Type : "segmentations" , Attributes : utils.AttributeMap {
52
+ "segmenter_name" : "fakeVizService" ,
53
+ },
54
+ },
55
+ },
56
+ }
57
+
58
+ am := transformConf .Pipeline [0 ].Attributes
59
+ conf , err := resource.TransformAttributeMap [* segmenterConfig ](am )
60
+ test .That (t , err , test .ShouldBeNil )
61
+ _ , err = conf .Validate ("path" )
62
+ test .That (t , err , test .ShouldBeNil )
63
+
64
+ _ , err = newTransformPipeline (context .Background (), cam , transformConf , r )
65
+ test .That (t , err , test .ShouldBeNil )
66
+
67
+ transformConf = & transformConfig {
68
+ Pipeline : []Transformation {
69
+ {
70
+ Type : "segmentations" , Attributes : utils.AttributeMap {},
71
+ },
72
+ },
73
+ }
74
+
75
+ am = transformConf .Pipeline [0 ].Attributes
76
+ conf , err = resource.TransformAttributeMap [* segmenterConfig ](am )
77
+ test .That (t , err , test .ShouldBeNil )
78
+ _ , err = conf .Validate ("path" )
79
+ test .That (t , err , test .ShouldNotBeNil )
80
+ }
81
+
82
+ func TestTransformSegmenterFunctionality (t * testing.T ) {
83
+ // TODO(RSDK-1200): remove skip when complete
84
+ t .Skip ("remove skip once RSDK-1200 improvement is complete" )
85
+
23
86
r := & inject.Robot {}
24
87
cam := & inject.Camera {}
25
88
vizServ := & inject.VisionService {}
@@ -85,12 +148,6 @@ func TestTransformSegmenter(t *testing.T) {
85
148
},
86
149
}
87
150
88
- am := transformConf .Pipeline [0 ].Attributes
89
- conf , err := resource.TransformAttributeMap [* segmenterConfig ](am )
90
- test .That (t , err , test .ShouldBeNil )
91
- _ , err = conf .Validate ("path" )
92
- test .That (t , err , test .ShouldBeNil )
93
-
94
151
pipeline , err := newTransformPipeline (context .Background (), cam , transformConf , r )
95
152
test .That (t , err , test .ShouldBeNil )
96
153
@@ -103,18 +160,4 @@ func TestTransformSegmenter(t *testing.T) {
103
160
test .That (t , isValid , test .ShouldBeTrue )
104
161
_ , isValid = pc .At (0 , 1 , 0 )
105
162
test .That (t , isValid , test .ShouldBeTrue )
106
-
107
- transformConf = & transformConfig {
108
- Pipeline : []Transformation {
109
- {
110
- Type : "segmentations" , Attributes : utils.AttributeMap {},
111
- },
112
- },
113
- }
114
-
115
- am = transformConf .Pipeline [0 ].Attributes
116
- conf , err = resource.TransformAttributeMap [* segmenterConfig ](am )
117
- test .That (t , err , test .ShouldBeNil )
118
- _ , err = conf .Validate ("path" )
119
- test .That (t , err , test .ShouldNotBeNil )
120
163
}
0 commit comments