mirror of
https://github.com/opencv/opencv.git
synced 2025-07-24 14:06:27 +08:00
dnn: fix build warnings
This commit is contained in:
parent
ee54bafe6b
commit
623de337e8
@ -60,7 +60,7 @@ inline std::ostream &operator<< (std::ostream &s, cv::Range &r)
|
||||
struct _Range : public cv::Range
|
||||
{
|
||||
_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)
|
||||
@ -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)
|
||||
{
|
||||
if (start == -1) start = 0;
|
||||
if (end == -1) end = shape.size();
|
||||
if (end == -1) end = (int)shape.size();
|
||||
|
||||
if (shape.empty())
|
||||
return 0;
|
||||
|
||||
int elems = 1;
|
||||
CV_Assert(start < shape.size() && end <= shape.size() &&
|
||||
CV_Assert(start < (int)shape.size() && end <= (int)shape.size() &&
|
||||
start <= end);
|
||||
for(int i = start; i < end; i++)
|
||||
{
|
||||
@ -187,7 +187,7 @@ inline int clamp(int ax, int dims)
|
||||
|
||||
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;
|
||||
using namespace std;
|
||||
|
||||
/* 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
|
||||
Point classNumber;
|
||||
@ -59,7 +59,7 @@ void getMaxClass(const Mat &probBlob, int *classId, double *classProb)
|
||||
*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;
|
||||
|
||||
|
@ -33,9 +33,9 @@ static vector<cv::Vec3b> readColors(const string &filename = "pascal-classes.txt
|
||||
string name; ss >> name;
|
||||
int temp;
|
||||
cv::Vec3b color;
|
||||
ss >> temp; color[0] = temp;
|
||||
ss >> temp; color[1] = temp;
|
||||
ss >> temp; color[2] = temp;
|
||||
ss >> temp; color[0] = (uchar)temp;
|
||||
ss >> temp; color[1] = (uchar)temp;
|
||||
ss >> temp; color[2] = (uchar)temp;
|
||||
colors.push_back(color);
|
||||
}
|
||||
}
|
||||
@ -64,7 +64,7 @@ static void colorizeSegmentation(const Mat &score, const vector<cv::Vec3b> &colo
|
||||
if (ptrScore[col] > ptrMaxVal[col])
|
||||
{
|
||||
ptrMaxVal[col] = ptrScore[col];
|
||||
ptrMaxCl[col] = ch;
|
||||
ptrMaxCl[col] = (uchar)ch;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,7 @@ using namespace cv::dnn;
|
||||
#include <cstdlib>
|
||||
|
||||
/* 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
|
||||
Point classNumber;
|
||||
@ -28,7 +28,7 @@ void getMaxClass(const Mat &probBlob, int *classId, double *classProb)
|
||||
*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;
|
||||
|
||||
|
@ -13,22 +13,22 @@ using namespace std;
|
||||
const size_t width = 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;
|
||||
|
||||
const int meanValues[3] = {104, 117, 123};
|
||||
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);
|
||||
}
|
||||
cv::merge(meanChannels, mean);
|
||||
return mean;
|
||||
}
|
||||
|
||||
Mat preprocess(const Mat& frame)
|
||||
static Mat preprocess(const Mat& frame)
|
||||
{
|
||||
Mat preprocessed;
|
||||
frame.convertTo(preprocessed, CV_32F);
|
||||
@ -124,7 +124,7 @@ int main(int argc, char** argv)
|
||||
|
||||
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 yLeftBottom = detectionMat.at<float>(i, 4) * frame.rows;
|
||||
@ -139,9 +139,9 @@ int main(int argc, char** argv)
|
||||
<< " " << xRightTop
|
||||
<< " " << yRightTop << std::endl;
|
||||
|
||||
Rect object(xLeftBottom, yLeftBottom,
|
||||
xRightTop - xLeftBottom,
|
||||
yRightTop - yLeftBottom);
|
||||
Rect object((int)xLeftBottom, (int)yLeftBottom,
|
||||
(int)(xRightTop - xLeftBottom),
|
||||
(int)(yRightTop - yLeftBottom));
|
||||
|
||||
rectangle(frame, object, Scalar(0, 255, 0));
|
||||
}
|
||||
|
@ -141,7 +141,7 @@ static void colorizeSegmentation(const Mat &score, Mat &segm, Mat &legend, vecto
|
||||
if (ptrScore[col] > ptrMaxVal[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
|
||||
if (classNames.size() == colors.size())
|
||||
{
|
||||
int blockHeight = 30;
|
||||
legend.create(blockHeight*classNames.size(), 200, CV_8UC3);
|
||||
for(int i = 0; i < classNames.size(); i++)
|
||||
legend.create(blockHeight*(int)classNames.size(), 200, CV_8UC3);
|
||||
for(int i = 0; i < (int)classNames.size(); i++)
|
||||
{
|
||||
cv::Mat block = legend.rowRange(i*blockHeight, (i+1)*blockHeight);
|
||||
block = colors[i];
|
||||
@ -194,9 +194,9 @@ static vector<Vec3b> readColors(const String &filename, vector<String>& classNam
|
||||
string name; ss >> name;
|
||||
int temp;
|
||||
cv::Vec3b color;
|
||||
ss >> temp; color[0] = temp;
|
||||
ss >> temp; color[1] = temp;
|
||||
ss >> temp; color[2] = temp;
|
||||
ss >> temp; color[0] = (uchar)temp;
|
||||
ss >> temp; color[1] = (uchar)temp;
|
||||
ss >> temp; color[2] = (uchar)temp;
|
||||
classNames.push_back(name);
|
||||
colors.push_back(color);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user