コード例 #1
0
ファイル: motiondetect.c プロジェクト: mojaves-forks/vid.stab
int initMotionDetect(MotionDetect* md, const DSFrameInfo* fi,
                     const char* modName) {
  assert(md && fi);
  md->fi = *fi;
  md->modName = modName;

  md->prev = ds_zalloc(md->fi.framesize);
  if (!md->prev) {
    ds_log_error(md->modName, "malloc failed");
    return DS_ERROR;
  }
  md->curr     = 0;
  md->currorig = 0;
  md->currtmp  = 0;
  md->hasSeenOneFrame = 0;

  // Options
  md->stepSize  = 6;
  md->allowMax  = 0;
  md->algo      = 1;
  md->accuracy  = 5;
  md->shakiness = 5;
  md->fieldSize = DS_MIN(md->fi.width, md->fi.height) / 12;
  md->show = 0;
  md->contrastThreshold = 0.25;
  md->maxAngleVariation = 1;
  md->initialized = 1;
  return DS_OK;
}
コード例 #2
0
ファイル: motiondetect.c プロジェクト: mojaves-forks/vid.stab
/** initialise measurement fields on the frame.
    The size of the fields and the maxshift is used to
    calculate an optimal distribution in the frame.
*/
int initFields(MotionDetect* md) {
  int size = md->fieldSize;
  int rows = DS_MAX(3,(md->fi.height - md->maxShift*2)/size-1);
  int cols = DS_MAX(3,(md->fi.width - md->maxShift*2)/size-1);
  // make sure that the remaining rows have the same length
  md->fieldNum = rows * cols;
  md->fieldRows = rows;
  // ds_log_msg(md->modName, "field setup: rows: %i cols: %i Total: %i fields",
  //            rows, cols, md->field_num);

  if (!(md->fields = (Field*) malloc(sizeof(Field) * md->fieldNum))) {
    ds_log_error(md->modName, "malloc failed!\n");
    return 0;
  } else {
    int i, j;
    // the border is the amount by which the field centers
    // have to be away from the image boundary
    // (stepsize is added in case shift is increased through stepsize)
    int border = size / 2 + md->maxShift + md->stepSize;
    int step_x = (md->fi.width - 2 * border) / DS_MAX(cols-1,1);
    int step_y = (md->fi.height - 2 * border) / DS_MAX(rows-1,1);
    for (j = 0; j < rows; j++) {
      for (i = 0; i < cols; i++) {
        int idx = j * cols + i;
        md->fields[idx].x = border + i * step_x;
        md->fields[idx].y = border + j * step_y;
        md->fields[idx].size = size;
      }
    }
  }
  return 1;
}
コード例 #3
0
ファイル: main.c プロジェクト: dynastysea/dslog
int main()
{   
    int errno;
    pthread_t tid;
    int a = 0;

    errno = pthread_create(&tid, NULL, print_test, NULL);
    if (0 != errno)
    {
        ds_log_error("thread create failed");
    }

    ds_log_error("a=%d, str=%s", a, "main thread");    

    return 0;
}
コード例 #4
0
ファイル: main.c プロジェクト: dynastysea/dslog
void *print_test1(void *args)
{
    ds_log_error("thread1 print");
    return ((void *)0);
}