zhengthomastang / 2018AICity_TeamUW

The winning method in Track 1 and Track 3 at the 2nd AI City Challenge Workshop in CVPR 2018 - Official Implementation
http://openaccess.thecvf.com/content_cvpr_2018_workshops/w3/html/Tang_Single-Camera_and_Inter-Camera_CVPR_2018_paper.html
550 stars 198 forks source link

how we compile in linux #8

Closed dahlan77 closed 4 years ago

dahlan77 commented 5 years ago

hi zheng tomas .. in speed estimation ,how we compile in cpp speed estimation in linux experiment

when I compile gcc compiler gcc -std=c++98 -o main main.cpp gcc -std=c++14 -o main main.cpp gcc -std=c++11 -o main main.cpp

the output is same

main.cpp:37:75: warning: format not a string literal and no format arguments [-Wformat-security] inline void setDetCls(char* acDetCls) { std::sprintf(m_acDetCls, acDetCls); } ^ main.cpp: In function ‘int main(int, char**)’: main.cpp:134:22: error: in C++98 ‘viVdo’ must be initialized by constructor, not by ‘{...}’ 23, 24, 25, 26, 27 }; ^ main.cpp:134:22: error: could not convert ‘{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27}’ from ‘’ to ‘std::vector’ main.cpp:136:118: error: in C++98 ‘vstrCam’ must be initialized by constructor, not by ‘{...}’ std::vector vstrCam = { "Loc1_1", "Loc1_2", "Loc1_3", "Loc1_4", "Loc1_5", "Loc1_6", "Loc1_7", "Loc1_8" }; ^ main.cpp:136:118: error: could not convert ‘{"Loc1_1", "Loc1_2", "Loc1_3", "Loc1_4", "Loc1_5", "Loc1_6", "Loc1_7", "Loc1_8"}’ from ‘’ to ‘std::vector<std::__cxx11::basic_string >’ main.cpp:144:22: error: in C++98 ‘vnSpdWinSz’ must be initialized by constructor, not by ‘{...}’ 31, 31, 31, 31, 31 }; ^ main.cpp:144:22: error: could not convert ‘{15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, 31}’ from ‘’ to ‘std::vector’ main.cpp:149:37: error: in C++98 ‘vfSpdScl’ must be initialized by constructor, not by ‘{...}’ 0.89f, 0.89f, 0.89f, 0.89f, 0.89f }; ^ main.cpp:149:37: error: could not convert ‘{1.25e+0f, 1.25e+0f, 1.25e+0f, 1.25e+0f, 1.25e+0f, 1.25e+0f, 1.25e+0f, 1.25e+0f, 1.04999995e+0f, 1.04999995e+0f, 1.04999995e+0f, 1.04999995e+0f, 1.04999995e+0f, 1.04999995e+0f, 1.04999995e+0f, 1.04999995e+0f, 8.00000012e-1f, 8.00000012e-1f, 8.00000012e-1f, 8.00000012e-1f, 8.00000012e-1f, 8.00000012e-1f, 8.89999986e-1f, 8.89999986e-1f, 8.89999986e-1f, 8.89999986e-1f, 8.89999986e-1f}’ from ‘’ to ‘std::vector’ main.cpp:154:32: error: in C++98 ‘vfSpdStdThld’ must be initialized by constructor, not by ‘{...}’ 5.0f, 5.0f, 5.0f, 5.0f, 5.0f }; ^ main.cpp:154:32: error: could not convert ‘{7.0e+1f, 7.0e+1f, 7.0e+1f, 7.0e+1f, 7.0e+1f, 7.0e+1f, 7.0e+1f, 7.0e+1f, 7.0e+1f, 7.0e+1f, 7.0e+1f, 7.0e+1f, 7.0e+1f, 7.0e+1f, 7.0e+1f, 7.0e+1f, 1.5e+1f, 1.5e+1f, 1.5e+1f, 1.5e+1f, 1.5e+1f, 1.5e+1f, 5.0e+0f, 5.0e+0f, 5.0e+0f, 5.0e+0f, 5.0e+0f}’ from ‘’ to ‘std::vector’ main.cpp:159:37: error: in C++98 ‘vfSpdLowThld’ must be initialized by constructor, not by ‘{...}’ 18.0f, 18.0f, 18.0f, 18.0f, 18.0f }; ^ main.cpp:159:37: error: could not convert ‘{1.0e+1f, 1.0e+1f, 1.0e+1f, 1.0e+1f, 1.0e+1f, 1.0e+1f, 1.0e+1f, 1.0e+1f, 1.0e+1f, 1.0e+1f, 1.0e+1f, 1.0e+1f, 1.0e+1f, 1.0e+1f, 1.0e+1f, 1.0e+1f, 2.8e+1f, 2.8e+1f, 2.8e+1f, 2.8e+1f, 2.8e+1f, 2.8e+1f, 1.8e+1f, 1.8e+1f, 1.8e+1f, 1.8e+1f, 1.8e+1f}’ from ‘’ to ‘std::vector’ main.cpp:164:32: error: in C++98 ‘vfSpdStpThld’ must be initialized by constructor, not by ‘{...}’ 5.0f, 5.0f, 5.0f, 5.0f, 5.0f }; ^ main.cpp:164:32: error: could not convert ‘{2.0e+0f, 2.0e+0f, 2.0e+0f, 2.0e+0f, 2.0e+0f, 2.0e+0f, 2.0e+0f, 2.0e+0f, 2.0e+0f, 2.0e+0f, 2.0e+0f, 2.0e+0f, 2.0e+0f, 2.0e+0f, 2.0e+0f, 2.0e+0f, 5.0e+0f, 5.0e+0f, 5.0e+0f, 5.0e+0f, 5.0e+0f, 5.0e+0f, 5.0e+0f, 5.0e+0f, 5.0e+0f, 5.0e+0f, 5.0e+0f}’ from ‘’ to ‘std::vector’ main.cpp:169:32: error: in C++98 ‘vfSpdPropFNThld’ must be initialized by constructor, not by ‘{...}’ 0.0f, 0.0f, 0.0f, 0.0f, 0.0f }; ^ main.cpp:169:32: error: could not convert ‘{0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 3.0e+1f, 3.0e+1f, 3.0e+1f, 3.0e+1f, 3.0e+1f, 3.0e+1f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f}’ from ‘’ to ‘std::vector’ main.cpp:186:41: warning: format not a string literal and no format arguments [-Wformat-security] std::sprintf(acOutSubmPth, acTrk1FlrPth); ^ main.cpp:195:41: warning: format not a string literal and no format arguments [-Wformat-security] std::sprintf(acOutVdoPth, acTrk1FlrPth); ^ main.cpp:205:41: warning: format not a string literal and no format arguments [-Wformat-security] std::sprintf(acCamFlrPth, acTrk1FlrPth); ^ main.cpp:210:44: warning: format not a string literal and no format arguments [-Wformat-security] std::sprintf(acInCamParamPth, acCamFlrPth); ^ main.cpp:216:41: warning: format not a string literal and no format arguments [-Wformat-security] std::sprintf(acInTrk2dPth, acCamFlrPth); ^ main.cpp:222:42: warning: format not a string literal and no format arguments [-Wformat-security] std::sprintf(acInFrmFlrPth, acCamFlrPth); ^ main.cpp:228:43: warning: format not a string literal and no format arguments [-Wformat-security] std::sprintf(acOutTrkFlrPth, acCamFlrPth); ^ main.cpp:234:43: warning: format not a string literal and no format arguments [-Wformat-security] std::sprintf(acOutTrkPth, acOutTrkFlrPth); ^ main.cpp:240:51: warning: format not a string literal and no format arguments [-Wformat-security] std::sprintf(acOutTrk3dImgFlrPth, acOutTrkFlrPth); ^ main.cpp:519:43: warning: format not a string literal and no format arguments [-Wformat-security] std::sprintf(acInFrmPth, acInFrmFlrPth); ^ main.cpp:579:50: warning: format not a string literal and no format arguments [-Wformat-security] std::sprintf(acOutFrmPth, acOutTrk3dImgFlrPth);

