Fixed the EdgeFlow Divergence computation Sign Error (#2096)

* Fixed the EdgeFlow Divergence computation Sign Error

* updated with definitions
This commit is contained in:
Titus
2017-10-20 16:17:32 +02:00
committed by Kirk Scheper
parent 679fcad03b
commit 7bbb52a203
3 changed files with 10 additions and 10 deletions
+1 -1
View File
@@ -62,7 +62,7 @@
<field name="flow_der_x" type="int16_t">The derotated flow calculation in the x direction (in subpixels)</field>
<field name="flow_der_y" type="int16_t">The derotated flow calculation in the y direction (in subpixels)</field>
<field name="quality" type="float"/>
<field name="size_divergence" type="float">Divergence as determined with the size method (in 1/seconds)</field>
<field name="size_divergence" type="float">Divergence as determined with the size method (in 1/seconds) with LK, and Divergence (1/seconds) itself with EF</field>
</message>
<message name="VELOCITY_ESTIMATE" id="12">
@@ -39,13 +39,14 @@ struct opticflow_result_t {
uint16_t corner_cnt; ///< The amount of coners found by FAST9
uint16_t tracked_cnt; ///< The amount of tracked corners
int16_t flow_x; ///< Flow in x direction from the camera (in subpixels)
int16_t flow_y; ///< Flow in y direction from the camera (in subpixels)
// Camera frame with the origin in the top left corner of the image
int16_t flow_x; ///< Flow in x direction from the camera (in subpixels) with X positive to the right
int16_t flow_y; ///< Flow in y direction from the camera (in subpixels) with Y positive to the bottom
int16_t flow_der_x; ///< The derotated flow calculation in the x direction (in subpixels)
int16_t flow_der_y; ///< The derotated flow calculation in the y direction (in subpixels)
struct FloatVect3 vel_cam; ///< The velocity in camera frame (m/s)
struct FloatVect3 vel_body; ///< The velocity in body frame (m/s)
struct FloatVect3 vel_body; ///< The velocity in body frame (m/s) with X positive to the front of the aircraft, Y positive to the right and Z positive downwards to the ground
float div_size; ///< Divergence as determined with the size_divergence script
@@ -680,8 +680,8 @@ bool calc_edgeflow_tot(struct opticflow_t *opticflow, struct image_t *img,
/* Save Resulting flow in results
* Warning: The flow detected here is different in sign
* and size, therefore this will be divided with
* the same subpixel factor and -1 to make it on par with
* the LK algorithm of t opticalflow_calculator.c
* the same subpixel factor and multiplied by -1 to make it
* on par with the LK algorithm in opticalflow_calculator.c
* */
edgeflow.flow_x = -1 * edgeflow.flow_x;
edgeflow.flow_y = -1 * edgeflow.flow_y;
@@ -697,9 +697,8 @@ bool calc_edgeflow_tot(struct opticflow_t *opticflow, struct image_t *img,
result->flow_der_y = result->flow_y;
result->corner_cnt = getAmountPeaks(edge_hist_x, 500 , img->w);
result->tracked_cnt = getAmountPeaks(edge_hist_x, 500 , img->w);
result->divergence = (float)edgeflow.div_x / RES;
result->div_size = 0.0f;
result->noise_measurement = 0.0f;
result->divergence = -1.0 * (float)edgeflow.div_x / RES; // Also multiply the divergence with -1.0 to make it on par with the LK algorithm of
result->div_size = result->divergence; // Fill the div_size with the divergence to atleast get some divergenge measurement when switching from LK to EF
result->surface_roughness = 0.0f;
//......................Calculating VELOCITY ..................... //
@@ -723,7 +722,7 @@ bool calc_edgeflow_tot(struct opticflow_t *opticflow, struct image_t *img,
// Calculate velocity
result->vel_cam.x = edgeflow.flow_x * fps_x * agl_dist_value_filtered * OPTICFLOW_FX / RES;
result->vel_cam.y = edgeflow.flow_y * fps_y * agl_dist_value_filtered * OPTICFLOW_FY / RES;
result->vel_cam.z = result->divergence * fps_y * agl_dist_value_filtered;
result->vel_cam.z = result->divergence * fps_x * agl_dist_value_filtered;
//Apply a median filter to the velocity if wanted
if (opticflow->median_filter == true) {