当前位置: 首页>>代码示例>>C++>>正文


C++ idx类代码示例

本文整理汇总了C++中idx的典型用法代码示例。如果您正苦于以下问题:C++ idx类的具体用法?C++ idx怎么用?C++ idx使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了idx类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: idx_copy

 void jitter::set(const idx<t_jitter> &j) {
   s = j.get(0);
   h = (int) j.get(1);
   w = (int) j.get(2);
   r = j.get(3);
   idx_copy(j, jitts);
 }
开发者ID:2php,项目名称:eblearn,代码行数:7,代码来源:dataset.cpp

示例2: draw_layer

  unsigned int draw_layer(idx<float> &img, int dimn, int layern, const char *s,
			  unsigned int h, unsigned int w) {
#ifdef __GUI__
    idx<float> layer = img.select(dimn, layern);
    draw_matrix(layer, s, h, w, 1.0, 1.0, (float)-1.0, (float)1.0);
#endif
    return img.dim(1) + 3;
  }
开发者ID:athuls,项目名称:gsra,代码行数:8,代码来源:dataset_generation.cpp

示例3: tmp

  void matlab::read_cast_matrix(mxArray *var, idx<T> &m) {
#ifdef __MATLAB__
    // allocate a temporary matrix with same type as original matrix type
    idx<Tmatlab> tmp(m.get_idxdim());
    // load data
    void *data = mxGetData(var);
    // copy to idx 
    memcpy(m.idx_ptr(), (Tmatlab*) data, m.nelements() * sizeof (Tmatlab));
    // copy-cast
    idx_copy(tmp, m);
#endif
  }
开发者ID:athuls,项目名称:gsra,代码行数:12,代码来源:matlab.hpp

示例4: idx_clear

 void padder<T>::pad(idx<T> &in, idx<T> &out) {
   // allocate padded buffer
   idxdim d = in;
   d.setdim(1, d.dim(1) + nrow + nrow2);
   d.setdim(2, d.dim(2) + ncol + ncol2);
   if (out.get_idxdim() != d)
     out.resize(d);
   idx_clear(out);
   // copy in to padded buffer
   idx<T> tmp = out.narrow(1, in.dim(1), nrow);
   tmp = tmp.narrow(2, in.dim(2), ncol);
   idx_copy(in, tmp);
   if (bmirror)
     mirror(in, out);
 }
开发者ID:2php,项目名称:eblearn,代码行数:15,代码来源:padder.hpp

示例5: out

 idx<T> padder<T>::pad(idx<T> &in) {
   // allocate padded buffer
   idxdim d = in;
   d.setdim(1, d.dim(1) + nrow + nrow2);
   d.setdim(2, d.dim(2) + ncol + ncol2);
   idx<T> out(d);
   idx_clear(out);
   // copy in to padded buffer
   idx<T> tmp = out.narrow(1, in.dim(1), nrow);
   tmp = tmp.narrow(2, in.dim(2), ncol);
   idx_copy(in, tmp);
   if (bmirror)
     mirror(in, out);
   // return result
   return out;
 }
开发者ID:2php,项目名称:eblearn,代码行数:16,代码来源:padder.hpp

示例6: draw_layer

unsigned int draw_layer(idx<float> &layer, const char *s,
			unsigned int h, unsigned int w) {
#ifdef __GUI__
  draw_matrix(layer, s, h, w, 1.0, 1.0, (float)-1.0, (float)1.0);
#endif
  return layer.dim(1) + 3;
}
开发者ID:2php,项目名称:eblearn,代码行数:7,代码来源:dsdisplay.cpp

