Skip to content

Commit 5300337

Browse files
authored
Merge pull request #3703 from vrabaud:cpp
Use proper C++ types. #3703 This is necessary to get opencv/opencv#25248 working. ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
1 parent 9373b72 commit 5300337

File tree

8 files changed

+27
-27
lines changed

8 files changed

+27
-27
lines changed

modules/videostab/src/precomp.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959

6060
inline float sqr(float x) { return x * x; }
6161

62-
inline float intensity(const cv::Point3_<uchar> &bgr)
62+
inline float intensity(const cv::Point3_<uint8_t> &bgr)
6363
{
6464
return 0.3f*bgr.x + 0.59f*bgr.y + 0.11f*bgr.z;
6565
}

modules/wechat_qrcode/src/zxing/common/binarizer/adaptive_threshold_mean_binarizer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,12 @@ int AdaptiveThresholdMeanBinarizer::TransMatToBuffer(cv::Mat mSrc, unsigned char
8888
unsigned char* pdi = ppBuffer + j * nWidth;
8989
for (int z = 0; z < nWidth; ++z) {
9090
int nj = nHeight - j - 1;
91-
int value = *(uchar*)(mSrc.ptr<uchar>(nj) + z);
91+
int value = *(uint8_t*)(mSrc.ptr<uint8_t>(nj) + z);
9292
if (value > 120)
9393
pdi[z] = 0;
9494
else
9595
pdi[z] = 1;
9696
}
9797
}
9898
return 0;
99-
}
99+
}

modules/xphoto/src/annf.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ static void dominantTransforms(const cv::Mat &img, std::vector <cv::Point2i> &tr
263263
cv::GaussianBlur( annfHist, annfHist,
264264
cv::Size(0, 0), std::sqrt(2.0), 0.0, cv::BORDER_CONSTANT);
265265
cv::dilate( annfHist, _annfHist,
266-
cv::Matx<uchar, 9, 9>::ones() );
266+
cv::Matx<uint8_t, 9, 9>::ones() );
267267

268268
std::vector < std::pair<double, int> > amount;
269269
std::vector <cv::Point2i> shiftM;

modules/xphoto/src/gcgraph.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ TWeight GCGraph<TWeight>::maxFlow()
187187
Vtx* v, *u;
188188
int e0 = -1, ei = 0, ej = 0;
189189
TWeight minWeight, weight;
190-
uchar vt;
190+
uint8_t vt;
191191

192192
// grow S & T search trees, find an edge connecting them
193193
while( first != nilNode )

modules/xphoto/src/inpainting.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ namespace xphoto
9999

