1
0
mirror of https://github.com/opencv/opencv_contrib.git synced 2025-10-17 15:26:00 +08:00

Merge pull request #3703 from vrabaud:cpp

Use proper C++ types. #3703

This is necessary to get https://github.com/opencv/opencv/pull/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
This commit is contained in:
Vincent Rabaud
2024-03-26 10:06:57 +01:00
committed by GitHub
parent 9373b72423
commit 5300337197
8 changed files with 27 additions and 27 deletions

View File

@@ -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;
}

View File

@@ -88,7 +88,7 @@ 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
@@ -96,4 +96,4 @@ int AdaptiveThresholdMeanBinarizer::TransMatToBuffer(cv::Mat mSrc, unsigned char
}
}
return 0;
}
}

View File

@@ -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;

View File

@@ -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 )

View File

@@ -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)
@@ -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)
{
@@ -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);
}
@@ -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
{
@@ -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 );

View File

@@ -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>{};
@@ -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__ */

View File

@@ -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<>
@@ -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);
}
@@ -84,7 +84,7 @@ public:
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)
@@ -104,7 +104,7 @@ public:
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)
{
@@ -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

View File

@@ -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
@@ -116,7 +116,7 @@ public:
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(){};
@@ -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 )
:
@@ -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 )
{