#include <sft/fpool.hpp>
#include <sft/random.hpp>
-#include <glob.h>
#include <queue>
// ========= FeaturePool ========= //
pool.reserve(nfeatures);
- sft::Random::engine eng(8854342234L);
- sft::Random::engine eng_ch(314152314L);
+ sft::Random::engine eng(8854342234LU);
+ sft::Random::engine eng_ch(314152314LU);
sft::Random::uniform chRand(0, N_CHANNELS - 1);
return std::string(s);
}
+}
+
+#if !defined (_WIN32) && ! defined(__MINGW32__)
+
+#include <glob.h>
+
+namespace {
+using namespace sft;
void glob(const string& path, svector& ret)
{
glob_t glob_result;
globfree(&glob_result);
}
+
+}
+#else
+
+#include <windows.h>
+namespace {
+using namespace sft;
+void glob(const string& refRoot, const string& refExt, svector &refvecFiles)
+{
+ std::string strFilePath; // Filepath
+ std::string strExtension; // Extension
+
+ std::string strPattern = refRoot + "\\*.*";
+
+ WIN32_FIND_DATA FileInformation; // File information
+ HANDLE hFile = ::FindFirstFile(strPattern.c_str(), &FileInformation);
+
+ if(hFile == INVALID_HANDLE_VALUE)
+ CV_Error(CV_StsBadArg, "Your dataset search path is incorrect");
+
+ do
+ {
+ if(FileInformation.cFileName[0] != '.')
+ {
+ strFilePath.erase();
+ strFilePath = refRoot + "\\" + FileInformation.cFileName;
+
+ if( !(FileInformation.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
+ {
+ // Check extension
+ strExtension = FileInformation.cFileName;
+ strExtension = strExtension.substr(strExtension.rfind(".") + 1);
+
+ if(strExtension == refExt)
+ // Save filename
+ refvecFiles.push_back(strFilePath);
+ }
+ }
+ }
+ while(::FindNextFile(hFile, &FileInformation) == TRUE);
+
+ // Close handle
+ ::FindClose(hFile);
+
+ DWORD dwError = ::GetLastError();
+ if(dwError != ERROR_NO_MORE_FILES)
+ CV_Error(CV_StsBadArg, "Your dataset search path is incorrect");
+}
}
+
+#endif
+
// in the default case data folders should be alligned as following:
// 1. positives: <train or test path>/octave_<octave number>/pos/*.png
// 2. negatives: <train or test path>/octave_<octave number>/neg/*.png
dprintf("%s\n", "get dataset file names...");
dprintf("%s\n", "Positives globbing...");
+
+#if !defined (_WIN32) && ! defined(__MINGW32__)
glob(path + "/pos/octave_" + itoa(oct) + "/*.png", pos);
+#else
+ glob(path + "/pos/octave_" + itoa(oct), "png", pos);
+#endif
dprintf("%s\n", "Negatives globbing...");
+#if !defined (_WIN32) && ! defined(__MINGW32__)
glob(path + "/neg/octave_" + itoa(oct) + "/*.png", neg);
+#else
+ glob(path + "/neg/octave_" + itoa(oct), "png", neg);
+#endif
// Check: files not empty
CV_Assert(pos.size() != size_t(0));
#if defined WITH_DEBUG_OUT
# include <stdio.h>
-# define dprintf(format, ...) \
- do { printf(format, ##__VA_ARGS__); } while (0)
+# define dprintf(format, ...) printf(format, ##__VA_ARGS__)
#else
# define dprintf(format, ...)
#endif
// Scaled and shrunk model size.
cv::Size model(ivector::const_iterator it) const
{
- float octave = powf(2, *it);
+ float octave = powf(2.f, *it);
return cv::Size( cvRound(modelWinSize.width * octave) / shrinkage,
cvRound(modelWinSize.height * octave) / shrinkage );
}
// Scaled but, not shrunk bounding box for object in sample image.
cv::Rect bbox(ivector::const_iterator it) const
{
- float octave = powf(2, *it);
+ float octave = powf(2.f, *it);
return cv::Rect( cvRound(offset.x * octave), cvRound(offset.y * octave),
cvRound(modelWinSize.width * octave), cvRound(modelWinSize.height * octave));
}
CV_EXPORTS bool initModule_ml(void);
-CV_EXPORTS class FeaturePool
+class CV_EXPORTS FeaturePool
{
public:
virtual ~FeaturePool();
};
-class Dataset
+class CV_EXPORTS Dataset
{
public:
typedef enum {POSITIVE = 1, NEGATIVE = 2} SampleType;
};
// used for traning single octave scale
-class Octave : cv::Boost
+class CV_EXPORTS Octave : public cv::Boost
{
public:
#if defined WITH_DEBUG_OUT
# include <stdio.h>
-# define dprintf(format, ...) \
- do { printf(format, ##__VA_ARGS__); } while (0)
+# define dprintf(format, ...) printf(format, ##__VA_ARGS__)
#else
# define dprintf(format, ...)
#endif
typedef rnd::uniform_int<int> uniform;
};
}
-
#endif
cv::FeaturePool::~FeaturePool(){}
void cv::Octave::generateNegatives(const Dataset* dataset, const FeaturePool* pool)
{
// ToDo: set seed, use offsets
- sft::Random::engine eng(65633343L);
- sft::Random::engine idxEng(764224349868L);
+ sft::Random::engine eng(65633343LU);
+ sft::Random::engine idxEng(764224349868LU);
int h = boundingBox.height;
void cv::Octave::write( cv::FileStorage &fso, const FeaturePool* pool, InputArray _thresholds) const
{
CV_Assert(!_thresholds.empty());
- cv::Mat used( 1, weak->total * ( pow(2.f, params.max_depth) - 1), CV_32SC1);
+ cv::Mat used( 1, weak->total * ( (int)pow(2.f, params.max_depth) - 1), CV_32SC1);
int* usedPtr = used.ptr<int>(0);
int nfeatures = 0;
cv::Mat thresholds = _thresholds.getMat();