Random scaling.
(bbox, sf, imgwidth, imght, train)
| 13 | |
| 14 | |
| 15 | def box_transform(bbox, sf, imgwidth, imght, train): |
| 16 | """Random scaling.""" |
| 17 | width = bbox[2] - bbox[0] |
| 18 | ht = bbox[3] - bbox[1] |
| 19 | if train: |
| 20 | scaleRate = 0.25 * np.clip(np.random.randn() * sf, - sf, sf) |
| 21 | |
| 22 | bbox[0] = max(0, bbox[0] - width * scaleRate / 2) |
| 23 | bbox[1] = max(0, bbox[1] - ht * scaleRate / 2) |
| 24 | bbox[2] = min(imgwidth, bbox[2] + width * scaleRate / 2) |
| 25 | bbox[3] = min(imght, bbox[3] + ht * scaleRate / 2) |
| 26 | else: |
| 27 | scaleRate = 0.25 |
| 28 | |
| 29 | bbox[0] = max(0, bbox[0] - width * scaleRate / 2) |
| 30 | bbox[1] = max(0, bbox[1] - ht * scaleRate / 2) |
| 31 | bbox[2] = min(imgwidth, max( |
| 32 | bbox[2] + width * scaleRate / 2, bbox[0] + 5)) |
| 33 | bbox[3] = min(imght, max(bbox[3] + ht * scaleRate / 2, bbox[1] + 5)) |
| 34 | |
| 35 | return bbox |
| 36 | |
| 37 | |
| 38 | def addDPG(bbox, imgwidth, imght): |
nothing calls this directly
no outgoing calls
no test coverage detected