Skip to content

Commit

Permalink
i forgot to n++
Browse files Browse the repository at this point in the history
  • Loading branch information
imyxh committed Jun 6, 2024
1 parent 2c8a008 commit 145fc7c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions devices/center_of_mass.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ void com_mat_uchar(gsl_matrix_uchar *src, double *dst)

// This is nice and fast, but doesn't work for us, because we want to find the
// com of a slice of non-contiguous memory....
// TODO: actually, it seems like contiguous matrices are one of the most likely
// scenarios in practice, e.g. if we're reading from a camera. Consider
// switching to this at runtime!
// /** Hardcoded 8x8 center of mass task so the compiler can optimize it.
// * Will look at 64 uchars at src, and write the output as two doubles in dst
// * in (y,x) order. */
Expand Down Expand Up @@ -139,15 +142,15 @@ int center_of_mass_process(struct aylp_device *self, struct aylp_state *state)
size_t y_subap_count = max_y / data->region_height;
size_t x_subap_count = max_x / data->region_width;
size_t subap_count = y_subap_count * x_subap_count;
if (!subap_count) {
if (UNLIKELY(!subap_count)) {
log_error("Refusing to process zero subapertures; "
"region size is %llu by %llu but image is %llu by %llu",
data->region_height, data->region_width, max_y, max_x
);
return -1;
}
// allocate the com vector if needed
if (!data->com || data->com->size < subap_count*2) {
if (UNLIKELY(!data->com || data->com->size < subap_count*2)) {
xfree_type(gsl_vector, data->com);
data->com = xmalloc_type(gsl_vector, subap_count*2);
}
Expand All @@ -174,6 +177,7 @@ int center_of_mass_process(struct aylp_device *self, struct aylp_state *state)
+ 2*y/(s*(data->region_height-1));
data->com->data[2*n+1] = -1.0
+ 2*x/(s*(data->region_width-1));
n += 1;
}
}

Expand Down

0 comments on commit 145fc7c

Please sign in to comment.