Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use proper C++ types. #3703

Merged
merged 2 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/videostab/src/precomp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@

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

inline float intensity(const cv::Point3_<uchar> &bgr)
inline float intensity(const cv::Point3_<uint8_t> &bgr)
{
return 0.3f*bgr.x + 0.59f*bgr.y + 0.11f*bgr.z;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ int AdaptiveThresholdMeanBinarizer::TransMatToBuffer(cv::Mat mSrc, unsigned char
unsigned char* pdi = ppBuffer + j * nWidth;
for (int z = 0; z < nWidth; ++z) {
int nj = nHeight - j - 1;
int value = *(uchar*)(mSrc.ptr<uchar>(nj) + z);
int value = *(uint8_t*)(mSrc.ptr<uint8_t>(nj) + z);
if (value > 120)
pdi[z] = 0;
else
pdi[z] = 1;
}
}
return 0;
}
}
2 changes: 1 addition & 1 deletion modules/xphoto/src/annf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ static void dominantTransforms(const cv::Mat &img, std::vector <cv::Point2i> &tr
cv::GaussianBlur( annfHist, annfHist,
cv::Size(0, 0), std::sqrt(2.0), 0.0, cv::BORDER_CONSTANT);
cv::dilate( annfHist, _annfHist,
cv::Matx<uchar, 9, 9>::ones() );
cv::Matx<uint8_t, 9, 9>::ones() );

std::vector < std::pair<double, int> > amount;
std::vector <cv::Point2i> shiftM;
Expand Down
2 changes: 1 addition & 1 deletion modules/xphoto/src/gcgraph.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ TWeight GCGraph<TWeight>::maxFlow()
Vtx* v, *u;
int e0 = -1, ei = 0, ej = 0;
TWeight minWeight, weight;
uchar vt;
uint8_t vt;

// grow S & T search trees, find an edge connecting them
while( first != nilNode )
Expand Down
18 changes: 9 additions & 9 deletions modules/xphoto/src/inpainting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ namespace xphoto

for (int i = 0; i < ddmask.rows; ++i)
{
uchar *dmask_data = (uchar *) ddmask.template ptr<uchar>(i);
uint8_t *dmask_data = (uint8_t *) ddmask.template ptr<uint8_t>(i);
int *backref_data = (int *) backref.template ptr< int >(i);

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

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

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

Expand Down Expand Up @@ -221,14 +221,14 @@ namespace xphoto
};

std::vector <cv::Vec <float, cn> > pointVec;
std::vector <uchar> maskVec;
std::vector <uint8_t> maskVec;

for (uint q = 0; q < sizeof(dv)/sizeof(cv::Point2i); ++q)
if (u.x + dv[q].x >= 0 && u.x + dv[q].x < img.cols
&& u.y + dv[q].y >= 0 && u.y + dv[q].y < img.rows)
{
pointVec.push_back(img.template at<cv::Vec <float, cn> >(u + dv[q]));
maskVec.push_back(_mask.template at<uchar>(u + dv[q]));
maskVec.push_back(_mask.template at<uint8_t>(u + dv[q]));
}
else
{
Expand Down Expand Up @@ -325,16 +325,16 @@ namespace xphoto
inpaint <char, 4>( src, mask, dst, algorithmType );
break;
case CV_8UC1:
inpaint <uchar, 1>( src, mask, dst, algorithmType );
inpaint <uint8_t, 1>( src, mask, dst, algorithmType );
break;
case CV_8UC2:
inpaint <uchar, 2>( src, mask, dst, algorithmType );
inpaint <uint8_t, 2>( src, mask, dst, algorithmType );
break;
case CV_8UC3:
inpaint <uchar, 3>( src, mask, dst, algorithmType );
inpaint <uint8_t, 3>( src, mask, dst, algorithmType );
break;
case CV_8UC4:
inpaint <uchar, 4>( src, mask, dst, algorithmType );
inpaint <uint8_t, 4>( src, mask, dst, algorithmType );
break;
case CV_16SC1:
inpaint <short, 1>( src, mask, dst, algorithmType );
Expand Down
4 changes: 2 additions & 2 deletions modules/xphoto/src/norm2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ template <class T> struct same_as<T, T> : ttype {}; // is_same

template <typename _Tp> struct is_norm2_type :
int_const<bool, !same_as<_Tp, char>::value
&& !same_as<_Tp, uchar>::value
&& !same_as<_Tp, uint8_t>::value
&& !same_as<_Tp, ushort>::value
&& !same_as<_Tp, uint>::value>{};

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

#endif /* __NORM2_HPP__ */
#endif /* __NORM2_HPP__ */
14 changes: 7 additions & 7 deletions modules/xphoto/src/oilpainting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public :
};

