def _draw_contour_impl(self, bitmap, color=None, thickness=1, config=None): if config is not None: # If a config with edges and colors is passed, make sure it is # consistent with the our set of points. self.validate(self.geometry_name(), config) # Draw edges first so that nodeas are then drawn on top. for edge in self._get_nested_or_default(config, [EDGES], []): src = self._nodes.get(edge[SRC], None) dst = self._nodes.get(edge[DST], None) if (src is not None) and (not src.disabled) and ( dst is not None) and (not dst.disabled): edge_color = edge.get(COLOR, color) cv2.line(bitmap, [src.location.col, src.location.row], [dst.location.col, dst.location.row], edge_color, thickness) nodes_config = self._get_nested_or_default(config, [NODES]) for node_id, node in self._nodes.items(): if not node.disabled: effective_color = self._get_nested_or_default( nodes_config, [node_id, COLOR], color) Point.from_json(node.location).draw(bitmap=bitmap, color=effective_color, thickness=thickness, config=None)
def test_from_json(self): packed_obj = { 'some_stuff': 'aaa', POINTS: { EXTERIOR: [[17, 3]], INTERIOR: [] } } res_point = Point.from_json(packed_obj) self.assertIsInstance(res_point, Point) self.assertEqual(res_point.row, 3) self.assertEqual(res_point.col, 17)