Commit 861d7bcf authored by jaco's avatar jaco

wip windows byte compile error fixing

parent 5fc5b4f8
...@@ -79,7 +79,7 @@ typedef unsigned short WORD; ...@@ -79,7 +79,7 @@ typedef unsigned short WORD;
typedef unsigned int UNINT32; typedef unsigned int UNINT32;
typedef bool BOOL; typedef bool BOOL;
typedef void *HANDLE; typedef void *HANDLE;
typedef unsigned char byte; typedef unsigned char byte_;
#endif #endif
typedef std::vector<int> vecI; typedef std::vector<int> vecI;
......
...@@ -41,91 +41,7 @@ ...@@ -41,91 +41,7 @@
#include "CmFile.h" #include "CmFile.h"
// Get image names from a wildcard. Eg: GetNames("D:\\*.jpg", imgNames);
int CmFile::GetNames( CStr &_nameW, vecS &_names, std::string _dir )
{
_dir = GetFolder( _nameW );
_names.clear();
DIR *dir;
struct dirent *ent;
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] == '.' )
continue;
if( ent->d_type == 4 )
continue;
_names.push_back( ent->d_name );
}
closedir( dir );
}
else
{
perror( "" );
return EXIT_FAILURE;
}
return (int) _names.size();
}
int CmFile::GetSubFolders( CStr &folder, vecS &subFolders )
{
subFolders.clear();
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] == '.' )
continue;
if( ent->d_type == 4 )
{
subFolders.push_back( ent->d_name );
}
}
closedir( dir );
}
else
{
perror( "" );
return EXIT_FAILURE;
}
return (int) subFolders.size();
}
int CmFile::GetNames( CStr& rootFolder, CStr &fileW, vecS &names )
{
GetNames( rootFolder + fileW, names );
vecS subFolders, tmpNames;
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] );
}
return (int) names.size();
}
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] );
return fNum;
}
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 );
return fNum;
}
bool CmFile::MkDir( CStr &_path ) bool CmFile::MkDir( CStr &_path )
{ {
if( _path.size() == 0 ) if( _path.size() == 0 )
...@@ -156,28 +72,3 @@ bool CmFile::MkDir( CStr &_path ) ...@@ -156,28 +72,3 @@ bool CmFile::MkDir( CStr &_path )
return mkdir( _S( _path ), 0 ); return mkdir( _S( _path ), 0 );
#endif #endif
} }
void CmFile::loadStrList( CStr &fName, vecS & strs, bool flag )
{
std::ifstream fIn( fName.c_str() );
std::string line;
//vecS strs;
while ( getline( fIn, line ) )
{
unsigned sz = line.size();
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 )
{
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 );
return true;
}
...@@ -53,68 +53,5 @@ ...@@ -53,68 +53,5 @@
struct CmFile struct CmFile
{ {
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, std::string dir = std::string(), std::string ext = std::string());
static int GetNamesNE(CStr& rootFolder, CStr &fileW, vecS &names);
static inline std::string GetExtention(CStr name);
static int GetSubFolders(CStr& folder, vecS& subFolders);
static inline std::string GetWkDir();
static bool MkDir(CStr& path); static bool MkDir(CStr& path);
static void loadStrList(CStr &fName, vecS &strs, bool flag=false);
static bool writeStrList(CStr &fName, const vecS &strs);
}; };
/************************************************************************/
/* Implementation of inline functions */
/************************************************************************/
std::string CmFile::GetFolder(CStr& path)
{
return path.substr(0, path.find_last_of("\\/")+1);
}
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);
}
std::string CmFile::GetNameNE(CStr& path)
{
int start = path.find_last_of("\\/")+1;
int end = path.find_last_of('.');
if (end >= 0)
return path.substr(start, end - start);
else
return path.substr(start, path.find_last_not_of(' ')+1 - start);
}
std::string CmFile::GetPathNE(CStr& path)
{
int end = path.find_last_of('.');
if (end >= 0)
return path.substr(0, end);
else
return path.substr(0, path.find_last_not_of(' ') + 1);
}
std::string CmFile::GetExtention(CStr name)
{
return name.substr(name.find_last_of('.'));
}
/************************************************************************/
/* Implementations */
/************************************************************************/
...@@ -88,12 +88,12 @@ Mat FilterTIG::matchTemplate( const Mat &mag1u ) ...@@ -88,12 +88,12 @@ Mat FilterTIG::matchTemplate( const Mat &mag1u )
const Size sz( W + 1, H + 1 ); // Expand original size to avoid dealing with boundary conditions 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> Tig1 = Mat_<INT64>::zeros( sz ), Tig2 = Mat_<INT64>::zeros( sz );
Mat_<INT64> Tig4 = Mat_<INT64>::zeros( sz ), Tig8 = 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_> Row1 = Mat_<byte_>::zeros( sz ), Row2 = Mat_<byte_>::zeros( sz );
Mat_<byte> Row4 = Mat_<byte>::zeros( sz ), Row8 = Mat_<byte>::zeros( sz ); Mat_<byte_> Row4 = Mat_<byte_>::zeros( sz ), Row8 = Mat_<byte_>::zeros( sz );
Mat_<float> scores( sz ); Mat_<float> scores( sz );
for ( int y = 1; y <= H; y++ ) for ( int y = 1; y <= H; y++ )
{ {
const byte* G = mag1u.ptr<byte>( y - 1 ); const byte_* G = mag1u.ptr<byte_>( y - 1 );
INT64* T1 = Tig1.ptr<INT64>( y ); // Binary TIG of current row INT64* T1 = Tig1.ptr<INT64>( y ); // Binary TIG of current row
INT64* T2 = Tig2.ptr<INT64>( y ); INT64* T2 = Tig2.ptr<INT64>( y );
INT64* T4 = Tig4.ptr<INT64>( y ); INT64* T4 = Tig4.ptr<INT64>( y );
...@@ -102,14 +102,14 @@ Mat FilterTIG::matchTemplate( const Mat &mag1u ) ...@@ -102,14 +102,14 @@ Mat FilterTIG::matchTemplate( const Mat &mag1u )
INT64* Tu2 = Tig2.ptr<INT64>( y - 1 ); INT64* Tu2 = Tig2.ptr<INT64>( y - 1 );
INT64* Tu4 = Tig4.ptr<INT64>( y - 1 ); INT64* Tu4 = Tig4.ptr<INT64>( y - 1 );
INT64* Tu8 = Tig8.ptr<INT64>( y - 1 ); INT64* Tu8 = Tig8.ptr<INT64>( y - 1 );
byte* R1 = Row1.ptr<byte>( y ); byte_* R1 = Row1.ptr<byte_>( y );
byte* R2 = Row2.ptr<byte>( y ); byte_* R2 = Row2.ptr<byte_>( y );
byte* R4 = Row4.ptr<byte>( y ); byte_* R4 = Row4.ptr<byte_>( y );
byte* R8 = Row8.ptr<byte>( y ); byte_* R8 = Row8.ptr<byte_>( y );
float *s = scores.ptr<float>( y ); float *s = scores.ptr<float>( y );
for ( int x = 1; x <= W; x++ ) for ( int x = 1; x <= W; x++ )
{ {
byte g = G[x - 1]; byte_ g = G[x - 1];
R1[x] = ( R1[x - 1] << 1 ) | ( ( g >> 4 ) & 1 ); R1[x] = ( R1[x - 1] << 1 ) | ( ( g >> 4 ) & 1 );
R2[x] = ( R2[x - 1] << 1 ) | ( ( g >> 5 ) & 1 ); R2[x] = ( R2[x - 1] << 1 ) | ( ( g >> 5 ) & 1 );
R4[x] = ( R4[x - 1] << 1 ) | ( ( g >> 6 ) & 1 ); R4[x] = ( R4[x - 1] << 1 ) | ( ( g >> 6 ) & 1 );
......
...@@ -230,7 +230,7 @@ void ObjectnessBING::nonMaxSup( CMat &matchCost1f, ValStructVec<float, Point> &m ...@@ -230,7 +230,7 @@ void ObjectnessBING::nonMaxSup( CMat &matchCost1f, ValStructVec<float, Point> &m
for ( int i = 0; i < valPnt.size(); i++ ) for ( int i = 0; i < valPnt.size(); i++ )
{ {
Point &pnt = valPnt[i]; Point &pnt = valPnt[i];
if( isMax1u.at<byte>( pnt ) ) if( isMax1u.at<byte_>( pnt ) )
{ {
matchCost.pushBack( valPnt( i ), pnt ); matchCost.pushBack( valPnt( i ), pnt );
for ( int dy = -NSS; dy <= NSS; dy++ ) for ( int dy = -NSS; dy <= NSS; dy++ )
...@@ -239,7 +239,7 @@ void ObjectnessBING::nonMaxSup( CMat &matchCost1f, ValStructVec<float, Point> &m ...@@ -239,7 +239,7 @@ void ObjectnessBING::nonMaxSup( CMat &matchCost1f, ValStructVec<float, Point> &m
Point neighbor = pnt + Point( dx, dy ); Point neighbor = pnt + Point( dx, dy );
if( !CHK_IND( neighbor ) ) if( !CHK_IND( neighbor ) )
continue; continue;
isMax1u.at<byte>( neighbor ) = false; isMax1u.at<byte_>( neighbor ) = false;
} }
} }
if( matchCost.size() >= maxPoint ) if( matchCost.size() >= maxPoint )
...@@ -311,24 +311,24 @@ void ObjectnessBING::gradientGray( CMat &bgr3u, Mat &mag1u ) ...@@ -311,24 +311,24 @@ void ObjectnessBING::gradientGray( CMat &bgr3u, Mat &mag1u )
// Left/right most column Ix // Left/right most column Ix
for ( int y = 0; y < H; y++ ) for ( int y = 0; y < H; y++ )
{ {
Ix.at<int>( y, 0 ) = abs( g1u.at<byte>( y, 1 ) - g1u.at<byte>( y, 0 ) ) * 2; Ix.at<int>( y, 0 ) = abs( g1u.at<byte_>( y, 1 ) - g1u.at<byte_>( y, 0 ) ) * 2;
Ix.at<int>( y, W - 1 ) = abs( g1u.at<byte>( y, W - 1 ) - g1u.at<byte>( y, W - 2 ) ) * 2; Ix.at<int>( y, W - 1 ) = abs( g1u.at<byte_>( y, W - 1 ) - g1u.at<byte_>( y, W - 2 ) ) * 2;
} }
// Top/bottom most column Iy // Top/bottom most column Iy
for ( int x = 0; x < W; x++ ) for ( int x = 0; x < W; x++ )
{ {
Iy.at<int>( 0, x ) = abs( g1u.at<byte>( 1, x ) - g1u.at<byte>( 0, x ) ) * 2; Iy.at<int>( 0, x ) = abs( g1u.at<byte_>( 1, x ) - g1u.at<byte_>( 0, x ) ) * 2;
Iy.at<int>( H - 1, x ) = abs( g1u.at<byte>( H - 1, x ) - g1u.at<byte>( H - 2, x ) ) * 2; Iy.at<int>( H - 1, x ) = abs( g1u.at<byte_>( H - 1, x ) - g1u.at<byte_>( H - 2, x ) ) * 2;
} }
// Find the gradient for inner regions // Find the gradient for inner regions
for ( int y = 0; y < H; y++ ) for ( int y = 0; y < H; y++ )
for ( int x = 1; x < W - 1; x++ ) for ( int x = 1; x < W - 1; x++ )
Ix.at<int>( y, x ) = abs( g1u.at<byte>( y, x + 1 ) - g1u.at<byte>( y, x - 1 ) ); Ix.at<int>( y, x ) = abs( g1u.at<byte_>( y, x + 1 ) - g1u.at<byte_>( y, x - 1 ) );
for ( int y = 1; y < H - 1; y++ ) for ( int y = 1; y < H - 1; y++ )
for ( int x = 0; x < W; x++ ) for ( int x = 0; x < W; x++ )
Iy.at<int>( y, x ) = abs( g1u.at<byte>( y + 1, x ) - g1u.at<byte>( y - 1, x ) ); Iy.at<int>( y, x ) = abs( g1u.at<byte_>( y + 1, x ) - g1u.at<byte_>( y - 1, x ) );
gradientXY( Ix, Iy, mag1u ); gradientXY( Ix, Iy, mag1u );
} }
...@@ -372,7 +372,7 @@ void ObjectnessBING::gradientXY( CMat &x1i, CMat &y1i, Mat &mag1u ) ...@@ -372,7 +372,7 @@ void ObjectnessBING::gradientXY( CMat &x1i, CMat &y1i, Mat &mag1u )
for ( int r = 0; r < H; r++ ) for ( int r = 0; r < H; r++ )
{ {
const int *x = x1i.ptr<int>( r ), *y = y1i.ptr<int>( r ); const int *x = x1i.ptr<int>( r ), *y = y1i.ptr<int>( r );
byte* m = mag1u.ptr<byte>( r ); byte_* m = mag1u.ptr<byte_>( r );
for ( int c = 0; c < W; c++ ) for ( int c = 0; c < W; c++ )
m[c] = min( x[c] + y[c], 255 ); //((int)sqrt(sqr(x[c]) + sqr(y[c])), 255); m[c] = min( x[c] + y[c], 255 ); //((int)sqrt(sqr(x[c]) + sqr(y[c])), 255);
} }
......
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