According to the matlab code of Deqing Sun and c++ source code of Daniel Scharstein Contact: dqsun@cs.brown.edu Contact: schar@middlebury.edu
(filename, uv)
| 19 | DEVICE = 'cuda' if torch.cuda.is_available() else 'cpu' |
| 20 | |
| 21 | def writeFlowFile(filename, uv): |
| 22 | """ |
| 23 | According to the matlab code of Deqing Sun and c++ source code of Daniel Scharstein |
| 24 | Contact: dqsun@cs.brown.edu |
| 25 | Contact: schar@middlebury.edu |
| 26 | """ |
| 27 | TAG_STRING = np.array(202021.25, dtype=np.float32) |
| 28 | if uv.shape[2] != 2: |
| 29 | sys.exit("writeFlowFile: flow must have two bands!") |
| 30 | H = np.array(uv.shape[0], dtype=np.int32) |
| 31 | W = np.array(uv.shape[1], dtype=np.int32) |
| 32 | with open(filename, 'wb') as f: |
| 33 | f.write(TAG_STRING.tobytes()) |
| 34 | f.write(W.tobytes()) |
| 35 | f.write(H.tobytes()) |
| 36 | f.write(uv.tobytes()) |
| 37 | |
| 38 | |
| 39 | def load_image(imfile, resolution=None): |