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)
| 27 | |
| 28 | |
| 29 | def writeFlowFile(filename, uv): |
| 30 | """ |
| 31 | According to the matlab code of Deqing Sun and c++ source code of Daniel Scharstein |
| 32 | Contact: dqsun@cs.brown.edu |
| 33 | Contact: schar@middlebury.edu |
| 34 | """ |
| 35 | TAG_STRING = np.array(202021.25, dtype=np.float32) |
| 36 | if uv.shape[2] != 2: |
| 37 | sys.exit("writeFlowFile: flow must have two bands!"); |
| 38 | H = np.array(uv.shape[0], dtype=np.int32) |
| 39 | W = np.array(uv.shape[1], dtype=np.int32) |
| 40 | with open(filename, 'wb') as f: |
| 41 | f.write(TAG_STRING.tobytes()) |
| 42 | f.write(W.tobytes()) |
| 43 | f.write(H.tobytes()) |
| 44 | f.write(uv.tobytes()) |
| 45 | |
| 46 | |
| 47 | def load_dict(filename_): |