(size, box)
| 16 | |
| 17 | |
| 18 | def convert(size, box): |
| 19 | dw = 1. / (size[0]) |
| 20 | dh = 1. / (size[1]) |
| 21 | x = box[0] + box[2] / 2.0 |
| 22 | y = box[1] + box[3] / 2.0 |
| 23 | w = box[2] |
| 24 | h = box[3] |
| 25 | |
| 26 | x = x * dw |
| 27 | w = w * dw |
| 28 | y = y * dh |
| 29 | h = h * dh |
| 30 | return (x, y, w, h) |
| 31 | |
| 32 | |
| 33 | if __name__ == '__main__': |