Merge pull request #899 from mshabunin:pr718
commit
88742e0ea7
15 changed files with 1521 additions and 190 deletions
@ -0,0 +1,107 @@ |
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2014, Itseez Inc, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Itseez Inc or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_DATASETS_TRACK_ALOV_HPP |
||||
#define OPENCV_DATASETS_TRACK_ALOV_HPP |
||||
|
||||
#include <string> |
||||
#include <vector> |
||||
|
||||
#include "opencv2/datasets/dataset.hpp" |
||||
#include "opencv2/datasets/util.hpp" |
||||
|
||||
using namespace std; |
||||
|
||||
namespace cv |
||||
{ |
||||
namespace datasets |
||||
{ |
||||
|
||||
//! @addtogroup datasets_track
|
||||
//! @{
|
||||
|
||||
struct TRACK_alovObj : public Object |
||||
{ |
||||
int id; |
||||
std::string imagePath; |
||||
vector <Point2f> gtbb; |
||||
}; |
||||
|
||||
const string sectionNames[] = { "01-Light", "02-SurfaceCover", "03-Specularity", "04-Transparency", "05-Shape", "06-MotionSmoothness", "07-MotionCoherence", |
||||
"08-Clutter", "09-Confusion", "10-LowContrast", "11-Occlusion", "12-MovingCamera", "13-ZoomingCamera", "14-LongDuration" }; |
||||
|
||||
const int sectionSizes[] = { 33, 15, 18, 20, 24, 22, 12, 15, 37, 23, 34, 22, 29, 10 }; |
||||
|
||||
class CV_EXPORTS TRACK_alov : public Dataset |
||||
{ |
||||
public: |
||||
static Ptr<TRACK_alov> create(); |
||||
|
||||
virtual void load(const std::string &path) = 0; |
||||
|
||||
//Load only frames with annotations (~every 5-th frame)
|
||||
virtual void loadAnnotatedOnly(const std::string &path) = 0; |
||||
|
||||
virtual int getDatasetsNum() = 0; |
||||
|
||||
virtual int getDatasetLength(int id) = 0; |
||||
|
||||
virtual bool initDataset(int id) = 0; |
||||
|
||||
virtual bool getNextFrame(Mat &frame) = 0; |
||||
virtual vector <Point2f> getNextGT() = 0; |
||||
|
||||
//Get frame/GT by datasetID (1..N) frameID (1..K)
|
||||
virtual bool getFrame(Mat &frame, int datasetID, int frameID) = 0; |
||||
virtual vector <Point2f> getGT(int datasetID, int frameID) = 0; |
||||
|
||||
protected: |
||||
vector <vector <Ptr<TRACK_alovObj> > > data; |
||||
int activeDatasetID; |
||||
int frameCounter; |
||||
}; |
||||
|
||||
//! @}
|
||||
|
||||
} |
||||
} |
||||
|
||||
#endif |
@ -0,0 +1,384 @@ |
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2014, Itseez Inc, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Itseez Inc or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "opencv2/datasets/track_alov.hpp" |
||||
|
||||
#include <sys/stat.h> |
||||
#include <opencv2/core.hpp> |
||||
#include <opencv2/highgui.hpp> |
||||
|
||||
using namespace std; |
||||
|
||||
namespace cv |
||||
{ |
||||
namespace datasets |
||||
{ |
||||
|
||||
class TRACK_alovImpl : public TRACK_alov |
||||
{ |
||||
public: |
||||
//Constructor
|
||||
TRACK_alovImpl() |
||||
{ |
||||
activeDatasetID = 1; |
||||
frameCounter = 0; |
||||
} |
||||
//Destructor
|
||||
virtual ~TRACK_alovImpl() {} |
||||
|
||||
//Load Dataset
|
||||
virtual void load(const string &path); |
||||
virtual void loadAnnotatedOnly(const std::string &path); |
||||
|
||||
protected: |
||||
virtual int getDatasetsNum(); |
||||
|
||||
virtual int getDatasetLength(int id); |
||||
|
||||
virtual bool initDataset(int id); |
||||
|
||||
virtual bool getNextFrame(Mat &frame); |
||||
virtual bool getFrame(Mat &frame, int datasetID, int frameID); |
||||
|
||||
virtual vector <Point2f> getNextGT(); |
||||
virtual vector <Point2f> getGT(int datasetID, int frameID); |
||||
|
||||
void loadDataset(const string &path); |
||||
void loadDatasetAnnotatedOnly(const string &path); |
||||
|
||||
string fullFramePath(string rootPath, int sectionID, int videoID, int frameID); |
||||
string fullAnnoPath(string rootPath, int sectionID, int videoID); |
||||
}; |
||||
|
||||
|
||||
void TRACK_alovImpl::load(const string &path) |
||||
{ |
||||
loadDataset(path); |
||||
} |
||||
|
||||
void TRACK_alovImpl::loadAnnotatedOnly(const string &path) |
||||
{ |
||||
loadDatasetAnnotatedOnly(path); |
||||
} |
||||
|
||||
string TRACK_alovImpl::fullFramePath(string rootPath, int sectionID, int videoID, int frameID) |
||||
{ |
||||
string out; |
||||
char videoNum[9]; |
||||
sprintf(videoNum, "%u", videoID+1); |
||||
char frameNum[9]; |
||||
sprintf(frameNum, "%u", frameID); |
||||
out = rootPath + "/imagedata++/" + sectionNames[sectionID] + "/" + sectionNames[sectionID] + "_video"; |
||||
|
||||
for (unsigned int i = 0; i < 5 - strlen(videoNum); ++i) |
||||
{ |
||||
out += "0"; |
||||
} |
||||
|
||||
out += videoNum; |
||||
out += "/"; |
||||
|
||||
for (unsigned int i = 0; i < 8 - strlen(frameNum); ++i) |
||||
{ |
||||
out += "0"; |
||||
} |
||||
|
||||
out += frameNum; |
||||
out += ".jpg"; |
||||
return out; |
||||
} |
||||
|
||||
string TRACK_alovImpl::fullAnnoPath(string rootPath, int sectionID, int videoID) |
||||
{ |
||||
string out; |
||||
char videoNum[9]; |
||||
sprintf(videoNum, "%u", videoID+1); |
||||
out = rootPath + "/alov300++_rectangleAnnotation_full/" + sectionNames[sectionID] + "/" + sectionNames[sectionID] + "_video"; |
||||
|
||||
for (unsigned int i = 0; i < 5 - strlen(videoNum); ++i) |
||||
{ |
||||
out += "0"; |
||||
} |
||||
|
||||
out += videoNum; |
||||
out += ".ann"; |
||||
return out; |
||||
} |
||||
|
||||
inline bool fileExists(const std::string& name) |
||||
{ |
||||
struct stat buffer; |
||||
return (stat(name.c_str(), &buffer) == 0); |
||||
} |
||||
|
||||
void TRACK_alovImpl::loadDataset(const string &rootPath) |
||||
{ |
||||
vector <int> datasetsLengths; |
||||
|
||||
printf("ALOV300++ Dataset Initialization...\n"); |
||||
|
||||
//Load frames
|
||||
//Loop for all sections of ALOV300++ (14 sections)
|
||||
for (int i = 0; i < 14; i++) |
||||
{ |
||||
//Loop for all videos in section
|
||||
for (int k = 0; k < sectionSizes[i]; k++) |
||||
{ |
||||
vector <Ptr<TRACK_alovObj> > objects; |
||||
|
||||
//Make a list of datasets lengths
|
||||
int currFrameID = 0; |
||||
|
||||
for (;;) |
||||
{ |
||||
currFrameID++; |
||||
string fullPath = fullFramePath(rootPath, i, k, currFrameID); |
||||
if (!fileExists(fullPath)) |
||||
break; |
||||
|
||||
//Make ALOV300++ Object
|
||||
Ptr<TRACK_alovObj> currObj(new TRACK_alovObj); |
||||
currObj->imagePath = fullPath; |
||||
currObj->id = currFrameID; |
||||
|
||||
currObj->gtbb.push_back(Point2d(0, 0)); |
||||
currObj->gtbb.push_back(Point2d(0, 0)); |
||||
currObj->gtbb.push_back(Point2d(0, 0)); |
||||
currObj->gtbb.push_back(Point2d(0, 0)); |
||||
|
||||
//Add object to storage
|
||||
objects.push_back(currObj); |
||||
|
||||
} |
||||
|
||||
datasetsLengths.push_back(currFrameID - 1); |
||||
data.push_back(objects); |
||||
} |
||||
} |
||||
|
||||
//Load annotations
|
||||
//Loop for all sections of ALOV300++ (14 sections)
|
||||
int currDatasetID = 0; |
||||
for (int i = 0; i < 14; i++) |
||||
{ |
||||
//Loop for all videos in section
|
||||
for (int k = 0; k < sectionSizes[i]; k++) |
||||
{ |
||||
currDatasetID++; |
||||
|
||||
//Open dataset's ground truth (annotation) file
|
||||
string annoPath = fullAnnoPath(rootPath, i, k); |
||||
ifstream annoList(annoPath.c_str()); |
||||
if (!annoList.is_open()) |
||||
{ |
||||
printf("Error: Can't open annotation file *.ANN!!!\n"); |
||||
break; |
||||
} |
||||
|
||||
//Ground Truth data
|
||||
int n = 0; |
||||
double x1 = 0, y1 = 0, |
||||
x2 = 0, y2 = 0, |
||||
x3 = 0, y3 = 0, |
||||
x4 = 0, y4 = 0; |
||||
|
||||
do |
||||
{ |
||||
//Make ALOV300++ Object
|
||||
string tmp; |
||||
|
||||
getline(annoList, tmp); |
||||
std::istringstream in(tmp); |
||||
in >> n >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4; |
||||
|
||||
Ptr<TRACK_alovObj> currObj = data[currDatasetID-1][n-1]; |
||||
|
||||
currObj->gtbb.clear(); |
||||
currObj->gtbb.push_back(Point2d(x1, y1)); |
||||
currObj->gtbb.push_back(Point2d(x2, y2)); |
||||
currObj->gtbb.push_back(Point2d(x3, y3)); |
||||
currObj->gtbb.push_back(Point2d(x4, y4)); |
||||
|
||||
} while (annoList.good()); |
||||
} |
||||
} |
||||
|
||||
return; |
||||
} |
||||
|
||||
void TRACK_alovImpl::loadDatasetAnnotatedOnly(const string &rootPath) |
||||
{ |
||||
vector <int> datasetsLengths; |
||||
int currDatasetID = 0; |
||||
|
||||
printf("ALOV300++ Annotated Dataset Initialization...\n"); |
||||
|
||||
//Loop for all sections of ALOV300++ (14 sections)
|
||||
for (int i = 0; i < 14; i++) |
||||
{ |
||||
//Loop for all videos in section
|
||||
for (int k = 0; k < sectionSizes[i]; k++) |
||||
{ |
||||
vector <Ptr<TRACK_alovObj> > objects; |
||||
currDatasetID++; |
||||
|
||||
//Open dataset's ground truth (annotation) file
|
||||
string annoPath = fullAnnoPath(rootPath, i, k); |
||||
ifstream annoList(annoPath.c_str()); |
||||
if (!annoList.is_open()) |
||||
{ |
||||
printf("Error: Can't open annotation file *.ANN!!!\n"); |
||||
break; |
||||
} |
||||
|
||||
int framesNum = 0; |
||||
|
||||
do |
||||
{ |
||||
//Make ALOV300++ Object
|
||||
Ptr<TRACK_alovObj> currObj(new TRACK_alovObj); |
||||
string tmp; |
||||
framesNum++; |
||||
|
||||
//Ground Truth data
|
||||
int n = 0; |
||||
double x1 = 0, y1 = 0, |
||||
x2 = 0, y2 = 0, |
||||
x3 = 0, y3 = 0, |
||||
x4 = 0, y4 = 0; |
||||
|
||||
getline(annoList, tmp); |
||||
std::istringstream in(tmp); |
||||
in >> n >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4; |
||||
|
||||
currObj->gtbb.push_back(Point2d(x1, y1)); |
||||
currObj->gtbb.push_back(Point2d(x2, y2)); |
||||
currObj->gtbb.push_back(Point2d(x3, y3)); |
||||
currObj->gtbb.push_back(Point2d(x4, y4)); |
||||
|
||||
string fullPath = fullFramePath(rootPath, i, k, n); |
||||
if (!fileExists(fullPath)) |
||||
break; |
||||
|
||||
currObj->imagePath = fullPath; |
||||
currObj->id = n; |
||||
|
||||
//Add object to storage
|
||||
objects.push_back(currObj); |
||||
|
||||
} while (annoList.good()); |
||||
|
||||
datasetsLengths.push_back(framesNum-1); |
||||
data.push_back(objects); |
||||
} |
||||
} |
||||
|
||||
return; |
||||
} |
||||
|
||||
int TRACK_alovImpl::getDatasetsNum() |
||||
{ |
||||
return (int)(data.size()); |
||||
} |
||||
|
||||
int TRACK_alovImpl::getDatasetLength(int id) |
||||
{ |
||||
if (id > 0 && id <= (int)data.size()) |
||||
return (int)(data[id - 1].size()); |
||||
else |
||||
{ |
||||
printf("Dataset ID is out of range...\nAllowed IDs are: 1~%d\n", (int)data.size()); |
||||
return -1; |
||||
} |
||||
} |
||||
|
||||
bool TRACK_alovImpl::initDataset(int id) |
||||
{ |
||||
if (id > 0 && id <= (int)data.size()) |
||||
{ |
||||
activeDatasetID = id; |
||||
return true; |
||||
} |
||||
else |
||||
{ |
||||
printf("Dataset ID is out of range...\nAllowed IDs are: 1~%d\n", (int)data.size()); |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
bool TRACK_alovImpl::getNextFrame(Mat &frame) |
||||
{ |
||||
if (frameCounter >= (int)data[activeDatasetID - 1].size()) |
||||
return false; |
||||
string imgPath = data[activeDatasetID - 1][frameCounter]->imagePath; |
||||
frame = imread(imgPath); |
||||
frameCounter++; |
||||
return !frame.empty(); |
||||
} |
||||
|
||||
bool TRACK_alovImpl::getFrame(Mat &frame, int datasetID, int frameID) |
||||
{ |
||||
if (frameID > (int)data[datasetID-1].size()) |
||||
return false; |
||||
string imgPath = data[datasetID-1][frameID-1]->imagePath; |
||||
frame = imread(imgPath); |
||||
return !frame.empty(); |
||||
} |
||||
|
||||
Ptr<TRACK_alov> TRACK_alov::create() |
||||
{ |
||||
return Ptr<TRACK_alovImpl>(new TRACK_alovImpl); |
||||
} |
||||
|
||||
vector <Point2f> TRACK_alovImpl::getNextGT() |
||||
{ |
||||
Ptr <TRACK_alovObj> currObj = data[activeDatasetID - 1][frameCounter - 1]; |
||||
return currObj->gtbb; |
||||
} |
||||
|
||||
vector <Point2f> TRACK_alovImpl::getGT(int datasetID, int frameID) |
||||
{ |
||||
Ptr <TRACK_alovObj> currObj = data[datasetID - 1][frameID - 1]; |
||||
return currObj->gtbb; |
||||
} |
||||
|
||||
} |
||||
} |
@ -1,2 +1,2 @@ |
||||
set(the_description "Tracking API") |
||||
ocv_define_module(tracking opencv_imgproc opencv_core opencv_video opencv_highgui opencv_plot OPTIONAL opencv_datasets WRAP python) |
||||
ocv_define_module(tracking opencv_imgproc opencv_core opencv_video opencv_highgui opencv_dnn opencv_plot OPTIONAL opencv_datasets WRAP python) |
@ -0,0 +1,217 @@ |
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
//Demo of GOTURN tracker
|
||||
//In order to use GOTURN tracker, GOTURN architecture goturn.prototxt and goturn.caffemodel are required to exist in root folder.
|
||||
//There are 2 ways to get caffemodel:
|
||||
//1 - Train you own GOTURN model using <https://github.com/Auron-X/GOTURN_Training_Toolkit>
|
||||
//2 - Download pretrained caffemodel from <https://github.com/opencv/opencv_extra>
|
||||
|
||||
#include "opencv2/datasets/track_alov.hpp" |
||||
#include <opencv2/core/utility.hpp> |
||||
#include <opencv2/tracking.hpp> |
||||
#include <opencv2/videoio.hpp> |
||||
#include <opencv2/highgui.hpp> |
||||
#include <iostream> |
||||
|
||||
using namespace std; |
||||
using namespace cv; |
||||
using namespace cv::datasets; |
||||
|
||||
#define NUM_TEST_FRAMES 1000 |
||||
|
||||
static Mat image; |
||||
static bool paused; |
||||
static bool selectObjects = false; |
||||
static bool startSelection = false; |
||||
Rect2d boundingBox; |
||||
|
||||
static const char* keys = |
||||
{ "{@dataset_path |true| Dataset path }" |
||||
"{@dataset_id |1| Dataset ID }" |
||||
}; |
||||
|
||||
static void onMouse(int event, int x, int y, int, void*) |
||||
{ |
||||
if (!selectObjects) |
||||
{ |
||||
switch (event) |
||||
{ |
||||
case EVENT_LBUTTONDOWN: |
||||
//set origin of the bounding box
|
||||
startSelection = true; |
||||
boundingBox.x = x; |
||||
boundingBox.y = y; |
||||
boundingBox.width = boundingBox.height = 0; |
||||
break; |
||||
case EVENT_LBUTTONUP: |
||||
//sei with and height of the bounding box
|
||||
boundingBox.width = std::abs(x - boundingBox.x); |
||||
boundingBox.height = std::abs(y - boundingBox.y); |
||||
paused = false; |
||||
selectObjects = true; |
||||
startSelection = false; |
||||
break; |
||||
case EVENT_MOUSEMOVE: |
||||
|
||||
if (startSelection && !selectObjects) |
||||
{ |
||||
//draw the bounding box
|
||||
Mat currentFrame; |
||||
image.copyTo(currentFrame); |
||||
rectangle(currentFrame, Point((int)boundingBox.x, (int)boundingBox.y), Point(x, y), Scalar(255, 0, 0), 2, 1); |
||||
imshow("GOTURN Tracking", currentFrame); |
||||
} |
||||
break; |
||||
} |
||||
} |
||||
} |
||||
|
||||
static void help() |
||||
{ |
||||
cout << "\nThis example is a simple demo of GOTURN tracking on ALOV300++ dataset" |
||||
"ALOV dataset contains videos with ID range: 1~314\n" |
||||
"-- pause video [p] and draw a bounding boxes around the targets to start the tracker\n" |
||||
"Example:\n" |
||||
"./goturnTracker <dataset_path> <dataset_id>\n" |
||||
<< endl; |
||||
|
||||
cout << "\n\nHot keys: \n" |
||||
"\tq - quit the program\n" |
||||
"\tp - pause video\n"; |
||||
} |
||||
|
||||
int main(int argc, char *argv[]) |
||||
{ |
||||
CommandLineParser parser(argc, argv, keys); |
||||
string datasetRootPath = parser.get<string>(0); |
||||
int datasetID = parser.get<int>(1); |
||||
|
||||
if (datasetRootPath.empty()) |
||||
{ |
||||
help(); |
||||
return -1; |
||||
} |
||||
|
||||
Mat frame; |
||||
paused = false; |
||||
namedWindow("GOTURN Tracking", 0); |
||||
setMouseCallback("GOTURN Tracking", onMouse, 0); |
||||
|
||||
//Create GOTURN tracker
|
||||
Ptr<Tracker> tracker = Tracker::create("GOTURN"); |
||||
|
||||
//Load and init full ALOV300++ dataset with a given datasetID, as alternative you can use loadAnnotatedOnly(..)
|
||||
//to load only frames with labled ground truth ~ every 5-th frame
|
||||
Ptr<cv::datasets::TRACK_alov> dataset = TRACK_alov::create(); |
||||
dataset->load(datasetRootPath); |
||||
dataset->initDataset(datasetID); |
||||
|
||||
//Read first frame
|
||||
dataset->getNextFrame(frame); |
||||
frame.copyTo(image); |
||||
rectangle(image, boundingBox, Scalar(255, 0, 0), 2, 1); |
||||
imshow("GOTURN Tracking", image); |
||||
|
||||
bool initialized = false; |
||||
paused = true; |
||||
int frameCounter = 0; |
||||
|
||||
//Time measurment
|
||||
int64 e3 = getTickCount(); |
||||
|
||||
for (;;) |
||||
{ |
||||
if (!paused) |
||||
{ |
||||
//Time measurment
|
||||
int64 e1 = getTickCount(); |
||||
if (initialized){ |
||||
if (!dataset->getNextFrame(frame)) |
||||
break; |
||||
frame.copyTo(image); |
||||
} |
||||
|
||||
if (!initialized && selectObjects) |
||||
{ |
||||
//Initialize the tracker and add targets
|
||||
if (!tracker->init(frame, boundingBox)) |
||||
{ |
||||
cout << "Tracker Init Error!!!"; |
||||
return 0; |
||||
} |
||||
rectangle(frame, boundingBox, Scalar(0, 0, 255), 2, 1); |
||||
initialized = true; |
||||
} |
||||
else if (initialized) |
||||
{ |
||||
//Update all targets
|
||||
if (tracker->update(frame, boundingBox)) |
||||
{ |
||||
rectangle(frame, boundingBox, Scalar(0, 0, 255), 2, 1); |
||||
} |
||||
} |
||||
imshow("GOTURN Tracking", frame); |
||||
frameCounter++; |
||||
//Time measurment
|
||||
int64 e2 = getTickCount(); |
||||
double t1 = (e2 - e1) / getTickFrequency(); |
||||
cout << frameCounter << "\tframe : " << t1 * 1000.0 << "ms" << endl; |
||||
} |
||||
|
||||
char c = (char)waitKey(2); |
||||
if (c == 'q') |
||||
break; |
||||
if (c == 'p') |
||||
paused = !paused; |
||||
} |
||||
|
||||
//Time measurment
|
||||
int64 e4 = getTickCount(); |
||||
double t2 = (e4 - e3) / getTickFrequency(); |
||||
cout << "Average Time for Frame: " << t2 * 1000.0 / frameCounter << "ms" << endl; |
||||
cout << "Average FPS: " << 1.0 / t2*frameCounter << endl; |
||||
|
||||
|
||||
waitKey(0); |
||||
|
||||
return 0; |
||||
} |
@ -0,0 +1,191 @@ |
||||
/*///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "gtrTracker.hpp" |
||||
|
||||
|
||||
namespace cv |
||||
{ |
||||
|
||||
TrackerGOTURN::Params::Params(){} |
||||
|
||||
void TrackerGOTURN::Params::read(const cv::FileNode& /*fn*/){} |
||||
|
||||
void TrackerGOTURN::Params::write(cv::FileStorage& /*fs*/) const {} |
||||
|
||||
|
||||
Ptr<TrackerGOTURN> TrackerGOTURN::createTracker(const TrackerGOTURN::Params ¶meters) |
||||
{ |
||||
return Ptr<gtr::TrackerGOTURNImpl>(new gtr::TrackerGOTURNImpl(parameters)); |
||||
} |
||||
|
||||
namespace gtr |
||||
{ |
||||
|
||||
class TrackerGOTURNModel : public TrackerModel{ |
||||
public: |
||||
TrackerGOTURNModel(TrackerGOTURN::Params){} |
||||
Rect2d getBoundingBox(){ return boundingBox_; } |
||||
void setBoudingBox(Rect2d boundingBox){ boundingBox_ = boundingBox; } |
||||
Mat getImage(){ return image_; } |
||||
void setImage(const Mat& image){ image.copyTo(image_); } |
||||
protected: |
||||
Rect2d boundingBox_; |
||||
Mat image_; |
||||
void modelEstimationImpl(const std::vector<Mat>&){} |
||||
void modelUpdateImpl(){} |
||||
}; |
||||
|
||||
TrackerGOTURNImpl::TrackerGOTURNImpl(const TrackerGOTURN::Params ¶meters) : |
||||
params(parameters){ |
||||
isInit = false; |
||||
}; |
||||
|
||||
void TrackerGOTURNImpl::read(const cv::FileNode& fn) |
||||
{ |
||||
params.read(fn); |
||||
} |
||||
|
||||
void TrackerGOTURNImpl::write(cv::FileStorage& fs) const |
||||
{ |
||||
params.write(fs); |
||||
} |
||||
|
||||
bool TrackerGOTURNImpl::initImpl(const Mat& image, const Rect2d& boundingBox) |
||||
{ |
||||
//Make a simple model from frame and bounding box
|
||||
model = Ptr<TrackerGOTURNModel>(new TrackerGOTURNModel(params)); |
||||
((TrackerGOTURNModel*)static_cast<TrackerModel*>(model))->setImage(image); |
||||
((TrackerGOTURNModel*)static_cast<TrackerModel*>(model))->setBoudingBox(boundingBox); |
||||
|
||||
//Load GOTURN architecture from *.prototxt and pretrained weights from *.caffemodel
|
||||
String modelTxt = "goturn.prototxt"; |
||||
String modelBin = "goturn.caffemodel"; |
||||
Ptr<dnn::Importer> importer; |
||||
try //Import GOTURN model
|
||||
{ |
||||
importer = dnn::createCaffeImporter(modelTxt, modelBin); |
||||
} |
||||
catch (const cv::Exception &err) //Importer can throw errors, we will catch them
|
||||
{ |
||||
std::cerr << err.msg << std::endl; |
||||
} |
||||
if (!importer) |
||||
{ |
||||
cvError(CV_StsError, "cv::gtr::InitImpl", "GOTURN network loading error...", "gtrTracker.cpp", 117); |
||||
} |
||||
|
||||
importer->populateNet(net); |
||||
importer.release(); //We don't need importer anymore
|
||||
|
||||
return true; |
||||
} |
||||
|
||||
bool TrackerGOTURNImpl::updateImpl(const Mat& image, Rect2d& boundingBox) |
||||
{ |
||||
int INPUT_SIZE = 227; |
||||
//Using prevFrame & prevBB from model and curFrame GOTURN calculating curBB
|
||||
Mat curFrame = image.clone(); |
||||
Mat prevFrame = ((TrackerGOTURNModel*)static_cast<TrackerModel*>(model))->getImage(); |
||||
Rect2d prevBB = ((TrackerGOTURNModel*)static_cast<TrackerModel*>(model))->getBoundingBox(); |
||||
Rect2d curBB; |
||||
|
||||
float padTargetPatch = 2.0; |
||||
Rect2f searchPatchRect, targetPatchRect; |
||||
Point2f currCenter, prevCenter; |
||||
Mat prevFramePadded, curFramePadded; |
||||
Mat searchPatch, targetPatch; |
||||
|
||||
prevCenter.x = (float)(prevBB.x + prevBB.width / 2); |
||||
prevCenter.y = (float)(prevBB.y + prevBB.height / 2); |
||||
|
||||
targetPatchRect.width = (float)(prevBB.width*padTargetPatch); |
||||
targetPatchRect.height = (float)(prevBB.height*padTargetPatch); |
||||
targetPatchRect.x = (float)(prevCenter.x - prevBB.width*padTargetPatch / 2.0 + targetPatchRect.width); |
||||
targetPatchRect.y = (float)(prevCenter.y - prevBB.height*padTargetPatch / 2.0 + targetPatchRect.height); |
||||
|
||||
copyMakeBorder(prevFrame, prevFramePadded, (int)targetPatchRect.height, (int)targetPatchRect.height, (int)targetPatchRect.width, (int)targetPatchRect.width, BORDER_REPLICATE); |
||||
targetPatch = prevFramePadded(targetPatchRect).clone(); |
||||
|
||||
copyMakeBorder(curFrame, curFramePadded, (int)targetPatchRect.height, (int)targetPatchRect.height, (int)targetPatchRect.width, (int)targetPatchRect.width, BORDER_REPLICATE); |
||||
searchPatch = curFramePadded(targetPatchRect).clone(); |
||||
|
||||
//Preprocess
|
||||
//Resize
|
||||
resize(targetPatch, targetPatch, Size(INPUT_SIZE, INPUT_SIZE)); |
||||
resize(searchPatch, searchPatch, Size(INPUT_SIZE, INPUT_SIZE)); |
||||
|
||||
//Mean Subtract
|
||||
targetPatch = targetPatch - 128; |
||||
searchPatch = searchPatch - 128; |
||||
|
||||
//Convert to Float type
|
||||
targetPatch.convertTo(targetPatch, CV_32F); |
||||
searchPatch.convertTo(searchPatch, CV_32F); |
||||
|
||||
dnn::Blob targetBlob = dnn::Blob(targetPatch); |
||||
dnn::Blob searchBlob = dnn::Blob(searchPatch); |
||||
|
||||
net.setBlob(".data1", targetBlob); |
||||
net.setBlob(".data2", searchBlob); |
||||
|
||||
net.forward(); |
||||
dnn::Blob res = net.getBlob("scale"); |
||||
|
||||
Mat resMat = res.matRefConst().reshape(1, 1); |
||||
|
||||
curBB.x = targetPatchRect.x + (resMat.at<float>(0) * targetPatchRect.width / INPUT_SIZE) - targetPatchRect.width; |
||||
curBB.y = targetPatchRect.y + (resMat.at<float>(1) * targetPatchRect.height / INPUT_SIZE) - targetPatchRect.height; |
||||
curBB.width = (resMat.at<float>(2) - resMat.at<float>(0)) * targetPatchRect.width / INPUT_SIZE; |
||||
curBB.height = (resMat.at<float>(3) - resMat.at<float>(1)) * targetPatchRect.height / INPUT_SIZE; |
||||
|
||||
//Predicted BB
|
||||
boundingBox = curBB; |
||||
|
||||
//Set new model image and BB from current frame
|
||||
((TrackerGOTURNModel*)static_cast<TrackerModel*>(model))->setImage(curFrame); |
||||
((TrackerGOTURNModel*)static_cast<TrackerModel*>(model))->setBoudingBox(curBB); |
||||
return true; |
||||
} |
||||
|
||||
} |
||||
|
||||
} |
@ -0,0 +1,76 @@ |
||||
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef OPENCV_GOTURN_TRACKER |
||||
#define OPENCV_GOTURN_TRACKER |
||||
|
||||
#include "precomp.hpp" |
||||
#include "opencv2/video/tracking.hpp" |
||||
#include "opencv2/dnn.hpp" |
||||
#include "gtrUtils.hpp" |
||||
#include "opencv2/imgproc.hpp" |
||||
#include<algorithm> |
||||
#include<limits.h> |
||||
|
||||
namespace cv |
||||
{ |
||||
namespace gtr |
||||
{ |
||||
|
||||
class TrackerGOTURNImpl : public TrackerGOTURN |
||||
{ |
||||
public: |
||||
TrackerGOTURNImpl(const TrackerGOTURN::Params ¶meters = TrackerGOTURN::Params()); |
||||
void read(const FileNode& fn); |
||||
void write(FileStorage& fs) const; |
||||
bool initImpl(const Mat& image, const Rect2d& boundingBox); |
||||
bool updateImpl(const Mat& image, Rect2d& boundingBox); |
||||
|
||||
TrackerGOTURN::Params params; |
||||
|
||||
dnn::Net net; |
||||
}; |
||||
|
||||
} |
||||
} |
||||
|
||||
#endif |
@ -0,0 +1,146 @@ |
||||
/*///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "gtrUtils.hpp" |
||||
|
||||
|
||||
namespace cv |
||||
{ |
||||
namespace gtr |
||||
{ |
||||
|
||||
double generateRandomLaplacian(double b, double m) |
||||
{ |
||||
double t = (double)rand() / (RAND_MAX); |
||||
double n = (double)rand() / (RAND_MAX); |
||||
|
||||
if (t > 0.5) |
||||
return m + b*log(n); |
||||
else |
||||
return m - b*log(n); |
||||
} |
||||
|
||||
Rect2f anno2rect(vector<Point2f> annoBB) |
||||
{ |
||||
Rect2f rectBB; |
||||
rectBB.x = min(annoBB[0].x, annoBB[1].x); |
||||
rectBB.y = min(annoBB[0].y, annoBB[2].y); |
||||
rectBB.width = fabs(annoBB[0].x - annoBB[1].x); |
||||
rectBB.height = fabs(annoBB[0].y - annoBB[2].y); |
||||
|
||||
return rectBB; |
||||
} |
||||
|
||||
vector <TrainingSample> gatherFrameSamples(Mat prevFrame, Mat currFrame, Rect2f prevBB, Rect2f currBB) |
||||
{ |
||||
vector <TrainingSample> trainingSamples; |
||||
Point2f currCenter, prevCenter; |
||||
Rect2f targetPatchRect, searchPatchRect; |
||||
Mat targetPatch, searchPatch; |
||||
Mat prevFramePadded, currFramePadded; |
||||
|
||||
//Crop Target Patch
|
||||
|
||||
//Padding
|
||||
|
||||
//Previous frame GTBBs center
|
||||
prevCenter.x = prevBB.x + prevBB.width / 2; |
||||
prevCenter.y = prevBB.y + prevBB.height / 2; |
||||
|
||||
targetPatchRect.width = (float)(prevBB.width*padTarget); |
||||
targetPatchRect.height = (float)(prevBB.height*padTarget); |
||||
targetPatchRect.x = (float)(prevCenter.x - prevBB.width*padTarget / 2.0 + targetPatchRect.width); |
||||
targetPatchRect.y = (float)(prevCenter.y - prevBB.height*padTarget / 2.0 + targetPatchRect.height); |
||||
|
||||
copyMakeBorder(prevFrame, prevFramePadded, (int)targetPatchRect.height, (int)targetPatchRect.height, (int)targetPatchRect.width, (int)targetPatchRect.width, BORDER_REPLICATE); |
||||
|
||||
targetPatch = prevFramePadded(targetPatchRect); |
||||
|
||||
|
||||
for (int i = 0; i < samplesInFrame; i++) |
||||
{ |
||||
TrainingSample sample; |
||||
|
||||
//Current frame GTBBs center
|
||||
currCenter.x = (float)(currBB.x + currBB.width / 2.0); |
||||
currCenter.y = (float)(currBB.y + currBB.height / 2.0); |
||||
|
||||
//Generate and add random Laplacian distribution (Scaling from target size)
|
||||
double dx, dy, ds; |
||||
dx = generateRandomLaplacian(bX, 0)*prevBB.width; |
||||
dy = generateRandomLaplacian(bY, 0)*prevBB.height; |
||||
ds = generateRandomLaplacian(bS, 1); |
||||
|
||||
//Limit coefficients
|
||||
dx = min(dx, (double)prevBB.width); |
||||
dx = max(dx, (double)-prevBB.width); |
||||
dy = min(dy, (double)prevBB.height); |
||||
dy = max(dy, (double)-prevBB.height); |
||||
ds = min(ds, Ymax); |
||||
ds = max(ds, Ymin); |
||||
|
||||
searchPatchRect.width = (float)(prevBB.width*padSearch*ds); |
||||
searchPatchRect.height =(float)(prevBB.height*padSearch*ds); |
||||
searchPatchRect.x = (float)(currCenter.x + dx - searchPatchRect.width / 2.0 + searchPatchRect.width); |
||||
searchPatchRect.y = (float)(currCenter.y + dy - searchPatchRect.height / 2.0 + searchPatchRect.height); |
||||
copyMakeBorder(currFrame, currFramePadded, (int)searchPatchRect.height, (int)searchPatchRect.height, (int)searchPatchRect.width, (int)searchPatchRect.width, BORDER_REPLICATE); |
||||
searchPatch = currFramePadded(searchPatchRect); |
||||
|
||||
//Calculate Relative GTBB in search patch
|
||||
Rect2f relGTBB; |
||||
relGTBB.width = currBB.width; |
||||
relGTBB.height = currBB.height; |
||||
relGTBB.x = currBB.x - searchPatchRect.x + searchPatchRect.width; |
||||
relGTBB.y = currBB.y - searchPatchRect.y + searchPatchRect.height; |
||||
|
||||
//Link to the sample struct
|
||||
sample.targetPatch = targetPatch.clone(); |
||||
sample.searchPatch = searchPatch.clone(); |
||||
sample.targetBB = relGTBB; |
||||
|
||||
trainingSamples.push_back(sample); |
||||
} |
||||
|
||||
return trainingSamples; |
||||
} |
||||
|
||||
} |
||||
} |
@ -0,0 +1,61 @@ |
||||
#ifndef OPENCV_GTR_UTILS |
||||
#define OPENCV_GTR_UTILS |
||||
|
||||
#include "precomp.hpp" |
||||
#include <vector> |
||||
#include "opencv2/highgui.hpp" |
||||
#include <opencv2/datasets/track_alov.hpp> |
||||
|
||||
namespace cv |
||||
{ |
||||
namespace gtr |
||||
{ |
||||
|
||||
//Number of samples in batch
|
||||
const int samplesInBatch = 50; |
||||
|
||||
//Number of samples to mine from video frame
|
||||
const int samplesInFrame = 10; |
||||
|
||||
//Number of samples to mine from still image
|
||||
const int samplesInImage = 10; |
||||
|
||||
//Padding coefficients for Target/Search Region
|
||||
const double padTarget = 2.0; |
||||
const double padSearch = 2.0; |
||||
|
||||
//Scale parameters for Laplace distribution for Translation/Scale
|
||||
const double bX = 1.0/10; |
||||
const double bY = 1.0/10; |
||||
const double bS = 1.0/15; |
||||
|
||||
//Limits of scale changes
|
||||
const double Ymax = 1.4; |
||||
const double Ymin = 0.6; |
||||
|
||||
//Lower boundary constraints for random samples (sample should include X% of target BB)
|
||||
const double minX = 0.5; |
||||
const double minY = 0.5; |
||||
|
||||
//Structure of sample for training
|
||||
struct TrainingSample |
||||
{ |
||||
Mat targetPatch; |
||||
Mat searchPatch; |
||||
//Output bounding box on search patch
|
||||
Rect2f targetBB; |
||||
}; |
||||
|
||||
//Laplacian distribution
|
||||
double generateRandomLaplacian(double b, double m); |
||||
|
||||
//Convert ALOV300++ anno coordinates to Rectangle BB
|
||||
Rect2f anno2rect(vector<Point2f> annoBB); |
||||
|
||||
//Gather samples from random video frame
|
||||
vector <TrainingSample> gatherFrameSamples(Mat prevFrame, Mat currFrame, Rect2f prevBB, Rect2f currBB); |
||||
|
||||
} |
||||
} |
||||
|
||||
#endif |
Loading…
Reference in new issue