Commit f0b542d466af9be3b5186cff1d3de7778e65f251

Authored by Austin Blanton
1 parent 405bf5f3

Reduce OF mat to one channel

openbr/plugins/opticalflow.cpp
@@ -8,7 +8,7 @@ namespace br @@ -8,7 +8,7 @@ namespace br
8 8
9 /*! 9 /*!
10 * \ingroup transforms 10 * \ingroup transforms
11 - * \brief Gets a two-channel dense optical flow from two images 11 + * \brief Gets a one-channel dense optical flow from two images
12 * \author Austin Blanton \cite imaus10 12 * \author Austin Blanton \cite imaus10
13 */ 13 */
14 class OpticalFlowTransform : public UntrainableTransform 14 class OpticalFlowTransform : public UntrainableTransform
@@ -37,7 +37,14 @@ class OpticalFlowTransform : public UntrainableTransform @@ -37,7 +37,14 @@ class OpticalFlowTransform : public UntrainableTransform
37 Mat nextImg = src[1]; 37 Mat nextImg = src[1];
38 Mat flow; 38 Mat flow;
39 calcOpticalFlowFarneback(prevImg, nextImg, flow, pyr_scale, levels, winsize, iterations, poly_n, poly_sigma, flags); 39 calcOpticalFlowFarneback(prevImg, nextImg, flow, pyr_scale, levels, winsize, iterations, poly_n, poly_sigma, flags);
40 - dst += flow; 40 +
  41 + // the result is two channels
  42 + std::vector<Mat> channels(2);
  43 + split(flow, channels);
  44 + Mat flowOneCh;
  45 + magnitude(channels[0], channels[1], flowOneCh);
  46 +
  47 + dst += flowOneCh;
41 // propagate interest points thru 48 // propagate interest points thru
42 dst.file = src.file; 49 dst.file = src.file;
43 } 50 }