Skip to content

Commit

Permalink
Merge pull request andrewssobral#13 from holgerfriedrich/master
Browse files Browse the repository at this point in the history
warnings and variable scope
  • Loading branch information
andrewssobral committed Jul 29, 2014
2 parents c211edf + 0ecc2a0 commit b808265
Show file tree
Hide file tree
Showing 21 changed files with 93 additions and 93 deletions.
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ project(bgs)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")

IF(UNIX)
# add some standard warnings
ADD_DEFINITIONS(-Wno-variadic-macros -Wno-long-long -Wall -Wextra -Winit-self -Woverloaded-virtual -Wsign-promo -Wno-unused-parameter -pedantic -Woverloaded-virtual -Wno-unknown-pragmas)

# -ansi does not compile with sjn module
#ADD_DEFINITIONS(-ansi)

# if you like to have warinings about conversions, e.g. double->int or double->float etc., or float compare
#ADD_DEFINITIONS(-Wconversion -Wfloat-equal)
endif(UNIX)

find_package(OpenCV REQUIRED)

if(${OpenCV_VERSION} VERSION_LESS 2.3.1)
Expand Down
2 changes: 1 addition & 1 deletion package_analysis/ForegroundMaskAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ along with BGSLibrary. If not, see <http://www.gnu.org/licenses/>.

