Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,24 @@ Original Python code and publication infomation found at https://github.com/abew

This code has been tested on Windows with Visual Studio Community 2013 + OpenCV 2.4.8. It depends on OpenCV without any other libs, so theoretically it can be compiled on Linux with OpenCV support.

### To compile on Ubuntu
#### Command to check OpenCV installation:

``` bash
pkg-config --modversion opencv4
```

If not installed, use below command to install

``` bash
sudo apt install libopencv-dev
```

To compile:

```bash
g++ -o main main.cpp KalmanTracker.cpp Hungarian.cpp $(pkg-config --cflags --libs opencv4)
```
Detection data in The ./data folder come from the original directory of SORT. They are the *Faster* RCNN detections for the MOT benchmark sequences in the benchmark format, created by Alex Bewley.

The Hungarian algorithm implementation comes from https://github.com/mcximing/hungarian-algorithm-cpp, which is derived from [Markus Buehren's code](http://www.mathworks.com/matlabcentral/fileexchange/6543-functions-for-the-rectangular-assignment-problem).
Expand Down
3 changes: 2 additions & 1 deletion sort-c++/Hungarian.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
//

#include "Hungarian.h"

#include <cfloat>
#include <cmath>

HungarianAlgorithm::HungarianAlgorithm(){}
HungarianAlgorithm::~HungarianAlgorithm(){}
Expand Down
2 changes: 1 addition & 1 deletion sort-c++/KalmanTracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void KalmanTracker::init_kf(StateType stateMat)

measurement = Mat::zeros(measureNum, 1, CV_32F);

kf.transitionMatrix = *(Mat_<float>(stateNum, stateNum) <<
kf.transitionMatrix = (Mat_<float>(stateNum, stateNum) <<
1, 0, 0, 0, 1, 0, 0,
0, 1, 0, 0, 0, 1, 0,
0, 0, 1, 0, 0, 0, 1,
Expand Down
Binary file added sort-c++/main
Binary file not shown.
13 changes: 9 additions & 4 deletions sort-c++/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,19 @@
#include <iostream>
#include <fstream>
#include <iomanip> // to format image names using setw() and setfill()
#include <io.h> // to check file existence using POSIX function access(). On Linux include <unistd.h>.
//#include <io.h> // to check file existence using POSIX function access(). On Linux include <unistd.h>.
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <set>

#include "Hungarian.h"
#include "KalmanTracker.h"

#include "opencv2/video/tracking.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <opencv2/opencv.hpp>

using namespace std;
using namespace cv;
Expand Down Expand Up @@ -94,10 +99,10 @@ void TestSORT(string seqName, bool display)
for (int i = 0; i < CNUM; i++)
rng.fill(randColor[i], RNG::UNIFORM, 0, 256);

string imgPath = "D:/Data/Track/2DMOT2015/train/" + seqName + "/img1/";
string imgPath = "/home/user6/Documents/cpp_sort/sort-cpp/MOT15/train/" + seqName + "/img1/";

if (display)
if (_access(imgPath.c_str(), 0) == -1)
if (access(imgPath.c_str(), F_OK) == -1)
{
cerr << "Image path not found!" << endl;
display = false;
Expand Down Expand Up @@ -361,7 +366,7 @@ void TestSORT(string seqName, bool display)
for (auto tb : frameTrackingResult)
cv::rectangle(img, tb.box, randColor[tb.id % CNUM], 2, 8, 0);
imshow(seqName, img);
cvWaitKey(40);
waitKey(40);
}
}

Expand Down
93 changes: 0 additions & 93 deletions sort-c++/sort-c++.vcxproj

This file was deleted.

36 changes: 0 additions & 36 deletions sort-c++/sort-c++.vcxproj.filters

This file was deleted.