1 | initial version |
If you have :
Ptr<Tracker> tracker = TrackerGOTURN::create();
.....
tracker->init(img,r);
then when you call init method model goturn.prototxt is loaded here and goturn.caffemodel is loaded here. File are loaded using ifstream. I don't know linux but I think it is default directory where is your executable file.
You can check using a ifstream at the beginning of your program and try to load goturn.prototxt
2 | No.2 Revision |
If you have :
Ptr<Tracker> tracker = TrackerGOTURN::create();
.....
tracker->init(img,r);
then when you call init method model goturn.prototxt is loaded here and goturn.caffemodel is loaded here. File are loaded using ifstream. I don't know linux but I think it is default directory where is your executable file.
You can check using a ifstream at the beginning of your program and try to load goturn.prototxt
When file problem is solved may be you will get this error.
3 | No.3 Revision |
If you have :
Ptr<Tracker> tracker = TrackerGOTURN::create();
.....
tracker->init(img,r);
then when you call init method model goturn.prototxt is loaded here and goturn.caffemodel is loaded here. File are loaded using ifstream. I don't know linux but I think it is default directory where is your executable file.
You can check using a ifstream at the beginning of your program and try to load goturn.prototxt
When file problem is solved may be you will get this error.
my basic program to test :
#include <opencv2/opencv.hpp>
#include "opencv2/opencv_modules.hpp"
#include <opencv2/tracking.hpp>
using namespace cv;
using namespace std;
struct ParamRect {
int rctEnCours;
Rect r;
Mat img;
Mat result;
String nomFenetre;
};
void DefRectangle(int event, int x, int y, int flags, void *userData)
{
ParamRect *pgc = (ParamRect*)userData;
if (pgc->img.empty())
return;
if (flags == EVENT_FLAG_LBUTTON)
{
if (pgc->rctEnCours == 0)
{
pgc->r.x = x;
pgc->r.y = y;
pgc->r.width = 0;
pgc->r.height = 0;
pgc->rctEnCours = 1;
}
else if (pgc->rctEnCours == 1)
{
Point tl = pgc->r.tl(), br = pgc->r.br();
if (x != pgc->r.x)
{
if (x < pgc->r.x)
{
pgc->r.x = x;
pgc->r.width = br.x - x - 1;
}
else
pgc->r.width = x - tl.x - 1;
}
if (y != pgc->r.y)
{
if (y < pgc->r.y)
{
pgc->r.y = y;
pgc->r.height = br.y - y - 1;
}
else
pgc->r.height = y - tl.y - 1;
}
if (pgc->r.br().x > pgc->img.size().width)
{
pgc->r.width = pgc->img.size().width - pgc->r.x;
}
if (pgc->r.br().y > pgc->img.size().height)
{
pgc->r.height = pgc->img.size().height - pgc->r.y;
}
}
}
if (event == EVENT_LBUTTONUP && pgc->rctEnCours == 1)
{
pgc->rctEnCours = 0;
}
if ((flags&EVENT_FLAG_LBUTTON) != 0 && (flags & EVENT_FLAG_CTRLKEY) != 0)
{
pgc->r.x = x;
pgc->r.y = y;
}
Mat img = pgc->img.clone();
rectangle(img, pgc->r, Scalar(0, 255, 0), 2);
imshow(pgc->nomFenetre, img );
waitKey(10);
}
int main()
{
{
std::ifstream fs("goturn.prototxt", std::ifstream::in);
if (fs.is_open())
cout << "WIN";
else
cout << "LOST";
}
Ptr<Tracker> tracker = TrackerGOTURN::create();
// Open the video file
VideoCapture capture("g:/lib/opencv/samples/data/Megamind.avi");
if (!capture.isOpened())
return 1;
bool stop(false);
ParamRect pgc;
pgc.rctEnCours = 0;
Mat frame; //current video frame
pgc.img=frame;
pgc.nomFenetre = "Extracted Frame";
namedWindow(pgc.nomFenetre);
int delay = 10;
setMouseCallback(pgc.nomFenetre, DefRectangle, &pgc);
cout << capture.get(CV_CAP_PROP_FPS);
// capture.set(CV_CAP_PROP_POS_AVI_RATIO, 0.5);
pgc.r= Rect(200, 150, 40, 40);
int i=0;
capture >> pgc.img;
capture >> pgc.img;
capture >> pgc.img;
tracker->init(pgc.img,pgc.r);
Rect2d r;
int code = 0;
while (code != 'g')
{
code =waitKey();
}
while (!stop)
{
capture>>pgc.img;
if (tracker->update(pgc.img, r))
{
rectangle(pgc.img, r, Scalar(0, 0, 255), 2, 1);
imshow(pgc.nomFenetre, pgc.img);
}
code = waitKey(delay);
if (pgc.img.empty())
stop = true;
}
waitKey();
}
4 | No.4 Revision |
If you have :
Ptr<Tracker> tracker = TrackerGOTURN::create();
.....
tracker->init(img,r);
then when you call init method model goturn.prototxt is loaded here and goturn.caffemodel is loaded here. File are loaded using ifstream. I don't know linux but I think it is default directory where is your executable file.
You can check using a ifstream at the beginning of your program and try to load goturn.prototxt
When file problem is solved may be you will get this error.
my basic program to test :
#include <opencv2/opencv.hpp>
#include "opencv2/opencv_modules.hpp"
#include <opencv2/tracking.hpp>
using namespace cv;
using namespace std;
struct ParamRect {
int rctEnCours;
Rect r;
Mat img;
Mat result;
String nomFenetre;
};
void DefRectangle(int event, int x, int y, int flags, void *userData)
{
ParamRect *pgc = (ParamRect*)userData;
if (pgc->img.empty())
return;
if (flags == EVENT_FLAG_LBUTTON)
{
if (pgc->rctEnCours == 0)
{
pgc->r.x = x;
pgc->r.y = y;
pgc->r.width = 0;
pgc->r.height = 0;
pgc->rctEnCours = 1;
}
else if (pgc->rctEnCours == 1)
{
Point tl = pgc->r.tl(), br = pgc->r.br();
if (x != pgc->r.x)
{
if (x < pgc->r.x)
{
pgc->r.x = x;
pgc->r.width = br.x - x - 1;
}
else
pgc->r.width = x - tl.x - 1;
}
if (y != pgc->r.y)
{
if (y < pgc->r.y)
{
pgc->r.y = y;
pgc->r.height = br.y - y - 1;
}
else
pgc->r.height = y - tl.y - 1;
}
if (pgc->r.br().x > pgc->img.size().width)
{
pgc->r.width = pgc->img.size().width - pgc->r.x;
}
if (pgc->r.br().y > pgc->img.size().height)
{
pgc->r.height = pgc->img.size().height - pgc->r.y;
}
}
}
if (event == EVENT_LBUTTONUP && pgc->rctEnCours == 1)
{
pgc->rctEnCours = 0;
}
if ((flags&EVENT_FLAG_LBUTTON) != 0 && (flags & EVENT_FLAG_CTRLKEY) != 0)
{
pgc->r.x = x;
pgc->r.y = y;
}
Mat img = pgc->img.clone();
rectangle(img, pgc->r, Scalar(0, 255, 0), 2);
imshow(pgc->nomFenetre, img );
waitKey(10);
}
int main()
{
{
std::ifstream fs("goturn.prototxt", std::ifstream::in);
if (fs.is_open())
cout << "WIN";
else
cout << "LOST";
}
Ptr<Tracker> tracker = TrackerGOTURN::create();
// Open the video file
VideoCapture capture("g:/lib/opencv/samples/data/Megamind.avi");
if (!capture.isOpened())
return 1;
bool stop(false);
ParamRect pgc;
pgc.rctEnCours = 0;
Mat frame; //current video frame
pgc.img=frame;
pgc.nomFenetre = "Extracted Frame";
namedWindow(pgc.nomFenetre);
int delay = 10;
setMouseCallback(pgc.nomFenetre, DefRectangle, &pgc);
cout << capture.get(CV_CAP_PROP_FPS);
// capture.set(CV_CAP_PROP_POS_AVI_RATIO, 0.5);
pgc.r= Rect(200, 150, 40, 40);
int i=0;
capture >> pgc.img;
capture >> pgc.img;
capture >> pgc.img;
tracker->init(pgc.img,pgc.r);
Rect2d r;
int code = 0;
while (code != 'g')
{
capture >> pgc.img;
Mat img = pgc.img.clone();
rectangle(img, pgc.r, Scalar(0, 255, 0), 2);
imshow(pgc.nomFenetre, img);
code =waitKey();
}
=waitKey(10);
}
tracker->init(pgc.img,pgc.r);
while (!stop)
{
capture>>pgc.img;
if (tracker->update(pgc.img, r))
{
rectangle(pgc.img, r, Scalar(0, 0, 255), 2, 1);
imshow(pgc.nomFenetre, pgc.img);
}
code = waitKey(delay);
if (pgc.img.empty())
stop = true;
}
waitKey();
}
5 | No.5 Revision |
If you have :
Ptr<Tracker> tracker = TrackerGOTURN::create();
.....
tracker->init(img,r);
then when you call init method model goturn.prototxt is loaded here and goturn.caffemodel is loaded here. File are loaded using ifstream. I don't know linux but I think it is default directory where is your executable file.
You can check using a ifstream at the beginning of your program and try to load goturn.prototxt
When file problem is solved may be you will get this error.
my basic program to test :
#include <opencv2/opencv.hpp>
#include "opencv2/opencv_modules.hpp"
#include <opencv2/tracking.hpp>
using namespace cv;
using namespace std;
struct ParamRect {
int rctEnCours;
Rect r;
Mat img;
Mat result;
String nomFenetre;
};
void DefRectangle(int event, int x, int y, int flags, void *userData)
{
ParamRect *pgc = (ParamRect*)userData;
if (pgc->img.empty())
return;
if (flags == EVENT_FLAG_LBUTTON)
{
if (pgc->rctEnCours == 0)
{
pgc->r.x = x;
pgc->r.y = y;
pgc->r.width = 0;
pgc->r.height = 0;
pgc->rctEnCours = 1;
}
else if (pgc->rctEnCours == 1)
{
Point tl = pgc->r.tl(), br = pgc->r.br();
if (x != pgc->r.x)
{
if (x < pgc->r.x)
{
pgc->r.x = x;
pgc->r.width = br.x - x - 1;
}
else
pgc->r.width = x - tl.x - 1;
}
if (y != pgc->r.y)
{
if (y < pgc->r.y)
{
pgc->r.y = y;
pgc->r.height = br.y - y - 1;
}
else
pgc->r.height = y - tl.y - 1;
}
if (pgc->r.br().x > pgc->img.size().width)
{
pgc->r.width = pgc->img.size().width - pgc->r.x;
}
if (pgc->r.br().y > pgc->img.size().height)
{
pgc->r.height = pgc->img.size().height - pgc->r.y;
}
}
}
if (event == EVENT_LBUTTONUP && pgc->rctEnCours == 1)
{
pgc->rctEnCours = 0;
}
if ((flags&EVENT_FLAG_LBUTTON) != 0 && (flags & EVENT_FLAG_CTRLKEY) != 0)
{
pgc->r.x = x;
pgc->r.y = y;
}
}
int main()
{
{
std::ifstream fs("goturn.prototxt", std::ifstream::in);
if (fs.is_open())
cout << "WIN";
else
cout << "LOST";
}
Ptr<Tracker> tracker = TrackerGOTURN::create();
// Open the video file
VideoCapture capture("g:/lib/opencv/samples/data/Megamind.avi");
if (!capture.isOpened())
return 1;
bool stop(false);
ParamRect pgc;
pgc.rctEnCours = 0;
Mat frame; //current video frame
pgc.img=frame;
pgc.nomFenetre = "Extracted Frame";
namedWindow(pgc.nomFenetre);
int delay = 10;
setMouseCallback(pgc.nomFenetre, DefRectangle, &pgc);
cout << capture.get(CV_CAP_PROP_FPS);
// capture.set(CV_CAP_PROP_POS_AVI_RATIO, 0.5);
pgc.r= Rect(200, 150, 40, 40);
int i=0;
Rect2d r;
int code = 0;
capture >> pgc.img;
capture >> pgc.img;
capture >> pgc.img;
while (code != 'g')
{
capture >> pgc.img;
Mat img = pgc.img.clone();
rectangle(img, pgc.r, Scalar(0, 255, 0), 2);
imshow(pgc.nomFenetre, img);
code =waitKey(10);
}
tracker->init(pgc.img,pgc.r);
while (!stop)
{
capture>>pgc.img;
if (tracker->update(pgc.img, r))
{
rectangle(pgc.img, r, Scalar(0, 0, 255), 2, 1);
imshow(pgc.nomFenetre, pgc.img);
}
code = waitKey(delay);
if (pgc.img.empty())
stop = true;
}
waitKey();
}