Commit 02aa9155 authored by jaco's avatar jaco

Pull Request mandatory changes

parent 3eb81b72
......@@ -10,7 +10,7 @@
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Copyright (C) 2014, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
......@@ -47,7 +47,10 @@
namespace cv
{
CV_EXPORTS bool initModule_saliency(void);
namespace saliency
{
CV_EXPORTS bool initModule_saliency( void );
}
}
#endif //__OPENCV_SALIENCY_HPP__
......@@ -10,7 +10,7 @@
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Copyright (C) 2014, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
......@@ -51,6 +51,8 @@
namespace cv
{
namespace saliency
{
/************************************ Saliency Base Class ************************************/
......@@ -117,6 +119,7 @@ class CV_EXPORTS Objectness : public virtual Saliency
};
} /* namespace saliency */
} /* namespace cv */
#endif
......@@ -10,7 +10,7 @@
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Copyright (C) 2014, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
......@@ -42,15 +42,17 @@
#ifndef __OPENCV_SALIENCY_SPECIALIZED_CLASSES_HPP__
#define __OPENCV_SALIENCY_SPECIALIZED_CLASSES_HPP__
#include "kyheader.h"
#include "ValStructVec.h"
#include "FilterTIG.h"
#include "src/kyheader.hpp"
#include "src/ValStructVec.hpp"
#include "src/FilterTIG.hpp"
#include <cstdio>
#include <string>
#include <iostream>
namespace cv
{
namespace saliency
{
/************************************ Specific Static Saliency Specialized Classes ************************************/
......@@ -66,12 +68,6 @@ class CV_EXPORTS StaticSaliencySpectralResidual : public StaticSaliency
StaticSaliencySpectralResidual();
~StaticSaliencySpectralResidual();
//typedef Ptr<Size> (Algorithm::*SizeGetter)();
//typedef void (Algorithm::*SizeSetter)( const Ptr<Size> & );
//Ptr<Size> getWsize();
//void setWsize( const Ptr<Size> &newSize );
void read( const FileNode& fn );
void write( FileStorage& fs ) const;
......@@ -100,12 +96,6 @@ class CV_EXPORTS MotionSaliencyBinWangApr2014 : public MotionSaliency
MotionSaliencyBinWangApr2014();
~MotionSaliencyBinWangApr2014();
/*typedef Ptr<Size> (Algorithm::*SizeGetter)();
typedef void (Algorithm::*SizeSetter)( const Ptr<Size> & );
Ptr<Size> getWsize();
void setWsize( const Ptr<Size> &newSize ); */
void setImagesize( int W, int H );
bool init();
......@@ -274,6 +264,7 @@ class CV_EXPORTS ObjectnessBING : public Objectness
};
} /* namespace saliency */
} /* namespace cv */
#endif
......@@ -10,7 +10,7 @@
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Copyright (C) 2014, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
......@@ -39,7 +39,13 @@
//
//M*/
#include "CmFile.h"
#include "precomp.hpp"
#include "CmFile.hpp"
namespace cv
{
namespace saliency
{
bool CmFile::MkDir( CStr &_path )
{
......@@ -74,3 +80,6 @@ bool CmFile::MkDir( CStr &_path )
return true;
#endif
}
} // namespace saliency
} // namespace cv
......@@ -10,7 +10,7 @@
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Copyright (C) 2014, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
......@@ -39,7 +39,8 @@
//
//M*/
#pragma once
#ifndef __OPENCV_CM_FILE_HPP__
#define __OPENCV_CM_FILE_HPP__
#ifdef _WIN32
#include <windows.h>
......@@ -48,10 +49,20 @@
#include <stdlib.h>
#include <sys/stat.h>
#include <dirent.h>
#include "opencv2/saliency/kyheader.h"
#include "src/kyheader.hpp"
#endif
namespace cv
{
namespace saliency
{
struct CmFile
{
static bool MkDir(CStr& path);
};
}
}
#endif
......@@ -10,7 +10,7 @@
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Copyright (C) 2014, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
......@@ -39,66 +39,71 @@
//
//M*/
#include "CmShow.h"
#include "precomp.hpp"
#include "CmShow.hpp"
#include "opencv2/core.hpp"
#include <opencv2/highgui.hpp>
typedef std::pair<int, int> CostiIdx;
using namespace cv;
Mat CmShow::HistBins(CMat& color3f, CMat& val, CStr& title, bool descendShow, CMat &with)
namespace cv
{
namespace saliency
{
Mat CmShow::HistBins( CMat& color3f, CMat& val, CStr& title, bool descendShow, CMat &with )
{
// Prepare data
int H = 300, spaceH = 6, barH = 10, n = color3f.cols;
CV_Assert(color3f.size() == val.size() && color3f.rows == 1);
CV_Assert( color3f.size() == val.size() && color3f.rows == 1 );
Mat binVal1i, binColor3b, width1i;
if (with.size() == val.size())
with.convertTo(width1i, CV_32S, 400/sum(with).val[0]); // Default shown width
if( with.size() == val.size() )
with.convertTo( width1i, CV_32S, 400 / sum( with ).val[0] ); // Default shown width
else
width1i = Mat(1, n, CV_32S, Scalar(10)); // Default bin width = 10
int W = cvRound(sum(width1i).val[0]);
color3f.convertTo(binColor3b, CV_8UC3, 255);
width1i = Mat( 1, n, CV_32S, Scalar( 10 ) ); // Default bin width = 10
int W = cvRound( sum( width1i ).val[0] );
color3f.convertTo( binColor3b, CV_8UC3, 255 );
double maxVal, minVal;
minMaxLoc(val, &minVal, &maxVal);
printf("%g\n", H/max(maxVal, -minVal));
val.convertTo(binVal1i, CV_32S, 20000);
Size szShow(W, H + spaceH + barH);
minMaxLoc( val, &minVal, &maxVal );
printf( "%g\n", H / max( maxVal, -minVal ) );
val.convertTo( binVal1i, CV_32S, 20000 );
Size szShow( W, H + spaceH + barH );
szShow.height += minVal < 0 && !descendShow ? H + spaceH : 0;
Mat showImg3b(szShow, CV_8UC3, Scalar(255, 255, 255));
int* binH = (int*)(binVal1i.data);
Vec3b* binColor = (Vec3b*)(binColor3b.data);
int* binW = (int*)(width1i.data);
std::vector<CostiIdx> costIdx(n);
if (descendShow){
for (int i = 0; i < n; i++)
costIdx[i] = std::make_pair(binH[i], i);
sort(costIdx.begin(), costIdx.end(), std::greater<CostiIdx>());
Mat showImg3b( szShow, CV_8UC3, Scalar( 255, 255, 255 ) );
int* binH = (int*) ( binVal1i.data );
Vec3b* binColor = (Vec3b*) ( binColor3b.data );
int* binW = (int*) ( width1i.data );
std::vector<CostiIdx> costIdx( n );
if( descendShow )
{
for ( int i = 0; i < n; i++ )
costIdx[i] = std::make_pair( binH[i], i );
sort( costIdx.begin(), costIdx.end(), std::greater<CostiIdx>() );
}
// Show image
for (int i = 0, x = 0; i < n; i++){
for ( int i = 0, x = 0; i < n; i++ )
{
int idx = descendShow ? costIdx[i].second : i;
int h = descendShow ? abs(binH[idx]) : binH[idx];
Scalar color(binColor[idx]);
Rect reg(x, H + spaceH, binW[idx], barH);
showImg3b(reg) = color; // Draw bar
rectangle(showImg3b, reg, Scalar(0));
int h = descendShow ? abs( binH[idx] ) : binH[idx];
Scalar color( binColor[idx] );
Rect reg( x, H + spaceH, binW[idx], barH );
showImg3b( reg ) = color; // Draw bar
rectangle( showImg3b, reg, Scalar( 0 ) );
reg.height = abs(h);
reg.height = abs( h );
reg.y = h >= 0 ? H - h : H + 2 * spaceH + barH;
showImg3b(reg) = color;
rectangle(showImg3b, reg, Scalar(0));
showImg3b( reg ) = color;
rectangle( showImg3b, reg, Scalar( 0 ) );
x += binW[idx];
}
imshow(String(title.c_str()), showImg3b);
imshow( String( title.c_str() ), showImg3b );
return showImg3b;
}
/* void CmShow::showTinyMat(CStr &title, CMat &m)
{
{
int scale = 50, sz = m.rows * m.cols;
while (sz > 200){
scale /= 2;
......@@ -110,10 +115,10 @@ Mat CmShow::HistBins(CMat& color3f, CMat& val, CStr& title, bool descendShow, CM
if (img.channels() == 3)
cvtColor(img, img, COLOR_RGB2BGR);
SaveShow(img, title);
}
}
void CmShow::SaveShow(CMat& img, CStr& title)
{
void CmShow::SaveShow(CMat& img, CStr& title)
{
if (title.size() == 0)
return;
......@@ -123,4 +128,7 @@ void CmShow::SaveShow(CMat& img, CStr& title)
imwrite(String(title.c_str()), img*scale);
else if (title.size())
imshow(String(title.c_str()), img);
} */
} */
} // namespace saliency
} // namespace cv
......@@ -10,7 +10,7 @@
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Copyright (C) 2014, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
......@@ -39,13 +39,24 @@
//
//M*/
#pragma once
#include "opencv2/saliency/kyheader.h"
#ifndef __OPENCV_CM_SHOW_HPP__
#define __OPENCV_CM_SHOW_HPP__
#include "src/kyheader.hpp"
namespace cv
{
namespace saliency
{
class CmShow
{
public:
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);
public:
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 );
};
}
}
#endif //__OPENCV_CM_SHOW_HPP__
......@@ -10,7 +10,7 @@
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Copyright (C) 2014, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
......@@ -39,30 +39,48 @@
//
//M*/
#pragma once
#ifndef CMTIMER_H
#define CMTIMER_H
#ifndef __OPENCV_CM_TIMER_HPP__
#define __OPENCV_CM_TIMER_HPP__
namespace cv
{
namespace saliency
{
class CmTimer
{
public:
CmTimer(CStr t):title(t) { is_started = false; start_clock = 0; cumulative_clock = 0; n_starts = 0; }
public:
CmTimer( CStr t ) :
title( t )
{
is_started = false;
start_clock = 0;
cumulative_clock = 0;
n_starts = 0;
}
~CmTimer(){ if (is_started) printf("CmTimer '%s' is started and is being destroyed.\n", title.c_str()); }
~CmTimer()
{
if( is_started )
printf( "CmTimer '%s' is started and is being destroyed.\n", title.c_str() );
}
inline void Start();
inline void Stop();
inline void Reset();
inline bool Report();
inline bool StopAndReport() { Stop(); return Report(); }
inline bool StopAndReport()
{
Stop();
return Report();
}
inline float TimeInSeconds();
private:
private:
CStr title;
CmTimer& operator=(const CmTimer&);
CmTimer& operator=( const CmTimer& );
bool is_started;
clock_t start_clock;
......@@ -76,8 +94,9 @@ private:
void CmTimer::Start()
{
if (is_started){
printf("CmTimer '%s' is already started. Nothing done.\n", title.c_str());
if( is_started )
{
printf( "CmTimer '%s' is already started. Nothing done.\n", title.c_str() );
return;
}
......@@ -88,8 +107,9 @@ void CmTimer::Start()
void CmTimer::Stop()
{
if (!is_started){
printf("CmTimer '%s' is started. Nothing done\n", title.c_str());
if( !is_started )
{
printf( "CmTimer '%s' is started. Nothing done\n", title.c_str() );
return;
}
......@@ -99,8 +119,9 @@ void CmTimer::Stop()
void CmTimer::Reset()
{
if (is_started) {
printf("CmTimer '%s'is started during reset request.\n Only reset cumulative time.\n", title.c_str());
if( is_started )
{
printf( "CmTimer '%s'is started during reset request.\n Only reset cumulative time.\n", title.c_str() );
return;
}
cumulative_clock = 0;
......@@ -108,23 +129,28 @@ void CmTimer::Reset()
bool CmTimer::Report()
{
if (is_started){
printf("CmTimer '%s' is started.\n Cannot provide a time report.", title.c_str());
if( is_started )
{
printf( "CmTimer '%s' is started.\n Cannot provide a time report.", title.c_str() );
return false;
}
float timeUsed = TimeInSeconds();
printf("[%s] CumuTime: %gs, #run: %d, AvgTime: %gs\n", title.c_str(), timeUsed, n_starts, timeUsed/n_starts);
printf( "[%s] CumuTime: %gs, #run: %d, AvgTime: %gs\n", title.c_str(), timeUsed, n_starts, timeUsed / n_starts );
return true;
}
float CmTimer::TimeInSeconds()
{
if (is_started){
printf("CmTimer '%s' is started. Nothing done\n", title.c_str());
if( is_started )
{
printf( "CmTimer '%s' is started. Nothing done\n", title.c_str() );
return 0;
}
return float(cumulative_clock) / CLOCKS_PER_SEC;
return float( cumulative_clock ) / CLOCKS_PER_SEC;
}
#endif // CMTIMER_H
} // namespace saliency
} // namespace cv
#endif // __OPENCV_CM_TIMER_HPP__
......@@ -10,7 +10,7 @@
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Copyright (C) 2014, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
......@@ -39,10 +39,14 @@
//
//M*/
#include "CmShow.h"
#include "opencv2/saliency/FilterTIG.h"
#include "precomp.hpp"
#include "CmShow.hpp"
#include "src/FilterTIG.hpp"
using namespace cv;
namespace cv
{
namespace saliency
{
void FilterTIG::update( CMat &w1f )
{
......@@ -125,3 +129,6 @@ Mat FilterTIG::matchTemplate( const Mat &mag1u )
scores( Rect( 8, 8, W - 7, H - 7 ) ).copyTo( matchCost1f );
return matchCost1f;
}
} // namespace saliency
} // namespace cv
......@@ -10,7 +10,7 @@
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Copyright (C) 2014, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
......@@ -41,11 +41,13 @@
#include "precomp.hpp"
#include "CmTimer.h"
#include "CmFile.h"
#include "CmTimer.hpp"
#include "CmFile.hpp"
namespace cv
{
namespace saliency
{
/**
* BING Objectness
......@@ -116,7 +118,7 @@ int ObjectnessBING::loadTrainedModel( std::string modelName ) // Return -1, 0,
CV_Assert( _svmSzIdxs.size() > 1 && filters1f.size() == Size(_W, _W) && filters1f.type() == CV_32F );
_svmFilter = filters1f;
if( !matRead( s2, _svmReW1f ) || _svmReW1f.size() != Size( 2, (int)_svmSzIdxs.size() ) )
if( !matRead( s2, _svmReW1f ) || _svmReW1f.size() != Size( 2, (int) _svmSzIdxs.size() ) )
{
_svmReW1f = Mat();
return -1;
......@@ -126,7 +128,7 @@ int ObjectnessBING::loadTrainedModel( std::string modelName ) // Return -1, 0,
void ObjectnessBING::predictBBoxSI( CMat &img3u, ValStructVec<float, Vec4i> &valBoxes, vecI &sz, int NUM_WIN_PSZ, bool fast )
{
const int numSz =(int) _svmSzIdxs.size();
const int numSz = (int) _svmSzIdxs.size();
const int imgW = img3u.cols, imgH = img3u.rows;
valBoxes.reserve( 10000 );
sz.clear();
......@@ -374,7 +376,7 @@ void ObjectnessBING::gradientXY( CMat &x1i, CMat &y1i, Mat &mag1u )
const int *x = x1i.ptr<int>( r ), *y = y1i.ptr<int>( r );
BYTE* m = mag1u.ptr<BYTE>( r );
for ( int c = 0; c < W; c++ )
m[c] = (BYTE)min( x[c] + y[c], 255 ); //((int)sqrt(sqr(x[c]) + sqr(y[c])), 255);
m[c] = (BYTE) min( x[c] + y[c], 255 ); //((int)sqrt(sqr(x[c]) + sqr(y[c])), 255);
}
}
......@@ -491,7 +493,7 @@ bool ObjectnessBING::computeSaliencyImpl( const InputArray image, OutputArray ob
Mat( sortedBB ).copyTo( objectnessBoundingBox );
// List of the rectangles' objectness value
unsigned long int valIdxesSize = (unsigned long int)finalBoxes.getvalIdxes().size();
unsigned long int valIdxesSize = (unsigned long int) finalBoxes.getvalIdxes().size();
objectnessValues.resize( valIdxesSize );
for ( uint i = 0; i < valIdxesSize; i++ )
objectnessValues[i] = finalBoxes.getvalIdxes()[i].first;
......@@ -499,4 +501,5 @@ bool ObjectnessBING::computeSaliencyImpl( const InputArray image, OutputArray ob
return true;
}
} /* namespace saliency */
}/* namespace cv */
......@@ -10,7 +10,7 @@
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Copyright (C) 2014, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
......@@ -39,22 +39,30 @@
//
//M*/
#pragma once
#include "kyheader.h"
#ifndef __OPENCV_FILTER_TIG_HPP__
#define __OPENCV_FILTER_TIG_HPP__
#include "src/kyheader.hpp"
namespace cv
{
namespace saliency
{
class FilterTIG
{
public:
void update(CMat &w);
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
cv::Mat matchTemplate(const cv::Mat &mag1u);
cv::Mat matchTemplate( const cv::Mat &mag1u );
inline float dot(const int64_t tig1, const int64_t tig2, const int64_t tig4, const int64_t tig8);
inline float dot( const int64_t tig1, const int64_t tig2, const int64_t tig4, const int64_t tig8 );
public:
void reconstruct(cv::Mat &w); // For illustration purpose
public:
void reconstruct( cv::Mat &w ); // For illustration purpose
private:
private:
static const int NUM_COMP = 2; // Number of components
static const int D = 64; // Dimension of TIG
int64_t _bTIGs[NUM_COMP]; // Binary TIG features
......@@ -64,23 +72,27 @@ private:
float _coeffs2[NUM_COMP], _coeffs4[NUM_COMP], _coeffs8[NUM_COMP];
};
inline float FilterTIG::dot(const int64_t tig1, const int64_t tig2, const int64_t tig4, const int64_t tig8)
inline float FilterTIG::dot( const int64_t tig1, const int64_t tig2, const int64_t tig4, const int64_t tig8 )
{
int64_t bcT1 = (int64_t)POPCNT64(tig1);
int64_t bcT2 = (int64_t)POPCNT64(tig2);
int64_t bcT4 = (int64_t)POPCNT64(tig4);
int64_t bcT8 = (int64_t)POPCNT64(tig8);
int64_t bcT1 = (int64_t) POPCNT64( tig1 );
int64_t bcT2 = (int64_t) POPCNT64( tig2 );
int64_t bcT4 = (int64_t) POPCNT64( tig4 );
int64_t bcT8 = (int64_t) POPCNT64( tig8 );
int64_t bc01 = (int64_t)(POPCNT64(_bTIGs[0] & tig1) << 1) - bcT1;
int64_t bc02 = (int64_t)((POPCNT64(_bTIGs[0] & tig2) << 1) - bcT2) << 1;
int64_t bc04 = (int64_t)((POPCNT64(_bTIGs[0] & tig4) << 1) - bcT4) << 2;
int64_t bc08 = (int64_t)((POPCNT64(_bTIGs[0] & tig8) << 1) - bcT8) << 3;
int64_t bc01 = (int64_t) ( POPCNT64(_bTIGs[0] & tig1) << 1 ) - bcT1;
int64_t bc02 = (int64_t) ( ( POPCNT64(_bTIGs[0] & tig2) << 1 ) - bcT2 ) << 1;
int64_t bc04 = (int64_t) ( ( POPCNT64(_bTIGs[0] & tig4) << 1 ) - bcT4 ) << 2;
int64_t bc08 = (int64_t) ( ( POPCNT64(_bTIGs[0] & tig8) << 1 ) - bcT8 ) << 3;
int64_t bc11 = (int64_t)(POPCNT64(_bTIGs[1] & tig1) << 1) - bcT1;
int64_t bc12 = (int64_t)((POPCNT64(_bTIGs[1] & tig2) << 1) - bcT2) << 1;
int64_t bc14 = (int64_t)((POPCNT64(_bTIGs[1] & tig4) << 1) - bcT4) << 2;
int64_t bc18 = (int64_t)((POPCNT64(_bTIGs[1] & tig8) << 1) - bcT8) << 3;
int64_t bc11 = (int64_t) ( POPCNT64(_bTIGs[1] & tig1) << 1 ) - bcT1;
int64_t bc12 = (int64_t) ( ( POPCNT64(_bTIGs[1] & tig2) << 1 ) - bcT2 ) << 1;
int64_t bc14 = (int64_t) ( ( POPCNT64(_bTIGs[1] & tig4) << 1 ) - bcT4 ) << 2;
int64_t bc18 = (int64_t) ( ( POPCNT64(_bTIGs[1] & tig8) << 1 ) - bcT8 ) << 3;
return _coeffs1[0] * (bc01 + bc02 + bc04 + bc08) + _coeffs1[1] * (bc11 + bc12 + bc14 + bc18);
return _coeffs1[0] * ( bc01 + bc02 + bc04 + bc08 ) + _coeffs1[1] * ( bc11 + bc12 + bc14 + bc18 );
}
} /* namespace saliency */
} /* namespace cv */
#endif //__OPENCV_FILTER_TIG_HPP__
......@@ -10,7 +10,7 @@
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Copyright (C) 2014, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
......@@ -39,12 +39,18 @@
//
//M*/
#pragma once
#ifndef __OPENCV_VAL_STRUCT_VEC_HPP__
#define __OPENCV_VAL_STRUCT_VEC_HPP__
/************************************************************************/
/* A value struct vector that supports efficient sorting */
/************************************************************************/
namespace cv
{
namespace saliency
{
template<typename VT, typename ST>
struct ValStructVec
{
......@@ -142,3 +148,7 @@ std::vector<std::pair<VT, int> > ValStructVec<VT, ST>::getvalIdxes()
return valIdxes;
}
} /* namespace saliency */
} /* namespace cv */
#endif //__OPENCV_VAL_STRUCT_VEC_HPP__
......@@ -10,7 +10,7 @@
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Copyright (C) 2014, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
......@@ -87,6 +87,11 @@ typedef unsigned char BYTE;
#include <windows.h>
#endif
namespace cv
{
namespace saliency
{
typedef std::vector<int> vecI;
typedef const std::string CStr;
typedef const cv::Mat CMat;
......@@ -280,6 +285,9 @@ inline int popcnt_byte( register uint32_t u )
return (int)c;
}
}
}
/////
#endif // KYHEADER_H
......@@ -10,7 +10,7 @@
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Copyright (C) 2014, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
......@@ -43,9 +43,12 @@
namespace cv
{
namespace saliency
{
/**
* Motion Saliency
*/
} /* namespace saliency */
}/* namespace cv */
......@@ -10,7 +10,7 @@
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Copyright (C) 2014, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
......@@ -48,6 +48,8 @@
namespace cv
{
namespace saliency
{
/* cv::Ptr<Size> MotionSaliencyBinWangApr2014::getWsize()
{
......@@ -157,7 +159,7 @@ bool MotionSaliencyBinWangApr2014::fullResolutionDetection( const Mat& image2, M
for ( size_t z = 0; z < backgroundModel.size(); z++ )
{
counter += (int)backgroundModel[z]->ptr<Vec2f>( i )[j][1];
counter += (int) backgroundModel[z]->ptr<Vec2f>( i )[j][1];
}
if( counter != 0 ) //if at least the first template is activated / initialized
......@@ -460,17 +462,17 @@ bool MotionSaliencyBinWangApr2014::templateReplacement( const Mat& finalBFMask,
else if( i == 0 && j == 0 ) // upper leftt
{
split( *backgroundModel[z], mv );
backgroundModelROI = mv[0]( Rect( j, i, (int)ceil( roiSize / 2 ), (int)ceil( roiSize / 2 ) ) );
backgroundModelROI = mv[0]( Rect( j, i, (int) ceil( roiSize / 2 ), (int) ceil( roiSize / 2 ) ) );
}
else if( j == 0 && i > 0 && i < ( backgroundModel[z]->rows - 1 ) ) // middle left
{
split( *backgroundModel[z], mv );
backgroundModelROI = mv[0]( Rect( j, i - (int) floor( roiSize / 2 ), (int)ceil( roiSize / 2 ), roiSize ) );
backgroundModelROI = mv[0]( Rect( j, i - (int) floor( roiSize / 2 ), (int) ceil( roiSize / 2 ), roiSize ) );
}
else if( i == ( backgroundModel[z]->rows - 1 ) && j == 0 ) //down left
{
split( *backgroundModel[z], mv );
backgroundModelROI = mv[0]( Rect( j, i - (int) floor( roiSize / 2 ), (int)ceil( roiSize / 2 ), (int)ceil( roiSize / 2 ) ) );
backgroundModelROI = mv[0]( Rect( j, i - (int) floor( roiSize / 2 ), (int) ceil( roiSize / 2 ), (int) ceil( roiSize / 2 ) ) );
}
else if( i == 0 && j > 0 && j < ( backgroundModel[z]->cols - 1 ) ) // upper - middle
{
......@@ -486,7 +488,7 @@ bool MotionSaliencyBinWangApr2014::templateReplacement( const Mat& finalBFMask,
else if( i == 0 && j == ( backgroundModel[z]->cols - 1 ) ) // upper right
{
split( *backgroundModel[z], mv );
backgroundModelROI = mv[0]( Rect( j - (int)floor( roiSize / 2 ), i, (int) ceil( roiSize / 2 ), (int) ceil( roiSize / 2 ) ) );
backgroundModelROI = mv[0]( Rect( j - (int) floor( roiSize / 2 ), i, (int) ceil( roiSize / 2 ), (int) ceil( roiSize / 2 ) ) );
}
else if( j == ( backgroundModel[z]->cols - 1 ) && i > 0 && i < ( backgroundModel[z]->rows - 1 ) ) // middle - right
{
......@@ -572,4 +574,5 @@ bool MotionSaliencyBinWangApr2014::computeSaliencyImpl( const InputArray image,
return true;
}
} // namespace saliency
} // namespace cv
......@@ -10,7 +10,7 @@
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Copyright (C) 2014, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
......@@ -43,9 +43,11 @@
namespace cv
{
namespace saliency
{
/**
* Objectness
*/
} /* namespace saliency*/
}/* namespace cv */
......@@ -10,7 +10,7 @@
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Copyright (C) 2014, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
......
......@@ -10,7 +10,7 @@
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Copyright (C) 2014, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
......@@ -43,6 +43,9 @@
namespace cv
{
namespace saliency
{
Saliency::~Saliency()
{
......@@ -68,4 +71,5 @@ String Saliency::getClassName() const
return className;
}
} /* namespace saliency */
} /* namespace cv */
......@@ -10,7 +10,7 @@
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Copyright (C) 2014, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
......@@ -44,6 +44,8 @@
namespace cv
{
namespace saliency
{
CV_INIT_ALGORITHM( StaticSaliencySpectralResidual, "SALIENCY.SPECTRAL_RESIDUAL",
obj.info()->addParam( obj, "resImWidth", obj.resImWidth); obj.info()->addParam( obj, "resImHeight", obj.resImHeight) );
......@@ -68,4 +70,5 @@ bool initModule_saliency( void )
return all;
}
}
} // namespace saliency
} // namespace cv
......@@ -10,7 +10,7 @@
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Copyright (C) 2014, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
......@@ -43,6 +43,8 @@
namespace cv
{
namespace saliency
{
/**
* StaticSaliency
......@@ -95,4 +97,5 @@ bool StaticSaliency::computeBinaryMap( const Mat& saliencyMap, Mat& BinaryMap )
}
}/* namespace saliency */
}/* namespace cv */
......@@ -10,7 +10,7 @@
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
// Copyright (C) 2014, OpenCV Foundation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
......@@ -43,25 +43,27 @@
namespace cv
{
namespace saliency
{
/**
* SaliencySpectralResidual
*/
/*cv::Ptr<Size> StaticSaliencySpectralResidual::getWsize()
{
{
return resizedImageSize;
}
void StaticSaliencySpectralResidual::setWsize( const cv::Ptr<Size>& newSize )
{
}
void StaticSaliencySpectralResidual::setWsize( const cv::Ptr<Size>& newSize )
{
resizedImageSize = newSize;
}*/
}*/
StaticSaliencySpectralResidual::StaticSaliencySpectralResidual()
{
className = "SPECTRAL_RESIDUAL";
resImWidth=64;
resImHeight=64;
resImWidth = 64;
resImHeight = 64;
//resizedImageSize = Ptr<Size>( new Size( 64, 64 ) );
}
......@@ -70,12 +72,12 @@ StaticSaliencySpectralResidual::~StaticSaliencySpectralResidual()
}
void StaticSaliencySpectralResidual::read( const cv::FileNode& /*fn*/ )
void StaticSaliencySpectralResidual::read( const cv::FileNode& /*fn*/)
{
//params.read( fn );
}
void StaticSaliencySpectralResidual::write( cv::FileStorage& /*fs*/ ) const
void StaticSaliencySpectralResidual::write( cv::FileStorage& /*fs*/) const
{
//params.write( fs );
}
......@@ -84,7 +86,7 @@ bool StaticSaliencySpectralResidual::computeSaliencyImpl( const InputArray image
{
Mat grayTemp, grayDown;
std::vector<Mat> mv;
Size resizedImageSize(resImWidth, resImHeight);
Size resizedImageSize( resImWidth, resImHeight );
Mat realImage( resizedImageSize, CV_64F );
Mat imaginaryImage( resizedImageSize, CV_64F );
......@@ -148,4 +150,5 @@ bool StaticSaliencySpectralResidual::computeSaliencyImpl( const InputArray image
}
} /* namespace saliency */
}/* namespace cv */
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