VideoSurveillance::VideoSurveillance(Configuration &conf) :
    Job("Video Surveillance") {
    LOG(INFO) << "VideoSurveillance start constructor";

    camera_attribute = conf.getCameraAttribute();
    image_processor_attribute = conf.getImageProcessorAttribute();

    auto tmp_ipa = image_processor_attribute->getImageProcessorAttributeVector();

    // TODO: make easy check multimedia recorder is available, need complex processor check again
    is_multimedia_recorder = false;

    //LOG(INFO) << "hello for";

    for(auto &it : tmp_ipa) {
        if(it->getName() == "Multimedia Recorder")
            is_multimedia_recorder = true;
    }
    if(!is_multimedia_recorder) {
        //std::cout << "in constructure " << std::endl;
        CameraFactory cf;

        this->camera = cf.getCamera(camera_attribute);
        this->image_acquisition = std::make_shared<ImageAcquisition>(*camera,
                                  image_processor_attribute->getImageProcessorAttributeVector().size());
    }



    ImageProcessorFactory ipf(camera_attribute);

    if(!is_multimedia_recorder) {
        this->image_processor_pool = ipf.getImageProcessorPool(
                                         image_processor_attribute,
                                         *this->image_acquisition->getOutputImageQueue());
    }
    else {
        MultipleImageQueue miq(1);
        this->image_processor_pool = ipf.getImageProcessorPool(
                                         image_processor_attribute,
                                         miq);
    }

}
Exemplo n.º 2
0
int main(int argc, char** argv) {
  try {
    RMF_ADD_INPUT_FILE("rmf");
    RMF_ADD_OUTPUT_FILE("pdb");
    RMF_ADD_FRAMES;
    process_options(argc, argv);

    RMF::FileConstHandle rh = RMF::open_rmf_file_read_only(input);
    std::ostream* out;
    std::ofstream fout;
    if (!output.empty()) {
      fout.open(output.c_str());
      if (!fout) {
        std::cerr << "Error opening file " << output << std::endl;
        return 1;
      }
      out = &fout;
    } else {
      out = &std::cout;
    }
    RMF::decorator::IntermediateParticleFactory ipf(rh);
    RMF::decorator::AtomFactory af(rh);
    RMF::decorator::ChainFactory cf(rh);
    RMF::decorator::ResidueFactory rf(rh);
    RMF::NodeConstHandle rn = rh.get_root_node();
    for (unsigned int input_frame = start_frame, output_frame = 0;
         input_frame < rh.get_number_of_frames();
         input_frame += step_frame, ++output_frame) {
      rh.set_current_frame(RMF::FrameID(input_frame));
      *out << (boost::format("MODEL%1$9d") % (output_frame + 1)) << std::endl;
      write_atoms(*out, 0, rn, ipf, af, cf, rf);
      *out << "ENDMDL" << output_frame + 1 << std::endl;
    }
    return 0;
  }
  catch (const std::exception& e) {
    std::cerr << "Error: " << e.what() << std::endl;
  }
}
Exemplo n.º 3
0
int emhap(const int nsnp, const int *gtable, const int *htable, 
	  GTYPE *gtypes, const int maxit, const double tol,
	  double *hprob, const int nllm, const unsigned int *llm){

  GTYPE *lookup;

  /* Minimum number of EM steps before warning messages */

  int minit = 3;
  
  /* IPF control */

  const int ipfsteps = 10; /* Max number of IPF steps in each EM step */
  const double ipfeps = 0.001; /* IPF criterion (relative change in expected) */

  /* If lookup table not supplied, create one */
  
  if(gtypes) 
    lookup = gtypes;
  else
    lookup = create_gtype_table(nsnp);


  /* Table sizes */

  int ngt = (1 << (2*nsnp));
  int nht = (1 << nsnp);


  /* Count of haplotypes  */

  int npu = 0, npk = 0;
  for (int i=1; i<ngt; i++) {
    npu += gtable[i];
    if (htable)
      npk += htable[i];
  }
  npu *= 2;

  double total = npu + npk;
  if (!total) 
    return -1;

  /* Maximum number of possible haplotype assignments */

  int maxhaps = (1 << 2*(nsnp - 1));

  /* Work arrays */
  
  double *sum = (double *)Calloc(nht, double);
  double *prg = (double *)Calloc(maxhaps, double);
  double *prh = NULL;
  if (htable)
    prh = (double *)Calloc(maxhaps, double);

  /* If no starting values, initialize haplotype frequency vector */

  if (hprob[0]<0.0) {
    double maxp = 1.0/ (double)nht; 
    for (int i=0; i<nht; i++)
      hprob[i] = maxp;
  }

  /* EM algorithm */

  int it = 0, result = 0;
  double logL_prev = 0.0;
  while(1) {
    memset(sum, 0x00, nht*sizeof(double));
    double logL = 0.0;
    for (int i=1; i<ngt; i++) {
      int gti = gtable[i];
      int hti = htable? htable[i]: 0;
      if (gti || hti) {
	double psumg = 0.0, psumh = 0.0;
	GTYPE *lupi = lookup + i - 1;
	int nph = lupi->nphase;

	/* Posterior probabilities */

	for (int j=0, jj=0; j<nph; j++) {
	  int h1 = lupi->haps[jj++];
	  int h2 = lupi->haps[jj++];
	  if (gti) {
	    double p = hprob[h1]*hprob[h2];
	    if (h1!=h2)
	      p *= 2;
	    prg[j] = p;
	    psumg += p;
	  }
	  if (hti && (h1==h2)) { /* Males are coded as homozygous on X */
	    double p = hprob[h1];
	    prh[j] = p;
	    psumh += p;
	  }
	}
	if (gti)
	  logL += gti*log(psumg);
	if (hti)
	  logL += hti*log(psumh);

	/* Increment haplotype table with expected frequencies */
	
	double fgi = psumg? gtable[i]/psumg: 0.0;
	double fhi = psumh? htable[i]/psumh: 0.0;
	if (fgi || fhi) {
	  for (int j=0, jj=0; j<nph; j++){
	    int h1 = lupi->haps[jj++];
	    int h2 = lupi->haps[jj++];
	    if (fgi) {
	      double fij = fgi*prg[j];
	      sum[h1] += fij;
	      sum[h2] += fij;
	    }
	    if (fhi && (h1==h2)) {
	      double fij = fhi*prh[j];
	      sum[h1] += fij;
	    }
	  }
	}
      }
    }

    /* New estimates of haplotype frequencies */

    int ipfault = 0;
    if (nllm) { /* Log-linear smoothing model */
      for (int i=0; i<nht; i++) {
	sum[i] /= total;
	/* do ipfsteps of IPF algorithm */
	ipfault = ipf(nsnp, sum, nllm, llm, hprob, ipfsteps, ipfeps);
      }
    }
    else { /* Saturated model */
      for (int i=0; i<nht; i++) 
      hprob[i] = sum[i]/total;
    }

    /* Convergence test */

    double ctest = logL - logL_prev;
    logL_prev = logL;
    if (it++) {
      if (it>minit && ctest<0.0) {
	warning("Log likelihood decreased in EM algorithm at iteration %d", it);
	result = -2;
	break;
      }
      else if (it>maxit) {
	result = 1;
	break;
      }
      else if (ctest < tol) {
	break;
      }
    }
  }

  /* Return work arrays */

  if(!gtypes)
    destroy_gtype_table(lookup, nsnp);
  Free(sum);
  Free(prg);
  if (prh)
    Free(prh);

  return result;
}