namespace bgslibrary
{
ForegroundMaskAnalysis::ForegroundMaskAnalysis() : firstTime(true), stopAt(0), showOutput(true), img_ref_path("")
ForegroundMaskAnalysis::ForegroundMaskAnalysis() : firstTime(true), showOutput(true), stopAt(0), img_ref_path("")
{
std::cout << "ForegroundMaskAnalysis()" << std::endl;
}
Expand Down
2 changes: 1 addition & 1 deletion package_bgs/WeightedMovingVarianceBGS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void WeightedMovingVarianceBGS::process(const cv::Mat &img_input, cv::Mat &img_o
}

//unused
cv::Mat WeightedMovingVarianceBGS::computeWeightedMean(const std::vector<cv::Mat> &v_img_input_f, const std::vector<double> weights)
cv::Mat WeightedMovingVarianceBGS::computeWeightedMean(const std::vector<cv::Mat> &v_img_input_f, const std::vector<double> &weights)
{
cv::Mat img;
return img;
Expand Down
2 changes: 1 addition & 1 deletion package_bgs/WeightedMovingVarianceBGS.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class WeightedMovingVarianceBGS : public IBGS
WeightedMovingVarianceBGS();
~WeightedMovingVarianceBGS();

cv::Mat computeWeightedMean(const std::vector<cv::Mat> &v_img_input_f, const std::vector<double> weights);
cv::Mat computeWeightedMean(const std::vector<cv::Mat> &v_img_input_f, const std::vector<double> &weights);
cv::Mat computeWeightedVariance(const cv::Mat &img_input_f, const cv::Mat &img_mean_f, const double weight);

void process(const cv::Mat &img_input, cv::Mat &img_output, cv::Mat &img_bgmodel);
Expand Down
10 changes: 5 additions & 5 deletions package_bgs/ae/NPBGSubtractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -902,7 +902,7 @@ void NPBGSubtractor::NPBGSubtraction_Subset_Kernel(
double p;
double th;

double alpha,beta,beta_over_alpha, betau,betau_over_alpha;
double alpha;

alpha= AlphaValue;

Expand Down Expand Up @@ -954,11 +954,11 @@ void NPBGSubtractor::NPBGSubtraction_Subset_Kernel(

unsigned int kerneltablewidth=2*KernelHalfWidth+1;

beta=3.0; // minimum bound on the range.
betau=100.0;
double beta=3.0; // minimum bound on the range.
double betau=100.0;

beta_over_alpha = beta / alpha;
betau_over_alpha = betau / alpha;
double beta_over_alpha = beta / alpha;
double betau_over_alpha = betau / alpha;


double brightness_lowerbound = 1-alpha;
Expand Down
4 changes: 2 additions & 2 deletions package_bgs/av/TBackground.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ int TBackground::Init(IplImage * pSource)
bool TBackground::isInitOk(IplImage * pSource, IplImage *pBackground, IplImage *pMotionMask)
{
bool bResult = true;
int nbl, nbc;

if(pSource == NULL || pSource->nChannels != 1 || pSource->depth != IPL_DEPTH_8U)
bResult = false;

if(bResult)
{
int nbl, nbc;
nbl = pSource->height;
nbc = pSource->width;

Expand Down Expand Up @@ -111,7 +111,6 @@ int TBackground::UpdateTest(IplImage *pSource, IplImage *pBackground, IplImage *
int nErr = 0;
CvScalar Color;
unsigned char *ptr;
int l, c;

if(pTest == NULL || !isInitOk(pSource, pBackground, pSource))
nErr = 1;
Expand All @@ -135,6 +134,7 @@ int TBackground::UpdateTest(IplImage *pSource, IplImage *pBackground, IplImage *

if(!nErr)
{
int l, c;
// recupere l'indice de la colonne
ptr = (unsigned char *)(pTest->imageData);
c = *ptr;
Expand Down
42 changes: 17 additions & 25 deletions package_bgs/av/TBackgroundVuMeter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ along with BGSLibrary. If not, see <http://www.gnu.org/licenses/>.

TBackgroundVuMeter::TBackgroundVuMeter(void)
: m_pHist(NULL)
, m_nBinSize(8)
, m_nBinCount(0)
, m_nBinSize(8)
, m_nCount(0)
, m_fAlpha(0.995)
, m_fThreshold(0.03)
, m_nCount(0)
{
std::cout << "TBackgroundVuMeter()" << std::endl;
}
Expand All @@ -44,13 +44,11 @@ TBackgroundVuMeter::~TBackgroundVuMeter(void)

void TBackgroundVuMeter::Clear(void)
{
int i;

TBackground::Clear();

if(m_pHist != NULL)
{
for(i = 0; i < m_nBinCount; ++i)
for(int i = 0; i < m_nBinCount; ++i)
{
if(m_pHist[i] != NULL)
cvReleaseImage(&m_pHist[i]);
Expand All @@ -66,7 +64,6 @@ void TBackgroundVuMeter::Clear(void)

void TBackgroundVuMeter::Reset(void)
{
int i;
float fVal = 0.0;

TBackground::Reset();
Expand All @@ -76,7 +73,7 @@ void TBackgroundVuMeter::Reset(void)
// fVal = (m_nBinCount != 0) ? (float)(1.0 / (double)m_nBinCount) : (float)0.0;
fVal = 0.0;

for(i = 0; i < m_nBinCount; ++i)
for(int i = 0; i < m_nBinCount; ++i)
{
if(m_pHist[i] != NULL)
{
Expand Down Expand Up @@ -175,7 +172,6 @@ int TBackgroundVuMeter::SetParameterValue(int nInd, std::string csNew)
int TBackgroundVuMeter::Init(IplImage * pSource)
{
int nErr = 0;
int i;
int nbl, nbc;

Clear();
Expand Down Expand Up @@ -208,7 +204,7 @@ int TBackgroundVuMeter::Init(IplImage * pSource)
// creation des images
if(!nErr)
{
for(i = 0; i < m_nBinCount; ++i)
for(int i = 0; i < m_nBinCount; ++i)
{
m_pHist[i] = cvCreateImage(cvSize(nbc, nbl), IPL_DEPTH_32F, 1);

Expand All @@ -229,7 +225,6 @@ bool TBackgroundVuMeter::isInitOk(IplImage * pSource, IplImage *pBackground, Ipl
{
bool bResult = true;
int i;
int nbl, nbc;

bResult = TBackground::isInitOk(pSource, pBackground, pMotionMask);

Expand All @@ -249,8 +244,8 @@ bool TBackgroundVuMeter::isInitOk(IplImage * pSource, IplImage *pBackground, Ipl

if(bResult)
{
nbl = pSource->height;
nbc = pSource->width;
int nbl = pSource->height;
int nbc = pSource->width;

for(i = 0; i < m_nBinCount; ++i)
{
Expand All @@ -265,35 +260,33 @@ bool TBackgroundVuMeter::isInitOk(IplImage * pSource, IplImage *pBackground, Ipl
int TBackgroundVuMeter::UpdateBackground(IplImage *pSource, IplImage *pBackground, IplImage *pMotionMask)
{
int nErr = 0;
int i, l, c, nbl, nbc;
unsigned char *ptrs, *ptrb, *ptrm;
float *ptr1, *ptr2;
unsigned char v;

if(!isInitOk(pSource, pBackground, pMotionMask))
nErr = Init(pSource);

if(!nErr)
{
m_nCount++;
nbc = pSource->width;
nbl = pSource->height;
v = m_nBinSize;
int nbc = pSource->width;
int nbl = pSource->height;
unsigned char v = m_nBinSize;

// multiplie tout par alpha
for(i = 0; i < m_nBinCount; ++i)
for(int i = 0; i < m_nBinCount; ++i)
cvConvertScale(m_pHist[i], m_pHist[i], m_fAlpha, 0.0);

for(l = 0; l < nbl; ++l)
for(int l = 0; l < nbl; ++l)
{
ptrs = (unsigned char *)(pSource->imageData + pSource->widthStep * l);
ptrm = (unsigned char *)(pMotionMask->imageData + pMotionMask->widthStep * l);
ptrb = (unsigned char *)(pBackground->imageData + pBackground->widthStep * l);

for(c = 0; c < nbc; ++c, ptrs++, ptrb++, ptrm++)
for(int c = 0; c < nbc; ++c, ptrs++, ptrb++, ptrm++)
{
// recherche le bin à augmenter
i = *ptrs / v;
int i = *ptrs / v;

if(i < 0 || i >= m_nBinCount)
i = 0;
Expand Down Expand Up @@ -341,16 +334,15 @@ IplImage *TBackgroundVuMeter::CreateTestImg()
int TBackgroundVuMeter::UpdateTest(IplImage *pSource, IplImage *pBackground, IplImage *pTest, int nX, int nY, int nInd)
{
int nErr = 0;
int i, nbl, nbc;
float *ptrf;

if(pTest == NULL || !isInitOk(pSource, pBackground, pSource))
nErr = 1;

if(!nErr)
{
nbl = pTest->height;
nbc = pTest->width;
int nbl = pTest->height;
int nbc = pTest->width;

if(nbl != 100 || nbc != m_nBinCount)
nErr = 1;
Expand All @@ -363,7 +355,7 @@ int TBackgroundVuMeter::UpdateTest(IplImage *pSource, IplImage *pBackground, Ipl
{
cvSetZero(pTest);

for(i = 0; i < m_nBinCount; ++i)
for(int i = 0; i < m_nBinCount; ++i)
{
ptrf = (float *)(m_pHist[i]->imageData + m_pHist[i]->widthStep * nY);
ptrf += nX;
Expand Down
2 changes: 1 addition & 1 deletion package_bgs/db/IndependentMultimodalBGS.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "IndependentMultimodalBGS.h"

IndependentMultimodalBGS::IndependentMultimodalBGS() : firstTime(true), fps(10), showOutput(true){
IndependentMultimodalBGS::IndependentMultimodalBGS() : fps(10), firstTime(true), showOutput(true){
pIMBS = new BackgroundSubtractorIMBS(fps);
}
IndependentMultimodalBGS::~IndependentMultimodalBGS(){
Expand Down
4 changes: 2 additions & 2 deletions package_bgs/dp/DPAdaptiveMedianBGS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ along with BGSLibrary. If not, see <http://www.gnu.org/licenses/>.
*/
#include "DPAdaptiveMedianBGS.h"

DPAdaptiveMedianBGS::DPAdaptiveMedianBGS() : firstTime(true), frameNumber(0), showOutput(true), threshold(40), samplingRate(7), learningFrames(30)
DPAdaptiveMedianBGS::DPAdaptiveMedianBGS() : firstTime(true), frameNumber(0), threshold(40), samplingRate(7), learningFrames(30), showOutput(true)
{
std::cout << "DPAdaptiveMedianBGS()" << std::endl;
}
Expand Down Expand Up @@ -101,4 +101,4 @@ void DPAdaptiveMedianBGS::loadConfig()
showOutput = cvReadIntByName(fs, 0, "showOutput", true);

cvReleaseFileStorage(&fs);
}
}
4 changes: 2 additions & 2 deletions package_bgs/dp/DPEigenbackgroundBGS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ along with BGSLibrary. If not, see <http://www.gnu.org/licenses/>.
*/
#include "DPEigenbackgroundBGS.h"

DPEigenbackgroundBGS::DPEigenbackgroundBGS() : firstTime(true), frameNumber(0), showOutput(true), threshold(225), historySize(20), embeddedDim(10)
DPEigenbackgroundBGS::DPEigenbackgroundBGS() : firstTime(true), frameNumber(0), threshold(225), historySize(20), embeddedDim(10), showOutput(true)
{
std::cout << "DPEigenbackgroundBGS()" << std::endl;
}
Expand Down Expand Up @@ -103,4 +103,4 @@ void DPEigenbackgroundBGS::loadConfig()
showOutput = cvReadIntByName(fs, 0, "showOutput", true);

cvReleaseFileStorage(&fs);
}
}
4 changes: 2 additions & 2 deletions package_bgs/dp/DPGrimsonGMMBGS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ along with BGSLibrary. If not, see <http://www.gnu.org/licenses/>.
*/
#include "DPGrimsonGMMBGS.h"

DPGrimsonGMMBGS::DPGrimsonGMMBGS() : firstTime(true), frameNumber(0), showOutput(true), threshold(9.0), alpha(0.01), gaussians(3)
DPGrimsonGMMBGS::DPGrimsonGMMBGS() : firstTime(true), frameNumber(0), threshold(9.0), alpha(0.01), gaussians(3), showOutput(true)
{
std::cout << "DPGrimsonGMMBGS()" << std::endl;
}
Expand Down Expand Up @@ -102,4 +102,4 @@ void DPGrimsonGMMBGS::loadConfig()
showOutput = cvReadIntByName(fs, 0, "showOutput", true);

cvReleaseFileStorage(&fs);
}
}
4 changes: 2 additions & 2 deletions package_bgs/dp/DPZivkovicAGMMBGS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ along with BGSLibrary. If not, see <http://www.gnu.org/licenses/>.
*/
#include "DPZivkovicAGMMBGS.h"

DPZivkovicAGMMBGS::DPZivkovicAGMMBGS() : firstTime(true), frameNumber(0), showOutput(true), threshold(25.0f), alpha(0.001f), gaussians(3)
DPZivkovicAGMMBGS::DPZivkovicAGMMBGS() : firstTime(true), frameNumber(0), threshold(25.0f), alpha(0.001f), gaussians(3), showOutput(true)
{
std::cout << "DPZivkovicAGMMBGS()" << std::endl;
}
Expand Down Expand Up @@ -101,4 +101,4 @@ void DPZivkovicAGMMBGS::loadConfig()
showOutput = cvReadIntByName(fs, 0, "showOutput", true);

cvReleaseFileStorage(&fs);
}
}
6 changes: 3 additions & 3 deletions package_bgs/jmo/BlobExtraction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1291,10 +1291,10 @@ namespace Blob
//if(RegionData[i]->parent == iOld) { RegionData[i]->parent = iNew; }
if ((*iti)->parent == iOld) { (*iti)->parent = iNew; }

iti++;
++iti;
}
iNew++;
itNew++;
++itNew;
}
}

Expand Down Expand Up @@ -1361,7 +1361,7 @@ namespace Blob
{
delete *itBlobs;
//RegionData.erase( itBlobs );
itBlobs++;
++itBlobs;
}
RegionData.erase(RegionData.begin() + HighRegionNum + 1, RegionData.end());

Expand Down
Loading

0 comments on commit b808265

Please sign in to comment.