Ch9 farnebackTracker.cpp calcOpticalFlowFarneback(...) has memory error
vk8051 opened this issue · 1 comments
vk8051 commented
Ch9
farnebackTracker.cpp
// Calculate optical flow map using Farneback algorithm
calcOpticalFlowFarneback(prevGray, curGray, flowImage, pyrScale, numLevels, windowSize, numIterations, neighborhoodSize, stdDeviation, OPTFLOW_USE_INITIAL_FLOW);
has memory error
CrazyKnightGR commented
The author forgot to initiate flowImage as CV_32FC2 type, adding the following solves the problem:
flowImage = Mat::zeros(frame.size(), CV_32FC2);
// Calculate optical flow map using Farneback algorithm
calcOpticalFlowFarneback(prevGray, curGray, flowImage, pyrScale, windowSize, numIterations,
neighborhoodSize, stdDeviation, OPTFLOW_USE_INITIAL_FLOW);