From f0b542d466af9be3b5186cff1d3de7778e65f251 Mon Sep 17 00:00:00 2001 From: Austin Blanton Date: Mon, 29 Jul 2013 16:16:34 -0400 Subject: [PATCH] Reduce OF mat to one channel --- openbr/plugins/opticalflow.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/openbr/plugins/opticalflow.cpp b/openbr/plugins/opticalflow.cpp index 7f085f3..17382d9 100644 --- a/openbr/plugins/opticalflow.cpp +++ b/openbr/plugins/opticalflow.cpp @@ -8,7 +8,7 @@ namespace br /*! * \ingroup transforms - * \brief Gets a two-channel dense optical flow from two images + * \brief Gets a one-channel dense optical flow from two images * \author Austin Blanton \cite imaus10 */ class OpticalFlowTransform : public UntrainableTransform @@ -37,7 +37,14 @@ class OpticalFlowTransform : public UntrainableTransform Mat nextImg = src[1]; Mat flow; calcOpticalFlowFarneback(prevImg, nextImg, flow, pyr_scale, levels, winsize, iterations, poly_n, poly_sigma, flags); - dst += flow; + + // the result is two channels + std::vector channels(2); + split(flow, channels); + Mat flowOneCh; + magnitude(channels[0], channels[1], flowOneCh); + + dst += flowOneCh; // propagate interest points thru dst.file = src.file; } -- libgit2 0.21.4