Skip to content

sometimes camshfit get the invalid width of return (RotatedRect)  #9152

Closed

Description

@vvck
System information (version)
  • OpenCV = 3.2:
  • Operating System / Platform = win 10:
  • Compiler = vs2013
Detailed description

sometimes when you use camshift to get the rectangle of object,you may get a invaild value of the rectangle's width,the vaule is -1.#IND. Obviously,there is some wrong with it.

when i view the source code of camshift, i find the place that the wrong may be happen.
file: sources\modules\video\src\camshift.cpp
line:171
code:
double width = std::sqrt( rotate_c * inv_m00 ) * 4;

if we put a negative number in sqrt , the return must be -1.#IND.
first inv_m00 can't be a negative number, because m00 is determined in line 150,
so the only mistake should be rotate_c .
i can't find out the reason can cause this situation,but if we can judge the rotate_c is a negative number may fix it.

Activity

  1. sovrasov commented on Jul 13, 2017

    @sovrasov
    Contributor

    @vvck this bug is probably hard to reproduce since nobody report it before. Could you please share a test video?

  2. vvck commented on Jul 14, 2017

    @vvck
    Author

    @sovrasov sorry, I tested the example used camera directly, so I don't have the video which use to reproduce the bug.
    as you say, this bug is hard to find, I will try my best to reproduce it and write the video file at same time.

  3. vvck commented on Jul 14, 2017

    @vvck
    Author

    @sovrasov the video had been saved, but It's size is up to 270MB. How can i send to you? email or other ways?

  4. sovrasov commented on Jul 14, 2017

    @sovrasov
    Contributor

    You can upload it to google drive.

  5. vvck commented on Jul 17, 2017

    @vvck
    Author

    @sovrasov Sorry, Because of the GWF, I can't visit google driver.

  6. sturkmen72 commented on Oct 15, 2017

    @sturkmen72
    Contributor

    maybe this will be helpful to reproduce the bug ( i can provide some more images if needed )

    bug

    #include "opencv2/video/tracking.hpp"
    #include "opencv2/imgproc.hpp"
    #include "opencv2/highgui.hpp"
    
    #include <iostream>
    
    using namespace cv;
    using namespace std;
    
    int main( int /*argc*/, const char** /*argv*/ )
    {
        Rect trackWindow(60, 73, 33, 25);
        Mat backproj = imread("31584749-c8af30c8-b1bc-11e7-819a-5df38eb141ee.png", -1);
                                                                 
        RotatedRect trackBox = CamShift(backproj, trackWindow,
            TermCriteria(TermCriteria::EPS | TermCriteria::COUNT, 10, 1));
        cout << trackBox.size;
    
        return 0;
    }
    

    output trackBox.size
    [-nan(ind) x 2.4574]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions