opencv_contrib: opencv3 class TrackerSamplerPF ERROR
When i using class TrackerSamplerPF,i get this error: Error: Assertion failed (0 <= _rowRange.start && _rowRange.start <= _rowRange.end && _rowRange.end <= m.rows) this is my code:
#include "opencv2/opencv.hpp"
#include "opencv2/tracking.hpp"
using namespace cv;
using namespace std;
int main()
{
VideoCapture video("2.avi");
// Exit if video is not opened
if (!video.isOpened())
{
cout << "Could not read video file" << endl;
return 1;
}
// Read first frame
Mat frame;
bool ok = video.read(frame);
// Define initial bounding box
Rect bbox;
vector<Mat> sample;
// Uncomment the line below to select a different bounding box
bbox = selectROI(frame, false);
// Display bounding box.
rectangle(frame, bbox, Scalar(255, 0, 0), 2, 1);
imshow("Tracking", frame);
vector<Mat> sampleImg;
Mat roi = frame(bbox);
TrackerSamplerPF *PFSampler = new TrackerSamplerPF(roi);
cout << PFSampler->getClassName() << endl;
while (1)
{
Mat new_frame;
video >> new_frame;
ok = PFSampler->sampling(new_frame, bbox, sampleImg);
//bool ok = true;
if (ok)
{
//Tracking success : Draw the tracked object
for (auto elem : sampleImg)
{
imshow("Tracking1", elem);
}
rectangle(new_frame, bbox, Scalar(255, 0, 0), 2, 1);
}
else
{
//Tracking failure detected.
putText(new_frame, "Tracking failure detected", Point(100, 80), FONT_HERSHEY_SIMPLEX, 0.75, Scalar(0, 0, 255), 2);
}
imshow("Tracking", new_frame);
//Exit if ESC pressed.
int k = waitKey(33);
if (k == 27)
{
break;
}
}
return 1;
}
About this issue
- Original URL
- State: open
- Created 6 years ago
- Comments: 15 (8 by maintainers)
@shodow @berak Guys, I wrote the code a while ago and haven’t touched it since then, so it will take me some time. I will take a look and reply within 24 hours.
i could reproduce it on master:
also: https://github.com/opencv/opencv_contrib/blob/91e16573629439029cbe8fabf163406ef071cbda/modules/tracking/src/PFSolver.hpp#L56
it should better use a fixed seed (for reproducability)
@berak hi, i use this video and get the same error. the 1st bounding box is 123,87,132,176
@alalek this function(cv::getBuildInformation()) return