@@ -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,7 +34,6 @@ 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 ;
40
38
node_index_ = 1000 ;
41
39
}
@@ -126,7 +124,6 @@ namespace FrameProcessor
126
124
{
127
125
// Clear all pixels to be 0
128
126
memset (summed_image_, 0 , image_pixels_ * sizeof (uint32_t ));
129
- images_written_ = 0 ;
130
127
reset_image_ = 0 ;
131
128
}
132
129
}
@@ -140,7 +137,6 @@ namespace FrameProcessor
140
137
reply.set_param (base_str + HexitecSummedImagePlugin::CONFIG_THRESHOLD_LOWER, threshold_lower_);
141
138
reply.set_param (base_str + HexitecSummedImagePlugin::CONFIG_THRESHOLD_UPPER, threshold_upper_);
142
139
reply.set_param (base_str + HexitecSummedImagePlugin::CONFIG_IMAGE_FREQUENCY, image_frequency_);
143
- reply.set_param (base_str + HexitecSummedImagePlugin::CONFIG_IMAGES_WRITTEN, images_written_);
144
140
reply.set_param (base_str + HexitecSummedImagePlugin::CONFIG_RESET_IMAGE, reset_image_);
145
141
}
146
142
@@ -157,7 +153,6 @@ namespace FrameProcessor
157
153
status.set_param (get_name () + " /threshold_lower" , threshold_lower_);
158
154
status.set_param (get_name () + " /threshold_upper" , threshold_upper_);
159
155
status.set_param (get_name () + " /image_frequency" , image_frequency_);
160
- status.set_param (get_name () + " /images_written" , images_written_);
161
156
status.set_param (get_name () + " /reset_image" , reset_image_);
162
157
}
163
158
@@ -170,6 +165,16 @@ namespace FrameProcessor
170
165
return true ;
171
166
}
172
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
+
173
178
/* *
174
179
* Perform processing on the frame.
175
180
*
@@ -187,57 +192,32 @@ namespace FrameProcessor
187
192
long long frame_number = incoming_frame_meta.get_frame_number ();
188
193
189
194
// Push dataset
190
- LOG4CXX_DEBUG_LEVEL (3 , logger_, " Pushing " << dataset << " dataset, frame number: "
195
+ LOG4CXX_DEBUG_LEVEL (2 , logger_, " Pushing " << dataset << " dataset, frame number: "
191
196
<< frame_number);
192
197
this ->push (frame);
193
198
194
199
if (dataset.compare (std::string (" processed_frames" )) == 0 )
195
200
{
196
201
try
197
202
{
198
- if (frame_number < node_index_)
199
- {
200
- node_index_ = frame_number;
201
- }
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?
202
218
if ((frame_number % image_frequency_) == 0 )
203
219
{
204
- // Create summed_image dataset
205
-
206
- FrameMetaData summed_image_meta;
207
- dimensions_t dims (2 );
208
- dims[0 ] = image_height_;
209
- dims[1 ] = image_width_;
210
- summed_image_meta.set_dimensions (dims);
211
- summed_image_meta.set_compression_type (no_compression);
212
- summed_image_meta.set_data_type (raw_32bit);
213
- summed_image_meta.set_frame_number (node_index_);
214
- summed_image_meta.set_dataset_name (" summed_images" );
215
-
216
- const std::size_t summed_image_size = image_width_ * image_height_ * sizeof (uint32_t );
217
-
218
- boost::shared_ptr<Frame> summed_frame;
219
- summed_frame = boost::shared_ptr<Frame>(new DataBlockFrame (summed_image_meta,
220
- summed_image_size));
221
-
222
- // Ensure frame is empty
223
- float *summed = static_cast <float *>(summed_frame->get_data_ptr ());
224
- memset (summed, 0 , image_pixels_ * sizeof (uint32_t ));
225
-
226
- // Define pointer to the input image data
227
- void * input_ptr = static_cast <void *>(
228
- static_cast <char *>(const_cast <void *>(data_ptr)));
229
-
230
- void * output_ptr = summed_frame->get_data_ptr ();
231
-
232
- // Apply algorithm
233
- apply_summed_image_algorithm (static_cast <float *>(input_ptr),
234
- static_cast <uint32_t *>(output_ptr));
235
-
236
- const std::string& dataset_name = summed_image_meta.get_dataset_name ();
237
- LOG4CXX_DEBUG_LEVEL (3 , logger_, " Pushing " << dataset_name << " dataset, frame number: "
238
- << summed_image_meta.get_frame_number ());
239
- this ->push (summed_frame);
240
- images_written_++;
220
+ pushSummedDataset ();
241
221
}
242
222
}
243
223
catch (const std::exception & e)
@@ -256,17 +236,56 @@ namespace FrameProcessor
256
236
*
257
237
* \param[frame] frame - Pointer to a frame object.
258
238
*/
259
- void HexitecSummedImagePlugin::apply_summed_image_algorithm (float *in, uint32_t *out )
239
+ void HexitecSummedImagePlugin::apply_summed_image_algorithm (float *in)
260
240
{
261
241
for (int i=0 ; i<image_pixels_; i++)
262
242
{
263
243
if (((uint32_t )in[i] > threshold_lower_) && ((uint32_t )in[i] < threshold_upper_))
264
244
{
265
245
summed_image_[i] += 1 ;
266
246
}
267
- // 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
+ {
268
282
out[i] = summed_image_[i];
269
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);
270
289
}
271
290
272
291
/* *
0 commit comments