@@ -15,7 +15,6 @@ namespace FrameProcessor
15
15
const std::string HexitecSummedImagePlugin::CONFIG_THRESHOLD_LOWER = " threshold_lower" ;
16
16
const std::string HexitecSummedImagePlugin::CONFIG_THRESHOLD_UPPER = " threshold_upper" ;
17
17
const std::string HexitecSummedImagePlugin::CONFIG_IMAGE_FREQUENCY = " image_frequency" ;
18
- const std::string HexitecSummedImagePlugin::CONFIG_IMAGES_WRITTEN = " images_written" ;
19
18
const std::string HexitecSummedImagePlugin::CONFIG_RESET_IMAGE = " reset_image" ;
20
19
21
20
/* *
@@ -35,8 +34,8 @@ namespace FrameProcessor
35
34
threshold_lower_ = 0 ;
36
35
threshold_upper_ = 16382 ;
37
36
image_frequency_ = 1 ;
38
- images_written_ = 0 ;
39
37
reset_image_ = 0 ;
38
+ node_index_ = 1000 ;
40
39
}
41
40
42
41
/* *
@@ -125,7 +124,6 @@ namespace FrameProcessor
125
124
{
126
125
// Clear all pixels to be 0
127
126
memset (summed_image_, 0 , image_pixels_ * sizeof (uint32_t ));
128
- images_written_ = 0 ;
129
127
reset_image_ = 0 ;
130
128
}
131
129
}
@@ -139,7 +137,6 @@ namespace FrameProcessor
139
137
reply.set_param (base_str + HexitecSummedImagePlugin::CONFIG_THRESHOLD_LOWER, threshold_lower_);
140
138
reply.set_param (base_str + HexitecSummedImagePlugin::CONFIG_THRESHOLD_UPPER, threshold_upper_);
141
139
reply.set_param (base_str + HexitecSummedImagePlugin::CONFIG_IMAGE_FREQUENCY, image_frequency_);
142
- reply.set_param (base_str + HexitecSummedImagePlugin::CONFIG_IMAGES_WRITTEN, images_written_);
143
140
reply.set_param (base_str + HexitecSummedImagePlugin::CONFIG_RESET_IMAGE, reset_image_);
144
141
}
145
142
@@ -156,7 +153,6 @@ namespace FrameProcessor
156
153
status.set_param (get_name () + " /threshold_lower" , threshold_lower_);
157
154
status.set_param (get_name () + " /threshold_upper" , threshold_upper_);
158
155
status.set_param (get_name () + " /image_frequency" , image_frequency_);
159
- status.set_param (get_name () + " /images_written" , images_written_);
160
156
status.set_param (get_name () + " /reset_image" , reset_image_);
161
157
}
162
158
@@ -169,6 +165,16 @@ namespace FrameProcessor
169
165
return true ;
170
166
}
171
167
168
+ /* * Process an EndOfAcquisition Frame.
169
+ *
170
+ * Push Summed Data set on end of acquisition
171
+ */
172
+ void HexitecSummedImagePlugin::process_end_of_acquisition ()
173
+ {
174
+ LOG4CXX_DEBUG_LEVEL (2 , logger_, " End of acquisition frame received, pushing dataset" );
175
+ pushSummedDataset ();
176
+ }
177
+
172
178
/* *
173
179
* Perform processing on the frame.
174
180
*
@@ -186,53 +192,32 @@ namespace FrameProcessor
186
192
long long frame_number = incoming_frame_meta.get_frame_number ();
187
193
188
194
// Push dataset
189
- LOG4CXX_DEBUG_LEVEL (3 , logger_, " Pushing " << dataset << " dataset, frame number: "
195
+ LOG4CXX_DEBUG_LEVEL (2 , logger_, " Pushing " << dataset << " dataset, frame number: "
190
196
<< frame_number);
191
197
this ->push (frame);
192
198
193
199
if (dataset.compare (std::string (" processed_frames" )) == 0 )
194
200
{
195
201
try
196
202
{
203
+ // Determine node index, i.e. 0 for first node, 1 = 2nd node, 2 = 3rd, etc
204
+ if (frame_number < node_index_)
205
+ {
206
+ node_index_ = frame_number;
207
+ }
208
+
209
+ // Define pointer to the input image data
210
+ void * input_ptr = static_cast <void *>(
211
+ static_cast <char *>(const_cast <void *>(data_ptr)));
212
+
213
+ // Apply algorithm
214
+ apply_summed_image_algorithm (static_cast <float *>(input_ptr));
215
+
216
+
217
+ // How often to write accumulated data to disk?
197
218
if ((frame_number % image_frequency_) == 0 )
198
219
{
199
- // Create summed_image dataset
200
-
201
- FrameMetaData summed_image_meta;
202
- dimensions_t dims (2 );
203
- dims[0 ] = image_height_;
204
- dims[1 ] = image_width_;
205
- summed_image_meta.set_dimensions (dims);
206
- summed_image_meta.set_compression_type (no_compression);
207
- summed_image_meta.set_data_type (raw_32bit);
208
- summed_image_meta.set_frame_number (frame_number);
209
- summed_image_meta.set_dataset_name (" summed_images" );
210
-
211
- const std::size_t summed_image_size = image_width_ * image_height_ * sizeof (uint32_t );
212
-
213
- boost::shared_ptr<Frame> summed_frame;
214
- summed_frame = boost::shared_ptr<Frame>(new DataBlockFrame (summed_image_meta,
215
- summed_image_size));
216
-
217
- // Ensure frame is empty
218
- float *summed = static_cast <float *>(summed_frame->get_data_ptr ());
219
- memset (summed, 0 , image_pixels_ * sizeof (uint32_t ));
220
-
221
- // Define pointer to the input image data
222
- void * input_ptr = static_cast <void *>(
223
- static_cast <char *>(const_cast <void *>(data_ptr)));
224
-
225
- void * output_ptr = summed_frame->get_data_ptr ();
226
-
227
- // Apply algorithm
228
- apply_summed_image_algorithm (static_cast <float *>(input_ptr),
229
- static_cast <uint32_t *>(output_ptr));
230
-
231
- const std::string& dataset_name = summed_image_meta.get_dataset_name ();
232
- LOG4CXX_DEBUG_LEVEL (3 , logger_, " Pushing " << dataset_name << " dataset, frame number: "
233
- << summed_image_meta.get_frame_number ());
234
- this ->push (summed_frame);
235
- images_written_++;
220
+ pushSummedDataset ();
236
221
}
237
222
}
238
223
catch (const std::exception & e)
@@ -251,17 +236,56 @@ namespace FrameProcessor
251
236
*
252
237
* \param[frame] frame - Pointer to a frame object.
253
238
*/
254
- void HexitecSummedImagePlugin::apply_summed_image_algorithm (float *in, uint32_t *out )
239
+ void HexitecSummedImagePlugin::apply_summed_image_algorithm (float *in)
255
240
{
256
241
for (int i=0 ; i<image_pixels_; i++)
257
242
{
258
243
if (((uint32_t )in[i] > threshold_lower_) && ((uint32_t )in[i] < threshold_upper_))
259
244
{
260
245
summed_image_[i] += 1 ;
261
246
}
262
- // Maintain history from previous frame(s)
247
+ }
248
+ }
249
+
250
+ /* *
251
+ * Create and push summed data set
252
+ */
253
+ void HexitecSummedImagePlugin::pushSummedDataset ()
254
+ {
255
+ // Create summed_image dataset
256
+
257
+ FrameMetaData summed_image_meta;
258
+ dimensions_t dims (2 );
259
+ dims[0 ] = image_height_;
260
+ dims[1 ] = image_width_;
261
+ summed_image_meta.set_dimensions (dims);
262
+ summed_image_meta.set_compression_type (no_compression);
263
+ summed_image_meta.set_data_type (raw_32bit);
264
+ summed_image_meta.set_frame_number (node_index_);
265
+ summed_image_meta.set_dataset_name (" summed_images" );
266
+
267
+ const std::size_t summed_image_size = image_width_ * image_height_ * sizeof (uint32_t );
268
+
269
+ boost::shared_ptr<Frame> summed_frame;
270
+ summed_frame = boost::shared_ptr<Frame>(new DataBlockFrame (summed_image_meta,
271
+ summed_image_size));
272
+
273
+ // Ensure frame is empty
274
+ float *summed = static_cast <float *>(summed_frame->get_data_ptr ());
275
+ memset (summed, 0 , image_pixels_ * sizeof (uint32_t ));
276
+
277
+ // void* output_ptr = summed_frame->get_data_ptr();
278
+
279
+ uint32_t *out = static_cast <uint32_t *>(summed_frame->get_data_ptr ());
280
+ for (int i=0 ; i<image_pixels_; i++)
281
+ {
263
282
out[i] = summed_image_[i];
264
283
}
284
+
285
+ const std::string& dataset_name = summed_image_meta.get_dataset_name ();
286
+ LOG4CXX_DEBUG_LEVEL (2 , logger_, " Pushing " << dataset_name << " dataset, frame number: "
287
+ << summed_image_meta.get_frame_number ());
288
+ this ->push (summed_frame);
265
289
}
266
290
267
291
/* *
0 commit comments