2014-08-04 10:52:58 -0500 answered a question calcOpticalFlowSF() doesn't respond 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/ 2014-08-04 10:34:07 -0500 commented answer how to use calcOpticalFlowSF The demo doesn't really help. No matter if I call the function with the arguments provided in the demo the function never returns. What is the time complexity for this algorithm compared to the image resolution? 2014-04-24 09:30:39 -0500 received badge ● Self-Learner (source) 2014-04-24 09:24:27 -0500 answered a question Assertion failure within findContours / _OutputArray::create Was incorrectly assuming all outputs were of cv::Mat types. Solution was to use std::vector> (or std::vector) for the contours and std::vector for the contour hierarchy. 2014-04-15 06:23:07 -0500 commented question Assertion failure within findContours / _OutputArray::create Yup! std::vector seemed to work for the contours. o.o So.. cv::Mat is interchangable with std::vector pretty much? 2014-04-15 05:48:57 -0500 commented question Assertion failure within findContours / _OutputArray::create That was the issue, yes. I was incorrectly using cv::Mat for both outputs (the contours and the hierarchy). Got it pointed out around the time you suggested the solution by my collegue/supervisor. It's interesting though that it didn't give any compilation errors. What is the relation between cv::Mat and these output data? Are they related at all? 2014-04-15 03:57:23 -0500 commented question Assertion failure within findContours / _OutputArray::create I have tried both using the output of Canny, as in the tutorial, but also the output of threshold. 2014-04-15 03:37:06 -0500 commented question Assertion failure within findContours / _OutputArray::create Yup, channels() return 1 and type() is equal to CV_8UC1, which should be correct. Edited to add it at the end of the post. 2014-04-15 03:34:39 -0500 received badge ● Editor (source) 2014-04-15 03:09:04 -0500 asked a question Assertion failure within findContours / _OutputArray::create I am currently trying to use the findContours function as presented in the tutorials. However, it fails on the assertion.. CV_Assert( i < 0 );  ..on row 1422 of matrix.cpp (based on release 248, corresponds to rows 2133 and onwards in current master branch), within the function _OutputArray::create(int, const int *, int, int, bool, int)  There are several of the same assertion querying i to be negative, even if i is not used where the program flows if I move the debug pointer beyond the assertion each time. In contours.cpp, function cv::findContours(InputOutputArray, OutputArrayOfArrays, OutputArray, int, int, Point) there is a for-loop on lines 1722 to 1730 which calls.. _contours.create((int)c->total, 1, CV_32SC2, i, true);  ..each iteration. i goes from 0 to total (amount of found contours?), triggering said assertion each time because the requested matrix-type demands it or something. allowTransposed is set to true and i is 0 or positive, making it call the specific/default constructor mentioned above. k or kind value is also set to MAT (65536) Even if I move the debug flow to skip that assertion it will fail on an assertion later on within the following line in cv::findContours: Mat ci = _contours.getMat(i);  I am guessing this means that the matrices are not created properly/as intended to be used by the findContours function. Are there any further prerequisites for the input image, or what else could be the problem? I have managed to get several other filters to work with little to no trouble compared to this (Canny, cornerHarris, threshold, etc). Input image is single-channel 1 byte per pixel (type CV_8UC1).