Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

calcOpticalFlowPyrLK segmentation fault

Hi!

I am using the calcOpticalFlowPyrLK in combination with object detection.

But sometimes this function causes a segmentation fault. I still don't figure it out why.

It happens often in the third or forth step of the loop So:

  1. Detect and get points to track

  2. Calculate the flow and get new points P_new

  3. Use p_new to calculate the next points in the next frame.

I am using it with a webcam such that each 5. Frame the object will be detected and then tracked for the next 4 frames

I already checked that the points which I pass to the function are not empty

The frames are not empty as well.

The error and status a configurares like in the example

But still it causes an segmentation fault.

Does anybody what could cause the seg fault?

calcOpticalFlowPyrLK segmentation fault

Hi!

I am using the calcOpticalFlowPyrLK in combination with object detection.

But sometimes this function causes a segmentation fault. I still don't figure it out why.

It happens often in the third or forth step of the loop So:

  1. Detect and get points to track

  2. Calculate the flow and get new points P_new

  3. Use p_new to calculate the next points in the next frame.

I am using it with a webcam such that each 5. Frame the object will be detected and then tracked for the next 4 frames

I already checked that the points which I pass to the function are not empty

The frames are not empty as well.

The error and status a configurares like in the example

But still it causes an segmentation fault.

Does anybody what could cause the seg fault?

There is no error message. It just crashes

    auto & prev = track->prev_points;

​ auto & cur = track->cur_points; ​ auto & orig = track->orig_points; ​ std::vector<cv::point2f> curP; //cur.clear(); ​

    std::vector<uchar> status;

​ std::vector<float> err; ​ try{

        cv::calcOpticalFlowPyrLK(lastFrame,currentFrame, track->prev_points,track->cur_points,status,err);
    }   
    catch(cv::Exception& e ){

​ const char* err_msg = e.what(); std::cerr << "exception caught: " << err_msg << std::endl; }

    size_t i,  k ;

​ auto it_1 = cur.begin(); auto it_2 = prev.begin(); auto it_3 = orig.begin();

    for (i = k = 0; i < cur.size(); i++)
    {

        if (!status[i])
            continue;

​ cur[k] = cur[i] ; std::cerr << cur[k] <<std::endl; prev[k]="prev[i];" orig[k]="orig[i];" k++;="" }="" ​<="" p="">

    cur.resize(k);
    prev.resize(k);
    orig.resize(k);


     prev = cur;
click to hide/show revision 3
None

updated 2018-03-21 07:31:14 -0600

berak gravatar image

calcOpticalFlowPyrLK segmentation fault

Hi!

I am using the calcOpticalFlowPyrLK in combination with object detection.

But sometimes this function causes a segmentation fault. I still don't figure it out why.

It happens often in the third or forth step of the loop So:

  1. Detect and get points to track

  2. Calculate the flow and get new points P_new

  3. Use p_new to calculate the next points in the next frame.

I am using it with a webcam such that each 5. Frame the object will be detected and then tracked for the next 4 frames

I already checked that the points which I pass to the function are not empty

The frames are not empty as well.

The error and status a configurares like in the example

But still it causes an segmentation fault.

Does anybody what could cause the seg fault?

There is no error message. It just crashes

  auto & prev = track->prev_points;

​ auto & cur = track->cur_points; auto & orig = track->orig_points; ​ std::vector<cv::point2f> ​ std::vector<cv::Point2f> curP; //cur.clear();

     std::vector<uchar> status;

​ std::vector<float> err; ​ try{

        try{

            cv::calcOpticalFlowPyrLK(lastFrame,currentFrame, track->prev_points,track->cur_points,status,err);
     }   
     catch(cv::Exception& e ){

​ const char* err_msg = e.what(); std::cerr << "exception caught: " << err_msg << std::endl; }

     size_t i,  k ;

​ auto it_1 = cur.begin(); auto it_2 = prev.begin(); auto it_3 = orig.begin();

orig.begin();

        for (i = k = 0; i < cur.size(); i++)
     {

         if (!status[i])
             continue;

​ cur[k] = cur[i] ; std::cerr << cur[k] <<std::endl; prev[k]="prev[i];" orig[k]="orig[i];" k++;="" }="" ​<="" p="">

<<std::endl;
            prev[k] = prev[i];
            orig[k] = orig[i];
            k++;
        }
        cur.resize(k);
     prev.resize(k);
     orig.resize(k);
       prev = cur;