100100
for (int i = 0; i < ddmask.rows; ++i)
101101
{
102-
uchar *dmask_data = (uchar *) ddmask.template ptr<uchar>(i);
102+
uint8_t *dmask_data = (uint8_t *) ddmask.template ptr<uint8_t>(i);
103103
int *backref_data = (int *) backref.template ptr< int >(i);
104104

105105
for (int j = 0; j < ddmask.cols; ++j)
@@ -123,7 +123,7 @@ namespace xphoto
123123

124124
for (size_t i = 0; i < pPath.size(); ++i)
125125
{
126-
uchar xmask = dmask.template at<uchar>(pPath[i]);
126+
uint8_t xmask = dmask.template at<uint8_t>(pPath[i]);
127127

128128
for (int j = 0; j < nTransform + 1; ++j)
129129
{
@@ -136,7 +136,7 @@ namespace xphoto
136136
&& u.x < src.cols && u.x >= 0 )
137137
{
138138
if ( xmask == 0 || j == nTransform )
139-
vmask = mask.template at<uchar>(u);
139+
vmask = mask.template at<uint8_t>(u);
140140
vimg = img.template at<cv::Vec<float, cn> >(u);
141141
}
142142

@@ -221,14 +221,14 @@ namespace xphoto
221221
};
222222

223223
std::vector <cv::Vec <float, cn> > pointVec;
224-
std::vector <uchar> maskVec;
224+
std::vector <uint8_t> maskVec;
225225

226226
for (uint q = 0; q < sizeof(dv)/sizeof(cv::Point2i); ++q)
227227
if (u.x + dv[q].x >= 0 && u.x + dv[q].x < img.cols
228228
&& u.y + dv[q].y >= 0 && u.y + dv[q].y < img.rows)
229229
{
230230
pointVec.push_back(img.template at<cv::Vec <float, cn> >(u + dv[q]));
231-
maskVec.push_back(_mask.template at<uchar>(u + dv[q]));
231+
maskVec.push_back(_mask.template at<uint8_t>(u + dv[q]));
232232
}
233233
else
234234
{
@@ -325,16 +325,16 @@ namespace xphoto
325325
inpaint <char, 4>( src, mask, dst, algorithmType );
326326
break;
327327
case CV_8UC1:
328-
inpaint <uchar, 1>( src, mask, dst, algorithmType );
328+
inpaint <uint8_t, 1>( src, mask, dst, algorithmType );
329329
break;
330330
case CV_8UC2:
331-
inpaint <uchar, 2>( src, mask, dst, algorithmType );
331+
inpaint <uint8_t, 2>( src, mask, dst, algorithmType );
332332
break;
333333
case CV_8UC3:
334-
inpaint <uchar, 3>( src, mask, dst, algorithmType );
334+
inpaint <uint8_t, 3>( src, mask, dst, algorithmType );
335335
break;
336336
case CV_8UC4:
337-
inpaint <uchar, 4>( src, mask, dst, algorithmType );
337+
inpaint <uint8_t, 4>( src, mask, dst, algorithmType );
338338
break;
339339
case CV_16SC1:
340340
inpaint <short, 1>( src, mask, dst, algorithmType );

modules/xphoto/src/norm2.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ template <class T> struct same_as<T, T> : ttype {}; // is_same
6060

6161
template <typename _Tp> struct is_norm2_type :
6262
int_const<bool, !same_as<_Tp, char>::value
63-
&& !same_as<_Tp, uchar>::value
63+
&& !same_as<_Tp, uint8_t>::value
6464
&& !same_as<_Tp, ushort>::value
6565
&& !same_as<_Tp, uint>::value>{};
6666

@@ -70,4 +70,4 @@ template <typename _Tp, int cn> static inline typename iftype< is_norm2_type<_Tp
7070
template <typename _Tp> static inline typename iftype< is_norm2_type<_Tp>::value, _Tp >::
7171
type norm2(const _Tp &a, const _Tp &b) { return (a - b)*(a - b); }
7272

73-
#endif /* __NORM2_HPP__ */
73+
#endif /* __NORM2_HPP__ */

modules/xphoto/src/oilpainting.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ public :
1818
};
1919

2020
template<>
21-
uchar Vec3fTo<uchar>::extract()
21+
uint8_t Vec3fTo<uint8_t>::extract()
2222
{
23-
return static_cast<uchar>(a[0]);
23+
return static_cast<uint8_t>(a[0]);
2424
}
2525

2626
template<>
@@ -30,7 +30,7 @@ cv::Vec3b Vec3fTo<cv::Vec3b>::extract()
3030
}
3131

