1 | initial version |
Not sure if this is a valid answer, but I had some problems with this function as well and took my time to do some testing on it, using just initialized cv::Mats with specified sizes and CV_8UC3 type.
What I found was that the time complexity of this function seems off the scales (at least in the CV version I am currently using). Size is the width and height of the matrix.
Size Time in Milliseconds 4 20 8 100 16 400~500 32 2100~2200
The code could be simplified to something like the following:
int size = 16;
cv::Mat lastFrame, frame, flow;
frame = cv::Mat(size, size, CV_8UC3);
frame.copyTo(lastFrame);
cv::calcOpticalFlowSF(lastFrame, frame,
flow,
3, 2, 4, 4.1, 25.5, 18, 55.0, 25.5, 0.35, 18, 55.0, 25.5, 10);
I'm guessing there is some issue with the code base, or that it was meant to be used on the GPU with parallel computing. I have tried both the calcOpticalFlowPyrLK and calcOpticalFlowFarneback methods, and they work without problems. From what I've seen this "SimpleFlow" might not be suitable for real-time analysis, but It could also be this specific implementation.
I noticed that the authors of the algorithm were talking in seconds, while using the algorithm on a GPU, which could be of relevance: http://graphics.berkeley.edu/papers/Tao-SAN-2012-05/
2 | No.2 Revision |
Not sure if this is a valid answer, but I had some problems with this function as well and took my time to do some testing on it, using just initialized cv::Mats with specified sizes and CV_8UC3 type.
What I found was that the time complexity of this function seems off the scales (at least in the CV version I am currently using). Size is the width and height of the matrix.
Size Time Time in Milliseconds
Milliseconds
4 20
20
8 100
100
16 400~500
400~500
32 2100~2200
The code could be simplified to something like the following:
int size = 16;
cv::Mat lastFrame, frame, flow;
frame = cv::Mat(size, size, CV_8UC3);
frame.copyTo(lastFrame);
cv::calcOpticalFlowSF(lastFrame, frame,
flow,
3, 2, 4, 4.1, 25.5, 18, 55.0, 25.5, 0.35, 18, 55.0, 25.5, 10);
I'm guessing there is some issue with the code base, or that it was meant to be used on the GPU with parallel computing. I have tried both the calcOpticalFlowPyrLK and calcOpticalFlowFarneback methods, and they work without problems. From what I've seen this "SimpleFlow" might not be suitable for real-time analysis, but It could also be this specific implementation.
I noticed that the authors of the algorithm were talking in seconds, while using the algorithm on a GPU, which could be of relevance: http://graphics.berkeley.edu/papers/Tao-SAN-2012-05/