Fixed some warnings on VisualStudio2010

This commit is contained in:
Mathieu Labbé
2015-04-01 10:38:59 -04:00
parent 6089a44589
commit 37c34e8186
10 changed files with 27 additions and 23 deletions

View File

@@ -99,7 +99,7 @@ cv::Mat compressImage2(const cv::Mat & image, const std::string & format)
std::vector<unsigned char> bytes = compressImage(image, format); std::vector<unsigned char> bytes = compressImage(image, format);
if(bytes.size()) if(bytes.size())
{ {
return cv::Mat(1, bytes.size(), CV_8UC1, bytes.data()).clone(); return cv::Mat(1, (int)bytes.size(), CV_8UC1, bytes.data()).clone();
} }
return cv::Mat(); return cv::Mat();
} }
@@ -201,7 +201,7 @@ cv::Mat uncompressData(const cv::Mat & bytes)
cv::Mat uncompressData(const std::vector<unsigned char> & bytes) cv::Mat uncompressData(const std::vector<unsigned char> & bytes)
{ {
return uncompressData(bytes.data(), bytes.size()); return uncompressData(bytes.data(), (unsigned long)bytes.size());
} }
cv::Mat uncompressData(const unsigned char * bytes, unsigned long size) cv::Mat uncompressData(const unsigned char * bytes, unsigned long size)

View File

