Commit d5d6f0a2 authored by jaco's avatar jaco

wip windows compiling error fixed

parent 5e6cef4c
......@@ -101,9 +101,9 @@ class CV_EXPORTS_W ObjectnessBING : public Objectness
void read();
void write() const;
vector<float> getobjectnessValues();
void setTrainingPath( string trainingPath );
void setBBResDir( string resultsDir );
std::vector<float> getobjectnessValues();
void setTrainingPath( std::string trainingPath );
void setBBResDir( std::string resultsDir );
protected:
bool computeSaliencyImpl( const InputArray image, OutputArray objectnessBoundingBox );
......@@ -137,7 +137,7 @@ class CV_EXPORTS_W ObjectnessBING : public Objectness
// List of the rectangles' objectness value, in the same order as
// the vector<Vec4i> objectnessBoundingBox returned by the algorithm (in computeSaliencyImpl function)
vector<float> objectnessValues;
std::vector<float> objectnessValues;
//vector<Vec4i> objectnessBoundingBox;
private:
......
......@@ -42,91 +42,102 @@
#include "kyheader.h"
#include "CmFile.h"
// Get image names from a wildcard. Eg: GetNames("D:\\*.jpg", imgNames);
int CmFile::GetNames(CStr &_nameW, vecS &_names, string _dir)
int CmFile::GetNames( CStr &_nameW, vecS &_names, std::string _dir )
{
_dir = GetFolder(_nameW);
_dir = GetFolder( _nameW );
_names.clear();
DIR *dir;
struct dirent *ent;
if((dir = opendir(_dir.c_str()))!=NULL){
if( ( dir = opendir( _dir.c_str() ) ) != NULL )
{
//print all the files and directories within directory
while((ent = readdir(dir))!=NULL){
if(ent->d_name[0] == '.')
while ( ( ent = readdir( dir ) ) != NULL )
{
if( ent->d_name[0] == '.' )
continue;
if(ent->d_type ==4)
if( ent->d_type == 4 )
continue;
_names.push_back(ent->d_name);
_names.push_back( ent->d_name );
}
closedir( dir );
}
closedir(dir);
} else {
perror("");
else
{
perror( "" );
return EXIT_FAILURE;
}
return (int)_names.size();
return (int) _names.size();
}
int CmFile::GetSubFolders(CStr &folder, vecS &subFolders)
int CmFile::GetSubFolders( CStr &folder, vecS &subFolders )
{
subFolders.clear();
string nameWC = GetFolder(folder);//folder + "/*";
std::string nameWC = GetFolder( folder ); //folder + "/*";
DIR *dir;
struct dirent *ent;
if((dir = opendir(nameWC.c_str()))!=NULL){
while((ent = readdir(dir))!=NULL){
if(ent->d_name[0] == '.')
if( ( dir = opendir( nameWC.c_str() ) ) != NULL )
{
while ( ( ent = readdir( dir ) ) != NULL )
{
if( ent->d_name[0] == '.' )
continue;
if(ent->d_type == 4){
subFolders.push_back(ent->d_name);
if( ent->d_type == 4 )
{
subFolders.push_back( ent->d_name );
}
}
closedir( dir );
}
closedir(dir);
} else {
perror("");
else
{
perror( "" );
return EXIT_FAILURE;
}
return (int)subFolders.size();
return (int) subFolders.size();
}
int CmFile::GetNames(CStr& rootFolder, CStr &fileW, vecS &names)
int CmFile::GetNames( CStr& rootFolder, CStr &fileW, vecS &names )
{
GetNames(rootFolder + fileW, names);
GetNames( rootFolder + fileW, names );
vecS subFolders, tmpNames;
int subNum = CmFile::GetSubFolders(rootFolder, subFolders);//
for (int i = 0; i < subNum; i++){
int subNum = CmFile::GetSubFolders( rootFolder, subFolders ); //
for ( int i = 0; i < subNum; i++ )
{
subFolders[i] += "/";
int subNum_ = GetNames(rootFolder + subFolders[i], fileW, tmpNames);
for (int j = 0; j < subNum_; j++)
names.push_back(subFolders[i] + tmpNames[j]);
int subNum_ = GetNames( rootFolder + subFolders[i], fileW, tmpNames );
for ( int j = 0; j < subNum_; j++ )
names.push_back( subFolders[i] + tmpNames[j] );
}
return (int)names.size();
return (int) names.size();
}
int CmFile::GetNamesNE(CStr& nameWC, vecS &names, string dir, string ext)
int CmFile::GetNamesNE( CStr& nameWC, vecS &names, std::string dir, std::string ext )
{
int fNum = GetNames(nameWC, names, dir);
ext = GetExtention(nameWC);
for (int i = 0; i < fNum; i++)
names[i] = GetNameNE(names[i]);
int fNum = GetNames( nameWC, names, dir );
ext = GetExtention( nameWC );
for ( int i = 0; i < fNum; i++ )
names[i] = GetNameNE( names[i] );
return fNum;
}
int CmFile::GetNamesNE(CStr& rootFolder, CStr &fileW, vecS &names)
int CmFile::GetNamesNE( CStr& rootFolder, CStr &fileW, vecS &names )
{
int fNum = GetNames(rootFolder, fileW, names);
int extS = GetExtention(fileW).size();
for (int i = 0; i < fNum; i++)
names[i].resize(names[i].size() - extS);
int fNum = GetNames( rootFolder, fileW, names );
int extS = GetExtention( fileW ).size();
for ( int i = 0; i < fNum; i++ )
names[i].resize( names[i].size() - extS );
return fNum;
}
bool CmFile::MkDir(CStr &_path)
bool CmFile::MkDir( CStr &_path )
{
if(_path.size() == 0)
if( _path.size() == 0 )
return false;
static char buffer[1024];
strcpy(buffer, _S(_path));
strcpy( buffer, _S( _path ) );
#ifdef _WIN32
for (int i = 0; buffer[i] != 0; i ++) {
if (buffer[i] == '\\' || buffer[i] == '/') {
for (int i = 0; buffer[i] != 0; i ++)
{
if (buffer[i] == '\\' || buffer[i] == '/')
{
buffer[i] = '\0';
CreateDirectoryA(buffer, 0);
buffer[i] = '/';
......@@ -134,37 +145,40 @@ bool CmFile::MkDir(CStr &_path)
}
return CreateDirectoryA(_S(_path), 0);
#else
for (int i = 0; buffer[i] != 0; i ++) {
if (buffer[i] == '\\' || buffer[i] == '/') {
for ( int i = 0; buffer[i] != 0; i++ )
{
if( buffer[i] == '\\' || buffer[i] == '/' )
{
buffer[i] = '\0';
mkdir(buffer, 0);
mkdir( buffer, 0 );
buffer[i] = '/';
}
}
return mkdir(_S(_path), 0);
return mkdir( _S( _path ), 0 );
#endif
}
void CmFile::loadStrList(CStr &fName, vecS & strs, bool flag)
void CmFile::loadStrList( CStr &fName, vecS & strs, bool flag )
{
ifstream fIn(fName.c_str());
string line;
std::ifstream fIn( fName.c_str() );
std::string line;
//vecS strs;
while(getline(fIn, line)){
while ( getline( fIn, line ) )
{
unsigned sz = line.size();
if(flag)
line.resize(sz - 1);
printf("%s\n",_S(line));
strs.push_back(line);
if( flag )
line.resize( sz - 1 );
printf( "%s\n", _S( line ) );
strs.push_back( line );
}
//return strs;
}
bool CmFile::writeStrList(CStr &fName, const vecS &strs)
bool CmFile::writeStrList( CStr &fName, const vecS &strs )
{
FILE *f = fopen(_S(fName), "w");
if (f == NULL)
FILE *f = fopen( _S( fName ), "w" );
if( f == NULL )
return false;
for (size_t i = 0; i < strs.size(); i++)
fprintf(f, "%s\n", _S(strs[i]));
fclose(f);
for ( size_t i = 0; i < strs.size(); i++ )
fprintf( f, "%s\n", _S( strs[i] ) );
fclose( f );
return true;
}
......@@ -53,21 +53,21 @@
struct CmFile
{
static inline string GetFolder(CStr& path);
static inline string GetName(CStr& path);
static inline string GetNameNE(CStr& path);
static inline string GetPathNE(CStr& path);
static inline std::string GetFolder(CStr& path);
static inline std::string GetName(CStr& path);
static inline std::string GetNameNE(CStr& path);
static inline std::string GetPathNE(CStr& path);
// Get file names from a wildcard. Eg: GetNames("D:\\*.jpg", imgNames);
static int GetNames(CStr &nameW, vecS &names, std::string _dir = std::string());
static int GetNames(CStr& rootFolder, CStr &fileW, vecS &names);
static int GetNamesNE(CStr& nameWC, vecS &names, string dir = string(), string ext = string());
static int GetNamesNE(CStr& nameWC, vecS &names, std::string dir = std::string(), std::string ext = std::string());
static int GetNamesNE(CStr& rootFolder, CStr &fileW, vecS &names);
static inline string GetExtention(CStr name);
static inline std::string GetExtention(CStr name);
static int GetSubFolders(CStr& folder, vecS& subFolders);
static inline string GetWkDir();
static inline std::string GetWkDir();
static bool MkDir(CStr& path);
static void loadStrList(CStr &fName, vecS &strs, bool flag=false);
......@@ -77,19 +77,19 @@ struct CmFile
/************************************************************************/
/* Implementation of inline functions */
/************************************************************************/
string CmFile::GetFolder(CStr& path)
std::string CmFile::GetFolder(CStr& path)
{
return path.substr(0, path.find_last_of("\\/")+1);
}
string CmFile::GetName(CStr& path)
std::string CmFile::GetName(CStr& path)
{
int start = path.find_last_of("\\/")+1;
int end = path.find_last_not_of(' ')+1;
return path.substr(start, end - start);
}
string CmFile::GetNameNE(CStr& path)
std::string CmFile::GetNameNE(CStr& path)
{
int start = path.find_last_of("\\/")+1;
int end = path.find_last_of('.');
......@@ -99,7 +99,7 @@ string CmFile::GetNameNE(CStr& path)
return path.substr(start, path.find_last_not_of(' ')+1 - start);
}
string CmFile::GetPathNE(CStr& path)
std::string CmFile::GetPathNE(CStr& path)
{
int end = path.find_last_of('.');
if (end >= 0)
......@@ -108,7 +108,7 @@ string CmFile::GetPathNE(CStr& path)
return path.substr(0, path.find_last_not_of(' ') + 1);
}
string CmFile::GetExtention(CStr name)
std::string CmFile::GetExtention(CStr name)
{
return name.substr(name.find_last_of('.'));
}
......
......@@ -46,7 +46,9 @@
typedef pair<int, int> CostiIdx;
typedef std::pair<int, int> CostiIdx;
using namespace cv;
Mat CmShow::HistBins(CMat& color3f, CMat& val, CStr& title, bool descendShow, CMat &with)
{
// Prepare data
......@@ -69,10 +71,10 @@ Mat CmShow::HistBins(CMat& color3f, CMat& val, CStr& title, bool descendShow, CM
int* binH = (int*)(binVal1i.data);
Vec3b* binColor = (Vec3b*)(binColor3b.data);
int* binW = (int*)(width1i.data);
vector<CostiIdx> costIdx(n);
std::vector<CostiIdx> costIdx(n);
if (descendShow){
for (int i = 0; i < n; i++)
costIdx[i] = make_pair(binH[i], i);
costIdx[i] = std::make_pair(binH[i], i);
sort(costIdx.begin(), costIdx.end(), std::greater<CostiIdx>());
}
......
......@@ -43,7 +43,7 @@
class CmShow
{
public:
static Mat HistBins(CMat& color3f, CMat& val, CStr& title, bool descendShow = false, CMat &with = Mat());
static cv::Mat HistBins(CMat& color3f, CMat& val, CStr& title, bool descendShow = false, CMat &with = cv::Mat());
static void showTinyMat(CStr &title, CMat &m);
static inline void SaveShow(CMat& img, CStr& title);
};
......
......@@ -43,77 +43,86 @@
#include "FilterTIG.h"
#include "CmShow.h"
using namespace cv;
void FilterTIG::update(CMat &w1f){
CV_Assert(w1f.cols * w1f.rows == D && w1f.type() == CV_32F && w1f.isContinuous());
void FilterTIG::update( CMat &w1f )
{
CV_Assert( w1f.cols * w1f.rows == D && w1f.type() == CV_32F && w1f.isContinuous() );
float b[D], residuals[D];
memcpy(residuals, w1f.data, sizeof(float)*D);
for (int i = 0; i < NUM_COMP; i++){
memcpy( residuals, w1f.data, sizeof(float) * D );
for ( int i = 0; i < NUM_COMP; i++ )
{
float avg = 0;
for (int j = 0; j < D; j++){
for ( int j = 0; j < D; j++ )
{
b[j] = residuals[j] >= 0.0f ? 1.0f : -1.0f;
avg += residuals[j] * b[j];
}
avg /= D;
_coeffs1[i] = avg, _coeffs2[i] = avg*2, _coeffs4[i] = avg*4, _coeffs8[i] = avg*8;
for (int j = 0; j < D; j++)
residuals[j] -= avg*b[j];
_coeffs1[i] = avg, _coeffs2[i] = avg * 2, _coeffs4[i] = avg * 4, _coeffs8[i] = avg * 8;
for ( int j = 0; j < D; j++ )
residuals[j] -= avg * b[j];
UINT64 tig = 0;
for (int j = 0; j < D; j++)
tig = (tig << 1) | (b[j] > 0 ? 1 : 0);
for ( int j = 0; j < D; j++ )
tig = ( tig << 1 ) | ( b[j] > 0 ? 1 : 0 );
_bTIGs[i] = tig;
}
}
void FilterTIG::reconstruct(Mat &w1f){
w1f = Mat::zeros(8, 8, CV_32F);
float *weight = (float*)w1f.data;
for (int i = 0; i < NUM_COMP; i++){
void FilterTIG::reconstruct( Mat &w1f )
{
w1f = Mat::zeros( 8, 8, CV_32F );
float *weight = (float*) w1f.data;
for ( int i = 0; i < NUM_COMP; i++ )
{
UINT64 tig = _bTIGs[i];
for (int j = 0; j < D; j++)
weight[j] += _coeffs1[i] * (((tig >> (63-j)) & 1) ? 1 : -1);
for ( int j = 0; j < D; j++ )
weight[j] += _coeffs1[i] * ( ( ( tig >> ( 63 - j ) ) & 1 ) ? 1 : -1 );
}
}
// For a W by H gradient magnitude map, find a W-7 by H-7 CV_32F matching score map
// Please refer to my paper for definition of the variables used in this function
Mat FilterTIG::matchTemplate(const Mat &mag1u){
Mat FilterTIG::matchTemplate( const Mat &mag1u )
{
const int H = mag1u.rows, W = mag1u.cols;
const Size sz(W+1, H+1); // Expand original size to avoid dealing with boundary conditions
Mat_<INT64> Tig1 = Mat_<INT64>::zeros(sz), Tig2 = Mat_<INT64>::zeros(sz);
Mat_<INT64> Tig4 = Mat_<INT64>::zeros(sz), Tig8 = Mat_<INT64>::zeros(sz);
Mat_<byte> Row1 = Mat_<byte>::zeros(sz), Row2 = Mat_<byte>::zeros(sz);
Mat_<byte> Row4 = Mat_<byte>::zeros(sz), Row8 = Mat_<byte>::zeros(sz);
Mat_<float> scores(sz);
for(int y = 1; y <= H; y++){
const byte* G = mag1u.ptr<byte>(y-1);
INT64* T1 = Tig1.ptr<INT64>(y); // Binary TIG of current row
INT64* T2 = Tig2.ptr<INT64>(y);
INT64* T4 = Tig4.ptr<INT64>(y);
INT64* T8 = Tig8.ptr<INT64>(y);
INT64* Tu1 = Tig1.ptr<INT64>(y-1); // Binary TIG of upper row
INT64* Tu2 = Tig2.ptr<INT64>(y-1);
INT64* Tu4 = Tig4.ptr<INT64>(y-1);
INT64* Tu8 = Tig8.ptr<INT64>(y-1);
byte* R1 = Row1.ptr<byte>(y);
byte* R2 = Row2.ptr<byte>(y);
byte* R4 = Row4.ptr<byte>(y);
byte* R8 = Row8.ptr<byte>(y);
float *s = scores.ptr<float>(y);
for (int x = 1; x <= W; x++) {
byte g = G[x-1];
R1[x] = (R1[x-1] << 1) | ((g >> 4) & 1);
R2[x] = (R2[x-1] << 1) | ((g >> 5) & 1);
R4[x] = (R4[x-1] << 1) | ((g >> 6) & 1);
R8[x] = (R8[x-1] << 1) | ((g >> 7) & 1);
T1[x] = (Tu1[x] << 8) | R1[x];
T2[x] = (Tu2[x] << 8) | R2[x];
T4[x] = (Tu4[x] << 8) | R4[x];
T8[x] = (Tu8[x] << 8) | R8[x];
s[x] = dot(T1[x], T2[x], T4[x], T8[x]);
const Size sz( W + 1, H + 1 ); // Expand original size to avoid dealing with boundary conditions
Mat_<INT64> Tig1 = Mat_<INT64>::zeros( sz ), Tig2 = Mat_<INT64>::zeros( sz );
Mat_<INT64> Tig4 = Mat_<INT64>::zeros( sz ), Tig8 = Mat_<INT64>::zeros( sz );
Mat_<byte> Row1 = Mat_<byte>::zeros( sz ), Row2 = Mat_<byte>::zeros( sz );
Mat_<byte> Row4 = Mat_<byte>::zeros( sz ), Row8 = Mat_<byte>::zeros( sz );
Mat_<float> scores( sz );
for ( int y = 1; y <= H; y++ )
{
const byte* G = mag1u.ptr<byte>( y - 1 );
INT64* T1 = Tig1.ptr<INT64>( y ); // Binary TIG of current row
INT64* T2 = Tig2.ptr<INT64>( y );
INT64* T4 = Tig4.ptr<INT64>( y );
INT64* T8 = Tig8.ptr<INT64>( y );
INT64* Tu1 = Tig1.ptr<INT64>( y - 1 ); // Binary TIG of upper row
INT64* Tu2 = Tig2.ptr<INT64>( y - 1 );
INT64* Tu4 = Tig4.ptr<INT64>( y - 1 );
INT64* Tu8 = Tig8.ptr<INT64>( y - 1 );
byte* R1 = Row1.ptr<byte>( y );
byte* R2 = Row2.ptr<byte>( y );
byte* R4 = Row4.ptr<byte>( y );
byte* R8 = Row8.ptr<byte>( y );
float *s = scores.ptr<float>( y );
for ( int x = 1; x <= W; x++ )
{
byte g = G[x - 1];
R1[x] = ( R1[x - 1] << 1 ) | ( ( g >> 4 ) & 1 );
R2[x] = ( R2[x - 1] << 1 ) | ( ( g >> 5 ) & 1 );
R4[x] = ( R4[x - 1] << 1 ) | ( ( g >> 6 ) & 1 );
R8[x] = ( R8[x - 1] << 1 ) | ( ( g >> 7 ) & 1 );
T1[x] = ( Tu1[x] << 8 ) | R1[x];
T2[x] = ( Tu2[x] << 8 ) | R2[x];
T4[x] = ( Tu4[x] << 8 ) | R4[x];
T8[x] = ( Tu8[x] << 8 ) | R8[x];
s[x] = dot( T1[x], T2[x], T4[x], T8[x] );
}
}
Mat matchCost1f;
scores(Rect(8, 8, W-7, H-7)).copyTo(matchCost1f);
scores( Rect( 8, 8, W - 7, H - 7 ) ).copyTo( matchCost1f );
return matchCost1f;
}
......@@ -47,12 +47,12 @@ public:
void update(CMat &w);
// For a W by H gradient magnitude map, find a W-7 by H-7 CV_32F matching score map
Mat matchTemplate(const Mat &mag1u);
cv::Mat matchTemplate(const cv::Mat &mag1u);
inline float dot(const INT64 tig1, const INT64 tig2, const INT64 tig4, const INT64 tig8);
public:
void reconstruct(Mat &w); // For illustration purpose
void reconstruct(cv::Mat &w); // For illustration purpose
private:
static const int NUM_COMP = 2; // Number of components
......
......@@ -70,7 +70,7 @@ struct ValStructVec
}
inline void pushBack( const VT& val, const ST& structVal )
{
valIdxes.push_back( make_pair( val, sz ) );
valIdxes.push_back( std::make_pair( val, sz ) );
structVals.push_back( structVal );
sz++;
}
......@@ -93,21 +93,21 @@ struct ValStructVec
} // Should be called after sort
void sort( bool descendOrder = true );
const vector<ST> &getSortedStructVal();
vector<pair<VT, int> > getvalIdxes();
const std::vector<ST> &getSortedStructVal();
std::vector<std::pair<VT, int> > getvalIdxes();
void append( const ValStructVec<VT, ST> &newVals, int startV = 0 );
vector<ST> structVals; // struct values
std::vector<ST> structVals; // struct values
private:
int sz; // size of the value struct vector
vector<pair<VT, int> > valIdxes; // Indexes after sort
std::vector<std::pair<VT, int> > valIdxes; // Indexes after sort
bool smaller()
{
return true;
}
;
vector<ST> sortedStructVals;
std::vector<ST> sortedStructVals;
};
template<typename VT, typename ST>
......@@ -122,13 +122,13 @@ template<typename VT, typename ST>
void ValStructVec<VT, ST>::sort( bool descendOrder /* = true */)
{
if( descendOrder )
std::sort( valIdxes.begin(), valIdxes.end(), std::greater<pair<VT, int> >() );
std::sort( valIdxes.begin(), valIdxes.end(), std::greater<std::pair<VT, int> >() );
else
std::sort( valIdxes.begin(), valIdxes.end(), std::less<pair<VT, int> >() );
std::sort( valIdxes.begin(), valIdxes.end(), std::less<std::pair<VT, int> >() );
}
template<typename VT, typename ST>
const vector<ST>& ValStructVec<VT, ST>::getSortedStructVal()
const std::vector<ST>& ValStructVec<VT, ST>::getSortedStructVal()
{
sortedStructVals.resize( sz );
for ( int i = 0; i < sz; i++ )
......@@ -137,7 +137,7 @@ const vector<ST>& ValStructVec<VT, ST>::getSortedStructVal()
}
template<typename VT, typename ST>
vector<pair<VT, int> > ValStructVec<VT, ST>::getvalIdxes()
std::vector<std::pair<VT, int> > ValStructVec<VT, ST>::getvalIdxes()
{
return valIdxes;
}
......
......@@ -69,8 +69,7 @@
//#pragma comment( lib, cvLIB("core"))
//#pragma comment( lib, cvLIB("imgproc"))
//#pragma comment( lib, cvLIB("highgui"))
using namespace cv;
using namespace std;
#ifdef WIN32
/* windows stuff */
#else
......@@ -84,9 +83,9 @@ typedef unsigned char byte;
typedef std::vector<int> vecI;
typedef const std::string CStr;
typedef const Mat CMat;
typedef const cv::Mat CMat;
typedef std::vector<std::string> vecS;
typedef std::vector<Mat> vecM;
typedef std::vector<cv::Mat> vecM;
typedef std::vector<float> vecF;
typedef std::vector<double> vecD;
......@@ -106,11 +105,10 @@ enum
cv::error(cv::Exception(CV_StsAssert, msg, __FUNCTION__, __FILE__, __LINE__) ); }\
}
using namespace std;
// Return -1 if not in the list
template<typename T>
static inline int findFromList( const T &word, const vector<T> &strList )
static inline int findFromList( const T &word, const std::vector<T> &strList )
{
//TODO delete test code
//cout << "\n\n" << "word" <<" "<< word << endl;
......@@ -120,7 +118,7 @@ static inline int findFromList( const T &word, const vector<T> &strList )
//cout << "Size w " << word.size() << " Size L "<< strList[i].size() << endl;
}
vector<String>::iterator it = std::find( strList.begin(), strList.end(), word );
std::vector<cv::String>::iterator it = std::find( strList.begin(), strList.end(), word );
if( it == strList.end() )
{
return -1;
......@@ -149,21 +147,21 @@ template<typename T> inline T sqr( T x )
{
return x * x;
} // out of range risk for T = byte, ...
template<class T, int D> inline T vecSqrDist( const Vec<T, D> &v1, const Vec<T, D> &v2 )
template<class T, int D> inline T vecSqrDist( const cv::Vec<T, D> &v1, const cv::Vec<T, D> &v2 )
{
T s = 0;
for ( int i = 0; i < D; i++ )
s += sqr( v1[i] - v2[i] );
return s;
} // out of range risk for T = byte, ...
template<class T, int D> inline T vecDist( const Vec<T, D> &v1, const Vec<T, D> &v2 )
template<class T, int D> inline T vecDist( const cv::Vec<T, D> &v1, const cv::Vec<T, D> &v2 )
{
return sqrt( vecSqrDist( v1, v2 ) );
} // out of range risk for T = byte, ...
inline Rect Vec4i2Rect( Vec4i &v )
inline cv::Rect Vec4i2Rect( cv::Vec4i &v )
{
return Rect( Point( v[0] - 1, v[1] - 1 ), Point( v[2], v[3] ) );
return cv::Rect( cv::Point( v[0] - 1, v[1] - 1 ), cv::Point( v[2], v[3] ) );
}
#ifdef __WIN32
......
......@@ -75,21 +75,21 @@ ObjectnessBING::~ObjectnessBING()
void ObjectnessBING::setColorSpace( int clr )
{
_Clr = clr;
_modelName = _trainingPath + "/" + string( format( "ObjNessB%gW%d%s", _base, _W, _clrName[_Clr] ).c_str() );
_bbResDir = _resultsDir + "/" + string( format( "BBoxesB%gW%d%s/", _base, _W, _clrName[_Clr] ).c_str() );
_modelName = _trainingPath + "/" + std::string( format( "ObjNessB%gW%d%s", _base, _W, _clrName[_Clr] ).c_str() );
_bbResDir = _resultsDir + "/" + std::string( format( "BBoxesB%gW%d%s/", _base, _W, _clrName[_Clr] ).c_str() );
}
void ObjectnessBING::setTrainingPath( string trainingPath )
void ObjectnessBING::setTrainingPath( std::string trainingPath )
{
_trainingPath = trainingPath;
}
void ObjectnessBING::setBBResDir( string resultsDir )
void ObjectnessBING::setBBResDir( std::string resultsDir )
{
_resultsDir = resultsDir;
}
int ObjectnessBING::loadTrainedModel( string modelName ) // Return -1, 0, or 1 if partial, none, or all loaded
int ObjectnessBING::loadTrainedModel( std::string modelName ) // Return -1, 0, or 1 if partial, none, or all loaded
{
if( modelName.size() == 0 )
modelName = _modelName;
......@@ -400,15 +400,15 @@ void ObjectnessBING::getObjBndBoxesForSingleImage( Mat img, ValStructVec<float,
CmFile::MkDir( _bbResDir );
CStr fName = _bbResDir + "bb";
vector<Vec4i> sortedBB = finalBoxes.getSortedStructVal();
std::vector<Vec4i> sortedBB = finalBoxes.getSortedStructVal();
std::ofstream ofs;
ofs.open( _S( fName + ".txt" ), std::ofstream::out );
stringstream dim;
std::stringstream dim;
dim << sortedBB.size();
ofs << dim.str() << "\n";
for ( size_t k = 0; k < sortedBB.size(); k++ )
{
stringstream str;
std::stringstream str;
str << sortedBB[k][0] << " " << sortedBB[k][1] << " " << sortedBB[k][2] << " " << sortedBB[k][3] << "\n";
ofs << str.str();
}
......@@ -435,7 +435,7 @@ std::string inline removeExtension( std::string const& filename )
}
// Read matrix from binary file
bool ObjectnessBING::matRead( const string& filename, Mat& _M )
bool ObjectnessBING::matRead( const std::string& filename, Mat& _M )
{
String filenamePlusExt( filename.c_str() );
filenamePlusExt += ".yml.gz";
......@@ -461,7 +461,7 @@ bool ObjectnessBING::matRead( const string& filename, Mat& _M )
M.copyTo( _M );
return true;
}
vector<float> ObjectnessBING::getobjectnessValues()
std::vector<float> ObjectnessBING::getobjectnessValues()
{
return objectnessValues;
}
......@@ -484,7 +484,7 @@ bool ObjectnessBING::computeSaliencyImpl( const InputArray image, OutputArray ob
// List of rectangles returned by objectess function in descending order.
// At the top there are the rectangles with higher values, ie more
// likely to have objects in them.
vector<Vec4i> sortedBB = finalBoxes.getSortedStructVal();
std::vector<Vec4i> sortedBB = finalBoxes.getSortedStructVal();
Mat( sortedBB ).copyTo( objectnessBoundingBox );
// List of the rectangles' objectness value
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment