Commit 623de337 authored by Alexander Alekhin's avatar Alexander Alekhin

dnn: fix build warnings

parent ee54bafe
...@@ -60,7 +60,7 @@ inline std::ostream &operator<< (std::ostream &s, cv::Range &r) ...@@ -60,7 +60,7 @@ inline std::ostream &operator<< (std::ostream &s, cv::Range &r)
struct _Range : public cv::Range struct _Range : public cv::Range
{ {
_Range(const Range &r) : cv::Range(r) {} _Range(const Range &r) : cv::Range(r) {}
_Range(int start, int size = 1) : cv::Range(start, start + size) {} _Range(int start_, int size_ = 1) : cv::Range(start_, start_ + size_) {}
}; };
static inline Mat slice(const Mat &m, const _Range &r0) 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) ...@@ -148,13 +148,13 @@ static inline MatShape shape(int a0, int a1=-1, int a2=-1, int a3=-1)
static inline int total(const MatShape& shape, int start = -1, int end = -1) static inline int total(const MatShape& shape, int start = -1, int end = -1)
{ {
if (start == -1) start = 0; if (start == -1) start = 0;
if (end == -1) end = shape.size(); if (end == -1) end = (int)shape.size();
if (shape.empty()) if (shape.empty())
return 0; return 0;
int elems = 1; int elems = 1;
CV_Assert(start < shape.size() && end <= shape.size() && CV_Assert(start < (int)shape.size() && end <= (int)shape.size() &&
start <= end); start <= end);
for(int i = start; i < end; i++) for(int i = start; i < end; i++)
{ {
...@@ -187,7 +187,7 @@ inline int clamp(int ax, int dims) ...@@ -187,7 +187,7 @@ inline int clamp(int ax, int dims)
inline int clamp(int ax, const MatShape& shape) inline int clamp(int ax, const MatShape& shape)
{ {
return clamp(ax, shape.size()); return clamp(ax, (int)shape.size());
} }
} }
......
...@@ -50,7 +50,7 @@ using namespace cv::dnn; ...@@ -50,7 +50,7 @@ using namespace cv::dnn;
using namespace std; using namespace std;
/* Find best class for the blob (i. e. class with maximal probability) */ /* Find best class for the blob (i. e. class with maximal probability) */
void getMaxClass(const Mat &probBlob, int *classId, double *classProb) static void getMaxClass(const Mat &probBlob, int *classId, double *classProb)
{ {
Mat probMat = probBlob.reshape(1, 1); //reshape the blob to 1x1000 matrix Mat probMat = probBlob.reshape(1, 1); //reshape the blob to 1x1000 matrix
Point classNumber; Point classNumber;
...@@ -59,7 +59,7 @@ void getMaxClass(const Mat &probBlob, int *classId, double *classProb) ...@@ -59,7 +59,7 @@ void getMaxClass(const Mat &probBlob, int *classId, double *classProb)
*classId = classNumber.x; *classId = classNumber.x;
} }
std::vector<String> readClassNames(const char *filename = "synset_words.txt") static std::vector<String> readClassNames(const char *filename = "synset_words.txt")
{ {
std::vector<String> classNames; std::vector<String> classNames;
......
...@@ -33,9 +33,9 @@ static vector<cv::Vec3b> readColors(const string &filename = "pascal-classes.txt ...@@ -33,9 +33,9 @@ static vector<cv::Vec3b> readColors(const string &filename = "pascal-classes.txt
string name; ss >> name; string name; ss >> name;
int temp; int temp;
cv::Vec3b color; cv::Vec3b color;
ss >> temp; color[0] = temp; ss >> temp; color[0] = (uchar)temp;
ss >> temp; color[1] = temp; ss >> temp; color[1] = (uchar)temp;
ss >> temp; color[2] = temp; ss >> temp; color[2] = (uchar)temp;
colors.push_back(color); colors.push_back(color);
} }
} }
...@@ -64,7 +64,7 @@ static void colorizeSegmentation(const Mat &score, const vector<cv::Vec3b> &colo ...@@ -64,7 +64,7 @@ static void colorizeSegmentation(const Mat &score, const vector<cv::Vec3b> &colo
if (ptrScore[col] > ptrMaxVal[col]) if (ptrScore[col] > ptrMaxVal[col])
{ {
ptrMaxVal[col] = ptrScore[col]; ptrMaxVal[col] = ptrScore[col];
ptrMaxCl[col] = ch; ptrMaxCl[col] = (uchar)ch;
} }
} }
} }
......
...@@ -19,7 +19,7 @@ using namespace cv::dnn; ...@@ -19,7 +19,7 @@ using namespace cv::dnn;
#include <cstdlib> #include <cstdlib>
/* Find best class for the blob (i. e. class with maximal probability) */ /* Find best class for the blob (i. e. class with maximal probability) */
void getMaxClass(const Mat &probBlob, int *classId, double *classProb) static void getMaxClass(const Mat &probBlob, int *classId, double *classProb)
{ {
Mat probMat = probBlob.reshape(1, 1); //reshape the blob to 1x1000 matrix Mat probMat = probBlob.reshape(1, 1); //reshape the blob to 1x1000 matrix
Point classNumber; Point classNumber;
...@@ -28,7 +28,7 @@ void getMaxClass(const Mat &probBlob, int *classId, double *classProb) ...@@ -28,7 +28,7 @@ void getMaxClass(const Mat &probBlob, int *classId, double *classProb)
*classId = classNumber.x; *classId = classNumber.x;
} }
std::vector<std::string> readClassNames(const char *filename = "synset_words.txt") static std::vector<std::string> readClassNames(const char *filename = "synset_words.txt")
{ {
std::vector<std::string> classNames; std::vector<std::string> classNames;
......
...@@ -13,22 +13,22 @@ using namespace std; ...@@ -13,22 +13,22 @@ using namespace std;
const size_t width = 300; const size_t width = 300;
const size_t height = 300; const size_t height = 300;
Mat getMean(const size_t& imageHeight, const size_t& imageWidth) static Mat getMean(const size_t& imageHeight, const size_t& imageWidth)
{ {
Mat mean; Mat mean;
const int meanValues[3] = {104, 117, 123}; const int meanValues[3] = {104, 117, 123};
vector<Mat> meanChannels; vector<Mat> meanChannels;
for(size_t i = 0; i < 3; i++) for(int i = 0; i < 3; i++)
{ {
Mat channel(imageHeight, imageWidth, CV_32F, Scalar(meanValues[i])); Mat channel((int)imageHeight, (int)imageWidth, CV_32F, Scalar(meanValues[i]));
meanChannels.push_back(channel); meanChannels.push_back(channel);
} }
cv::merge(meanChannels, mean); cv::merge(meanChannels, mean);
return mean; return mean;
} }
Mat preprocess(const Mat& frame) static Mat preprocess(const Mat& frame)
{ {
Mat preprocessed; Mat preprocessed;
frame.convertTo(preprocessed, CV_32F); frame.convertTo(preprocessed, CV_32F);
...@@ -124,7 +124,7 @@ int main(int argc, char** argv) ...@@ -124,7 +124,7 @@ int main(int argc, char** argv)
if(confidence > confidenceThreshold) if(confidence > confidenceThreshold)
{ {
size_t objectClass = detectionMat.at<float>(i, 1); size_t objectClass = (size_t)(detectionMat.at<float>(i, 1));
float xLeftBottom = detectionMat.at<float>(i, 3) * frame.cols; float xLeftBottom = detectionMat.at<float>(i, 3) * frame.cols;
float yLeftBottom = detectionMat.at<float>(i, 4) * frame.rows; float yLeftBottom = detectionMat.at<float>(i, 4) * frame.rows;
...@@ -139,9 +139,9 @@ int main(int argc, char** argv) ...@@ -139,9 +139,9 @@ int main(int argc, char** argv)
<< " " << xRightTop << " " << xRightTop
<< " " << yRightTop << std::endl; << " " << yRightTop << std::endl;
Rect object(xLeftBottom, yLeftBottom, Rect object((int)xLeftBottom, (int)yLeftBottom,
xRightTop - xLeftBottom, (int)(xRightTop - xLeftBottom),
yRightTop - yLeftBottom); (int)(yRightTop - yLeftBottom));
rectangle(frame, object, Scalar(0, 255, 0)); rectangle(frame, object, Scalar(0, 255, 0));
} }
......
...@@ -141,7 +141,7 @@ static void colorizeSegmentation(const Mat &score, Mat &segm, Mat &legend, vecto ...@@ -141,7 +141,7 @@ static void colorizeSegmentation(const Mat &score, Mat &segm, Mat &legend, vecto
if (ptrScore[col] > ptrMaxVal[col]) if (ptrScore[col] > ptrMaxVal[col])
{ {
ptrMaxVal[col] = ptrScore[col]; ptrMaxVal[col] = ptrScore[col];
ptrMaxCl[col] = ch; ptrMaxCl[col] = (uchar)ch;
} }
} }
} }
...@@ -161,8 +161,8 @@ static void colorizeSegmentation(const Mat &score, Mat &segm, Mat &legend, vecto ...@@ -161,8 +161,8 @@ static void colorizeSegmentation(const Mat &score, Mat &segm, Mat &legend, vecto
if (classNames.size() == colors.size()) if (classNames.size() == colors.size())
{ {
int blockHeight = 30; int blockHeight = 30;
legend.create(blockHeight*classNames.size(), 200, CV_8UC3); legend.create(blockHeight*(int)classNames.size(), 200, CV_8UC3);
for(int i = 0; i < classNames.size(); i++) for(int i = 0; i < (int)classNames.size(); i++)
{ {
cv::Mat block = legend.rowRange(i*blockHeight, (i+1)*blockHeight); cv::Mat block = legend.rowRange(i*blockHeight, (i+1)*blockHeight);
block = colors[i]; block = colors[i];
...@@ -194,9 +194,9 @@ static vector<Vec3b> readColors(const String &filename, vector<String>& classNam ...@@ -194,9 +194,9 @@ static vector<Vec3b> readColors(const String &filename, vector<String>& classNam
string name; ss >> name; string name; ss >> name;
int temp; int temp;
cv::Vec3b color; cv::Vec3b color;
ss >> temp; color[0] = temp; ss >> temp; color[0] = (uchar)temp;
ss >> temp; color[1] = temp; ss >> temp; color[1] = (uchar)temp;
ss >> temp; color[2] = temp; ss >> temp; color[2] = (uchar)temp;
classNames.push_back(name); classNames.push_back(name);
colors.push_back(color); colors.push_back(color);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment