Vehicle Speed Estimation via Blob
<p>I have detected vehicles as a blob in OpenCV. Below is the blob.h file</p>

<pre><code>class Blob {
public:
    // member variables 
    std::vector&lt;cv::Point&gt; currentContour;
    cv::Rect currentBoundingRect;
    std::vector&lt;cv::Point&gt; centerPositions;
    double dblCurrentDiagonalSize;
    double dblCurrentAspectRatio;
    bool blnCurrentMatchFoundOrNewBlob;
    bool blnStillBeingTracked;
    int intNumOfConsecutiveFramesWithoutAMatch;
    cv::Point predictedNextPosition;
    // function prototypes 
    Blob(std::vector&lt;cv::Point&gt; _contour);
    void predictNextPosition(void);
};
</code></pre>

<p>What algorithm should I use to estimate the speed of the detected vehicle??</p>

<p>Thanks in Advance.</p>

<p><strong>UPDATE</strong></p>

<p>Here is the code I have tried to estimate the speed, but it doesn't put the text plus it crashes.</p>

<pre><code>for (auto blob : blobs) {

    if (blob.blnStillBeingTracked == true &amp;&amp; blob.centerPositions.size() &gt;= 2) {
        int prevFrameIndex = (int)blob.centerPositions.size() - 2;
        int currFrameIndex = (int)blob.centerPositions.size() - 1;
        if (blob.centerPositions[prevFrameIndex].y &gt; (intHorizontalLinePosition-50) &amp;&amp; blob.centerPositions[currFrameIndex].y &lt;= intHorizontalLinePosition) {
            int distance = blob.centerPositions[currFrameIndex].y - blob.centerPositions[0].y;
            int tickCount = cv::getTickCount();
            int time = (tickCount - blob.firstTickCount)/cv::getTickFrequency();
            int speed = distance/time;
            double dblFontScale = blobs[currFrameIndex].dblCurrentDiagonalSize / 10.0;
            int intFontThickness = (int)std::round(dblFontScale * 1.0);
            std::cout&lt;&lt;"Speed: "&lt;&lt;speed&lt;&lt;std::endl;
            cv::putText(img, std::to_string(speed), blobs[currFrameIndex].centerPositions.back(), CV_FONT_HERSHEY_SIMPLEX, dblFontScale, SCALAR_GREEN, intFontThickness);
        }

    }
}
</code></pre>