Fixed ~20 potential errors identified by the MS complier.

This commit is contained in:
Andrey Kamaev 2012-03-31 11:09:16 +00:00
parent 1e5a600d13
commit 72f2523d0f
15 changed files with 150 additions and 133 deletions

View File

@ -2102,8 +2102,8 @@ static jpc_enc_tcmpt_t *tcmpt_create(jpc_enc_tcmpt_t *tcmpt, jpc_enc_cp_t *cp,
tcmpt->numstepsizes = tcmpt->numbands;
assert(tcmpt->numstepsizes <= JPC_MAXBANDS);
memset(tcmpt->stepsizes, 0, sizeof(tcmpt->numstepsizes *
sizeof(uint_fast16_t)));
memset(tcmpt->stepsizes, 0, tcmpt->numstepsizes *
sizeof(uint_fast16_t));
/* Retrieve information about the various bands. */
jpc_tsfb_getbands(tcmpt->tsfb, jas_seq2d_xstart(tcmpt->data),

View File

@ -499,7 +499,7 @@ void cv::Mesh3D::computeNormals(const vector<int>& subset, float normalRadius, i
::computeNormals(octree, vtx, normals, mask, normalRadius, minNeighbors);
}
void cv::Mesh3D::writeAsVrml(const String& file, const vector<Scalar>& colors) const
void cv::Mesh3D::writeAsVrml(const String& file, const vector<Scalar>& _colors) const
{
ofstream ofs(file.c_str());
@ -515,13 +515,13 @@ void cv::Mesh3D::writeAsVrml(const String& file, const vector<Scalar>& colors) c
ofs << "]" << endl; //point[
ofs << "}" << endl; //Coordinate{
if (vtx.size() == colors.size())
if (vtx.size() == _colors.size())
{
ofs << "color Color" << endl << "{" << endl;
ofs << "color[" << endl;
for(size_t i = 0; i < colors.size(); ++i)
ofs << (float)colors[i][2] << " " << (float)colors[i][1] << " " << (float)colors[i][0] << endl;
for(size_t i = 0; i < _colors.size(); ++i)
ofs << (float)_colors[i][2] << " " << (float)_colors[i][1] << " " << (float)_colors[i][0] << endl;
ofs << "]" << endl; //color[
ofs << "}" << endl; //color Color{
@ -1171,7 +1171,7 @@ private:
break;
std::transform(left.begin(), left.end(), buf_beg, WgcHelper(group, groupingMat));
size_t minInd = min_element(buf_beg, buf_beg + left_size) - buf_beg;
int minInd = min_element(buf_beg, buf_beg + left_size) - buf_beg;
if (buf[minInd] < model.T_GroupingCorespondances) /* can add corespondance to group */
{

View File

@ -1628,7 +1628,7 @@ void cv::dft( InputArray _src0, OutputArray _dst, int flags, int nonzero_rows )
uchar* tmp_buf = 0;
int dptr_offset = 0;
int dst_full_len = len*elem_size;
int _flags = inv + (src.channels() != dst.channels() ?
int _flags = (int)inv + (src.channels() != dst.channels() ?
DFT_COMPLEX_INPUT_OR_OUTPUT : 0);
if( use_buf )
{
@ -2246,7 +2246,7 @@ void cv::dct( InputArray _src0, OutputArray _dst, int flags )
_dst.create( src.rows, src.cols, type );
Mat dst = _dst.getMat();
DCTFunc dct_func = dct_tbl[inv + (depth == CV_64F)*2];
DCTFunc dct_func = dct_tbl[(int)inv + (depth == CV_64F)*2];
if( (flags & DFT_ROWS) || src.rows == 1 ||
(src.cols == 1 && (src.isContinuous() && dst.isContinuous())))

View File

@ -46,8 +46,8 @@ void find_nearest(const Matrix<typename Distance::ElementType>& dataset, typenam
typedef typename Distance::ResultType DistanceType;
int n = nn + skip;
int* match = new int[n];
DistanceType* dists = new DistanceType[n];
std::vector<int> match(n);
std::vector<DistanceType> dists(n);
dists[0] = distance(dataset[0], query, dataset.cols);
match[0] = 0;
@ -77,9 +77,6 @@ void find_nearest(const Matrix<typename Distance::ElementType>& dataset, typenam
for (int i=0; i<nn; ++i) {
matches[i] = match[i+skip];
}
delete[] match;
delete[] dists;
}

View File

@ -98,9 +98,9 @@ float search_with_ground_truth(NNIndex<Distance>& index, const Matrix<typename D
KNNResultSet<DistanceType> resultSet(nn+skipMatches);
SearchParams searchParams(checks);
int* indices = new int[nn+skipMatches];
DistanceType* dists = new DistanceType[nn+skipMatches];
int* neighbors = indices + skipMatches;
std::vector<int> indices(nn+skipMatches);
std::vector<DistanceType> dists(nn+skipMatches);
int* neighbors = &indices[skipMatches];
int correct = 0;
DistanceType distR = 0;
@ -112,7 +112,7 @@ float search_with_ground_truth(NNIndex<Distance>& index, const Matrix<typename D
correct = 0;
distR = 0;
for (size_t i = 0; i < testData.rows; i++) {
resultSet.init(indices, dists);
resultSet.init(&indices[0], &dists[0]);
index.findNeighbors(resultSet, testData[i], searchParams);
correct += countCorrectMatches(neighbors,matches[i], nn);
@ -122,9 +122,6 @@ float search_with_ground_truth(NNIndex<Distance>& index, const Matrix<typename D
}
time = float(t.value/repeats);
delete[] indices;
delete[] dists;
float precicion = (float)correct/(nn*testData.rows);
dist = distR/(testData.rows*nn);

View File

@ -674,7 +674,7 @@ private:
}
delete[] centers_idx;
DistanceType* radiuses = new DistanceType[branching];
std::vector<DistanceType> radiuses(branching);
int* count = new int[branching];
for (int i=0; i<branching; ++i) {
radiuses[i] = 0;
@ -817,7 +817,6 @@ private:
delete[] dcenters.data;
delete[] centers;
delete[] radiuses;
delete[] count;
delete[] belongs_to;
}

View File

@ -195,15 +195,15 @@ displayOverlay
------------------
Displays a text on a window image as an overlay for a specified duration.
.. ocv:function:: void displayOverlay(const string& name, const string& text, int delayms CV_DEFAULT(0))
.. ocv:function:: void displayOverlay(const string& name, const string& text, int delayms = 0)
.. ocv:cfunction:: void cvDisplayOverlay(const char* name, const char* text, int delayms CV_DEFAULT(0))
.. ocv:cfunction:: void cvDisplayOverlay(const char* name, const char* text, int delayms = 0)
:param name: Name of the window.
:param text: Overlay text to write on a window image.
:param delayms: The period (in milliseconds), during which the overlay text is displayed. If this function is called before the previous overlay text timed out, the timer is restarted and the text is updated. If this value is zero, the text never disappears. Optional - default 0.
:param delayms: The period (in milliseconds), during which the overlay text is displayed. If this function is called before the previous overlay text timed out, the timer is restarted and the text is updated. If this value is zero, the text never disappears.
The function ``displayOverlay`` displays useful information/tips on top of the window for a certain amount of time *delayms*. The function does not modify the image, displayed in the window, that is, after the specified delay the original content of the window is restored.
@ -212,15 +212,15 @@ displayStatusBar
--------------------
Displays a text on the window statusbar during the specified period of time.
.. ocv:function:: void displayStatusBar(const string& name, const string& text, int delayms CV_DEFAULT(0))
.. ocv:function:: void displayStatusBar(const string& name, const string& text, int delayms = 0)
.. ocv:cfunction:: void cvDisplayStatusBar(const char* name, const char* text, int delayms CV_DEFAULT(0))
.. ocv:cfunction:: void cvDisplayStatusBar(const char* name, const char* text, int delayms = 0)
:param name: Name of the window.
:param text: Text to write on the window statusbar.
:param delayms: Duration (in milliseconds) to display the text. If this function is called before the previous text timed out, the timer is restarted and the text is updated. If this value is zero, the text never disappears. Optional - default 0.
:param delayms: Duration (in milliseconds) to display the text. If this function is called before the previous text timed out, the timer is restarted and the text is updated. If this value is zero, the text never disappears.
The function ``displayOverlay`` displays useful information/tips on top of the window for a certain amount of time
*delayms*

View File

@ -2029,7 +2029,7 @@ void cv::fitLine( InputArray _points, OutputArray _line, int distType,
bool is2d = points.checkVector(2) >= 0;
CV_Assert( (is2d || is3d) && (points.depth() == CV_32F || points.depth() == CV_32S) );
CvMat _cpoints = points.reshape(2 + is3d);
CvMat _cpoints = points.reshape(2 + (int)is3d);
float line[6];
cvFitLine(&_cpoints, distType, param, reps, aeps, &line[0]);

View File

@ -322,8 +322,12 @@ cvPyrMeanShiftFiltering( const CvArr* srcarr, CvArr* dstarr,
{
const int cn = 3;
const int MAX_LEVELS = 8;
cv::Mat* src_pyramid = new cv::Mat[MAX_LEVELS+1];
cv::Mat* dst_pyramid = new cv::Mat[MAX_LEVELS+1];
if( (unsigned)max_level > (unsigned)MAX_LEVELS )
CV_Error( CV_StsOutOfRange, "The number of pyramid levels is too large or negative" );
std::vector<cv::Mat> src_pyramid(max_level+1);
std::vector<cv::Mat> dst_pyramid(max_level+1);
cv::Mat mask0;
int i, j, level;
//uchar* submask = 0;
@ -346,9 +350,6 @@ cvPyrMeanShiftFiltering( const CvArr* srcarr, CvArr* dstarr,
if( src0.size() != dst0.size() )
CV_Error( CV_StsUnmatchedSizes, "The input and output images must have the same size" );
if( (unsigned)max_level > (unsigned)MAX_LEVELS )
CV_Error( CV_StsOutOfRange, "The number of pyramid levels is too large or negative" );
if( !(termcrit.type & CV_TERMCRIT_ITER) )
termcrit.max_iter = 5;
termcrit.max_iter = MAX(termcrit.max_iter,1);
@ -523,8 +524,6 @@ cvPyrMeanShiftFiltering( const CvArr* srcarr, CvArr* dstarr,
}
}
}
delete[] src_pyramid;
delete[] dst_pyramid;
}
void cv::pyrMeanShiftFiltering( InputArray _src, OutputArray _dst,

View File

@ -1048,7 +1048,7 @@ public:
virtual void SetFileName(char* DataBaseName)
{
if(m_HistMat.m_Volume!=m_HistVolumeSaved)SaveHist();
m_DataFileName[0] = 0;
m_DataFileName[0] = m_DataFileName[1000] = 0;
if(DataBaseName)
{
@ -1496,7 +1496,7 @@ public:
virtual void SetFileName(char* DataBaseName)
{
if(m_pTrainData)SaveStatModel();
m_DataFileName[0] = 0;
m_DataFileName[0] = m_DataFileName[1000] = 0;
if(DataBaseName)
{
strncpy(m_DataFileName,DataBaseName,1000);

View File

@ -565,7 +565,7 @@ public:
virtual void SetFileName(char* DataBaseName)
{
m_DataFileName[0] = 0;
m_DataFileName[0] = m_DataFileName[1000] = 0;
if(DataBaseName)
{
strncpy(m_DataFileName,DataBaseName,1000);

View File

@ -302,120 +302,137 @@ void FaceDetection::FindFace(IplImage *img)
void FaceDetection::FindCandidats()
{
bool bFound1 = false;
MouthFaceTemplate * lpFaceTemplate1;
RFace * lpFace1;
MouthFaceTemplate * lpFaceTemplate1 = 0;
RFace * lpFace1 = 0;
bool bInvalidRect1 = false;
CvRect * lpRect1 = NULL;
for (int i = 0; i < m_seqRects->total; i++)
try
{
CvContourRect* pRect = (CvContourRect*)cvGetSeqElem(m_seqRects, i);
CvRect rect = pRect->r;
if (rect.width >= 2*rect.height)
for (int i = 0; i < m_seqRects->total; i++)
{
CvContourRect* pRect = (CvContourRect*)cvGetSeqElem(m_seqRects, i);
CvRect rect = pRect->r;
if (rect.width >= 2*rect.height)
{
lpFaceTemplate1 = new MouthFaceTemplate(3,rect,3*(double)rect.width/(double)4,
3*(double)rect.width/(double)4,
(double)rect.width/(double)2,
(double)rect.width/(double)2);
lpFaceTemplate1 = new MouthFaceTemplate(3,rect,3*(double)rect.width/(double)4,
3*(double)rect.width/(double)4,
(double)rect.width/(double)2,
(double)rect.width/(double)2);
lpFace1 = new RFace(lpFaceTemplate1);
lpFace1 = new RFace(lpFaceTemplate1);
for (int j = 0; j < m_seqRects->total; j++)
{
CvContourRect* pRect = (CvContourRect*)cvGetSeqElem(m_seqRects, j);
for (int j = 0; j < m_seqRects->total; j++)
{
CvContourRect* pRect = (CvContourRect*)cvGetSeqElem(m_seqRects, j);
if ( !bInvalidRect1 )
{
lpRect1 = NULL;
lpRect1 = new CvRect();
*lpRect1 = pRect->r;
}else
{
delete lpRect1;
lpRect1 = new CvRect();
*lpRect1 = pRect->r;
if ( !bInvalidRect1 )
{
lpRect1 = NULL;
lpRect1 = new CvRect();
*lpRect1 = pRect->r;
}else
{
delete lpRect1;
lpRect1 = new CvRect();
*lpRect1 = pRect->r;
}
if ( lpFace1->isFeature(lpRect1) )
{
bFound1 = true;
bInvalidRect1 = false;
}else
bInvalidRect1 = true;
}
if ( lpFace1->isFeature(lpRect1) )
{
bFound1 = true;
bInvalidRect1 = false;
if (bFound1)
{
m_pFaceList->AddElem(lpFace1);
bFound1 = false;
lpFace1 = NULL;
}else
bInvalidRect1 = true;
{
delete lpFace1;
lpFace1 = NULL;
}
delete lpFaceTemplate1;
}
}
if (bFound1)
{
m_pFaceList->AddElem(lpFace1);
bFound1 = false;
lpFace1 = NULL;
}else
{
delete lpFace1;
lpFace1 = NULL;
}
delete lpFaceTemplate1;
}
}
catch(...)
{
delete lpFaceTemplate1;
delete lpFace1;
throw;
}
}
void FaceDetection::PostBoostingFindCandidats(IplImage * FaceImage)
{
BoostingFaceTemplate * lpFaceTemplate1;
RFace * lpFace1;
BoostingFaceTemplate * lpFaceTemplate1 = 0;
RFace * lpFace1 = 0;
bool bInvalidRect1 = false;
CvRect * lpRect1 = NULL;
if ( ( !FaceImage->roi ) )
lpFaceTemplate1 = new BoostingFaceTemplate(3,cvRect(0,0,FaceImage->width,FaceImage->height));
else
lpFaceTemplate1 = new BoostingFaceTemplate(3,cvRect(FaceImage->roi->xOffset,FaceImage->roi->yOffset,
FaceImage->roi->width,FaceImage->roi->height));
lpFace1 = new RFace(lpFaceTemplate1);
for (int i = 0; i < m_seqRects->total; i++)
try
{
CvContourRect* pRect = (CvContourRect*)cvGetSeqElem(m_seqRects, i);
if ( ( !FaceImage->roi ) )
lpFaceTemplate1 = new BoostingFaceTemplate(3,cvRect(0,0,FaceImage->width,FaceImage->height));
else
lpFaceTemplate1 = new BoostingFaceTemplate(3,cvRect(FaceImage->roi->xOffset,FaceImage->roi->yOffset,
FaceImage->roi->width,FaceImage->roi->height));
lpFace1 = new RFace(lpFaceTemplate1);
for (int i = 0; i < m_seqRects->total; i++)
{
CvContourRect* pRect = (CvContourRect*)cvGetSeqElem(m_seqRects, i);
if ( !bInvalidRect1 )
{
lpRect1 = NULL;
lpRect1 = new CvRect();
*lpRect1 = pRect->r;
}else
{
delete lpRect1;
lpRect1 = new CvRect();
*lpRect1 = pRect->r;
if ( !bInvalidRect1 )
{
lpRect1 = NULL;
lpRect1 = new CvRect();
*lpRect1 = pRect->r;
}else
{
delete lpRect1;
lpRect1 = new CvRect();
*lpRect1 = pRect->r;
}
if ( lpFace1->isFeature(lpRect1) )
{
//bFound1 = true;
bInvalidRect1 = false;
}else
bInvalidRect1 = true;
}
if ( lpFace1->isFeature(lpRect1) )
{
//bFound1 = true;
bInvalidRect1 = false;
}else
bInvalidRect1 = true;
m_pFaceList->AddElem(lpFace1);
lpFace1 = NULL;
delete lpFaceTemplate1;
}
catch(...)
{
delete lpFace1;
delete lpFaceTemplate1;
throw;
}
m_pFaceList->AddElem(lpFace1);
delete lpFaceTemplate1;
}//void FaceDetection::PostBoostingFindCandidats(IplImage * FaceImage)
/////////////////////////

View File

@ -1750,7 +1750,7 @@ static int _cvConvertSameOrientation(CvVoronoiDiagram2D* VoronoiDiagram,
CvSet *NewSiteSeq = NULL,*CurrNewSiteSeq = NULL, *PrevNewSiteSeq = NULL;;
CvSeqWriter SiteWriter;
CvVoronoiSite2D NewSite = {{0,0},{0,0},{0,0}},NewSite_prev;
CvVoronoiSite2D NewSite = {{0,0},{0,0},{0,0}},NewSite_prev = {{0,0},{0,0},{0,0}};
CvVoronoiSite2D *pNewSite, *pNewSite_prev = &NewSite_prev;
pCvVoronoiSite pSite,pFirstSite;
@ -1940,7 +1940,7 @@ static int _cvConvertChangeOrientation(CvVoronoiDiagram2D* VoronoiDiagram,
CvSet *NewSiteSeq = NULL,*CurrNewSiteSeq = NULL, *PrevNewSiteSeq = NULL;;
CvSeqWriter SiteWriter;
CvVoronoiSite2D NewSite = {{0,0},{0,0},{0,0}},NewSite_prev;
CvVoronoiSite2D NewSite = {{0,0},{0,0},{0,0}},NewSite_prev = {{0,0},{0,0},{0,0}};
CvVoronoiSite2D *pNewSite, *pNewSite_prev = &NewSite_prev;
pCvVoronoiSite pSite,pFirstSite;

View File

@ -336,10 +336,18 @@ CvLSH* cvCreateLSH(CvLSHOperations* ops, int d, int L, int k, int type, double r
if (type != CV_32FC1 && type != CV_64FC1)
CV_Error(CV_StsUnsupportedFormat, "vectors must be either CV_32FC1 or CV_64FC1");
lsh = new CvLSH;
lsh->type = type;
switch (type) {
case CV_32FC1: lsh->u.lsh_32f = new lsh_pstable_l2_32f(ops, d, L, k, r, rng); break;
case CV_64FC1: lsh->u.lsh_64f = new lsh_pstable_l2_64f(ops, d, L, k, r, rng); break;
try
{
lsh->type = type;
switch (type) {
case CV_32FC1: lsh->u.lsh_32f = new lsh_pstable_l2_32f(ops, d, L, k, r, rng); break;
case CV_64FC1: lsh->u.lsh_64f = new lsh_pstable_l2_64f(ops, d, L, k, r, rng); break;
}
}
catch(...)
{
delete lsh;
throw;
}
return lsh;

View File

@ -1031,7 +1031,7 @@ static PyObject *cvquadedge_repr(PyObject *self)
char str[1000];
sprintf(str, "<cvsubdiv2dedge(");
char *d = str + strlen(str);
sprintf(d, "%zx.%d", m & ~3, (int)(m & 3));
sprintf(d, "%lux.%d", (unsigned long)(m & ~3), (int)(m & 3));
d += strlen(d);
sprintf(d, ")>");
return PyString_FromString(str);