Salome HOME
Update copyrights
[tools/configuration.git] / config / patches / occ / opencv.002_gcc6.patch
1 diff -Naur opencv-2.4.6.1_SRC_orig/cmake/OpenCVPCHSupport.cmake opencv-2.4.6.1_SRC_modif/cmake/OpenCVPCHSupport.cmake
2 --- opencv-2.4.6.1_SRC_orig/cmake/OpenCVPCHSupport.cmake        2013-07-10 15:49:00.000000000 +0400
3 +++ opencv-2.4.6.1_SRC_modif/cmake/OpenCVPCHSupport.cmake       2016-10-17 17:34:32.000000000 +0300
4 @@ -19,7 +19,7 @@
5          ARGS ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
6          OUTPUT_VARIABLE gcc_compiler_version)
7      #MESSAGE("GCC Version: ${gcc_compiler_version}")
8 -    IF(gcc_compiler_version VERSION_GREATER "4.2.-1")
9 +    IF(gcc_compiler_version VERSION_GREATER "4.2.-1" AND gcc_compiler_version VERSION_LESS "6.0.0")
10          SET(PCHSupport_FOUND TRUE)
11      ENDIF()
12  
13 diff -Naur opencv-2.4.6.1_SRC_orig/modules/contrib/src/chamfermatching.cpp opencv-2.4.6.1_SRC_modif/modules/contrib/src/chamfermatching.cpp
14 --- opencv-2.4.6.1_SRC_orig/modules/contrib/src/chamfermatching.cpp     2013-07-10 15:49:00.000000000 +0400
15 +++ opencv-2.4.6.1_SRC_modif/modules/contrib/src/chamfermatching.cpp    2016-10-17 18:11:47.000000000 +0300
16 @@ -959,10 +959,8 @@
17      for (int y=0;y<h;++y) {
18          for (int x=0;x<w;++x) {
19              // initialize
20 -            if (&annotate_img!=NULL) {
21 -                annotate_img.at<Vec2i>(y,x)[0]=x;
22 -                annotate_img.at<Vec2i>(y,x)[1]=y;
23 -            }
24 +           annotate_img.at<Vec2i>(y,x)[0]=x;
25 +            annotate_img.at<Vec2i>(y,x)[1]=y;
26  
27              uchar edge_val = edges_img.at<uchar>(y,x);
28              if( (edge_val!=0) ) {
29 @@ -1005,11 +1003,9 @@
30              if (dt==-1 || dt>dist) {
31                  dist_img.at<float>(ny,nx) = dist;
32                  q.push(std::make_pair(nx,ny));
33 -
34 -                if (&annotate_img!=NULL) {
35 -                    annotate_img.at<Vec2i>(ny,nx)[0]=annotate_img.at<Vec2i>(y,x)[0];
36 -                    annotate_img.at<Vec2i>(ny,nx)[1]=annotate_img.at<Vec2i>(y,x)[1];
37 -                }
38 +               
39 +               annotate_img.at<Vec2i>(ny,nx)[0]=annotate_img.at<Vec2i>(y,x)[0];
40 +               annotate_img.at<Vec2i>(ny,nx)[1]=annotate_img.at<Vec2i>(y,x)[1];
41              }
42          }
43      }
44 @@ -1101,26 +1097,24 @@
45      float cost = (sum_distance/truncate_)/addr.size();
46  
47  
48 -    if (&orientation_img!=NULL) {
49 -        float* optr = orientation_img.ptr<float>(y)+x;
50 -        float sum_orientation = 0;
51 -        int cnt_orientation = 0;
52 -
53 -        for (size_t i=0;i<addr.size();++i) {
54 -
55 -            if(addr[i] < (orientation_img.cols*orientation_img.rows) - (offset.y*orientation_img.cols + offset.x)){
56 -                                if (tpl->orientations[i]>=-CV_PI && (*(optr+addr[i]))>=-CV_PI) {
57 -                    sum_orientation += orientation_diff(tpl->orientations[i], (*(optr+addr[i])));
58 -                    cnt_orientation++;
59 -                }
60 -            }
61 -        }
62  
63 -        if (cnt_orientation>0) {
64 -                        cost = (float)(beta*cost+alpha*(sum_orientation/(2*CV_PI))/cnt_orientation);
65 -        }
66 -
67 -    }
68 +    float* optr = orientation_img.ptr<float>(y)+x;
69 +    float sum_orientation = 0;
70 +    int cnt_orientation = 0;
71 +    
72 +    for (size_t i=0;i<addr.size();++i) {
73 +      
74 +      if(addr[i] < (orientation_img.cols*orientation_img.rows) - (offset.y*orientation_img.cols + offset.x)){
75 +       if (tpl->orientations[i]>=-CV_PI && (*(optr+addr[i]))>=-CV_PI) {
76 +         sum_orientation += orientation_diff(tpl->orientations[i], (*(optr+addr[i])));
77 +         cnt_orientation++;
78 +       }
79 +      }
80 +    }
81 +    
82 +    if (cnt_orientation>0) {
83 +      cost = (float)(beta*cost+alpha*(sum_orientation/(2*CV_PI))/cnt_orientation);
84 +    }    
85  
86      if(cost > 0){
87          ChamferMatcher::Match* istance = new ChamferMatcher::Match();
88 diff -Naur opencv-2.4.6.1_SRC_orig/modules/legacy/src/dpstereo.cpp opencv-2.4.6.1_SRC_modif/modules/legacy/src/dpstereo.cpp
89 --- opencv-2.4.6.1_SRC_orig/modules/legacy/src/dpstereo.cpp     2013-07-10 15:49:00.000000000 +0400
90 +++ opencv-2.4.6.1_SRC_modif/modules/legacy/src/dpstereo.cpp    2016-10-18 10:22:03.257968598 +0300
91 @@ -76,8 +76,8 @@
92      uchar min_val, max_val;
93  } _CvRightImData;
94  
95 -#define CV_IMAX3(a,b,c) ((temp3 = (a) >= (b) ? (a) : (b)),(temp3 >= (c) ? temp3 : (c)))
96 -#define CV_IMIN3(a,b,c) ((temp3 = (a) <= (b) ? (a) : (b)),(temp3 <= (c) ? temp3 : (c)))
97 +#define CV_IMAX3(a,b,c) (std::max(std::max((a), (b)), (c)))
98 +#define CV_IMIN3(a,b,c) (std::min(std::min((a), (b)), (c)))
99  
100  static void icvFindStereoCorrespondenceByBirchfieldDP( uchar* src1, uchar* src2,
101                                                  uchar* disparities,
102 @@ -87,7 +87,7 @@
103                                                  float  _param3, float _param4,
104                                                  float  _param5 )
105  {
106 -    int     x, y, i, j, temp3;
107 +    int     x, y, i, j;
108      int     d, s;
109      int     dispH =  maxDisparity + 3;
110      uchar  *dispdata;
111 diff -Naur opencv-2.4.6.1_SRC_orig/modules/ts/include/opencv2/ts/ts_perf.hpp opencv-2.4.6.1_SRC_modif/modules/ts/include/opencv2/ts/ts_perf.hpp
112 --- opencv-2.4.6.1_SRC_orig/modules/ts/include/opencv2/ts/ts_perf.hpp   2013-07-10 15:49:00.000000000 +0400
113 +++ opencv-2.4.6.1_SRC_modif/modules/ts/include/opencv2/ts/ts_perf.hpp  2016-10-17 17:52:29.000000000 +0300
114 @@ -475,9 +475,16 @@
115      INSTANTIATE_TEST_CASE_P(/*none*/, fixture##_##name, params);\
116      void fixture##_##name::PerfTestBody()
117  
118 +   #if defined(_MSC_VER) && (_MSC_VER <= 1400)
119 +    #define CV_PERF_TEST_MAIN_INTERNALS_ARGS(...)      \
120 +       while (++argc >= (--argc,-1)) {__VA_ARGS__; break;} /*this ugly construction is needed for VS 2005*/
121 +    #else
122 +    #define CV_PERF_TEST_MAIN_INTERNALS_ARGS(...) \
123 +       __VA_ARGS__;
124 +    #endif
125  
126  #define CV_PERF_TEST_MAIN_INTERNALS(modulename, impls, ...) \
127 -    while (++argc >= (--argc,-1)) {__VA_ARGS__; break;} /*this ugly construction is needed for VS 2005*/\
128 +    CV_PERF_TEST_MAIN_INTERNALS_ARGS(__VA_ARGS__) \
129      ::perf::Regression::Init(#modulename);\
130      ::perf::TestBase::Init(std::vector<std::string>(impls, impls + sizeof impls / sizeof *impls),\
131                             argc, argv);\