Skip to content

Commit 22f5843

Browse files
committed
Merge pull request #338 from patricksnape:msvc_python_fixes
2 parents 88a72a0 + 0507e16 commit 22f5843

File tree

4 files changed

+35
-34
lines changed

4 files changed

+35
-34
lines changed

modules/bioinspired/src/transientareassegmentationmodule.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ void TransientAreasSegmentationModuleImpl::_run(const std::valarray<float> &inpu
454454

455455
// first square the input in order to increase the signal to noise ratio
456456
// get motion local energy
457-
_squaringSpatiotemporalLPfilter(&inputToSegment[channelIndex*getNBpixels()], &_localMotion[0]);
457+
_squaringSpatiotemporalLPfilter(&const_cast<std::valarray<float>&>(inputToSegment)[channelIndex*getNBpixels()], &_localMotion[0]);
458458

459459
// second low pass filter: access to the neighborhood motion energy
460460
_spatiotemporalLPfilter(&_localMotion[0], &_neighborhoodMotion[0], 1);

modules/line_descriptor/src/LSDDetector.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ void LSDDetector::detectImpl( const Mat& imageSrc, std::vector<KeyLine>& keyline
179179
kl.sPointInOctaveY = (float) extremes[1];
180180
kl.ePointInOctaveX = (float) extremes[2];
181181
kl.ePointInOctaveY = (float) extremes[3];
182-
kl.lineLength = (float) sqrt( pow( extremes[0] - extremes[2], 2 ) + pow( extremes[1] - extremes[3], 2 ) );
182+
kl.lineLength = (float) sqrt( pow( (float) extremes[0] - extremes[2], 2 ) + pow( (float) extremes[1] - extremes[3], 2 ) );
183183

184184
/* compute number of pixels covered by line */
185185
LineIterator li( gaussianPyrs[j], Point( extremes[0], extremes[1] ), Point( extremes[2], extremes[3] ) );

modules/line_descriptor/src/binary_descriptor.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ void BinaryDescriptor::computeImpl( const Mat& imageSrc, std::vector<KeyLine>& k
653653
uchar* pointerToRow = descriptors.ptr( originalIndex );
654654

655655
/* get LBD data */
656-
float* desVec = sl[k][lineC].descriptor.data();
656+
float* desVec = &sl[k][lineC].descriptor.front();
657657

658658
/* fill current row with binary descriptor */
659659
for ( int comb = 0; comb < 32; comb++ )
@@ -692,7 +692,7 @@ int BinaryDescriptor::OctaveKeyLines( cv::Mat& image, ScaleLines &keyLines )
692692
/* sigma values and reduction factor used in Gaussian pyramids */
693693
float preSigma2 = 0; //orignal image is not blurred, has zero sigma;
694694
float curSigma2 = 1.0; //[sqrt(2)]^0=1;
695-
double factor = sqrt( 2 ); //the down sample factor between connective two octave images
695+
double factor = sqrt( 2.0 ); //the down sample factor between connective two octave images
696696

697697
/* loop over number of octaves */
698698
for ( int octaveCount = 0; octaveCount < params.numOfOctave_; octaveCount++ )
@@ -1241,7 +1241,7 @@ int BinaryDescriptor::computeLBD( ScaleLines &keyLines, bool useDetectionData )
12411241

12421242
/* construct line descriptor */
12431243
pSingleLine->descriptor.resize( descriptor_size );
1244-
desVec = pSingleLine->descriptor.data();
1244+
desVec = &pSingleLine->descriptor.front();
12451245

12461246
short desID;
12471247

@@ -1280,7 +1280,7 @@ int BinaryDescriptor::computeLBD( ScaleLines &keyLines, bool useDetectionData )
12801280
float tempM, tempS;
12811281
tempM = 0;
12821282
tempS = 0;
1283-
desVec = pSingleLine->descriptor.data();
1283+
desVec = &pSingleLine->descriptor.front();
12841284

12851285
int base = 0;
12861286
for ( short i = 0; i < (short) ( NUM_OF_BANDS * 8 ); ++base, i = (short) ( base * 8 ) )
@@ -1297,7 +1297,7 @@ int BinaryDescriptor::computeLBD( ScaleLines &keyLines, bool useDetectionData )
12971297

12981298
tempM = 1 / sqrt( tempM );
12991299
tempS = 1 / sqrt( tempS );
1300-
desVec = pSingleLine->descriptor.data();
1300+
desVec = &pSingleLine->descriptor.front();
13011301
base = 0;
13021302
for ( short i = 0; i < (short) ( NUM_OF_BANDS * 8 ); ++base, i = (short) ( base * 8 ) )
13031303
{
@@ -1315,7 +1315,7 @@ int BinaryDescriptor::computeLBD( ScaleLines &keyLines, bool useDetectionData )
13151315
* a threshold is used to limit the value of element in the unit feature
13161316
* vector no larger than this threshold. In Z.Wang's work, a value of 0.4 is found
13171317
* empirically to be a proper threshold.*/
1318-
desVec = pSingleLine->descriptor.data();
1318+
desVec = &pSingleLine->descriptor.front();
13191319
for ( short i = 0; i < descriptor_size; i++ )
13201320
{
13211321
if( desVec[i] > 0.4 )
@@ -1344,7 +1344,7 @@ int BinaryDescriptor::computeLBD( ScaleLines &keyLines, bool useDetectionData )
13441344
for ( int g = 0; g < 32; g++ )
13451345
{
13461346
/* get LBD data */
1347-
float* des_Vec = keyLines[lineIDInScaleVec][0].descriptor.data();
1347+
float* des_Vec = &keyLines[lineIDInScaleVec][0].descriptor.front();
13481348
*pointerToRow = des_Vec[g];
13491349
pointerToRow++;
13501350

@@ -2204,9 +2204,9 @@ int BinaryDescriptor::EDLineDetector::EdgeDrawing( cv::Mat &image, EdgeChains &e
22042204
edgeChains.xCors.resize( offsetPFirst + offsetPSecond );
22052205
edgeChains.yCors.resize( offsetPFirst + offsetPSecond );
22062206
edgeChains.sId.resize( offsetPS + 1 );
2207-
unsigned int *pxCors = edgeChains.xCors.data();
2208-
unsigned int *pyCors = edgeChains.yCors.data();
2209-
unsigned int *psId = edgeChains.sId.data();
2207+
unsigned int *pxCors = &edgeChains.xCors.front();
2208+
unsigned int *pyCors = &edgeChains.yCors.front();
2209+
unsigned int *psId = &edgeChains.sId.front();
22102210
offsetPFirst = 0;
22112211
offsetPSecond = 0;
22122212
unsigned int indexInCors = 0;
@@ -2252,12 +2252,12 @@ int BinaryDescriptor::EDLineDetector::EDline( cv::Mat &image, LineChains &lines
22522252
lines.xCors.resize( linePixelID );
22532253
lines.yCors.resize( linePixelID );
22542254
lines.sId.resize( 5 * edges.numOfEdges );
2255-
unsigned int *pEdgeXCors = edges.xCors.data();
2256-
unsigned int *pEdgeYCors = edges.yCors.data();
2257-
unsigned int *pEdgeSID = edges.sId.data();
2258-
unsigned int *pLineXCors = lines.xCors.data();
2259-
unsigned int *pLineYCors = lines.yCors.data();
2260-
unsigned int *pLineSID = lines.sId.data();
2255+
unsigned int *pEdgeXCors = &edges.xCors.front();
2256+
unsigned int *pEdgeYCors = &edges.yCors.front();
2257+
unsigned int *pEdgeSID = &edges.sId.front();
2258+
unsigned int *pLineXCors = &lines.xCors.front();
2259+
unsigned int *pLineYCors = &lines.yCors.front();
2260+
unsigned int *pLineSID = &lines.sId.front();
22612261
logNT_ = 2.0 * ( log10( (double) imageWidth ) + log10( (double) imageHeight ) );
22622262
double lineFitErr = 0; //the line fit error;
22632263
std::vector<double> lineEquation( 2, 0 );
@@ -2732,9 +2732,9 @@ int BinaryDescriptor::EDLineDetector::EDline( cv::Mat &image )
27322732
lineSalience_.resize( lines_.numOfLines );
27332733
unsigned char *pgImg = gImgWO_.ptr();
27342734
unsigned int indexInLineArray;
2735-
unsigned int *pXCor = lines_.xCors.data();
2736-
unsigned int *pYCor = lines_.yCors.data();
2737-
unsigned int *pSID = lines_.sId.data();
2735+
unsigned int *pXCor = &lines_.xCors.front();
2736+
unsigned int *pYCor = &lines_.yCors.front();
2737+
unsigned int *pSID = &lines_.sId.front();
27382738
for ( unsigned int i = 0; i < lineSalience_.size(); i++ )
27392739
{
27402740
int salience = 0;

modules/saliency/src/motionSaliencyBinWangApr2014.cpp

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
//
4040
//M*/
4141

42+
#include <limits>
4243
#include "precomp.hpp"
4344
//TODO delete highgui include
4445
//#include <opencv2/highgui.hpp>
@@ -81,15 +82,15 @@ bool MotionSaliencyBinWangApr2014::init()
8182
// Since data is even, the median is estimated using two values ​​that occupy
8283
// the position (n / 2) and ((n / 2) +1) (choose their arithmetic mean).
8384

84-
potentialBackground = Mat( imgSize.height, imgSize.width, CV_32FC2, Scalar( NAN, 0 ) );
85+
potentialBackground = Mat( imgSize.height, imgSize.width, CV_32FC2, Scalar( std::numeric_limits<float>::quiet_NaN(), 0 ) );
8586

8687
backgroundModel.resize( K + 1 );
8788

8889
for ( int i = 0; i < K + 1; i++ )
8990
{
9091
Mat* tmpm = new Mat;
9192
tmpm->create( imgSize.height, imgSize.width, CV_32FC2 );
92-
tmpm->setTo( Scalar( NAN, 0 ) );
93+
tmpm->setTo( Scalar( std::numeric_limits<float>::quiet_NaN(), 0 ) );
9394
Ptr<Mat> tmp = Ptr<Mat>( tmpm );
9495
backgroundModel[i] = tmp;
9596
}
@@ -418,50 +419,50 @@ bool MotionSaliencyBinWangApr2014::templateReplacement( const Mat& finalBFMask,
418419
if( i > 0 && j > 0 && i < ( backgroundModel[z]->rows - 1 ) && j < ( backgroundModel[z]->cols - 1 ) )
419420
{
420421
split( *backgroundModel[z], mv );
421-
backgroundModelROI = mv[0]( Rect( j - (int) floor( roiSize / 2 ), i - (int) floor( roiSize / 2 ), roiSize, roiSize ) );
422+
backgroundModelROI = mv[0]( Rect( j - (int) floor((float) roiSize / 2 ), i - (int) floor((float) roiSize / 2 ), roiSize, roiSize ) );
422423
}
423424
else if( i == 0 && j == 0 ) // upper leftt
424425
{
425426
split( *backgroundModel[z], mv );
426-
backgroundModelROI = mv[0]( Rect( j, i, (int) ceil( roiSize / 2 ), (int) ceil( roiSize / 2 ) ) );
427+
backgroundModelROI = mv[0]( Rect( j, i, (int) ceil((float) roiSize / 2 ), (int) ceil((float) roiSize / 2 ) ) );
427428
}
428429
else if( j == 0 && i > 0 && i < ( backgroundModel[z]->rows - 1 ) ) // middle left
429430
{
430431
split( *backgroundModel[z], mv );
431-
backgroundModelROI = mv[0]( Rect( j, i - (int) floor( roiSize / 2 ), (int) ceil( roiSize / 2 ), roiSize ) );
432+
backgroundModelROI = mv[0]( Rect( j, i - (int) floor((float) roiSize / 2 ), (int) ceil((float) roiSize / 2 ), roiSize ) );
432433
}
433434
else if( i == ( backgroundModel[z]->rows - 1 ) && j == 0 ) //down left
434435
{
435436
split( *backgroundModel[z], mv );
436-
backgroundModelROI = mv[0]( Rect( j, i - (int) floor( roiSize / 2 ), (int) ceil( roiSize / 2 ), (int) ceil( roiSize / 2 ) ) );
437+
backgroundModelROI = mv[0]( Rect( j, i - (int) floor((float) roiSize / 2 ), (int) ceil((float) roiSize / 2 ), (int) ceil((float) roiSize / 2 ) ) );
437438
}
438439
else if( i == 0 && j > 0 && j < ( backgroundModel[z]->cols - 1 ) ) // upper - middle
439440
{
440441
split( *backgroundModel[z], mv );
441-
backgroundModelROI = mv[0]( Rect( ( j - (int) floor( roiSize / 2 ) ), i, roiSize, (int) ceil( roiSize / 2 ) ) );
442+
backgroundModelROI = mv[0]( Rect( ( j - (int) floor((float) roiSize / 2 ) ), i, roiSize, (int) ceil((float) roiSize / 2 ) ) );
442443
}
443444
else if( i == ( backgroundModel[z]->rows - 1 ) && j > 0 && j < ( backgroundModel[z]->cols - 1 ) ) //down middle
444445
{
445446
split( *backgroundModel[z], mv );
446447
backgroundModelROI = mv[0](
447-
Rect( j - (int) floor( roiSize / 2 ), i - (int) floor( roiSize / 2 ), roiSize, (int) ceil( roiSize / 2 ) ) );
448+
Rect( j - (int) floor((float) roiSize / 2 ), i - (int) floor((float) roiSize / 2 ), roiSize, (int) ceil((float) roiSize / 2 ) ) );
448449
}
449450
else if( i == 0 && j == ( backgroundModel[z]->cols - 1 ) ) // upper right
450451
{
451452
split( *backgroundModel[z], mv );
452-
backgroundModelROI = mv[0]( Rect( j - (int) floor( roiSize / 2 ), i, (int) ceil( roiSize / 2 ), (int) ceil( roiSize / 2 ) ) );
453+
backgroundModelROI = mv[0]( Rect( j - (int) floor((float) roiSize / 2 ), i, (int) ceil((float) roiSize / 2 ), (int) ceil((float) roiSize / 2 ) ) );
453454
}
454455
else if( j == ( backgroundModel[z]->cols - 1 ) && i > 0 && i < ( backgroundModel[z]->rows - 1 ) ) // middle - right
455456
{
456457
split( *backgroundModel[z], mv );
457458
backgroundModelROI = mv[0](
458-
Rect( j - (int) floor( roiSize / 2 ), i - (int) floor( roiSize / 2 ), (int) ceil( roiSize / 2 ), roiSize ) );
459+
Rect( j - (int) floor((float) roiSize / 2 ), i - (int) floor((float) roiSize / 2 ), (int) ceil((float) roiSize / 2 ), roiSize ) );
459460
}
460461
else if( i == ( backgroundModel[z]->rows - 1 ) && j == ( backgroundModel[z]->cols - 1 ) ) // down right
461462
{
462463
split( *backgroundModel[z], mv );
463464
backgroundModelROI = mv[0](
464-
Rect( j - (int) floor( roiSize / 2 ), i - (int) floor( roiSize / 2 ), (int) ceil( roiSize / 2 ), (int) ceil( roiSize / 2 ) ) );
465+
Rect( j - (int) floor((float) roiSize / 2 ), i - (int) floor((float) roiSize / 2 ), (int) ceil((float) roiSize / 2 ), (int) ceil((float) roiSize / 2 ) ) );
465466
}
466467

467468
/* Check if the value of current pixel BA in potentialBackground model is already contained in at least one of its neighbors'
@@ -479,7 +480,7 @@ bool MotionSaliencyBinWangApr2014::templateReplacement( const Mat& finalBFMask,
479480
/////////////////// REPLACEMENT of backgroundModel template ///////////////////
480481
//replace TA with current TK
481482
backgroundModel[backgroundModel.size() - 1]->at<Vec2f>( i, j ) = potentialBackground.at<Vec2f>( i, j );
482-
potentialBackground.at<Vec2f>( i, j )[0] = (float)NAN;
483+
potentialBackground.at<Vec2f>( i, j )[0] = std::numeric_limits<float>::quiet_NaN();
483484
potentialBackground.at<Vec2f>( i, j )[1] = 0;
484485

485486
break;
@@ -489,7 +490,7 @@ bool MotionSaliencyBinWangApr2014::templateReplacement( const Mat& finalBFMask,
489490
else
490491
{
491492
backgroundModel[backgroundModel.size() - 1]->at<Vec2f>( i, j ) = potentialBackground.at<Vec2f>( i, j );
492-
potentialBackground.at<Vec2f>( i, j )[0] = (float)NAN;
493+
potentialBackground.at<Vec2f>( i, j )[0] = std::numeric_limits<float>::quiet_NaN();
493494
potentialBackground.at<Vec2f>( i, j )[1] = 0;
494495
}
495496
} // close if of EVALUATION

0 commit comments

Comments
 (0)