aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@physics.org>2020-04-01 14:36:43 +0200
committerThomas White <taw@physics.org>2020-07-29 18:42:57 +0200
commit2a1419da3799a25a061e86849fd084ca397f6d09 (patch)
tree724dd7ce69fa9d2f88510b7a5e47ae99d12548b9
parent6f9306896ab99acfbd2fb111449a98bea6dce5e5 (diff)
get_peaks_msgpack(): Convert to new API
-rw-r--r--src/im-zmq.c33
-rw-r--r--src/im-zmq.h5
-rw-r--r--src/process_image.c5
3 files changed, 23 insertions, 20 deletions
diff --git a/src/im-zmq.c b/src/im-zmq.c
index fa0306d3..da0a5fff 100644
--- a/src/im-zmq.c
+++ b/src/im-zmq.c
@@ -45,6 +45,7 @@
#include "image.h"
#include "hdf5-file.h"
#include "utils.h"
+#include "im-zmq.h"
struct im_zmq
@@ -180,10 +181,11 @@ static msgpack_object *find_msgpack_kv(msgpack_object *obj, const char *key)
* Returns: non-zero on error, zero otherwise.
*
*/
-int get_peaks_msgpack(msgpack_object *obj, struct image *image,
- int half_pixel_shift)
+ImageFeatureList *get_peaks_msgpack(msgpack_object *obj,
+ const DataTemplate *dtempl,
+ int half_pixel_shift)
{
-
+ ImageFeatureList *features;
int num_peaks;
int pk;
msgpack_object *peak_list;
@@ -194,7 +196,7 @@ int get_peaks_msgpack(msgpack_object *obj, struct image *image,
if ( obj == NULL ) {
ERROR("No MessagePack object to get peaks from.\n");
- return 1;
+ return NULL;
}
/* Object has structure:
@@ -212,15 +214,12 @@ int get_peaks_msgpack(msgpack_object *obj, struct image *image,
/* Length of peak_x array gives number of peaks */
num_peaks = peak_x->via.array.size;
- if ( image->features != NULL ) {
- image_feature_list_free(image->features);
- }
- image->features = image_feature_list_new();
+ features = image_feature_list_new();
for ( pk=0; pk<num_peaks; pk++ ) {
float fs, ss, val;
- struct panel *p;
+ int pn;
/* Retrieve data from peak_list and apply half_pixel_shift,
* if appropriate */
@@ -228,18 +227,20 @@ int get_peaks_msgpack(msgpack_object *obj, struct image *image,
ss = peak_y->via.array.ptr[pk].via.f64 + peak_offset;
val = peak_i->via.array.ptr[pk].via.f64;
- p = find_orig_panel(image->det, fs, ss);
- if ( p == NULL ) continue;
- if ( p->no_index ) continue;
+ pn = data_template_find_panel(dtempl, fs, ss);
+ if ( pn < -1 ) {
+ ERROR("Peak not in panel!\n");
+ continue;
+ }
/* Convert coordinates to panel-relative */
- fs = fs - p->orig_min_fs;
- ss = ss - p->orig_min_ss;
+ data_template_file_to_panel_coords(dtempl, &fs, &ss);
- image_add_feature(image->features, fs, ss, p, image, val, NULL);
+ image_add_feature(features, fs, ss, pn,
+ NULL, val, NULL);
}
- return 0;
+ return features;
}
diff --git a/src/im-zmq.h b/src/im-zmq.h
index 50a9dde3..bc6175af 100644
--- a/src/im-zmq.h
+++ b/src/im-zmq.h
@@ -50,8 +50,9 @@ extern void im_zmq_shutdown(struct im_zmq *z);
extern msgpack_object *im_zmq_fetch(struct im_zmq *z);
-extern int get_peaks_msgpack(msgpack_object *obj, struct image *image,
- int half_pixel_shift);
+extern ImageFeatureList *get_peaks_msgpack(msgpack_object *obj,
+ const DataTemplate *dtempl,
+ int half_pixel_shift);
extern int unpack_msgpack_data(msgpack_object *obj, struct image *image,
int no_image_data);
diff --git a/src/process_image.c b/src/process_image.c
index 34c0d0c5..a7640718 100644
--- a/src/process_image.c
+++ b/src/process_image.c
@@ -389,8 +389,9 @@ void process_image(const struct index_args *iargs, struct pattern_args *pargs,
break;
case PEAK_MSGPACK:
- get_peaks_msgpack(pargs->msgpack_obj, &image,
- iargs->half_pixel_shift);
+ image.features = get_peaks_msgpack(pargs->msgpack_obj,
+ iargs->dtempl,
+ iargs->half_pixel_shift);
break;
case PEAK_NONE: