Project update‎ > ‎

2012/12/6-David-Real-Time Human Detection Using Contour Cues的Source Code編譯

posted Dec 6, 2012, 12:01 AM by 梁仲偉
2012/12/6

移植到Windows後在main.cpp檔編譯OK
在Pedestrian_ICRA.cpp檔編譯出現error
1>c:\opencv2.0\vc2008\include\opencv\cvcompat.h(803) : warning C4819: The file contains a character that cannot be represented in the current code page (950). Save the file in Unicode format to prevent data loss
1>c:\users\user\desktop\pedestrian_icra\pedestrian_icra\pedestrian_icra.cpp(153) : error C2589: '(' : illegal token on right side of '::'
1>c:\users\user\desktop\pedestrian_icra\pedestrian_icra\pedestrian_icra.cpp(153) : error C2059: syntax error : '::'
1>c:\users\user\desktop\pedestrian_icra\pedestrian_icra\pedestrian_icra.cpp(154) : error C2589: '(' : illegal token on right side of '::'
1>c:\users\user\desktop\pedestrian_icra\pedestrian_icra\pedestrian_icra.cpp(154) : error C2059: syntax error : '::'
1>c:\users\user\desktop\pedestrian_icra\pedestrian_icra\pedestrian_icra.cpp(155) : error C2589: '(' : illegal token on right side of '::'
1>c:\users\user\desktop\pedestrian_icra\pedestrian_icra\pedestrian_icra.cpp(155) : error C2059: syntax error : '::'
1>c:\users\user\desktop\pedestrian_icra\pedestrian_icra\pedestrian_icra.cpp(156) : error C2589: '(' : illegal token on right side of '::'
1>c:\users\user\desktop\pedestrian_icra\pedestrian_icra\pedestrian_icra.cpp(156) : error C2059: syntax error : '::'
1>c:\users\user\desktop\pedestrian_icra\pedestrian_icra\pedestrian_icra.cpp(179) : error C2589: '(' : illegal token on right side of '::'
1>c:\users\user\desktop\pedestrian_icra\pedestrian_icra\pedestrian_icra.cpp(179) : error C2059: syntax error : '::'
1>c:\users\user\desktop\pedestrian_icra\pedestrian_icra\pedestrian_icra.cpp(180) : error C2589: '(' : illegal token on right side of '::'
1>c:\users\user\desktop\pedestrian_icra\pedestrian_icra\pedestrian_icra.cpp(180) : error C2059: syntax error : '::'
1>c:\users\user\desktop\pedestrian_icra\pedestrian_icra\pedestrian_icra.cpp(181) : error C2589: '(' : illegal token on right side of '::'
1>c:\users\user\desktop\pedestrian_icra\pedestrian_icra\pedestrian_icra.cpp(181) : error C2059: syntax error : '::'
1>c:\users\user\desktop\pedestrian_icra\pedestrian_icra\pedestrian_icra.cpp(182) : error C2589: '(' : illegal token on right side of '::'
1>c:\users\user\desktop\pedestrian_icra\pedestrian_icra\pedestrian_icra.cpp(182) : error C2059: syntax error : '::'
1>c:\users\user\desktop\pedestrian_icra\pedestrian_icra\pedestrian_icra.cpp(495) : warning C4244: 'argument' : conversion from 'double' to 'int', possible loss of data
1>c:\users\user\desktop\pedestrian_icra\pedestrian_icra\pedestrian_icra.cpp(495) : warning C4244: 'argument' : conversion from 'double' to 'int', possible loss of data
1>c:\users\user\desktop\pedestrian_icra\pedestrian_icra\pedestrian_icra.cpp(495) : warning C4244: 'argument' : conversion from 'double' to 'int', possible loss of data
1>c:\users\user\desktop\pedestrian_icra\pedestrian_icra\pedestrian_icra.cpp(495) : warning C4244: 'argument' : conversion from 'double' to 'int', possible loss of data
1>Build log was saved at "file://d:\Visual Studio 2008\Projects\test\test\Debug\BuildLog.htm"
1>test - 16 error(s), 5 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
 
解決error C2589的方法
在153、154、155、156、179、180、181、182行的std::max改成(std::max),std::min改成(std::min)
再次編譯
無error
 
 
在Pedestrian_ICRA.cpp檔中的15~16行的標頭檔
#include <sys/types.h>
是linux中使用的
因此要改掉
 
#include <sys/types.h>
要換成
#include <windows.h>
 
另外290行的
filenames.push_back("combined.txt.model");
要改成
filenames.push_back("C:\\Users\\USER\\Desktop\\Pedestrian_ICRA\\Pedestrian_ICRA\\combined.txt.model");
 
293行
filenames.push_back("combined2.txt.model");
改成
filenames.push_back("C:\\Users\\USER\\Desktop\\Pedestrian_ICRA\\Pedestrian_ICRA\\combined2.txt.model");
 
514~519行
const std::string base_dir = "video2/";
const char* out_dir = "./";
const char* listname = "video2/files.txt";
std::ifstream in(listname);
std::string filename;
std::ofstream out("video2/result_HIK.txt");
改成
const std::string base_dir = "C:\\Users\\USER\\Desktop\\Pedestrian_ICRA\\Pedestrian_ICRA\\video2";
const char* out_dir = "C:\\Users\\USER\\Desktop\\Pedestrian_ICRA\\Pedestrian_ICRA\\video2";
const char* listname = "C:\\Users\\USER\\Desktop\\Pedestrian_ICRA\\Pedestrian_ICRA\\video2\\files.txt";
std::ifstream in(listname);
std::string filename;
std::ofstream out("C:\\Users\\USER\\Desktop\\Pedestrian_ICRA\\Pedestrian_ICRA\\video2\\result_HIK.txt");
 
重新編譯並執行
出現錯誤
1>Pedestrian_ICRA.obj : error LNK2019: unresolved external symbol _cvReleaseImage referenced in function "int __cdecl DetectHuman(char const *,char const *,class DetectionScanner &,class std::basic_ofstream<char,struct std::char_traits<char> > &)" (?DetectHuman@@YAHPBD0AAVDetectionScanner@@AAV?$basic_ofstream@DU?$char_traits@D@std@@@std@@@Z)
1>Pedestrian_ICRA.obj : error LNK2019: unresolved external symbol _cvWaitKey referenced in function "int __cdecl DetectHuman(char const *,char const *,class DetectionScanner &,class std::basic_ofstream<char,struct std::char_traits<char> > &)" (?DetectHuman@@YAHPBD0AAVDetectionScanner@@AAV?$basic_ofstream@DU?$char_traits@D@std@@@std@@@Z)
1>Pedestrian_ICRA.obj : error LNK2019: unresolved external symbol _cvShowImage referenced in function "int __cdecl DetectHuman(char const *,char const *,class DetectionScanner &,class std::basic_ofstream<char,struct std::char_traits<char> > &)" (?DetectHuman@@YAHPBD0AAVDetectionScanner@@AAV?$basic_ofstream@DU?$char_traits@D@std@@@std@@@Z)
1>Pedestrian_ICRA.obj : error LNK2019: unresolved external symbol _cvRectangle referenced in function "int __cdecl DetectHuman(char const *,char const *,class DetectionScanner &,class std::basic_ofstream<char,struct std::char_traits<char> > &)" (?DetectHuman@@YAHPBD0AAVDetectionScanner@@AAV?$basic_ofstream@DU?$char_traits@D@std@@@std@@@Z)
1>Pedestrian_ICRA.obj : error LNK2019: unresolved external symbol _cvLoadImage referenced in function "int __cdecl DetectHuman(char const *,char const *,class DetectionScanner &,class std::basic_ofstream<char,struct std::char_traits<char> > &)" (?DetectHuman@@YAHPBD0AAVDetectionScanner@@AAV?$basic_ofstream@DU?$char_traits@D@std@@@std@@@Z)
1>Pedestrian_ICRA.obj : error LNK2019: unresolved external symbol _cvNamedWindow referenced in function "int __cdecl DetectHuman(char const *,char const *,class DetectionScanner &,class std::basic_ofstream<char,struct std::char_traits<char> > &)" (?DetectHuman@@YAHPBD0AAVDetectionScanner@@AAV?$basic_ofstream@DU?$char_traits@D@std@@@std@@@Z)
1>Pedestrian_ICRA.obj : error LNK2019: unresolved external symbol _cvCvtColor referenced in function "public: bool __thiscall IntImage<double>::Load(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,char)" (?Load@?$IntImage@N@@QAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@D@Z)
1>Pedestrian_ICRA.obj : error LNK2019: unresolved external symbol _cvCreateImage referenced in function "public: bool __thiscall IntImage<double>::Load(class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > const &,char)" (?Load@?$IntImage@N@@QAE_NABV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@D@Z)
1>D:\Visual Studio 2008\Projects\test\Debug\test.exe : fatal error LNK1120: 8 unresolved externals
1>Build log was saved at "file://d:\Visual Studio 2008\Projects\test\test\Debug\BuildLog.htm"
1>test - 9 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
 
結果發現錯在很簡單的問題上
在project中少加入opencv的.lib
加入後順利編譯並且執行
結果很快就結束
因此在main.cpp中的return 0;前面加入
system("pause");
 
執行發現不能顯示偵測結果的圖
結果發現
 
問題出在514和515行
const std::string base_dir = "C:\\Users\\USER\\Desktop\\Pedestrian_ICRA\\Pedestrian_ICRA\\video2";
const char* out_dir = "C:\\Users\\USER\\Desktop\\Pedestrian_ICRA\\Pedestrian_ICRA\\video2";
video2後面還要再加\\
變成
const std::string base_dir = "C:\\Users\\USER\\Desktop\\Pedestrian_ICRA\\Pedestrian_ICRA\\video2\\";
const char* out_dir = "C:\\Users\\USER\\Desktop\\Pedestrian_ICRA\\Pedestrian_ICRA\\video2\\";
 
再次編譯並執行
成功執行
 
執行結果圖
 
 
  
 
 
Comments