diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/im-zmq.c | 33 | ||||
-rw-r--r-- | src/im-zmq.h | 5 | ||||
-rw-r--r-- | src/process_image.c | 5 |
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: |