Skip to content

opencv3 class TrackerSamplerPF ERROR #1866

@shodow

Description

@shodow

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;
}

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