template<>
uchar Vec3fTo<uchar>::extract()
uint8_t Vec3fTo<uint8_t>::extract()
{
return static_cast<uchar>(a[0]);
return static_cast<uint8_t>(a[0]);
}

template<>
Expand All @@ -30,7 +30,7 @@ cv::Vec3b Vec3fTo<cv::Vec3b>::extract()
}

template<>
cv::Vec3f Vec3fTo<uchar>::make(int x)
cv::Vec3f Vec3fTo<uint8_t>::make(int x)
{
return cv::Vec3f((a*x)/x);
}
Expand Down Expand Up @@ -84,7 +84,7 @@ class ParallelOilPainting : public ParallelLoopBody
if (y + yy >= 0 && y + yy < imgSrc.rows)
{
Type *vPtr = imgSrc.ptr<Type>(y + yy) + x - 0;
uchar *uc = imgLuminance.ptr(y + yy) + x - 0;
uint8_t *uc = imgLuminance.ptr(y + yy) + x - 0;
for (int xx = 0; xx <= halfsize; xx++, vPtr++, uc++)
{
if (x + xx >= 0 && x + xx < imgSrc.cols)
Expand All @@ -104,7 +104,7 @@ class ParallelOilPainting : public ParallelLoopBody
if (y + yy >= 0 && y + yy < imgSrc.rows)
{
Type *vPtr = imgSrc.ptr<Type>(y + yy) + x - halfsize - 1;
uchar *uc = imgLuminance.ptr(y + yy) + x - halfsize - 1;
uint8_t *uc = imgLuminance.ptr(y + yy) + x - halfsize - 1;
int xx = -halfsize - 1;
if (x + xx >= 0 && x + xx < imgSrc.cols)
{
Expand Down Expand Up @@ -154,10 +154,10 @@ void oilPainting(InputArray _src, OutputArray _dst, int size, int dynValue,int c
else
lum = src.clone();
double dratio = 1 / double(dynValue);
lum.forEach<uchar>([=](uchar &pixel, const int * /*position*/) { pixel = saturate_cast<uchar>(cvRound(pixel * dratio)); });
lum.forEach<uint8_t>([=](uint8_t &pixel, const int * /*position*/) { pixel = saturate_cast<uint8_t>(cvRound(pixel * dratio)); });
if (_src.type() == CV_8UC1)
{
ParallelOilPainting<uchar> oilAlgo(src, dst, lum, size, dynValue);
ParallelOilPainting<uint8_t> oilAlgo(src, dst, lum, size, dynValue);
parallel_for_(Range(0, src.rows), oilAlgo);
}
else
Expand Down
8 changes: 4 additions & 4 deletions modules/xphoto/src/photomontage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ template <typename Tp> class Photomontage
{
private:
const std::vector <std::vector <Tp> > &pointSeq; // points for stitching
const std::vector <std::vector <uchar> > &maskSeq; // corresponding masks
const std::vector <std::vector <uint8_t> > &maskSeq; // corresponding masks

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

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

Photomontage(const std::vector <std::vector <Tp> > &pointSeq,
const std::vector <std::vector <uchar> > &maskSeq,
const std::vector <std::vector <uint8_t> > &maskSeq,
const std::vector <std::vector <int> > &linkIdx,
std::vector <labelTp> &labelSeq);
virtual ~Photomontage(){};
Expand Down Expand Up @@ -219,7 +219,7 @@ gradientDescent()

template <typename Tp> Photomontage <Tp>::
Photomontage( const std::vector <std::vector <Tp> > &_pointSeq,
const std::vector <std::vector <uchar> > &_maskSeq,
const std::vector <std::vector <uint8_t> > &_maskSeq,
const std::vector <std::vector <int> > &_linkIdx,
std::vector <labelTp> &_labelSeq )
:
Expand All @@ -235,7 +235,7 @@ Photomontage( const std::vector <std::vector <Tp> > &_pointSeq,

template <typename Tp> static inline
void photomontage( const std::vector <std::vector <Tp> > &pointSeq,
const std::vector <std::vector <uchar> > &maskSeq,
const std::vector <std::vector <uint8_t> > &maskSeq,
const std::vector <std::vector <int> > &linkIdx,
std::vector <gcoptimization::labelTp> &labelSeq )
{
Expand Down
Loading