Skip to content

Commit 623de33

Browse files
committed
dnn: fix build warnings
1 parent ee54baf commit 623de33

File tree

6 files changed

+26
-26
lines changed

6 files changed

+26
-26
lines changed

modules/dnn/include/opencv2/dnn/shape_utils.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ inline std::ostream &operator<< (std::ostream &s, cv::Range &r)
6060
struct _Range : public cv::Range
6161
{
6262
_Range(const Range &r) : cv::Range(r) {}
63-
_Range(int start, int size = 1) : cv::Range(start, start + size) {}
63+
_Range(int start_, int size_ = 1) : cv::Range(start_, start_ + size_) {}
6464
};
6565

6666
static inline Mat slice(const Mat &m, const _Range &r0)
@@ -148,13 +148,13 @@ static inline MatShape shape(int a0, int a1=-1, int a2=-1, int a3=-1)
148148
static inline int total(const MatShape& shape, int start = -1, int end = -1)
149149
{
150150
if (start == -1) start = 0;
151-
if (end == -1) end = shape.size();
151+
if (end == -1) end = (int)shape.size();
152152

153153
if (shape.empty())
154154
return 0;
155155

156156
int elems = 1;
157-
CV_Assert(start < shape.size() && end <= shape.size() &&
157+
CV_Assert(start < (int)shape.size() && end <= (int)shape.size() &&
158158
start <= end);
159159
for(int i = start; i < end; i++)
160160
{
@@ -187,7 +187,7 @@ inline int clamp(int ax, int dims)
187187

188188
inline int clamp(int ax, const MatShape& shape)
189189
{
190-
return clamp(ax, shape.size());
190+
return clamp(ax, (int)shape.size());
191191
}
192192

193193
}

samples/dnn/caffe_googlenet.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ using namespace cv::dnn;
5050
using namespace std;
5151

5252
/* Find best class for the blob (i. e. class with maximal probability) */
53-
void getMaxClass(const Mat &probBlob, int *classId, double *classProb)
53+
static void getMaxClass(const Mat &probBlob, int *classId, double *classProb)
5454
{
5555
Mat probMat = probBlob.reshape(1, 1); //reshape the blob to 1x1000 matrix
5656
Point classNumber;
@@ -59,7 +59,7 @@ void getMaxClass(const Mat &probBlob, int *classId, double *classProb)
5959
*classId = classNumber.x;
6060
}
6161

62-
std::vector<String> readClassNames(const char *filename = "synset_words.txt")
62+
static std::vector<String> readClassNames(const char *filename = "synset_words.txt")
6363
{
6464
std::vector<String> classNames;
6565

samples/dnn/fcn_semsegm.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ static vector<cv::Vec3b> readColors(const string &filename = "pascal-classes.txt
3333
string name; ss >> name;
3434
int temp;
3535
cv::Vec3b color;
36-
ss >> temp; color[0] = temp;
37-
ss >> temp; color[1] = temp;
38-
ss >> temp; color[2] = temp;
36+
ss >> temp; color[0] = (uchar)temp;
37+
ss >> temp; color[1] = (uchar)temp;
38+
ss >> temp; color[2] = (uchar)temp;
3939
colors.push_back(color);
4040
}
4141
}
@@ -64,7 +64,7 @@ static void colorizeSegmentation(const Mat &score, const vector<cv::Vec3b> &colo
6464
if (ptrScore[col] > ptrMaxVal[col])
6565
{
6666
ptrMaxVal[col] = ptrScore[col];
67-
ptrMaxCl[col] = ch;
67+
ptrMaxCl[col] = (uchar)ch;
6868
}
6969
}
7070
}

samples/dnn/squeezenet_halide.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ using namespace cv::dnn;
1919
#include <cstdlib>
2020

2121
/* Find best class for the blob (i. e. class with maximal probability) */
22-
void getMaxClass(const Mat &probBlob, int *classId, double *classProb)
22+
static void getMaxClass(const Mat &probBlob, int *classId, double *classProb)
2323
{
2424
Mat probMat = probBlob.reshape(1, 1); //reshape the blob to 1x1000 matrix
2525
Point classNumber;
@@ -28,7 +28,7 @@ void getMaxClass(const Mat &probBlob, int *classId, double *classProb)
2828
*classId = classNumber.x;
2929
}
3030

31-
std::vector<std::string> readClassNames(const char *filename = "synset_words.txt")
31+
static std::vector<std::string> readClassNames(const char *filename = "synset_words.txt")
3232
{
3333
std::vector<std::string> classNames;
3434

samples/dnn/ssd_object_detection.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@ using namespace std;
1313
const size_t width = 300;
1414
const size_t height = 300;
1515

16-
Mat getMean(const size_t& imageHeight, const size_t& imageWidth)
16+
static Mat getMean(const size_t& imageHeight, const size_t& imageWidth)
1717
{
1818
Mat mean;
1919

2020
const int meanValues[3] = {104, 117, 123};
2121
vector<Mat> meanChannels;
22-
for(size_t i = 0; i < 3; i++)
22+
for(int i = 0; i < 3; i++)
2323
{
24-
Mat channel(imageHeight, imageWidth, CV_32F, Scalar(meanValues[i]));
24+
Mat channel((int)imageHeight, (int)imageWidth, CV_32F, Scalar(meanValues[i]));
2525
meanChannels.push_back(channel);
2626
}
2727
cv::merge(meanChannels, mean);
2828
return mean;
2929
}
3030

31-
Mat preprocess(const Mat& frame)
31+
static Mat preprocess(const Mat& frame)
3232
{
3333
Mat preprocessed;
3434
frame.convertTo(preprocessed, CV_32F);
@@ -124,7 +124,7 @@ int main(int argc, char** argv)
124124

125125
if(confidence > confidenceThreshold)
126126
{
127-
size_t objectClass = detectionMat.at<float>(i, 1);
127+
size_t objectClass = (size_t)(detectionMat.at<float>(i, 1));
128128

129129
float xLeftBottom = detectionMat.at<float>(i, 3) * frame.cols;
130130
float yLeftBottom = detectionMat.at<float>(i, 4) * frame.rows;
@@ -139,9 +139,9 @@ int main(int argc, char** argv)
139139
<< " " << xRightTop
140140
<< " " << yRightTop << std::endl;
141141

142-
Rect object(xLeftBottom, yLeftBottom,
143-
xRightTop - xLeftBottom,
144-
yRightTop - yLeftBottom);
142+
Rect object((int)xLeftBottom, (int)yLeftBottom,
143+
(int)(xRightTop - xLeftBottom),
144+
(int)(yRightTop - yLeftBottom));
145145

146146
rectangle(frame, object, Scalar(0, 255, 0));
147147
}

samples/dnn/torch_enet.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ static void colorizeSegmentation(const Mat &score, Mat &segm, Mat &legend, vecto
141141
if (ptrScore[col] > ptrMaxVal[col])
142142
{
143143
ptrMaxVal[col] = ptrScore[col];
144-
ptrMaxCl[col] = ch;
144+
ptrMaxCl[col] = (uchar)ch;
145145
}
146146
}
147147
}
@@ -161,8 +161,8 @@ static void colorizeSegmentation(const Mat &score, Mat &segm, Mat &legend, vecto
161161
if (classNames.size() == colors.size())
162162
{
163163
int blockHeight = 30;
164-
legend.create(blockHeight*classNames.size(), 200, CV_8UC3);
165-
for(int i = 0; i < classNames.size(); i++)
164+
legend.create(blockHeight*(int)classNames.size(), 200, CV_8UC3);
165+
for(int i = 0; i < (int)classNames.size(); i++)
166166
{
167167
cv::Mat block = legend.rowRange(i*blockHeight, (i+1)*blockHeight);
168168
block = colors[i];
@@ -194,9 +194,9 @@ static vector<Vec3b> readColors(const String &filename, vector<String>& classNam
194194
string name; ss >> name;
195195
int temp;
196196
cv::Vec3b color;
197-
ss >> temp; color[0] = temp;
198-
ss >> temp; color[1] = temp;
199-
ss >> temp; color[2] = temp;
197+
ss >> temp; color[0] = (uchar)temp;
198+
ss >> temp; color[1] = (uchar)temp;
199+
ss >> temp; color[2] = (uchar)temp;
200200
classNames.push_back(name);
201201
colors.push_back(color);
202202
}

0 commit comments

Comments
 (0)