Skip to content

Commit 7f270b3

Browse files
committed
new initial weights and fix indentation
1 parent 6019298 commit 7f270b3

File tree

3 files changed

+305
-305
lines changed

3 files changed

+305
-305
lines changed

modules/saliency/include/opencv2/saliency/saliencySpecializedClasses.hpp

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -161,38 +161,38 @@ This method use the convolution layers of the pretrained AlexNet, linear combina
161161
class CV_EXPORTS_W DeepGaze1 : public StaticSaliency
162162
{
163163
private:
164-
dnn::Net net;
165-
std::vector<std::string> layers_names;
166-
std::vector<double> weights;
164+
dnn::Net net;
165+
std::vector<std::string> layers_names;
166+
std::vector<double> weights;
167167

168168
public:
169-
DeepGaze1();
170-
DeepGaze1(std::string, std::string, std::vector<std::string>, unsigned);
171-
virtual ~DeepGaze1();
172-
CV_WRAP static Ptr<DeepGaze1> create()
173-
{
174-
return makePtr<DeepGaze1>();
175-
}
176-
CV_WRAP bool computeSaliency(InputArray image, OutputArray saliencyMap)
177-
{
178-
if(image.empty())
179-
return false;
180-
return computeSaliencyImpl(image, saliencyMap);
181-
}
182-
Mat saliencyMapGenerator(Mat, Size = Size(227, 227));
183-
void training(std::vector<Mat>&, std::vector<Mat>&, unsigned = 100, double = 0.9, double = 0.01, double = 0.01, Size = Size(227, 227));
184-
double computeAUC(InputArray _saliencyMap, InputArray _fixtionMap);
185-
void saliencyMapVisualize(InputArray _saliencyMap);
169+
DeepGaze1();
170+
DeepGaze1( std::string, std::string, std::vector<std::string>, unsigned );
171+
virtual ~DeepGaze1();
172+
CV_WRAP static Ptr<DeepGaze1> create()
173+
{
174+
return makePtr<DeepGaze1>();
175+
}
176+
CV_WRAP bool computeSaliency( InputArray image, OutputArray saliencyMap )
177+
{
178+
if( image.empty() )
179+
return false;
180+
return computeSaliencyImpl( image, saliencyMap );
181+
}
182+
Mat saliencyMapGenerator( Mat, Size = Size(227, 227) );
183+
void training( std::vector<Mat>&, std::vector<Mat>&, unsigned = 100, double = 0.9, double = 0.01, double = 0.01, Size = Size(227, 227) );
184+
double computeAUC( InputArray _saliencyMap, InputArray _fixtionMap );
185+
void saliencyMapVisualize( InputArray _saliencyMap );
186186
protected:
187-
bool computeSaliencyImpl(InputArray image, OutputArray saliencyMap);
188-
std::vector<Mat> featureMapGenerator(Mat, Size);
189-
static Mat comb(std::vector<Mat>&, std::vector<double>);
190-
static Mat softmax(Mat);
191-
static std::vector<double> evalGrad(std::vector<Mat>&, std::vector<unsigned>&, std::vector<double>, Size);
192-
std::vector<unsigned> batchIndex(unsigned, unsigned);
193-
static double loss(std::vector<double>, std::vector<double>);
194-
static std::vector<double> mapSampler(Mat, std::vector<unsigned>);
195-
std::vector<unsigned> fixationLoc(Mat, Size);
187+
bool computeSaliencyImpl( InputArray image, OutputArray saliencyMap );
188+
std::vector<Mat> featureMapGenerator( Mat, Size );
189+
static Mat comb( std::vector<Mat>&, std::vector<double> );
190+
static Mat softmax( Mat );
191+
static std::vector<double> evalGrad( std::vector<Mat>&, std::vector<unsigned>&, std::vector<double>, Size );
192+
std::vector<unsigned> batchIndex( unsigned, unsigned );
193+
static double loss( std::vector<double>, std::vector<double> );
194+
static std::vector<double> mapSampler( Mat, std::vector<unsigned> );
195+
std::vector<unsigned> fixationLoc( Mat, Size );
196196
};
197197

