Skip to content

Commit 268af90

Browse files
committed
Code cleaning
1 parent 3045bbb commit 268af90

File tree

2 files changed

+6
-123
lines changed

2 files changed

+6
-123
lines changed

tests/detectobj2.cpp

Lines changed: 3 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -39,131 +39,13 @@ string extractModelName (string modelPath)
3939

4040
return name;
4141
}
42-
/*
43-
string saveImage (const IplImage *im, string imgPath, int mode, const CvMat *results)
44-
{
45-
string name, path;
46-
size_t pos;
47-
char imgNameCh[8];
48-
IplImage *cut = NULL;
49-
int x, y, w, h;
50-
51-
pos = imgPath.find_last_of ("/");
52-
path = imgPath.substr(0, pos);
53-
54-
if (mode == TAGGED)
55-
{
56-
pos = imgPath.find_last_of(".");
57-
58-
name = imgPath.substr (0, pos);
59-
60-
name.append ("_tagged");
61-
name.append(imgPath.substr(pos));
62-
63-
cvSaveImage (name.c_str(), im);
64-
}
65-
66-
else if (mode == CUT)
67-
{
68-
for (int i = 0; i < results->rows; i++)
69-
{
70-
x = min (cvGetReal2D (results, i, 0), cvGetReal2D (results, i, 2));
71-
y = min (cvGetReal2D (results, i, 1), cvGetReal2D (results, i, 3));
72-
w = abs(cvGetReal2D (results, i, 0) - cvGetReal2D (results, i, 2));
73-
h = abs(cvGetReal2D (results, i, 1) - cvGetReal2D (results, i, 3));
74-
75-
cut = cvCreateImage (cvSize (w, h), im->depth, im->nChannels);
76-
77-
for (int m = x; m < w+x; m++)
78-
for (int n = y; n < h+y; n++)
79-
cvSet2D (cut, n-y, m-x, cvGet2D(im, n, m));
80-
81-
82-
pos = imgPath.find_last_of(".");
83-
84-
name = imgPath.substr (0, pos);
85-
86-
sprintf (imgNameCh, "_cut%d", i+1);
87-
88-
name.append (imgNameCh);
89-
name.append(imgPath.substr(pos));
90-
91-
cvSaveImage (name.c_str(), cut);
9242

93-
cvReleaseImage (&cut);
94-
cut = NULL;
95-
}
96-
}
97-
98-
return path;
99-
}
100-
*/
101-
/*
102-
string saveImage (const cv::Mat & im, string imgPath, int mode, const cv::Mat * results)
103-
{
104-
string name, path;
105-
size_t pos;
106-
char imgNameCh[8];
107-
108-
int x, y, w, h;
109-
110-
pos = imgPath.find_last_of ("/");
111-
path = imgPath.substr(0, pos);
112-
113-
if (mode == TAGGED)
114-
{
115-
pos = imgPath.find_last_of(".");
116-
117-
name = imgPath.substr (0, pos);
118-
119-
name.append ("_tagged");
120-
name.append(imgPath.substr(pos));
121-
122-
cv::imwrite(name,im);
123-
124-
}
125-
126-
else if (mode == CUT)
127-
{
128-
for (int i = 0; i < results->rows; i++)
129-
{
130-
x = min (results->at<float>(i, 0), results->at<float>(i, 2));
131-
y = min (results->at<float>(i, 1), results->at<float>(i, 3));
132-
w = abs(results->at<float>(i, 0) - results->at<float>(i, 2));
133-
h = abs(results->at<float>(i, 1) - results->at<float>(i, 3));
134-
135-
cv::Mat cut2(cv::Size(w, h), cv::DataType<cv::Vec<uchar,3>>::type);
136-
cout << im.channels() << endl;
137-
138-
for (int m = x; m < w+x; m++)
139-
for (int n = y; n < h+y; n++)
140-
cut2.at<cv::Vec3b>(n-y, m-x) = im.at<cv::Vec3b>(n, m);
141-
142-
143-
pos = imgPath.find_last_of(".");
144-
145-
name = imgPath.substr (0, pos);
146-
147-
sprintf (imgNameCh, "_cut%d", i+1);
148-
149-
name.append (imgNameCh);
150-
name.append(imgPath.substr(pos));
151-
152-
153-
cv::imwrite(name, cut2);
154-
cut2.release();
155-
}
156-
}
157-
158-
return path;
159-
}
160-
*/
16143
string saveImage (const cv::Mat & im, string imgPath, int mode, const LDetections & results)
16244
{
16345
string name, path;
16446
size_t pos;
16547
char imgNameCh[8];
166-
48+
int nresults;
16749
int x, y, w, h;
16850

16951
pos = imgPath.find_last_of ("/");
@@ -185,8 +67,8 @@ string saveImage (const cv::Mat & im, string imgPath, int mode, const LDetection
18567
break;
18668

18769
case CUT:
188-
189-
for (int i = 0; i < results.size(); i++)
70+
nresults = (int) results.size();
71+
for (int i = 0; i < nresults; i++)
19072
{
19173
x = min (results[i].getX1(), results[i].getX2());
19274
y = min (results[i].getY1(), results[i].getY2());

tests/detectvid.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ string saveImage (const cv::Mat & im, string imgPath, int mode, const LDetection
103103
string name, path;
104104
size_t pos;
105105
char imgNameCh[8];
106-
106+
int nresults;
107107
int x, y, w, h;
108108

109109
pos = imgPath.find_last_of ("/");
@@ -124,7 +124,8 @@ string saveImage (const cv::Mat & im, string imgPath, int mode, const LDetection
124124

125125
else if (mode == CUT)
126126
{
127-
for (int i = 0; i < results.size(); i++)
127+
nresults = (int) results.size();
128+
for (int i = 0; i < nresults; i++)
128129
{
129130
x = min (results[i].getX1(), results[i].getX2());
130131
y = min (results[i].getY1(), results[i].getY2());

0 commit comments

Comments
 (0)