Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 57 additions & 57 deletions 3rdparty/SiftGPU/src/SiftGPU/GLTexImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ int GLTexInput::SetImageData( int width, int height, const void * data,
{
int simple_format = IsSimpleGlFormat(gl_format, gl_type);//no cpu code to handle other formats
int ws, hs, done = 1;

if(_converted_data) {delete [] _converted_data; _converted_data = NULL; }

_rgb_converted = 1;
Expand Down Expand Up @@ -1126,64 +1126,64 @@ int GLTexInput::LoadImageFile(char *imagepath, int &w, int &h )

return done;
#else
FILE * file = fopen(imagepath, "rb"); if (file ==NULL) return 0;
char buf[8]; int width, height, cn, g, done = 1;
if(fscanf(file, "%s %d %d %d", buf, &width, &height, &cn )<4 || cn > 255 || width < 0 || height < 0)
{
fclose(file);
std::cerr << "ERROR: fileformat not supported\n";
return 0;
}else
{
w = width;
h = height;
}
unsigned char * data = new unsigned char[width * height];
unsigned char * pixels = data;
if (strcmp(buf, "P5")==0 )
{
fscanf(file, "%c",buf);//skip one byte
fread(pixels, 1, width*height, file);
}else if (strcmp(buf, "P2")==0 )
{
for (int i = 0 ; i< height; i++)
{
for ( int j = 0; j < width; j++)
{
fscanf(file, "%d", &g);
*pixels++ = (unsigned char) g;
}
}
}else if (strcmp(buf, "P6")==0 )
{
fscanf(file, "%c", buf);//skip one byte
int j, num = height*width;
unsigned char buf[3];
for ( j =0 ; j< num; j++)
{
fread(buf,1,3, file);
*pixels++=int(0.10454f* buf[2]+0.60581f* buf[1]+0.28965f* buf[0]);
}
}else if (strcmp(buf, "P3")==0 )
{
int r, g, b;
int i , num =height*width;
for ( i = 0 ; i< num; i++)
{
fscanf(file, "%d %d %d", &r, &g, &b);
*pixels++ = int(0.10454f* b+0.60581f* g+0.28965f* r);
}
}else
{
std::cerr << "ERROR: fileformat not supported\n";
done = 0;
FILE * file = fopen(imagepath, "rb"); if (file ==NULL) return 0;

char buf[8]; int width, height, cn, g, done = 1;

if(fscanf(file, "%s %d %d %d", buf, &width, &height, &cn )<4 || cn > 255 || width < 0 || height < 0)
{
fclose(file);
std::cerr << "ERROR: fileformat not supported\n";
return 0;
}else
{
w = width;
h = height;
}
unsigned char * data = new unsigned char[width * height];
unsigned char * pixels = data;
if (strcmp(buf, "P5")==0 )
{
fscanf(file, "%c",buf);//skip one byte
fread(pixels, 1, width*height, file);
}else if (strcmp(buf, "P2")==0 )
{
for (int i = 0 ; i< height; i++)
{
for ( int j = 0; j < width; j++)
{
fscanf(file, "%d", &g);
*pixels++ = (unsigned char) g;
}
}
}else if (strcmp(buf, "P6")==0 )
{
fscanf(file, "%c", buf);//skip one byte
int j, num = height*width;
unsigned char buf[3];
for ( j =0 ; j< num; j++)
{
fread(buf,1,3, file);
*pixels++=int(0.10454f* buf[2]+0.60581f* buf[1]+0.28965f* buf[0]);
}
}else if (strcmp(buf, "P3")==0 )
{
int r, g, b;
int i , num =height*width;
for ( i = 0 ; i< num; i++)
{
fscanf(file, "%d %d %d", &r, &g, &b);
*pixels++ = int(0.10454f* b+0.60581f* g+0.28965f* r);
}

}else
{
std::cerr << "ERROR: fileformat not supported\n";
done = 0;
}
if(done) SetImageData(width, height, data, GL_LUMINANCE, GL_UNSIGNED_BYTE);
fclose(file);
delete data;
fclose(file);
delete [] data;
if(GlobalUtil::_verbose && done) std::cout<< "Image loaded :\t" << imagepath << "\n";
return 1;
#endif
Expand Down
5 changes: 2 additions & 3 deletions common/pipeline/ODAlgorithmBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,14 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

#ifndef OPENDETECTION_ODALGORITHMBASE_H
#define OPENDETECTION_ODALGORITHMBASE_H
#include<iostream>
#include <iostream>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>


namespace od
{

/** \brief The base of all algorithm classes
/** \brief The base of all algorithm classes.
*
* \author Kripasindhu Sarkar
*
Expand Down
29 changes: 7 additions & 22 deletions common/pipeline/ObjectDetector.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ namespace od
IMAGE_GLOBAL_CLASSIFICATION,
};

/** \brief The common class for detectors. Both Trainers and Detectors drerives from this and therefore, all the common data/functionalities of Trainers and Detectors should go here.
*
/** \brief The common class for detectors. Both Trainers and Detectors derives from this and therefore, all the common data/functionalities of Trainers and Detectors should go here.
*
* \author Kripasindhu Sarkar
*
Expand All @@ -63,24 +62,23 @@ namespace od

ODDetectorCommon( std::string const &trained_data_location_="") : trained_data_location_(trained_data_location_)
{
std::string clasname = typeid(this).name();
TRAINED_DATA_ID_ = clasname;
std::transform(clasname.begin(), clasname.end(), clasname.begin(), ::toupper);
TRAINED_LOCATION_DENTIFIER_ = clasname;
std::string classname = typeid(this).name();
TRAINED_DATA_ID_ = classname;
std::transform(classname.begin(), classname.end(), classname.begin(), ::toupper);
TRAINED_LOCATION_DENTIFIER_ = classname;
}

virtual void init() = 0;


/** \brief Gets/Sets the directory containing the data for training. The trainer uses the data from directory for training. Detectors can use this location to get additional information in its detection algirhtms as well.
/** \brief Gets/Sets the directory containing the data for training. The trainer uses the data from directory for training.
* Detectors can use this location to get additional information in its detection algirhtms as well.
*/
std::string getTrainingInputLocation() const
{
return training_input_location_;
}

/** \brief Gets/Sets the directory containing the data for training. The trainer uses the data from directory for training. Detectors can use this location to get additional information in its detection algirhtms as well.
*/
void setTrainingInputLocation(std::string training_input_location_)
{
this->training_input_location_ = training_input_location_;
Expand Down Expand Up @@ -132,7 +130,6 @@ namespace od
};

/** \brief This is the main class for object detection and recognition.
*
*
* \author Kripasindhu Sarkar
*
Expand Down Expand Up @@ -164,16 +161,6 @@ namespace od
this->always_train_ = always_train_;
}

std::string getTrainingInputLocation() const
{
return training_input_location_;
}

void setTrainingInputLocation(std::string training_input_location_)
{
this->training_input_location_ = training_input_location_;
}

std::string getTrainingDataLocation() const
{
return training_data_location_;
Expand All @@ -196,7 +183,6 @@ namespace od

virtual int train() = 0;


virtual int detect(ODScene *scene, std::vector<ODDetection *> detections) {}

virtual ODDetection* detect(ODScene *scene) {}
Expand All @@ -207,7 +193,6 @@ namespace od
bool always_train_;
bool trained_;
std::string training_input_location_, training_data_location_;

std::string TRAINED_DATA_EXT_, TRAINED_DATA_IDENTIFIER_;
};

Expand Down
Loading