int PhotoViewer::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: showList(); break; case 1: showFlow(); break; case 2: showFileInfo(); break; case 3: showImage(); break; } _id -= 4; } return _id; }
void my_plugin_run(unsigned char *frame) { short threshold_n_points = 25; int tot_x=0; int tot_y=0; int x_avg = 0; int y_avg = 0; //magical scaling needed in order to calibrate opt flow angles to imu angles short scalex = 1024; //1024*(1/0.75) short scaley = 1024; //1024*(1/0.76) int i; if(old_img_init == 1) { memcpy(prev_frame,frame,imgHeight*imgWidth*2); old_img_init = 0; } // *********************************************************************************************************************** // (1) possibly find new points - keeping possible old ones (normal cv methods / efficient point finding / active corners) // *********************************************************************************************************************** if(ALWAYS_NEW_POINTS) { // Clear corners memset(flow_points,0,sizeof(flowPoint)*flow_point_size); findPoints(gray_frame, frame, imgWidth, imgHeight, &count, max_count, MAX_COUNT, flow_points, &flow_point_size, detected_points); } else { if(flow_point_size < threshold_n_points) { findPoints(gray_frame, frame, imgWidth, imgHeight, &count, max_count, MAX_COUNT, flow_points, &flow_point_size, detected_points); } } // ********************************************************************************************************************** // (2) track the points to the new image, possibly using external information (TTC, known lateral / rotational movements) // ********************************************************************************************************************** if(count) { trackPoints(frame, prev_frame, imgWidth, imgHeight, &count, max_count, MAX_COUNT, flow_points, &flow_point_size, detected_points, x, y, new_x, new_y, dx, dy, status); //showFlow(frame, x, y, status, count, new_x, new_y, imgWidth, imgHeight); for (i=0; i<count;i++) { // dx[i] = (new_x[i]-x[i]); // dy[i] = (new_y[i]-y[i]); dx[i] = flow_points[i].dx; dy[i] = flow_points[i].dy; tot_x = tot_x + dx[i]; tot_y = tot_y + dy[i]; } // using moving average to filter out the noise if(count) { x_buf[buf_point] = (tot_x*scalex)/count; y_buf[buf_point] = (tot_y*scaley)/count; buf_point = (buf_point+1) %5; } for (i=0;i<5;i++) { x_avg+=x_buf[i]; y_avg+=y_buf[i]; } //raw optic flow (for telemetry purpose) opt_angle_x_raw = x_avg; opt_angle_y_raw = y_avg; //tele purpose //int diff_roll, diff_pitch, mean_alt; //float mean_tti, median_tti, d_heading, d_pitch, pu[3], pv[3], divergence_error; /*int USE_FITTING = 0; if(USE_FITTING == 1) { analyseTTI(&divergence, x, y, dx, dy, n_inlier_minu, n_inlier_minv, count, imgWidth, imgHeight); }*/ memcpy(prev_frame,frame,imgHeight*imgWidth*2); showFlow(frame, x, y, status, count, new_x, new_y, imgWidth, imgHeight); //DOWNLINK_SEND_OPTIC_FLOW(DefaultChannel, DefaultDevice, &FPS, &opt_angle_x_raw, &opt_angle_y_raw, &opt_trans_x, &opt_trans_y, &diff_roll, &diff_pitch, &mean_alt, &count, &count, &divergence, &mean_tti, &median_tti, &d_heading, &d_pitch, &pu[2], &pv[2], &divergence_error, n_inlier_minu, n_inlier_minv); } //DOWNLINK_SEND_OF_ERROR(DefaultChannel, DefaultDevice, &error_corner, &error_opticflow); // Send to paparazzi //gst2ppz.ID = 0x0001; //gst2ppz.counter++; // to keep track of data through ppz communication }