Middleburyis that everyone who studies the optical flow algorithm cannot use the site,MiddleburyA number of standard test libraries are provided, which greatly advances the optical flow algorithm. Middleburyprovides a standard library whose computed optical stream is saved in the suffix named. Floof the file,Middleburyitself also provides the read. Floin the fileC + +Source code andMatlabsource code. However, the source code is written withOpenCVThe form of the combination is what we expect more, and the following I write read and write. Flothe source code of the document. Relative toMiddleburyGiven the source code, more concise and understandable.
#include "ccc/comcv.h" #include <fstream>void writeflow (mat_<point2f> &flow, String outpath) {Ofstream Out (Outpath, ios_base::binary); string tag = "Pieh";//File Flag Out.write (Tag.c_str (), tag.size ()); Out.write ((const char*) ( &flow.cols), sizeof (int)),///number of rows Out.write ((const char*) (&flow.rows), sizeof (int)),//column number for (int i = 0; i < Flow.rows; i++) for (int j = 0; J < Flow.cols; J + +) {Out.write ((const char*) (&flow (i, J). x), sizeof (float)), Out.write ((const CHA r*) (&flow (i, J). Y), sizeof (float));}} void Readflow (mat_<point2f> &flow, string path) {Ifstream in (path, ios_base::binary); string tag (4, ' 0 ');// File Flags In.read ((char*) Tag.data (), 4), int rows, Cols;in.read ((char*) (&cols), sizeof (int)),//number of Rows In.read ((char*) ( &rows), sizeof (int)),///Number of columns flow.create (rows, cols), for (int i = 0; i < flow.rows; i++) for (int j = 0; J < Flow.col S J + +) {In.read ((char*) (& (Flow (i, J). x), sizeof (float)), In.read ((char*) (& (Flow (i, j). Y), sizeof (float));}}
Optical flow algorithm: About OpenCV Read/write Middlebury The code for the given optical stream of the site
Optical Flow algorithm: code for OPENCV read-write Middlebury Web site given optical flow