@@ -20,11 +20,11 @@ public class TargetListTargetData extends TargetData {
2020 static final int DATA_LENGTH = 5 ;
2121
2222 /**
23- * A <code>List</code> containing all < code>Target</code> instances identified by the
23+ * A <code>List</code> containing all {@ code Rect} instances identified by the
2424 * <code>TargetListPipeline</code>.
2525 */
2626 @ NotNull
27- public final List <Target > targets ;
27+ public final List <Rect > targets ;
2828
2929 /**
3030 * Constructs and initializes an invalid <code>TargetListTargetData</code> with no id, serial 0,
@@ -43,7 +43,7 @@ public TargetListTargetData() {
4343 * @param targets the list of <code>Target</code> instances identified.
4444 */
4545 public TargetListTargetData (
46- @ NotNull String id , int serial , boolean valid , @ NotNull List <Target > targets ) {
46+ @ NotNull String id , int serial , boolean valid , @ NotNull List <Rect > targets ) {
4747 super (id , serial , valid );
4848 this .targets = targets ;
4949 }
@@ -80,112 +80,6 @@ public String toString() {
8080 return "TargetListTargetData{" + "targets=" + targets + "} " + super .toString ();
8181 }
8282
83- /**
84- * A <code>Target</code> represents a single target returned in a <code>TargetListTargetData</code>.
85- */
86- public static class Target {
87-
88- /**
89- * Top left corner <code>Point</code> of the upright bounding box enclosing this target.
90- */
91- @ NotNull
92- public final Point topLeft ;
93- /**
94- * Bottom right corner <code>Point</code> of the upright bounding box enclosing this target.
95- */
96- @ NotNull
97- public final Point bottomRight ;
98- /**
99- * Center <code>Point</code> of the upright bounding box enclosing this target.
100- */
101- @ NotNull
102- public final Point center ;
103- /**
104- * Gets the area of the contour enclosing the target.
105- */
106- public final int contourArea ;
107-
108- /**
109- * Constructs and initializes a <code>Target</code> with the specified values.
110- *
111- * @param topLeft the top left corner of the bounding box enclosing this target.
112- * @param bottomRight the top left corner of the bounding box enclosing this target.
113- * @param center the center of the bounding box enclosing this target.
114- * @param contourArea the area of the contour enclosing the target.
115- */
116- public Target (
117- @ NotNull Point topLeft ,
118- @ NotNull Point bottomRight ,
119- @ NotNull Point center ,
120- int contourArea ) {
121- this .topLeft = topLeft ;
122- this .bottomRight = bottomRight ;
123- this .center = center ;
124- this .contourArea = contourArea ;
125- }
126-
127- /**
128- * Gets the area of the upright bounding box surrounding this target.
129- *
130- * @return the area of the bounding box.
131- */
132- public int area () {
133- return width () * height ();
134- }
135-
136- /**
137- * Gets the width of the upright bounding box surrounding this target.
138- *
139- * @return the width of the bounding box.
140- */
141- public int width () {
142- return bottomRight .x - topLeft .x ;
143- }
144-
145- /**
146- * Gets the height of the upright bounding box surrounding this target.
147- *
148- * @return the height of the bounding box.
149- */
150- public int height () {
151- return bottomRight .y - topLeft .y ;
152- }
153-
154- @ Override
155- public boolean equals (Object o ) {
156- if (this == o ) {
157- return true ;
158- }
159- if (o == null || getClass () != o .getClass ()) {
160- return false ;
161- }
162- Target target = (Target ) o ;
163- return contourArea == target .contourArea
164- && topLeft .equals (target .topLeft )
165- && bottomRight .equals (target .bottomRight )
166- && center .equals (target .center );
167- }
168-
169- @ Override
170- public int hashCode () {
171- return Objects .hash (topLeft , bottomRight , center , contourArea );
172- }
173-
174- @ Override
175- public String toString () {
176- return "Target{"
177- + "topLeft="
178- + topLeft
179- + ", bottomRight="
180- + bottomRight
181- + ", center="
182- + center
183- + ", contourArea="
184- + contourArea
185- + '}' ;
186- }
187- }
188-
18983 private static class JsonAdapterImpl implements DeadeyeJsonAdapter <TargetListTargetData > {
19084
19185 // json d field: bb.tl().x, bb.tl().y, bb.br().x, bb.br().y, center.x, center.y
@@ -197,7 +91,7 @@ public TargetListTargetData fromJson(BufferedSource source) throws IOException {
19791 String id = null ;
19892 int serial = -1 ;
19993 boolean valid = false ;
200- List <Target > targets = new ArrayList <>();
94+ List <Rect > targets = new ArrayList <>();
20195
20296 reader .beginObject ();
20397 while (reader .hasNext ()) {
@@ -223,8 +117,7 @@ public TargetListTargetData fromJson(BufferedSource source) throws IOException {
223117 // bb.x, bb.y, bb.width, bb.height, area
224118 Point topLeft = new Point (data [0 ], data [1 ]);
225119 Point bottomRight = new Point (data [0 ] + data [2 ], data [1 ] + data [3 ]);
226- Point center = Point .boundingBoxCenterFrom (topLeft , bottomRight );
227- targets .add (new Target (topLeft , bottomRight , center , data [4 ]));
120+ targets .add (new Rect (topLeft , bottomRight ));
228121 }
229122 reader .endArray ();
230123 break ;
@@ -246,11 +139,11 @@ public String toJson(TargetListTargetData targetData) throws IOException {
246139 writer .name ("v" ).value (targetData .valid );
247140
248141 writer .name ("d" ).beginArray ();
249- for (Target t : targetData .targets ) {
142+ for (Rect t : targetData .targets ) {
250143 writer .beginArray ();
251144 writer .value (t .topLeft .x ).value (t .topLeft .y );
252145 writer .value (t .width ()).value (t .height ());
253- writer .value (t . contourArea );
146+ writer .value (0 ); // contour area not in Rect
254147 writer .endArray ();
255148 }
256149 writer .endArray ();
0 commit comments