22{
24 std::string save_img = "";
25 std::string save_dat = "";
26
27
28 for (int i = 1; i < argc; i++)
29 {
30 if (i + 1 != argc)
31 {
32
33 if (strcmp(argv[i], "-filename") == 0)
34 {
36 i++;
37 }
38
39 if (strcmp(argv[i], "-ip") == 0)
40 {
43 i++;
44 }
45
46 if (strcmp(argv[i], "-port") == 0)
47 {
50 i++;
51 }
52
53 if (strcmp(argv[i], "-nx") == 0)
54 {
55 ricom->
nx = std::stoi(argv[i + 1]);
56 i++;
57 }
58
59 if (strcmp(argv[i], "-ny") == 0)
60 {
61 ricom->
ny = std::stoi(argv[i + 1]);
62 i++;
63 }
64
65 if (strcmp(argv[i], "-cam_nx") == 0)
66 {
69 i++;
70 }
71
72 if (strcmp(argv[i], "-cam_ny") == 0)
73 {
76 i++;
77 }
78
79 if (strcmp(argv[i], "-skipr") == 0)
80 {
81 ricom->
skip_row = std::stoi(argv[i + 1]);
82 i++;
83 }
84
85 if (strcmp(argv[i], "-skipi") == 0)
86 {
87 ricom->
skip_img = std::stoi(argv[i + 1]);
88 i++;
89 }
90
91 if (strcmp(argv[i], "-k") == 0)
92 {
94 i++;
95 }
96
97 if (strcmp(argv[i], "-r") == 0)
98 {
100 i++;
101 }
102
103 if (strcmp(argv[i], "-offset") == 0)
104 {
105 ricom->
offset[0] = std::stof(argv[i + 1]);
106 i++;
107 ricom->
offset[1] = std::stof(argv[i + 1]);
108 i++;
109 }
110
111 if (strcmp(argv[i], "-update_offset") == 0)
112 {
114 i++;
115 }
116
117 if (strcmp(argv[i], "-radius") == 0)
118 {
121 i++;
123 i++;
124 }
125
126 if (strcmp(argv[i], "-f") == 0)
127 {
130 i++;
132 i++;
133 }
134
135 if (strcmp(argv[i], "-depth") == 0)
136 {
139 i++;
140 }
141
142 if (strcmp(argv[i], "-rep") == 0)
143 {
144 ricom->
rep = std::stoi(argv[i + 1]);
145 i++;
146 }
147
148 if (strcmp(argv[i], "-dwell_time") == 0)
149 {
152 i++;
153 }
154
155 if (strcmp(argv[i], "-threads") == 0)
156 {
157 ricom->
n_threads = std::stoi(argv[i + 1]);
158 i++;
159 }
160
161 if (strcmp(argv[i], "-queue_size") == 0)
162 {
164 i++;
165 }
166
167 if (strcmp(argv[i], "-redraw_interval") == 0)
168 {
171 i++;
172 }
173
174 if (strcmp(argv[i], "-save_img_path") == 0)
175 {
176 save_img = argv[i + 1];
178 i++;
179 }
180
181 if (strcmp(argv[i], "-save_data_path") == 0)
182 {
183 save_dat = argv[i + 1];
184 i++;
185 }
186
187 if (strcmp(argv[i], "-plot_e_field") == 0)
188 {
189 ricom->
b_e_mag = (bool)std::stoi(argv[i + 1]);
190 i++;
191 }
192 }
193 }
194
196 {
197 std::vector<SdlImageWindow> image_windows;
198 std::thread run_thread;
201 {
203 }
204
205 run_thread.detach();
206
207
208 SDL_DisplayMode DM;
209 SDL_Event event;
210
211 SDL_Init(SDL_INIT_EVERYTHING);
212 SDL_GetCurrentDisplayMode(0, &DM);
213 float scale = (std::min)(((
float)DM.w) / ricom->
nx, ((float)DM.h) / ricom->
ny) * 0.8;
214 bool b_redraw = false;
217 {
219 }
221 {
223 }
224
225 bool b_open_window = true;
226 while (b_open_window)
227 {
229 {
231 {
232 b_redraw = true;
234 }
235 else
236 {
237 b_redraw = true;
238 }
239 }
240
241 if (b_redraw)
242 {
243 for (auto &wnd : image_windows)
244 {
245 wnd.update_image();
246 }
247 }
248
249 while (SDL_PollEvent(&event))
250 {
251 if (event.type == SDL_QUIT ||
252 (event.type == SDL_WINDOWEVENT &&
253 event.window.event == SDL_WINDOWEVENT_CLOSE))
254 {
257 b_open_window = false;
258 }
259 }
260 }
261 }
262 else
263 {
265 }
266 if (save_dat != "")
267 {
269 std::cout << "riCOM reconstruction data saved as " + save_dat << std::endl;
270 }
271 if (save_img != "")
272 {
274 std::cout << "riCOM reconstruction image saved as " + save_img << std::endl;
275 }
276 return 0;
277}
void save_numpy(std::string *path, int nx, int ny, std::vector< T > *data)
void save_image(std::string *path, SDL_Surface *sdl_srf)
std::atomic< bool > report_set_public
std::array< float, 2 > radius
std::array< int, 2 > kernel_filter_frequency
std::vector< float > ricom_data
ProgressMonitor * p_prog_mon
enum CAMERA::Camera_model select_mode_by_file(const char *filename)
CAMERA::Camera_BASE camera
std::array< float, 2 > offset
void run_ricom(Ricom *r, RICOM::modes mode)