3232
template<>
33-
cv::Vec3f Vec3fTo<uchar>::make(int x)
33+
cv::Vec3f Vec3fTo<uint8_t>::make(int x)
3434
{
3535
return cv::Vec3f((a*x)/x);
3636
}
@@ -84,7 +84,7 @@ class ParallelOilPainting : public ParallelLoopBody
8484
if (y + yy >= 0 && y + yy < imgSrc.rows)
8585
{
8686
Type *vPtr = imgSrc.ptr<Type>(y + yy) + x - 0;
87-
uchar *uc = imgLuminance.ptr(y + yy) + x - 0;
87+
uint8_t *uc = imgLuminance.ptr(y + yy) + x - 0;
8888
for (int xx = 0; xx <= halfsize; xx++, vPtr++, uc++)
8989
{
9090
if (x + xx >= 0 && x + xx < imgSrc.cols)
@@ -104,7 +104,7 @@ class ParallelOilPainting : public ParallelLoopBody
104104
if (y + yy >= 0 && y + yy < imgSrc.rows)
105105
{
106106
Type *vPtr = imgSrc.ptr<Type>(y + yy) + x - halfsize - 1;
107-
uchar *uc = imgLuminance.ptr(y + yy) + x - halfsize - 1;
107+
uint8_t *uc = imgLuminance.ptr(y + yy) + x - halfsize - 1;
108108
int xx = -halfsize - 1;
109109
if (x + xx >= 0 && x + xx < imgSrc.cols)
110110
{
@@ -154,10 +154,10 @@ void oilPainting(InputArray _src, OutputArray _dst, int size, int dynValue,int c
154154
else
155155
lum = src.clone();
156156
double dratio = 1 / double(dynValue);
157-
lum.forEach<uchar>([=](uchar &pixel, const int * /*position*/) { pixel = saturate_cast<uchar>(cvRound(pixel * dratio)); });
157+
lum.forEach<uint8_t>([=](uint8_t &pixel, const int * /*position*/) { pixel = saturate_cast<uint8_t>(cvRound(pixel * dratio)); });
158158
if (_src.type() == CV_8UC1)
159159
{
160-
ParallelOilPainting<uchar> oilAlgo(src, dst, lum, size, dynValue);
160+
ParallelOilPainting<uint8_t> oilAlgo(src, dst, lum, size, dynValue);
161161
parallel_for_(Range(0, src.rows), oilAlgo);
162162
}
163163
else

modules/xphoto/src/photomontage.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ template <typename Tp> class Photomontage
7979
{
8080
private:
8181
const std::vector <std::vector <Tp> > &pointSeq; // points for stitching
82-
const std::vector <std::vector <uchar> > &maskSeq; // corresponding masks
82+
const std::vector <std::vector <uint8_t> > &maskSeq; // corresponding masks
8383

8484
const std::vector <std::vector <int> > &linkIdx; // vector of neighbors for pointSeq
8585

@@ -116,7 +116,7 @@ template <typename Tp> class Photomontage
116116
void gradientDescent(); // gradient descent in alpha-expansion topology
117117

118118
Photomontage(const std::vector <std::vector <Tp> > &pointSeq,
119-
const std::vector <std::vector <uchar> > &maskSeq,
119+
const std::vector <std::vector <uint8_t> > &maskSeq,
120120
const std::vector <std::vector <int> > &linkIdx,
121121
std::vector <labelTp> &labelSeq);
122122
virtual ~Photomontage(){};
@@ -219,7 +219,7 @@ gradientDescent()
219219

220220
template <typename Tp> Photomontage <Tp>::
221221
Photomontage( const std::vector <std::vector <Tp> > &_pointSeq,
222-
const std::vector <std::vector <uchar> > &_maskSeq,
222+
const std::vector <std::vector <uint8_t> > &_maskSeq,
223223
const std::vector <std::vector <int> > &_linkIdx,
224224
std::vector <labelTp> &_labelSeq )
225225
:
@@ -235,7 +235,7 @@ Photomontage( const std::vector <std::vector <Tp> > &_pointSeq,
235235

236236
template <typename Tp> static inline
237237
void photomontage( const std::vector <std::vector <Tp> > &pointSeq,
238-
const std::vector <std::vector <uchar> > &maskSeq,
238+
const std::vector <std::vector <uint8_t> > &maskSeq,
239239
const std::vector <std::vector <int> > &linkIdx,
240240
std::vector <gcoptimization::labelTp> &labelSeq )
241241
{

0 commit comments

Comments
 (0)