示例7: display_images

  // display original and new images.
  void display_images(idx<ubyte> &classes, int label, idx<float> &original,
		      idx<float> &new_images, const int channels_mode,
		      idx<ubyte> &ds_names, int current_ds) {
#ifdef __GUI__
    unsigned int h = 0, w = 0;
    static unsigned int cnt = 0;
    idx<float> layer;

    // only display every 15 images
    if (cnt++ % 15 != 0) return ;
    
    // reset window and do a batch display
    disable_window_updates();
    clear_window();
    
    // original image (RGB)
    static string s;
    s = "RGB"; s += " - "; s += (char *) classes[label].idx_ptr();
    draw_matrix(original, s.c_str(), h, w);
    w = 0; h += new_images.dim(1) + 5;
    gui << at(h, w) << black_on_white();
    gui << ds_names[current_ds].idx_ptr() << " dataset:";
    h += 15;
    
    // new images
    idx_bloop1(image, new_images, float) {
      switch (channels_mode) {
      case 1: // YpUV
	w += draw_layer(image, 2, 0, "Yp", h, w);
	w += draw_layer(image, 2, 1, "U", h, w);
	w += draw_layer(image, 2, 2, "V", h, w);
	break ;
      case 3: // Yp
	w += draw_layer(image, 2, 0, "Yp", h, w);
	break ;
      case 4: { // YpH3
	w += draw_layer(image, 2, 0, "Yp", h, w);
	w += draw_layer(image, 2, 1, "H3", h, w);
	idx_addc(layer, (float)1.0, layer);
	idx_dotc(layer, (float)210.0, layer);
	w += layer.dim(1) + 5;
	static idx<float> rgb(layer.dim(0), layer.dim(1), 3);
	h3_to_rgb(layer, rgb);
	draw_matrix(rgb, "H3 (colored)", h, w);
	break ;
      }
      case 5: // VpH2SV
	w += draw_layer(image, 2, 0, "Vp", h, w);
	w += draw_layer(image, 2, 1, "H1", h, w);
	w += draw_layer(image, 2, 2, "H2", h, w);
	w += draw_layer(image, 2, 3, "S", h, w);
	w += draw_layer(image, 2, 4, "V", h, w);
	w = 0; h += image.dim(1) + 5;
	break ;
      }
    }
    enable_window_updates();
#endif
  }
开发者ID:athuls,项目名称:gsra,代码行数:60,代码来源:dataset_generation.cpp

示例8: image_region_to_rect

idx<T> image_region_to_rect(idx<T> &im, const rect<int> &r, uint oheight,
                            uint owidth, rect<int> *cropped,
                            uint dh, uint dw)
{
    // TODO: check that rectangle is within image
    if (im.order() != 2 && im.order() != 3)
        eblerror("expected a 2d or 3d input but got " << im);
    idxdim d(im);
    d.setdim(dh, oheight);
    d.setdim(dw, owidth);
    idx<T> res(d);

    float hcenter = r.h0 + (float)r.height / 2; // input height center
    float wcenter = r.w0 + (float)r.width / 2; // input width center
    // // limit centers to half the width/height away from borders
    // // to handle incorrect regions
    // hcenter = MIN((float)im.dim(dh) - (float)r.height/2,
    //            std::max((float)r.height/2, hcenter));
    // wcenter = MIN((float)im.dim(dw) - (float)r.width/2,
    //            std::max((float)r.width/2, wcenter));
    float h0 = hcenter - (float)oheight / 2; // out height offset in input
    float w0 = wcenter - (float)owidth / 2; // out width offset in input
    float h1 = hcenter + (float)oheight / 2;
    float w1 = wcenter + (float)owidth / 2;
    int gh0 = (int)std::max(0, (int)MIN(im.dim(dh), h0)); // input h offset
    int gw0 = (int)std::max(0, (int)MIN(im.dim(dw), w0)); // input w offset
    int gh1 = (int)std::max(0, (int)MIN(im.dim(dh), h1));
    int gw1 = (int)std::max(0, (int)MIN(im.dim(dw), w1));
    int h = gh1 - gh0 + std::max(0, -r.h0); // out height narrow
    int w = gw1 - gw0 + std::max(0, -r.w0); // out width narrow
    int fh0 = (int)std::max(0, (int)(gh0 - h0)); // out height offset narrow
    int fw0 = (int)std::max(0, (int)(gw0 - w0)); // out width offset narrow

    // narrow original image
    int hmin = std::max(0, std::min((int)res.dim(dh) - fh0,
                                    std::min((int)im.dim(dh) - gh0, h)));
    int wmin = std::max(0, std::min((int)res.dim(dw) - fw0,
                                    std::min((int)im.dim(dw) - gw0, w)));
    // clear result image
    idx_clear(res);
    if (hmin != 0 && wmin != 0)  // only copy if overlap with image
    {
        idx<T> tmpim = im.narrow(dh, hmin, gh0);
        tmpim = tmpim.narrow(dw, wmin, gw0);
        // narrow target image
        idx<T> tmpres = res.narrow(dh, hmin, fh0);
        tmpres = tmpres.narrow(dw, wmin, fw0);
        // copy original to target
        idx_copy(tmpim, tmpres);
    }
    // set cropped rectangle to region in the output image containing input
    if (cropped)
    {
        cropped->h0 = fh0;
        cropped->w0 = fw0;
        cropped->height = hmin;
        cropped->width = wmin;
    }
    return res;
}
开发者ID:1292765944,项目名称:MobileDemo,代码行数:60,代码来源:padder.hpp