any reccommendation for it?

zhengthomastang commented 5 years ago

This issue may be caused by the misalignment between C++ compilers in Windows and Linux. For this specific error, here is a possible solution. Or you can rewrite the vector initialization by using push_back() instead.

dahlan77 commented 5 years ago

Actually I have tested with other compilers like std 11,std 14 and also std 98

zhengthomastang commented 5 years ago

@dahlan77 Can you try to change the initialization by using push_back() instead?

dahlan77 commented 5 years ago

Hi zhengthomas,,I finally can compile the speed but I must do camera calibration first ,but in calibration tutorial I still confuse the procedure

but when i compiler with g++ -std=c++11 -o camtest main.cpp pkg-config opencv --cflags --libs

the output is /tmp/cctyn5r3.o: In function main': main.cpp:(.text+0x12da): undefined reference toCCamCal::CCamCal()' main.cpp:(.text+0x12e9): undefined reference to CCfg::CCfg()' main.cpp:(.text+0x12f8): undefined reference toCCfg::ldCfgFl()' main.cpp:(.text+0x1519): undefined reference to CCamCal::initialize(CCfg, cv::Mat)' main.cpp:(.text+0x1528): undefined reference toCCfg::~CCfg()' main.cpp:(.text+0x157f): undefined reference to oVanLnSel' main.cpp:(.text+0x1584): undefined reference toCVanLnSel::initialize(CCfg, cv::Mat)' main.cpp:(.text+0x1593): undefined reference to CCfg::~CCfg()' main.cpp:(.text+0x15ae): undefined reference tooVanLnSel' main.cpp:(.text+0x15b6): undefined reference to CVanLnSel::process()' main.cpp:(.text+0x15e8): undefined reference toCCamCal::process(std::vector<cv::Point, std::allocator<cv::Point > >)' main.cpp:(.text+0x161a): undefined reference to CCfg::~CCfg()' main.cpp:(.text+0x1629): undefined reference toCCamCal::~CCamCal()' main.cpp:(.text+0x168c): undefined reference to CCfg::~CCfg()' main.cpp:(.text+0x16b4): undefined reference toCCfg::~CCfg()' main.cpp:(.text+0x1704): undefined reference to CCfg::~CCfg()' main.cpp:(.text+0x1718): undefined reference toCCamCal::~CCamCal()' collect2: error: ld returned 1 exit status

