Tai-Hsu Lin | 63e1a73 | 2012-03-03 19:20:26 +0800 | [diff] [blame^] | 1 | # Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
| 2 | # Use of this source code is governed by a BSD-style license that can be |
| 3 | # found in the LICENSE file. |
| 4 | |
| 5 | import numpy as np |
| 6 | |
| 7 | # Dimension padding/unpadding function for converting points matrices to |
| 8 | # the OpenCV format (channel-based). |
| 9 | def Pad(x): |
| 10 | return np.expand_dims(x, axis=0) |
| 11 | |
| 12 | |
| 13 | def Unpad(x): |
| 14 | return np.squeeze(x) |
| 15 | |
| 16 | |
| 17 | class Pod(object): |
| 18 | '''A POD (plain-old-data) object containing arbitrary fields.''' |
| 19 | def __init__(self, **args): |
| 20 | self.__dict__.update(args) |
| 21 | |
| 22 | def __repr__(self): |
| 23 | '''Returns a representation of the object, including its properties.''' |
| 24 | return (self.__class__.__name__ + '(' + |
| 25 | ', '.join('%s=%s' % (k, v) for k, v in sorted(self.__dict__.items()) |
| 26 | if not k.startswith('_')) + ')') |