示例9: serialize

    void serialize(Archive & ar, idx<ubyte>& mat, const unsigned int version) {
      intg d1, d2, d3;
      if (Archive::is_saving::value) { // saving to stream
	if (!mat.contiguousp())
	  eblerror("expected contiguous idx for serialization");
	if (mat.order() != 3)
	  eblerror("no support for idx order != 3 for now, got: " << mat);

	d1 = mat.dim(0); 
	d2 = mat.dim(1); 
	d3 = mat.dim(2); 
	
	ar & d1;
	ar & d2;
	ar & d3;
	idx_aloop1(m, mat, ubyte) {
	  ar & *m;
	}
      } else { // loading from stream
开发者ID:athuls,项目名称:gsra,代码行数:19,代码来源:mpidetect.cpp

示例10: eblerror

idxlooper<T>::idxlooper(idx<T> &m, int ld) : idx<T>((dummyt*)0) {
  if (m.order() == 0) // TODO: allow looping once on 0-order idx
    eblerror("cannot loop on idx with order 0. idx is: " << m);
  i = 0;
  dimd = m.spec.dim[ld];
  modd = m.spec.mod[ld];
  m.spec.select_into(&(this->spec), ld, i);
  this->storage = m.storage;
  this->storage->lock();
}
开发者ID:2php,项目名称:eblearn,代码行数:10,代码来源:idxiter.hpp

示例11: if

bool detection_thread<T>::set_data(idx<ubyte> &frame2,
                                   std::string &fullname,
                                   std::string &name, uint id) {
  // lock data (non blocking)
  if (!mutex_in.trylock())
    return false;
  // check frame is correctly allocated, if not, allocate.
  if (frame2.order() != uframe.order())
    uframe = idx<ubyte>(frame2.get_idxdim());
  else if (frame2.get_idxdim() != uframe.get_idxdim())
    uframe.resize(frame2.get_idxdim());
  idx_copy(frame2, uframe);	// copy frame
  frame_loaded = true;        // frame is loaded
  frame_fullname = fullname;
  frame_name = name;		// copy name
  frame_id   = id;		// copy frame_id
  in_updated = true;		// reset updated flag
  bavailable = false;		// declare thread as not available
  bfed       = true;		// data has been fed at least once
  mutex_in.unlock();		// unlock data
  return true;		// confirm that we copied data.
}
开发者ID:2php,项目名称:eblearn,代码行数:22,代码来源:detection_thread.hpp

示例12: image_paste_center

 void image_paste_center(idx<T> &in, idx<T> &out) {
   if (in.order() != 3 || out.order() != 3)
     eblerror("expected 3d idx but got " << in << " and " << out);
   int d0 = 1;
   int d1 = d0 + 1;
   intg ci = in.dim(d0) - out.dim(d0);
   intg cj = in.dim(d1) - out.dim(d1);
   intg xci = (int) (ci / 2);
   intg xcj = (int) (cj / 2);
   idx<T> i = in.narrow(d0, out.dim(d0), xci);
   i = i.narrow(d1, out.dim(d1), xcj);
   idx_copy(i, out);
 }
开发者ID:2php,项目名称:eblearn,代码行数:13,代码来源:padder.hpp

示例13: make_pairs

  //! Return an idx of dimensions Nx2 containing all possible N similar pairs.
  idx<int> make_pairs(idx<int> &labels) {
    // allocate maximum number of pairs
    idx<int> pairs((labels.dim(0) * (labels.dim(0) - 1)) / 2, 2);
    int n = 0, r = 0;
    // for each label, loop over all following labels to find pairs
    for (int i = 0; i < labels.dim(0) - 1; ++i) {
      for (int j = i + 1; j < labels.dim(0); ++j) {
	if (labels.get(i) == labels.get(j)) {
	  r = drand(0.0, 1.0); // randomize distribution as 1st or 2nd element
	  pairs.set(i, n, (r > 0.5) ? 0 : 1);
	  pairs.set(j, n, (r > 0.5) ? 1 : 0);
	  n++;
	}
      }
    }
    pairs.resize(n, pairs.dim(1));
    return pairs;
  }
开发者ID:athuls,项目名称:gsra,代码行数:19,代码来源:dataset_generation.cpp

示例14: pthread_mutex_lock

  bool tracking_thread<Tnet>::get_data(vector<bbox*> &bboxes2,
				       idx<ubyte> &frame2, idx<ubyte> &tpl2) {
    // lock data
    pthread_mutex_lock(&mutex_out);
    // only read data if it has been updated
    if (!out_updated) {
      // unlock data
      pthread_mutex_unlock(&mutex_out);
      return false;
    }
    // clear bboxes
    for (ibox = bboxes2.begin(); ibox != bboxes2.end(); ++ibox) {
      if (*ibox)
	delete *ibox;
    }
    bboxes2.clear();
    // copy bboxes pointers (now responsible for deleting them).
    for (ibox = bboxes.begin(); ibox != bboxes.end(); ++ibox) {
      bboxes2.push_back(*ibox);
    }
    // check frame is correctly allocated, if not, allocate.
    if (frame2.order() != frame.order()) 
      frame2 = idx<ubyte>(frame.get_idxdim());
    else if (frame2.get_idxdim() != frame.get_idxdim())
      frame2.resize(frame.get_idxdim());
    // copy frame
    idx_copy(frame, frame2);    
    // check tpl is correctly allocated, if not, allocate.
    if (tpl2.order() != tpl.order()) 
      tpl2 = idx<ubyte>(tpl.get_idxdim());
    else if (tpl2.get_idxdim() != tpl.get_idxdim())
      tpl2.resize(tpl.get_idxdim());
    // copy tpl
    idx_copy(tpl, tpl2);    
    // reset updated flag
    out_updated = false; 
    // unlock data
    pthread_mutex_unlock(&mutex_out);
    // confirm that we copied data.
    return true;
  }
开发者ID:athuls,项目名称:gsra,代码行数:41,代码来源:tracking_thread.hpp

示例15: read_cast_matrix

 void read_cast_matrix(FILE *fp, idx<T2> &out) {
   idx<T> m(out.get_idxdim());
   read_matrix_body(fp, m);
   idx_copy(m, out);
 }
开发者ID:athuls,项目名称:gsra,代码行数:5,代码来源:idxIO.hpp


注:本文中的idx类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。