diff --git a/README.md b/README.md index 3080146..31c3103 100644 --- a/README.md +++ b/README.md @@ -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). diff --git a/sort-c++/Hungarian.cpp b/sort-c++/Hungarian.cpp index 601bb1d..7d5a879 100644 --- a/sort-c++/Hungarian.cpp +++ b/sort-c++/Hungarian.cpp @@ -10,7 +10,8 @@ // #include "Hungarian.h" - +#include +#include HungarianAlgorithm::HungarianAlgorithm(){} HungarianAlgorithm::~HungarianAlgorithm(){} diff --git a/sort-c++/KalmanTracker.cpp b/sort-c++/KalmanTracker.cpp index 03728b6..9569c19 100644 --- a/sort-c++/KalmanTracker.cpp +++ b/sort-c++/KalmanTracker.cpp @@ -16,7 +16,7 @@ void KalmanTracker::init_kf(StateType stateMat) measurement = Mat::zeros(measureNum, 1, CV_32F); - kf.transitionMatrix = *(Mat_(stateNum, stateNum) << + kf.transitionMatrix = (Mat_(stateNum, stateNum) << 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1, diff --git a/sort-c++/main b/sort-c++/main new file mode 100644 index 0000000..64850d3 Binary files /dev/null and b/sort-c++/main differ diff --git a/sort-c++/main.cpp b/sort-c++/main.cpp index 0d3faa0..f18d7cc 100644 --- a/sort-c++/main.cpp +++ b/sort-c++/main.cpp @@ -25,7 +25,11 @@ #include #include #include // to format image names using setw() and setfill() -#include // to check file existence using POSIX function access(). On Linux include . +//#include // to check file existence using POSIX function access(). On Linux include . +#include +#include +#include +#include #include #include "Hungarian.h" @@ -33,6 +37,7 @@ #include "opencv2/video/tracking.hpp" #include "opencv2/highgui/highgui.hpp" +#include using namespace std; using namespace cv; @@ -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; @@ -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); } } diff --git a/sort-c++/sort-c++.vcxproj b/sort-c++/sort-c++.vcxproj deleted file mode 100644 index 6375281..0000000 --- a/sort-c++/sort-c++.vcxproj +++ /dev/null @@ -1,93 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - - - - - - - - - - {481C5078-B5CA-4E0E-86FD-D2D2DFD68E64} - Win32Proj - sortc - - - - Application - true - v120 - Unicode - - - Application - false - v120 - true - Unicode - - - - - - - - - - - - - true - C:\opencv\build\include;$(IncludePath) - C:\opencv\build\x86\vc12\lib;$(LibraryPath) - - - false - - - - - - Level3 - Disabled - WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) - - - Console - true - opencv_core248d.lib;opencv_highgui248d.lib;opencv_imgproc248d.lib;opencv_video248d.lib;%(AdditionalDependencies) - - - - - Level3 - - - MaxSpeed - true - true - WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions) - - - Console - true - true - true - - - - - - \ No newline at end of file diff --git a/sort-c++/sort-c++.vcxproj.filters b/sort-c++/sort-c++.vcxproj.filters deleted file mode 100644 index 13b64a9..0000000 --- a/sort-c++/sort-c++.vcxproj.filters +++ /dev/null @@ -1,36 +0,0 @@ - - - - - {4FC737F1-C7A5-4376-A066-2A32D752A2FF} - cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx - - - {93995380-89BD-4b04-88EB-625FBE52EBFB} - h;hh;hpp;hxx;hm;inl;inc;xsd - - - {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} - rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - - - - Source Files - - - Source Files - - - Source Files - - - - - Header Files - - - Header Files - - - \ No newline at end of file