198198

modules/saliency/samples/DeepGaze1Sample.cpp

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -20,47 +20,47 @@ using namespace cv::saliency;
2020

2121
int main()
2222
{
23-
DeepGaze1 g = DeepGaze1();
24-
vector<Mat> images;
25-
vector<Mat> fixs;
23+
DeepGaze1 g = DeepGaze1();
24+
vector<Mat> images;
25+
vector<Mat> fixs;
2626

2727
//Download mit1003 saliency dataset in the working directory
2828
//ALLSTIMULI folder store images
2929
//ALLFIXATIONMAPS foler store training eye fixation
3030
//************ Code only work in linux platform ****
31-
/* DIR *dp;
32-
struct dirent *dirp;
33-
if((dp = opendir("ALLSTIMULI")) == NULL)
34-
{
35-
cout << "Can not open dataset directory" << endl;
36-
}
37-
unsigned n = 0;
38-
while((dirp = readdir(dp)) != NULL)
39-
{
40-
if(dirp->d_type != 8) continue;
41-
if((n++) >= 400) break;
42-
string f_name(dirp->d_name);
43-
images.push_back(imread("ALLSTIMULI/" + f_name));
44-
fixs.push_back(imread("ALLFIXATIONMAPS/" + f_name.substr(0, f_name.find_first_of('.')) + "_fixPts.jpg", 0));
45-
}
31+
/* DIR *dp;
32+
struct dirent *dirp;
33+
if ( ( dp = opendir( "ALLSTIMULI" ) ) == NULL )
34+
{
35+
cout << "Can not open dataset directory" << endl;
36+
}
37+
unsigned n = 0;
38+
while ( ( dirp = readdir( dp ) ) != NULL )
39+
{
40+
if ( dirp->d_type != 8 ) continue;
41+
if ( (n++) >= 400 ) break;
42+
string f_name( dirp->d_name );
43+
images.push_back( imread( "ALLSTIMULI/" + f_name ) );
44+
fixs.push_back( imread( "ALLFIXATIONMAPS/" + f_name.substr( 0, f_name.find_first_of('.') ) + "_fixPts.jpg", 0 ) );
45+
}
4646
47-
g.training(images, fixs);*/
48-
ofstream file;
49-
Mat res2;
50-
g.computeSaliency(imread("ALLSTIMULI/i05june05_static_street_boston_p1010764.jpeg"), res2);
51-
log(res2, res2);
52-
resize(res2, res2, Size(1024, 768));
53-
cout << "AUC = " << g.computeAUC(res2, imread("ALLSTIMULI/i05june05_static_street_boston_p1010764_fixPts.jpeg", 0)) << endl;;
54-
g.saliencyMapVisualize(res2);
55-
file.open("saliency.csv");
56-
for (int i = 0;i < res2.rows;i++)
57-
{
58-
for (int j=0;j < res2.cols;j++)
59-
{
60-
file << res2.at<double>(i, j) << " ";
61-
}
62-
file << endl;
63-
}
64-
file.close();
47+
g.training( images, fixs );*/
48+
ofstream file;
49+
Mat res2;
50+
g.computeSaliency( imread( "ALLSTIMULI/i05june05_static_street_boston_p1010764.jpeg"), res2 );
51+
log( res2, res2 );
52+
resize( res2, res2, Size( 1024, 768 ) );
53+
cout << "AUC = " << g.computeAUC( res2, imread( "ALLFIXATIONMAPS/i05june05_static_street_boston_p1010764_fixPts.jpeg", 0 ) ) << endl;;
54+
g.saliencyMapVisualize( res2 );
55+
file.open( "saliency.csv" );
56+
for ( int i = 0; i < res2.rows; i++)
57+
{
58+
for ( int j=0; j < res2.cols; j++)
59+
{
60+
file << res2.at<double>( i, j ) << " ";
61+
}
62+
file << endl;
63+
}
64+
file.close();
6565
return 0;
6666
} //main

0 commit comments

Comments
 (0)