@@ -1016,7 +1016,7 @@ void Memory::clear()
// Save some stats to the db, save only when the mem is not empty // Save some stats to the db, save only when the mem is not empty
if(_dbDriver && (_stMem.size() || _workingMem.size())) if(_dbDriver && (_stMem.size() || _workingMem.size()))
{ {
unsigned int memSize = _workingMem.size() + _stMem.size(); unsigned int memSize = (unsigned int)(_workingMem.size() + _stMem.size());
if(_workingMem.size() && _workingMem.begin()->first < 0) if(_workingMem.size() && _workingMem.begin()->first < 0)
{ {
--memSize; --memSize;
@@ -1863,7 +1863,7 @@ Transform Memory::computeVisualTransform(
true, 3.0, 10, true, 3.0, 10,
&inliersV, &inliersV,
variance); variance);
inliersCount = inliersV.size(); inliersCount = (int)inliersV.size();
if(!t.isNull() && inliersCount >= _bowMinInliers) if(!t.isNull() && inliersCount >= _bowMinInliers)
{ {
transform = t; transform = t;

View File

@@ -2057,8 +2057,8 @@ void Rtabmap::setWorkingDirectory(std::string path)
} }
} }
void Rtabmap::deleteLocation(int locationId) void Rtabmap::deleteLocation(int locationId)
{ {
if(_memory) if(_memory)

View File

@@ -95,7 +95,7 @@ void TreeOptimizer3::iterate(TreePoseGraph3::EdgeSet* eset, bool noPreconditione
maxRotationalErrors.push_back(mre); maxRotationalErrors.push_back(mre);
int interval=3; int interval=3;
if ((int)maxRotationalErrors.size()>=interval){ if ((int)maxRotationalErrors.size()>=interval){
uint s=maxRotationalErrors.size(); uint s=(uint)maxRotationalErrors.size();
double re0 = maxRotationalErrors[s-interval]; double re0 = maxRotationalErrors[s-interval];
double re1 = maxRotationalErrors[s-1]; double re1 = maxRotationalErrors[s-1];

View File

@@ -129,8 +129,8 @@ void DataRecorder::addData(const rtabmap::SensorData & data)
UTimer time; UTimer time;
memory_->update(data); memory_->update(data);
const Signature * s = memory_->getLastWorkingSignature(); const Signature * s = memory_->getLastWorkingSignature();
totalSizeKB_ += s->getImageCompressed().total()/1000; totalSizeKB_ += (int)s->getImageCompressed().total()/1000;
totalSizeKB_ += s->getDepthCompressed().total()/1000; totalSizeKB_ += (int)s->getDepthCompressed().total()/1000;
memory_->cleanup(); memory_->cleanup();
if(++count_ % 30) if(++count_ % 30)

View File

@@ -23,7 +23,7 @@ INCLUDE_DIRECTORIES(${INCLUDE_DIRS})
ADD_LIBRARY(rtabmap_utilite ${SRC_FILES}) ADD_LIBRARY(rtabmap_utilite ${SRC_FILES})
IF(MINGW) IF(MINGW)
TARGET_LINK_LIBRARIES(rtabmap_utilite ${PTHREADS_LIBRARY} "-lpsapi") TARGET_LINK_LIBRARIES(rtabmap_utilite ${PTHREADS_LIBRARY} "-lpsapi")
ELSEIF(WIN32) ELSEIF(WIN32 OR MSVC)
FIND_LIBRARY(PSAPI_LIBRARIES NAMES psapi libpsapi.dll.a libpsapi.a libpsapi.lib ) FIND_LIBRARY(PSAPI_LIBRARIES NAMES psapi libpsapi.dll.a libpsapi.a libpsapi.lib )
TARGET_LINK_LIBRARIES(rtabmap_utilite ${PSAPI_LIBRARIES}) TARGET_LINK_LIBRARIES(rtabmap_utilite ${PSAPI_LIBRARIES})
ELSE() ELSE()

View File

@@ -172,7 +172,7 @@ std::string uBytes2Hex(const char * bytes, unsigned int bytesLen)
std::vector<char> uHex2Bytes(const std::string & hex) std::vector<char> uHex2Bytes(const std::string & hex)
{ {
return uHex2Bytes(&hex[0], hex.length()); return uHex2Bytes(&hex[0], (int)hex.length());
} }
std::vector<char> uHex2Bytes(const char * hex, int hexLen) std::vector<char> uHex2Bytes(const char * hex, int hexLen)
@@ -287,7 +287,11 @@ std::string uFormatv (const char *fmt, va_list args)
#endif #endif
// Try to vsnprintf into our buffer. // Try to vsnprintf into our buffer.
#ifdef _MSC_VER
int needed = vsnprintf_s(buf, size, size, fmt, argsTmp);
#else
int needed = vsnprintf (buf, size, fmt, argsTmp); int needed = vsnprintf (buf, size, fmt, argsTmp);
#endif
va_end(argsTmp); va_end(argsTmp);
// NB. C99 (which modern Linux and OS X follow) says vsnprintf // NB. C99 (which modern Linux and OS X follow) says vsnprintf
// failure returns the length it would have needed. But older // failure returns the length it would have needed. But older

View File

@@ -249,7 +249,7 @@ void UDirectory::rewind()
bool UDirectory::exists(const std::string & dirPath) bool UDirectory::exists(const std::string & dirPath)
{ {
bool r = false; bool r = false;
#if WIN32 #ifdef _WIN32
#ifdef UNICODE #ifdef UNICODE
wchar_t * wDirPath = createWCharFromChar(dirPath.c_str()); wchar_t * wDirPath = createWCharFromChar(dirPath.c_str());
DWORD dwAttrib = GetFileAttributes(wDirPath); DWORD dwAttrib = GetFileAttributes(wDirPath);
@@ -273,7 +273,7 @@ bool UDirectory::exists(const std::string & dirPath)
std::string UDirectory::getDir(const std::string & filePath) std::string UDirectory::getDir(const std::string & filePath)
{ {
std::string dir = filePath; std::string dir = filePath;
int i=dir.size()-1; int i=(int)dir.size()-1;
for(; i>=0; --i) for(; i>=0; --i)
{ {
if(dir[i] == '/' || dir[i] == '\\') if(dir[i] == '/' || dir[i] == '\\')
@@ -333,7 +333,7 @@ std::string UDirectory::currentDir(bool trailingSeparator)
bool UDirectory::makeDir(const std::string & dirPath) bool UDirectory::makeDir(const std::string & dirPath)
{ {
int status; int status;
#if WIN32 #ifdef _WIN32
status = _mkdir(dirPath.c_str()); status = _mkdir(dirPath.c_str());
#else #else
status = mkdir(dirPath.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); status = mkdir(dirPath.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
@@ -344,7 +344,7 @@ bool UDirectory::makeDir(const std::string & dirPath)
bool UDirectory::removeDir(const std::string & dirPath) bool UDirectory::removeDir(const std::string & dirPath)
{ {
int status; int status;
#if WIN32 #ifdef _WIN32
status = _rmdir(dirPath.c_str()); status = _rmdir(dirPath.c_str());
#else #else
status = rmdir(dirPath.c_str()); status = rmdir(dirPath.c_str());
@@ -355,7 +355,7 @@ bool UDirectory::removeDir(const std::string & dirPath)
std::string UDirectory::homeDir() std::string UDirectory::homeDir()
{ {
std::string path; std::string path;
#if WIN32 #ifdef _WIN32
#ifdef UNICODE #ifdef UNICODE
wchar_t wProfilePath[250]; wchar_t wProfilePath[250];
ExpandEnvironmentStrings(L"%userprofile%",wProfilePath,250); ExpandEnvironmentStrings(L"%userprofile%",wProfilePath,250);

View File

@@ -36,12 +36,12 @@ bool UFile::exists(const std::string &filePath)
long UFile::length(const std::string &filePath) long UFile::length(const std::string &filePath)
{ {
long fileSize = 0; long fileSize = 0;
FILE* fp = 0; FILE* fp = 0;
#ifdef _MSC_VER #ifdef _MSC_VER
fopen_s(&fp, filePath.c_str(), "rb"); fopen_s(&fp, filePath.c_str(), "rb");
#else #else
fp = fopen(filePath.c_str(), "rb"); fp = fopen(filePath.c_str(), "rb");
#endif #endif
if(fp == NULL) if(fp == NULL)
{ {
@@ -70,7 +70,7 @@ std::string UFile::getName(const std::string & filePath)
{ {
std::string fullPath = filePath; std::string fullPath = filePath;
std::string name; std::string name;
for(int i=fullPath.size()-1; i>=0; --i) for(int i=(int)fullPath.size()-1; i>=0; --i)
{ {
if(fullPath[i] == '/' || fullPath[i] == '\\') if(fullPath[i] == '/' || fullPath[i] == '\\')
{ {

View File

@@ -90,7 +90,7 @@ void UThread::join(bool killFirst)
uSleep(1); uSleep(1);
} }
#if WIN32 #ifdef _WIN32
#if PRINT_DEBUG #if PRINT_DEBUG
UDEBUG("Thread %d joining %d", UThreadC<void>::Self(), threadId_); UDEBUG("Thread %d joining %d", UThreadC<void>::Self(), threadId_);
#endif #endif