Optical Flow algorithm: code for OPENCV read-write Middlebury Web site given optical flow

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.