Commit c8b31cd9 authored by Alex Leontiev's avatar Alex Leontiev

Vadim

parent c06bb0dc
......@@ -23,18 +23,6 @@ vector<Scalar> palette;
void print_table(char* videos[],int videoNum,char* algorithms[],int algNum,const vector<vector<char*> >& results,char* tableName);
static void listTrackers(){
vector<String> algorithms;
Algorithm::getList(algorithms);
cout << "\nAvailable tracker algorithms:\n";
for (size_t i=0; i < algorithms.size(); i++){
const char* algoname=algorithms[i].c_str();
char *pos=NULL;
if((pos=strstr((char*)algoname,"TRACKER."))!=NULL){
printf("%s\n",pos+8);
}
}
}
static int lineToRect(char* line,Rect2d& res){
char * ptr=line,*pos=ptr;
if(line==NULL || line[0]=='\0'){
......@@ -75,21 +63,11 @@ static void help(){
cout << "\n\nHot keys: \n"
"\tq - quit the program\n"
"\tp - pause video\n";
listTrackers();
exit(EXIT_SUCCESS);
}
static void parseCommandLineArgs(int argc, char** argv,char* videos[],char* gts[],
int* vc,char* algorithms[],char* initBoxes[][CMDLINEMAX],int* ac){
vector<String> trackers;
Algorithm::getList(trackers);
for(int i=0;i<(int)trackers.size();i++){
if(strstr(trackers[i].c_str(),"TRACKER.")!=trackers[i].c_str()){
trackers.erase(trackers.begin()+i);
i--;
}
}
*ac=*vc=0;
for(int i=1;i<argc;i++){
if(argv[i][0]=='-'){
......@@ -105,13 +83,14 @@ static void parseCommandLineArgs(int argc, char** argv,char* videos[],char* gts[
}
continue;
}
bool isVideo=true;
for(int j=0;j<(int)trackers.size();j++){
if(strcmp(argv[i],trackers[j].c_str()+8)==0){
isVideo=false;
bool isVideo=false;
for(int j=0,len=strlen(argv[i]);j<len;j++){
if(!('A'<=argv[i][j] && argv[i][j]<='Z') && argv[i][j]!='.'){
isVideo=true;
break;
}
}
if(isVideo){
videos[*vc]=argv[i];
i++;
......
......@@ -19,19 +19,6 @@ static const char* keys =
"{@start_frame |0| Start frame }"
"{@bounding_frame |0,0,0,0| Initial bounding frame}"};
static void listTrackers(){
vector<String> algorithms;
Algorithm::getList(algorithms);
cout << "\nAvailable tracker algorithms:\n";
for (size_t i=0; i < algorithms.size(); i++){
const char* algoname=algorithms[i].c_str();
char *pos=NULL;
if((pos=strstr((char*)algoname,"TRACKER."))!=NULL){
printf("%s\n",pos+8);
}
}
}
static void onMouse( int event, int x, int y, int, void* )
{
if( !selectObject )
......@@ -78,7 +65,6 @@ static void help()
cout << "\n\nHot keys: \n"
"\tq - quit the program\n"
"\tp - pause video\n";
listTrackers();
}
int main( int argc, char** argv ){
......
......@@ -77,8 +77,12 @@ namespace cv
class TrackerMedianFlowImpl : public TrackerMedianFlow{
public:
TrackerMedianFlowImpl(TrackerMedianFlow::Params paramsIn):termcrit(TermCriteria::COUNT|TermCriteria::EPS,20,0.3){params=paramsIn;isInit=false;}
bool medianFlowImpl(Mat oldImage,Mat newImage,Rect2d& oldBox);
void read( const FileNode& fn );
void write( FileStorage& fs ) const;
private:
bool initImpl( const Mat& image, const Rect2d& boundingBox );
bool updateImpl( const Mat& image, Rect2d& boundingBox );
bool medianFlowImpl(Mat oldImage,Mat newImage,Rect2d& oldBox);
Rect2d vote(const std::vector<Point2f>& oldPoints,const std::vector<Point2f>& newPoints,const Rect2d& oldRect,Point2f& mD);
//FIXME: this can be optimized: current method uses sort->select approach, there are O(n) selection algo for median; besides
//it makes copy all the time
......
......@@ -102,7 +102,7 @@ private:
TLDDetector* detector_;
};
class Data : public TrackerTLD::Private{
class Data {
public:
Data(Rect2d initBox);
Size getMinSize(){return minSize;}
......@@ -118,7 +118,7 @@ private:
class TrackerTLDModel;
class TLDDetector : public TrackerTLD::Private{
class TLDDetector {
public:
TLDDetector(const TrackerTLD::Params& params,Ptr<TrackerModel>model_in):model(model_in),params_(params){}
~TLDDetector(){}
......@@ -128,6 +128,7 @@ public:
protected:
friend class MyMouseCallbackDEBUG;
Ptr<TrackerModel> model;
void computeIntegralImages(const Mat& img,Mat_<double>& intImgP,Mat_<double>& intImgP2){integral(img,intImgP,intImgP2,CV_64F);}
inline bool patchVariance(Mat_<double>& intImgP,Mat_<double>& intImgP2,double originalVariance,Point pt,Size size);
bool ensembleClassifier(const uchar* data,int rowstep){return ensembleClassifierNum(data,rowstep)>0.5;}
double ensembleClassifierNum(const uchar* data,int rowstep);
......@@ -168,7 +169,7 @@ class TrackerProxyImpl : public TrackerProxy{
public:
TrackerProxyImpl(Tparams params=Tparams()):params_(params){}
bool init( const Mat& image, const Rect2d& boundingBox ){
trackerPtr=Ptr<T>(new T(params_));
trackerPtr=T::createTracker();
return trackerPtr->init(image,boundingBox);
}
bool update( const Mat& image,Rect2d& boundingBox){
......@@ -223,7 +224,7 @@ class TrackerTLDImpl : public TrackerTLD
TrackerTLD::Params params;
Ptr<Data> data;
Ptr<TrackerProxy> tracker;
Ptr<TrackerProxy> trackerProxy;
Ptr<TLDDetector> detector;
};
......@@ -244,28 +245,25 @@ Ptr<TrackerTLD> TrackerTLD::createTracker(const TrackerTLD::Params &parameters){
TrackerTLDImpl::TrackerTLDImpl( const TrackerTLD::Params &parameters) :
params( parameters ){
isInit = false;
tracker=Ptr<TrackerProxyImpl<TrackerMedianFlow,TrackerMedianFlow::Params> >(
trackerProxy=Ptr<TrackerProxyImpl<TrackerMedianFlow,TrackerMedianFlow::Params> >(
new TrackerProxyImpl<TrackerMedianFlow,TrackerMedianFlow::Params>());
}
TrackerTLD::~TrackerTLD(){
}
void TrackerTLD::read( const cv::FileNode& fn )
void TrackerTLDImpl::read( const cv::FileNode& fn )
{
params.read( fn );
}
void TrackerTLD::write( cv::FileStorage& fs ) const
void TrackerTLDImpl::write( cv::FileStorage& fs ) const
{
params.write( fs );
}
bool TrackerTLD::initImpl(const Mat& image, const Rect2d& boundingBox ){
bool TrackerTLDImpl::initImpl(const Mat& image, const Rect2d& boundingBox ){
Mat image_gray;
tracker->init(image,boundingBox);
trackerProxy->init(image,boundingBox);
cvtColor( image, image_gray, COLOR_BGR2GRAY );
data=new Data(boundingBox);
data=Ptr<Data>(new Data(boundingBox));
double scale=data->getScale();
Rect2d myBoundingBox=boundingBox;
if(scale>1.0){
......@@ -278,7 +276,7 @@ bool TrackerTLD::initImpl(const Mat& image, const Rect2d& boundingBox ){
myBoundingBox.height*=scale;
}
model=Ptr<TrackerTLDModel>(new TrackerTLDModel(params,image_gray,myBoundingBox,data->getMinSize()));
detector=new TLDDetector(params,model);
detector=Ptr<TLDDetector>(new TLDDetector(params,model));
data->confident=false;
data->failedLastTime=false;
......@@ -294,10 +292,9 @@ bool TrackerTLD::initImpl(const Mat& image, const Rect2d& boundingBox ){
return true;
}
bool TrackerTLD::updateImpl(const Mat& image, Rect2d& boundingBox){
bool TrackerTLDImpl::updateImpl(const Mat& image, Rect2d& boundingBox){
Mat image_gray,image_blurred,imageForDetector;
cvtColor( image, image_gray, COLOR_BGR2GRAY );
Data* data=((Data*)static_cast<TrackerTLD::Private*>(privateInfo[2]));
double scale=data->getScale();
if(scale>1.0){
resize(image_gray,imageForDetector,Size(cvRound(image.cols*scale),cvRound(image.rows*scale)));
......@@ -306,8 +303,6 @@ bool TrackerTLD::updateImpl(const Mat& image, Rect2d& boundingBox){
}
GaussianBlur(imageForDetector,image_blurred,GaussBlurKernelSize,0.0);
TrackerTLDModel* tldModel=((TrackerTLDModel*)static_cast<TrackerModel*>(model));
TrackerProxy* trackerProxy=(TrackerProxy*)static_cast<Private*>(privateInfo[0]);
TLDDetector* detector=((TLDDetector*)static_cast<TrackerTLD::Private*>(privateInfo[1]));
data->frameNum++;
Mat_<uchar> standardPatch(15,15);
std::vector<Rect2d> detectorResults;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment