diff --git a/3rdparty/libjasper/jpc_enc.c b/3rdparty/libjasper/jpc_enc.c index cb844b703..dcd6183f7 100644 --- a/3rdparty/libjasper/jpc_enc.c +++ b/3rdparty/libjasper/jpc_enc.c @@ -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), diff --git a/modules/contrib/src/spinimages.cpp b/modules/contrib/src/spinimages.cpp index 62f21c634..bd0f6086b 100644 --- a/modules/contrib/src/spinimages.cpp +++ b/modules/contrib/src/spinimages.cpp @@ -499,7 +499,7 @@ void cv::Mesh3D::computeNormals(const vector& subset, float normalRadius, i ::computeNormals(octree, vtx, normals, mask, normalRadius, minNeighbors); } -void cv::Mesh3D::writeAsVrml(const String& file, const vector& colors) const +void cv::Mesh3D::writeAsVrml(const String& file, const vector& _colors) const { ofstream ofs(file.c_str()); @@ -515,13 +515,13 @@ void cv::Mesh3D::writeAsVrml(const String& file, const vector& 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 */ { diff --git a/modules/core/src/dxt.cpp b/modules/core/src/dxt.cpp index a2074a117..e08fc98c4 100644 --- a/modules/core/src/dxt.cpp +++ b/modules/core/src/dxt.cpp @@ -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()))) diff --git a/modules/flann/include/opencv2/flann/ground_truth.h b/modules/flann/include/opencv2/flann/ground_truth.h index 7208b5263..69d978ba0 100644 --- a/modules/flann/include/opencv2/flann/ground_truth.h +++ b/modules/flann/include/opencv2/flann/ground_truth.h @@ -46,8 +46,8 @@ void find_nearest(const Matrix& dataset, typenam typedef typename Distance::ResultType DistanceType; int n = nn + skip; - int* match = new int[n]; - DistanceType* dists = new DistanceType[n]; + std::vector match(n); + std::vector dists(n); dists[0] = distance(dataset[0], query, dataset.cols); match[0] = 0; @@ -77,9 +77,6 @@ void find_nearest(const Matrix& dataset, typenam for (int i=0; i& index, const Matrix resultSet(nn+skipMatches); SearchParams searchParams(checks); - int* indices = new int[nn+skipMatches]; - DistanceType* dists = new DistanceType[nn+skipMatches]; - int* neighbors = indices + skipMatches; + std::vector indices(nn+skipMatches); + std::vector dists(nn+skipMatches); + int* neighbors = &indices[skipMatches]; int correct = 0; DistanceType distR = 0; @@ -112,7 +112,7 @@ float search_with_ground_truth(NNIndex& index, const Matrix& index, const Matrix radiuses(branching); int* count = new int[branching]; for (int i=0; i= 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]); diff --git a/modules/imgproc/src/segmentation.cpp b/modules/imgproc/src/segmentation.cpp index 2a0a101e1..7fbb03921 100644 --- a/modules/imgproc/src/segmentation.cpp +++ b/modules/imgproc/src/segmentation.cpp @@ -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 src_pyramid(max_level+1); + std::vector 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, diff --git a/modules/legacy/src/blobtrackanalysishist.cpp b/modules/legacy/src/blobtrackanalysishist.cpp index c4b36613f..bc524222d 100644 --- a/modules/legacy/src/blobtrackanalysishist.cpp +++ b/modules/legacy/src/blobtrackanalysishist.cpp @@ -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); diff --git a/modules/legacy/src/blobtrackanalysistrackdist.cpp b/modules/legacy/src/blobtrackanalysistrackdist.cpp index 6988a2e79..3c8a346a9 100644 --- a/modules/legacy/src/blobtrackanalysistrackdist.cpp +++ b/modules/legacy/src/blobtrackanalysistrackdist.cpp @@ -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); diff --git a/modules/legacy/src/facedetection.cpp b/modules/legacy/src/facedetection.cpp index 349058eaa..3f9555920 100644 --- a/modules/legacy/src/facedetection.cpp +++ b/modules/legacy/src/facedetection.cpp @@ -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) ///////////////////////// diff --git a/modules/legacy/src/lee.cpp b/modules/legacy/src/lee.cpp index 733448562..518ec779e 100644 --- a/modules/legacy/src/lee.cpp +++ b/modules/legacy/src/lee.cpp @@ -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; diff --git a/modules/legacy/src/lsh.cpp b/modules/legacy/src/lsh.cpp index 75e1016e1..76b64c518 100644 --- a/modules/legacy/src/lsh.cpp +++ b/modules/legacy/src/lsh.cpp @@ -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; diff --git a/modules/python/src2/cv2.cv.hpp b/modules/python/src2/cv2.cv.hpp index 0f20fe98f..d971d20e8 100644 --- a/modules/python/src2/cv2.cv.hpp +++ b/modules/python/src2/cv2.cv.hpp @@ -1031,7 +1031,7 @@ static PyObject *cvquadedge_repr(PyObject *self) char str[1000]; sprintf(str, ""); return PyString_FromString(str);