質問編集履歴
1
ソースコードの記載
title
CHANGED
File without changes
|
body
CHANGED
@@ -3,4 +3,139 @@
|
|
3
3
|
VC18で表示されます。
|
4
4
|
|
5
5
|
int*とintの値を比べる方法を教えていただきたいです。
|
6
|
-
よろしくおねがいします
|
6
|
+
よろしくおねがいします
|
7
|
+
|
8
|
+
###ソースコード
|
9
|
+
```lang-C++
|
10
|
+
#include <fstream> //ファイル読み込み用
|
11
|
+
#include <iostream> //ファイル読み込み用
|
12
|
+
#include <string> //String型使用をする用
|
13
|
+
#include <opencv2/opencv.hpp> //画像サイズ取得用
|
14
|
+
#include <stdio.h> //タイトルバー設定用
|
15
|
+
#include <windows.h> //タイトルバー設定用
|
16
|
+
#include <vector> //可変長配列使用をする用
|
17
|
+
#include <sstream> //stoi用(stringからint)
|
18
|
+
#include <stdint.h>//intptr_t用(ポインタ)
|
19
|
+
using namespace std;
|
20
|
+
|
21
|
+
const int imgnum = 7600;
|
22
|
+
string strdata[7600];
|
23
|
+
|
24
|
+
string imgdata_pass[7600];
|
25
|
+
int imgdata_box[7600][15][4];
|
26
|
+
int imgdata_size[7600][2];
|
27
|
+
|
28
|
+
int road()//読み込み関数
|
29
|
+
{
|
30
|
+
ifstream ifs("annotation.txt");
|
31
|
+
string str;
|
32
|
+
if (ifs.fail())
|
33
|
+
{
|
34
|
+
cerr << "リストファイルが読み込めません" << endl;
|
35
|
+
return -1;
|
36
|
+
}
|
37
|
+
int i = 0;
|
38
|
+
while (getline(ifs, str))
|
39
|
+
{
|
40
|
+
strdata[i] = str;
|
41
|
+
cout << "[" << strdata[i] << "]" << endl;
|
42
|
+
::SetConsoleTitle(TEXT("リスト読み込み中"));
|
43
|
+
i++;
|
44
|
+
}
|
45
|
+
return 0;
|
46
|
+
}
|
47
|
+
|
48
|
+
|
49
|
+
vector<string> split(const string &str, char sep)//分割関数
|
50
|
+
{
|
51
|
+
vector<string> v;
|
52
|
+
stringstream ss(str);
|
53
|
+
string buffer;
|
54
|
+
while (getline(ss, buffer, sep))
|
55
|
+
{
|
56
|
+
v.push_back(buffer);
|
57
|
+
}
|
58
|
+
return v;
|
59
|
+
}
|
60
|
+
|
61
|
+
int analysis()//解析関数
|
62
|
+
{
|
63
|
+
::SetConsoleTitle(TEXT("リスト解析中"));
|
64
|
+
int a = 0;
|
65
|
+
int b[4] = { 0,0,0,0 };
|
66
|
+
for (int i = 0; i < imgnum; i++)
|
67
|
+
{
|
68
|
+
vector<string> v = split(strdata[i], ' ');
|
69
|
+
imgdata_pass[i] = v[0];//画像パス代入
|
70
|
+
a = stoi(v[1]);
|
71
|
+
for (int j=0;j<a;j++)
|
72
|
+
{
|
73
|
+
b[0] = stoi(v[j*5+2]);//string型をint型に変換
|
74
|
+
b[1] = stoi(v[j * 5 + 3]);
|
75
|
+
b[2] = stoi(v[j * 5 + 4]);
|
76
|
+
b[3] = stoi(v[j * 5 + 5]);
|
77
|
+
|
78
|
+
imgdata_box[i][j][0] = b[0];//短形情報を代入
|
79
|
+
imgdata_box[i][j][1] = b[1];
|
80
|
+
imgdata_box[i][j][2] = b[2];
|
81
|
+
imgdata_box[i][j][3] = b[3];
|
82
|
+
}
|
83
|
+
}
|
84
|
+
|
85
|
+
return 0;
|
86
|
+
}
|
87
|
+
|
88
|
+
int count(int num) {//要素数カウント
|
89
|
+
|
90
|
+
int count = 0;
|
91
|
+
for (int i; i < 13; i++) {
|
92
|
+
if (imgdata_box[num][i][2] != NULL)
|
93
|
+
{
|
94
|
+
count++;
|
95
|
+
}
|
96
|
+
}
|
97
|
+
return count;
|
98
|
+
}
|
99
|
+
|
100
|
+
int trimming()//情報修正関数 OpenCV使用
|
101
|
+
{
|
102
|
+
//画像のサイズを取得
|
103
|
+
::SetConsoleTitle(TEXT("リスト修正中"));
|
104
|
+
for (int i = 0; i < imgnum; i++)
|
105
|
+
{
|
106
|
+
cv::Mat img = cv::imread(imgdata_pass[i]);
|
107
|
+
if (img.empty()) {
|
108
|
+
cout << "画像が読み込めません" << endl;
|
109
|
+
return 1;
|
110
|
+
}
|
111
|
+
imgdata_size[i][1] = img.rows;//縦
|
112
|
+
imgdata_size[i][0] = img.cols;//横
|
113
|
+
}
|
114
|
+
|
115
|
+
//情報修正
|
116
|
+
int a = 0;
|
117
|
+
for (int i = 0; i < imgnum; i++)
|
118
|
+
{
|
119
|
+
a = count(i);
|
120
|
+
for (int j = 0; j < a; j++)
|
121
|
+
{
|
122
|
+
/*ここです*/if (imgdata_box[i][j][0]+imgdata_box[i][j][2]>imgdata_size[1])
|
123
|
+
{
|
124
|
+
|
125
|
+
}
|
126
|
+
}
|
127
|
+
}
|
128
|
+
|
129
|
+
return 0;
|
130
|
+
}
|
131
|
+
|
132
|
+
int main()
|
133
|
+
{
|
134
|
+
road();
|
135
|
+
analysis();
|
136
|
+
trimming();
|
137
|
+
|
138
|
+
return 0;
|
139
|
+
}
|
140
|
+
|
141
|
+
```
|