Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8063333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:59:43+00:00 2026-06-05T10:59:43+00:00

I’m trying to use cv::calcOpticalFlowPyrLK but sometimes an internal assertion in that function fails.

  • 0

I’m trying to use cv::calcOpticalFlowPyrLK but sometimes an internal assertion in that function fails. The assertion is npoints = prevPtsMat.checkVector(2, CV_32F, true)) >= 0. I’m using OpenCV 2.3.1. The source code for this function is available here.

It’s hard to wrap my head around their code, especially because of my limited experience with computer graphics and their lack of comments. Why is this assertion being triggered and what does it say about my problem?

Edit: I call the function as follows:

cv::calcOpticalFlowPyrLK(curBwFrame, prvFrame, features, newFeatures, trackingStatus, errors);

I found out that the features vector, which was obtained by calling cv::goodFeaturesToTrack(curBwFrame, features, 5, 0.2, 0.5, skinMask); with a non-empty mask that appears to be sufficiently big and a valid image, doesn’t contain any features. How can this happen?

curBwFrame

curBwFrame

skinMask

skinMask

I’m able to reproduce the problem using the following code snippet:

#include <vector>
#include <cassert>
#include <opencv2\opencv.hpp>
using std::vector;
using namespace cv;

int main() {
    vector<Point2f> features;
    cv::Mat curBwFrame = imread("curBwFrame.png");
    cv::cvtColor(curBwFrame, curBwFrame, CV_RGB2GRAY);
    imwrite("test.png", curBwFrame);

    cv::Mat skinMask = imread("skinMask.png");
    cv::cvtColor(skinMask, skinMask, CV_RGB2GRAY);
    imwrite("test.png", skinMask);

    cv::goodFeaturesToTrack(curBwFrame, features, 5, 0.2, 0.5, skinMask);
    assert(features.size() > 0);

    return 0;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T10:59:45+00:00Added an answer on June 5, 2026 at 10:59 am

    The main problem are your parameters.In the OpenCV 2.3.2 documentation (no compatibility change between 2.3.1) this is the description of the method parameters:

    void goodFeaturesToTrack(InputArray image, OutputArray corners, int maxCorners, double qualityLevel, double minDistance, InputArray mask=noArray(), int blockSize=3, bool useHarrisDetector=false, double k=0.04 )
    

    Parameters:

    • image – Input 8-bit or floating-point 32-bit, single-channel image.
    • corners – Output vector of detected corners.
    • maxCorners – Maximum number of corners to return. If there are more
      corners than are found, the strongest of them is returned.
    • qualityLevel – Parameter characterizing the minimal accepted quality
      of image corners. The parameter value is multiplied by the best
      corner quality measure, which is the minimal eigenvalue (see
      cornerMinEigenVal() ) or the Harris function response (see
      cornerHarris() ). The corners with the quality measure less than the
      product are rejected. For example, if the best corner has the quality
      measure = 1500, and the qualityLevel=0.01 , then all the corners with
      the quality measure less than 15 are rejected.
    • minDistance – Minimum possible Euclidean distance between the
      returned corners.
    • mask – Optional region of interest. If the image is not empty (it
      needs to have the type CV_8UC1 and the same size as image ), it
      specifies the region in which the corners are detected.
    • blockSize – Size of an average block for computing a derivative
      covariation matrix over each pixel neighborhood. See
      cornerEigenValsAndVecs() .
    • useHarrisDetector – Parameter indicating whether to use a Harris
      detector (see cornerHarris()) or cornerMinEigenVal().
    • k – Free parameter of the Harris detector.

    I recommend you to play a little with qualityLevel and minDistance to suffice your needs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I want to construct a data frame in an Rcpp function, but when I
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
Basically, what I'm trying to create is a page of div tags, each has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.