This commit is contained in:
Anatoly Baksheev 2011-09-05 14:37:27 +00:00
parent fbe2e6fb01
commit 415978b1c9
5 changed files with 453 additions and 455 deletions

View File

@ -199,15 +199,15 @@ void CvHybridTracker::updateTrackerWithEM(Mat image) {
for (int i = 0; i < proj.rows; i++)
for (int j = 0; j < proj.cols; j++)
if (proj.at<double> (i, j) > 0) {
samples->data.fl[count * 2] = i;
samples->data.fl[count * 2 + 1] = j;
samples->data.fl[count * 2] = (float)i;
samples->data.fl[count * 2 + 1] = (float)j;
count++;
}
em_model.train(samples, 0, params.em_params, labels);
curr_center.x = em_model.getMeans().at<double> (0, 0);
curr_center.y = em_model.getMeans().at<double> (0, 1);
curr_center.x = (float)em_model.getMeans().at<double> (0, 0);
curr_center.y = (float)em_model.getMeans().at<double> (0, 1);
}
void CvHybridTracker::updateTrackerWithLowPassFilter(Mat image) {

View File

@ -73,9 +73,9 @@
namespace cv
{
// standard constructor without any log sampling of the input frame
RetinaFilter::RetinaFilter(const unsigned int sizeRows, const unsigned int sizeColumns, const bool colorMode, const RETINA_COLORSAMPLINGMETHOD samplingMethod, const bool useRetinaLogSampling, const double reductionFactor, const double samplingStrenght)
:
// standard constructor without any log sampling of the input frame
RetinaFilter::RetinaFilter(const unsigned int sizeRows, const unsigned int sizeColumns, const bool colorMode, const RETINA_COLORSAMPLINGMETHOD samplingMethod, const bool useRetinaLogSampling, const double reductionFactor, const double samplingStrenght)
:
_retinaParvoMagnoMappedFrame(0),
_retinaParvoMagnoMapCoefTable(0),
_photoreceptorsPrefilter((1-(int)useRetinaLogSampling)*sizeRows+useRetinaLogSampling*ImageLogPolProjection::predictOutputSize(sizeRows, reductionFactor), (1-(int)useRetinaLogSampling)*sizeColumns+useRetinaLogSampling*ImageLogPolProjection::predictOutputSize(sizeColumns, reductionFactor), 4),
@ -84,7 +84,7 @@ RetinaFilter::RetinaFilter(const unsigned int sizeRows, const unsigned int sizeC
_colorEngine((1-(int)useRetinaLogSampling)*sizeRows+useRetinaLogSampling*ImageLogPolProjection::predictOutputSize(sizeRows, reductionFactor), (1-(int)useRetinaLogSampling)*sizeColumns+useRetinaLogSampling*ImageLogPolProjection::predictOutputSize(sizeColumns, reductionFactor), samplingMethod),
// configure retina photoreceptors log sampling... if necessary
_photoreceptorsLogSampling(NULL)
{
{
#ifdef RETINADEBUG
std::cout<<"RetinaFilter::size( "<<_photoreceptorsPrefilter.getNBrows()<<", "<<_photoreceptorsPrefilter.getNBcolumns()<<")"<<" =? "<<_photoreceptorsPrefilter.getNBpixels()<<std::endl;
@ -128,18 +128,18 @@ RetinaFilter::RetinaFilter(const unsigned int sizeRows, const unsigned int sizeC
// std::cout<<"RetinaFilter::size( "<<this->getNBrows()<<", "<<this->getNBcolumns()<<")"<<_filterOutput.size()<<" =? "<<_filterOutput.getNBpixels()<<std::endl;
}
}
// destructor
RetinaFilter::~RetinaFilter()
{
// destructor
RetinaFilter::~RetinaFilter()
{
if (_photoreceptorsLogSampling!=NULL)
delete _photoreceptorsLogSampling;
}
}
// function that clears all buffers of the object
void RetinaFilter::clearAllBuffers()
{
// function that clears all buffers of the object
void RetinaFilter::clearAllBuffers()
{
_photoreceptorsPrefilter.clearAllBuffers();
_ParvoRetinaFilter.clearAllBuffers();
_MagnoRetinaFilter.clearAllBuffers();
@ -148,15 +148,15 @@ void RetinaFilter::clearAllBuffers()
_photoreceptorsLogSampling->clearAllBuffers();
// stability controls value init
_setInitPeriodCount();
}
}
/**
* resize retina filter object (resize all allocated buffers
* @param NBrows: the new height size
* @param NBcolumns: the new width size
*/
void RetinaFilter::resize(const unsigned int NBrows, const unsigned int NBcolumns)
{
/**
* resize retina filter object (resize all allocated buffers
* @param NBrows: the new height size
* @param NBcolumns: the new width size
*/
void RetinaFilter::resize(const unsigned int NBrows, const unsigned int NBcolumns)
{
unsigned int rows=NBrows, cols=NBcolumns;
// resize optionnal member and adjust other modules size if required
@ -178,21 +178,21 @@ void RetinaFilter::resize(const unsigned int NBrows, const unsigned int NBcolumn
// clean buffers
clearAllBuffers();
}
}
// stability controls value init
void RetinaFilter::_setInitPeriodCount()
{
// stability controls value init
void RetinaFilter::_setInitPeriodCount()
{
// find out the maximum temporal constant value and apply a security factor
// false value (obviously too long) but appropriate for simple use
_globalTemporalConstant=(unsigned int)(_ParvoRetinaFilter.getPhotoreceptorsTemporalConstant()+_ParvoRetinaFilter.getHcellsTemporalConstant()+_MagnoRetinaFilter.getTemporalConstant());
// reset frame counter
_ellapsedFramesSinceLastReset=0;
}
}
void RetinaFilter::_createHybridTable()
{
void RetinaFilter::_createHybridTable()
{
// create hybrid output and related coefficient table
_retinaParvoMagnoMappedFrame.resize(_photoreceptorsPrefilter.getNBpixels());
@ -218,11 +218,11 @@ void RetinaFilter::_createHybridTable()
}
}
}
}
}
// setup parameters function and global data filling
void RetinaFilter::setGlobalParameters(const float OPLspatialResponse1, const float OPLtemporalresponse1, const float OPLassymetryGain, const float OPLspatialResponse2, const float OPLtemporalresponse2, const float LPfilterSpatialResponse, const float LPfilterGain, const float LPfilterTemporalresponse, const float MovingContoursExtractorCoefficient, const bool normalizeParvoOutput_0_maxOutputValue, const bool normalizeMagnoOutput_0_maxOutputValue, const float maxOutputValue, const float maxInputValue, const float meanValue)
{
// setup parameters function and global data filling
void RetinaFilter::setGlobalParameters(const float OPLspatialResponse1, const float OPLtemporalresponse1, const float OPLassymetryGain, const float OPLspatialResponse2, const float OPLtemporalresponse2, const float LPfilterSpatialResponse, const float LPfilterGain, const float LPfilterTemporalresponse, const float MovingContoursExtractorCoefficient, const bool normalizeParvoOutput_0_maxOutputValue, const bool normalizeMagnoOutput_0_maxOutputValue, const float maxOutputValue, const float maxInputValue, const float meanValue)
{
_normalizeParvoOutput_0_maxOutputValue=normalizeParvoOutput_0_maxOutputValue;
_normalizeMagnoOutput_0_maxOutputValue=normalizeMagnoOutput_0_maxOutputValue;
_maxOutputValue=maxOutputValue;
@ -238,10 +238,10 @@ void RetinaFilter::setGlobalParameters(const float OPLspatialResponse1, const fl
// stability controls value init
_setInitPeriodCount();
}
}
const bool RetinaFilter::checkInput(const std::valarray<float> &input, const bool)
{
const bool RetinaFilter::checkInput(const std::valarray<float> &input, const bool)
{
BasicRetinaFilter *inputTarget=&_photoreceptorsPrefilter;
if (_photoreceptorsLogSampling)
@ -256,11 +256,11 @@ const bool RetinaFilter::checkInput(const std::valarray<float> &input, const boo
}
return true;
}
}
// main function that runs the filter for a given input frame
const bool RetinaFilter::runFilter(const std::valarray<float> &imageInput, const bool useAdaptiveFiltering, const bool processRetinaParvoMagnoMapping, const bool useColorMode, const bool inputIsColorMultiplexed)
{
// main function that runs the filter for a given input frame
const bool RetinaFilter::runFilter(const std::valarray<float> &imageInput, const bool useAdaptiveFiltering, const bool processRetinaParvoMagnoMapping, const bool useColorMode, const bool inputIsColorMultiplexed)
{
// preliminary check
bool processSuccess=true;
if (!checkInput(imageInput, useColorMode))
@ -344,29 +344,29 @@ const bool RetinaFilter::runFilter(const std::valarray<float> &imageInput, const
}
return processSuccess;
}
}
const std::valarray<float> &RetinaFilter::getContours()
{
const std::valarray<float> &RetinaFilter::getContours()
{
if (_useColorMode)
return _colorEngine.getLuminance();
else
return _ParvoRetinaFilter.getOutput();
}
}
// run the initilized retina filter in order to perform gray image tone mapping, after this call all retina outputs are updated
void RetinaFilter::runGrayToneMapping(const std::valarray<float> &grayImageInput, std::valarray<float> &grayImageOutput, const float PhotoreceptorsCompression, const float ganglionCellsCompression)
{
// run the initilized retina filter in order to perform gray image tone mapping, after this call all retina outputs are updated
void RetinaFilter::runGrayToneMapping(const std::valarray<float> &grayImageInput, std::valarray<float> &grayImageOutput, const float PhotoreceptorsCompression, const float ganglionCellsCompression)
{
// preliminary check
if (!checkInput(grayImageInput, false))
return;
this->_runGrayToneMapping(grayImageInput, grayImageOutput, PhotoreceptorsCompression, ganglionCellsCompression);
}
}
// run the initilized retina filter in order to perform gray image tone mapping, after this call all retina outputs are updated
void RetinaFilter::_runGrayToneMapping(const std::valarray<float> &grayImageInput, std::valarray<float> &grayImageOutput, const float PhotoreceptorsCompression, const float ganglionCellsCompression)
{
// run the initilized retina filter in order to perform gray image tone mapping, after this call all retina outputs are updated
void RetinaFilter::_runGrayToneMapping(const std::valarray<float> &grayImageInput, std::valarray<float> &grayImageOutput, const float PhotoreceptorsCompression, const float ganglionCellsCompression)
{
// stability controls value update
++_ellapsedFramesSinceLastReset;
@ -389,10 +389,10 @@ void RetinaFilter::_runGrayToneMapping(const std::valarray<float> &grayImageInpu
_photoreceptorsPrefilter.setV0CompressionParameterToneMapping(ganglionCellsCompression, temp2.max(), temp2.sum()/(float)_photoreceptorsPrefilter.getNBpixels());
_photoreceptorsPrefilter.runFilter_LocalAdapdation(temp2, grayImageOutput, grayImageOutput); // adapt contrast to local luminance
}
// run the initilized retina filter in order to perform color tone mapping, after this call all retina outputs are updated
void RetinaFilter::runRGBToneMapping(const std::valarray<float> &RGBimageInput, std::valarray<float> &RGBimageOutput, const bool useAdaptiveFiltering, const float PhotoreceptorsCompression, const float ganglionCellsCompression)
{
}
// run the initilized retina filter in order to perform color tone mapping, after this call all retina outputs are updated
void RetinaFilter::runRGBToneMapping(const std::valarray<float> &RGBimageInput, std::valarray<float> &RGBimageOutput, const bool useAdaptiveFiltering, const float PhotoreceptorsCompression, const float ganglionCellsCompression)
{
// preliminary check
if (!checkInput(RGBimageInput, true))
return;
@ -411,10 +411,10 @@ void RetinaFilter::runRGBToneMapping(const std::valarray<float> &RGBimageInput,
// return the result
RGBimageOutput=_colorEngine.getDemultiplexedColorFrame();
}
}
void RetinaFilter::runLMSToneMapping(const std::valarray<float> &, std::valarray<float> &, const bool, const float, const float)
{
void RetinaFilter::runLMSToneMapping(const std::valarray<float> &, std::valarray<float> &, const bool, const float, const float)
{
std::cerr<<"not working, sorry"<<std::endl;
/* // preliminary check
@ -468,11 +468,11 @@ void RetinaFilter::runLMSToneMapping(const std::valarray<float> &, std::valarray
// rewrite output to the appropriate buffer
_colorEngine->setDemultiplexedColorFrame(lmsTempBuffer.Buffer());
*/
}
}
// return image with center Parvo and peripheral Magno channels
void RetinaFilter::_processRetinaParvoMagnoMapping()
{
// return image with center Parvo and peripheral Magno channels
void RetinaFilter::_processRetinaParvoMagnoMapping()
{
register float *hybridParvoMagnoPTR= &_retinaParvoMagnoMappedFrame[0];
register const float *parvoOutputPTR= get_data(_ParvoRetinaFilter.getOutput());
register const float *magnoXOutputPTR= get_data(_MagnoRetinaFilter.getOutput());
@ -486,10 +486,10 @@ void RetinaFilter::_processRetinaParvoMagnoMapping()
TemplateBuffer<float>::normalizeGrayOutput_0_maxOutputValue(&_retinaParvoMagnoMappedFrame[0], _photoreceptorsPrefilter.getNBpixels());
}
}
const bool RetinaFilter::getParvoFoveaResponse(std::valarray<float> &parvoFovealResponse)
{
const bool RetinaFilter::getParvoFoveaResponse(std::valarray<float> &parvoFovealResponse)
{
if (!_useParvoOutput)
return false;
if (parvoFovealResponse.size() != _ParvoRetinaFilter.getNBpixels())
@ -505,11 +505,11 @@ const bool RetinaFilter::getParvoFoveaResponse(std::valarray<float> &parvoFoveal
}
return true;
}
}
// method to retrieve the parafoveal magnocellular pathway response (no energy motion in fovea)
const bool RetinaFilter::getMagnoParaFoveaResponse(std::valarray<float> &magnoParafovealResponse)
{
// method to retrieve the parafoveal magnocellular pathway response (no energy motion in fovea)
const bool RetinaFilter::getMagnoParaFoveaResponse(std::valarray<float> &magnoParafovealResponse)
{
if (!_useMagnoOutput)
return false;
if (magnoParafovealResponse.size() != _MagnoRetinaFilter.getNBpixels())
@ -525,7 +525,5 @@ const bool RetinaFilter::getMagnoParaFoveaResponse(std::valarray<float> &magnoPa
}
return true;
}
}
}

View File

@ -287,25 +287,25 @@ std::string CommandLineParser::analizeValue<std::string>(const std::string& str,
}
template<>
int CommandLineParser::analizeValue<int>(const std::string& str, bool space_delete)
int CommandLineParser::analizeValue<int>(const std::string& str, bool /*space_delete*/)
{
return fromStringNumber<int>(str);
}
template<>
unsigned int CommandLineParser::analizeValue<unsigned int>(const std::string& str, bool space_delete)
unsigned int CommandLineParser::analizeValue<unsigned int>(const std::string& str, bool /*space_delete*/)
{
return fromStringNumber<unsigned int>(str);
}
template<>
float CommandLineParser::analizeValue<float>(const std::string& str, bool space_delete)
float CommandLineParser::analizeValue<float>(const std::string& str, bool /*space_delete*/)
{
return fromStringNumber<float>(str);
}
template<>
double CommandLineParser::analizeValue<double>(const std::string& str, bool space_delete)
double CommandLineParser::analizeValue<double>(const std::string& str, bool /*space_delete*/)
{
return fromStringNumber<double>(str);
}

View File

@ -780,14 +780,14 @@ bool CV_OperationsTest::TestVec()
//these compile
cv::Vec3b b = a;
hsvImage_f.at<cv::Vec3f>(i,j) = cv::Vec3f(i,0,1);
hsvImage_b.at<cv::Vec3b>(i,j) = cv::Vec3b(cv::Vec3f(i,0,1));
hsvImage_f.at<cv::Vec3f>(i,j) = cv::Vec3f((float)i,0,1);
hsvImage_b.at<cv::Vec3b>(i,j) = cv::Vec3b(cv::Vec3f((float)i,0,1));
//these don't
b = cv::Vec3f(1,0,0);
cv::Vec3b c;
c = cv::Vec3f(0,0,1);
hsvImage_b.at<cv::Vec3b>(i,j) = cv::Vec3f(i,0,1);
hsvImage_b.at<cv::Vec3b>(i,j) = cv::Vec3f((float)i,0,1);
hsvImage_b.at<cv::Vec3b>(i,j) = a;
hsvImage_b.at<cv::Vec3b>(i,j) = cv::Vec3f(1,2,3);
}

View File

@ -322,7 +322,7 @@ void cv::createHanningWindow(OutputArray _dst, cv::Size winSize, int type)
for(int j = 0; j < cols; j++)
{
double wc = 0.5 * (1.0f - cos(2.0f * CV_PI * (double)j / (double)(cols - 1)));
dstData[i*cols + j] = wr * wc;
dstData[i*cols + j] = (float)(wr * wc);
}
}