zhengthomastang commented 5 years ago

@dahlan77 You will need to link the other source files in 2018AICity_TeamUW/Track1/CAM_CAL_IPL/CAM_CAL_IPL/src/ during compilation. Another option for camera calibration is here. But please note that the output format is 3x3 homography matrix instead of 3x4 projection matrix.

dahlan77 commented 5 years ago

Error: configuration file not opened

after i compiled the CAM calibration but the out put is above

zhengthomastang commented 5 years ago

By default, the configuration file cfg.json is under .\\data\\ (in Linux you will need to change the backslashes into slashes). You can check Cfg.cpp for more details.

dahlan77 commented 5 years ago

Vanishing point (right): (300000,500) Vanishing point (left): (926,-100)

The output for cam calibration but the output for speed still configuration

the out put for speed : Error: camera parameters not loaded

zhengthomastang commented 5 years ago

@dahlan77 I am not sure about your issue/question. Please check in cfg.json and the code that all the \\ in file paths have been changed into /.

dahlan77 commented 5 years ago

Actually I have changed the configure in cfg.json..

and the result is

Vanishing point (right): (300000,500) Vanishing point (left): (926,-100) Start EDA optimization for camera calibration ==== generation 0: ==== 25%...50%...75%...100%! current error mean = 2634.767281 current error standard deviation = 21089.085288

==== generation 1: ==== 25%...50%...75%...100%! current error mean = 16.639031 current error standard deviation = 7.898482

==== generation 2: ==== 25%...50%...75%...100%! current error mean = 6.162161 current error standard deviation = 2.477083

==== generation 3: ==== 25%...50%...75%...100%! current error mean = 3.504104 current error standard deviation = 0.844408

==== generation 4: ==== 25%...50%...75%...100%! current error mean = 2.835919 current error standard deviation = 0.332255

==== generation 5: ==== 25%...50%...75%...100%! current error mean = 2.605511 current error standard deviation = 0.146056

==== generation 6: ==== 25%...50%...75%...100%! current error mean = 2.500789 current error standard deviation = 0.061076

==== generation 7: ==== 25%...50%...75%...100%! current error mean = 2.474164 current error standard deviation = 0.039133

==== generation 8: ==== 25%...50%...75%...100%! current error mean = 2.457497 current error standard deviation = 0.026974 Reprojection error is small enough. Stop generation. ..and it will be save in camParam.text and connected with Speed Estimation but still have no good result with Error: camera parameters not loaded

in cfg.json I changed into my configuration folder

"inFrmPth": "/home/dahlan/AICITY/Track1/CAM_CAL_IPL/CAM_CAL_IPL/data/frm.png",
// path of output text file of camera parameters
"outCamParamPth": "/home/dahlan/AICITY/Track1/CAM_CAL_IPL/CAM_CAL_IPL/data/camParam.txt",

So,am i missing something?

zhengthomastang commented 5 years ago

@dahlan77 Sorry for the inconvenience, but please change the file/directory paths at Lines 214, 220, 226, 232, 238 and 244 of Track1/SPD_EST_IPL/SPD_EST_IPL/src/main.cpp.

dahlan77 commented 5 years ago

I am sorry before,,how we got track2d.txt and track1.txt?

zhengthomastang commented 5 years ago

@dahlan77 track2d.txt gives the 2D tracking results. You can use our tracklet-clustering-based method to get the 2D tracking results or your own chosen methods. track1.txt is the output file.

dahlan77 commented 5 years ago

so its okay we create track2d.txt with empty files,because that text is the result?

zhengthomastang commented 5 years ago

@dahlan77 The track2d.txt file cannot be empty. 3D tracking requires the camera projection matrix and also the 2D tracking results, so that the 2D trajectories can be projected to 3D in order to measure 3D speed. However, you do not need to create those output files such as track1.txt.

dahlan77 commented 5 years ago

Okay I see,am I missing something,,because I don't got the track2d.txt ,what should I compile to got track2d.txt

Thank you for your helping zheng thomas..

zhengthomastang commented 5 years ago

@dahlan77 You can use our provided YOLO package YOLO_VEH_IPL to run vehicle detection, and then use the tracklet-based tracking method TC_tracker for tracking-by-detection. Sorry for making things complicated..