Commit f0b542d466af9be3b5186cff1d3de7778e65f251
1 parent
405bf5f3
Reduce OF mat to one channel
Showing
1 changed file
with
9 additions
and
2 deletions
openbr/plugins/opticalflow.cpp
| ... | ... | @@ -8,7 +8,7 @@ namespace br |
| 8 | 8 | |
| 9 | 9 | /*! |
| 10 | 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 | 12 | * \author Austin Blanton \cite imaus10 |
| 13 | 13 | */ |
| 14 | 14 | class OpticalFlowTransform : public UntrainableTransform |
| ... | ... | @@ -37,7 +37,14 @@ class OpticalFlowTransform : public UntrainableTransform |
| 37 | 37 | Mat nextImg = src[1]; |
| 38 | 38 | Mat flow; |
| 39 | 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 | 48 | // propagate interest points thru |
| 42 | 49 | dst.file = src.file; |
| 43 | 50 | } | ... | ... |