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


C++ channel类代码示例

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


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

示例1: setStatusString

  /*
   * compute the second and up iterations of a probability map
   * using the given aPriori probabilites per pixel.
   */
  bool probabilityMap2D::computeMap(const channel8& src1, const channel8& src2,
				    channel& aPrioriDest) const {
 
    point chnl1_size = src1.size();
    point chnl2_size = src2.size();
      
      // size of src1 equals src2 ?
    if ( (chnl1_size.x != chnl2_size.x) || (chnl1_size.y != chnl2_size.y) ) {
      setStatusString("probabilityMap2D: channels do not match");
      return false;

    } else {
      int y;
      vector<channel8::value_type>::const_iterator srcIterator1, eit1;
      vector<channel8::value_type>::const_iterator srcIterator2, eit2;
      vector<channel::value_type>::iterator destIterator;
 
      const parameters& param = getParameters();
      const thistogram<double>& objModel = param.getObjectColorModel();
      const thistogram<double>& nonObjModel = param.getNonObjectColorModel();
      
      float relObjProb;
      float relNonObjProb;
      
      ivector theBin(2);
      
      for (y=0;y<src1.rows();++y) {
	srcIterator1 = src1.getRow(y).begin();
	eit1 = src1.getRow(y).end();
	srcIterator2 = src2.getRow(y).begin();
	eit2 = src2.getRow(y).end();

	destIterator = aPrioriDest.getRow(y).begin();

	while (srcIterator1 != eit1) {
	  theBin[0] = lookupTable[0][*srcIterator1];
	  theBin[1] = lookupTable[1][*srcIterator2];
	  
	  relObjProb = static_cast<float>(objModel.getProbability(theBin) *
					  (*destIterator));
	  relNonObjProb = static_cast<float>(nonObjModel.getProbability(theBin)*
					     (1.0f-(*destIterator)));

	  // assume non-object if no entries are given
	  if ((relObjProb == 0.0f) && (relNonObjProb == 0.0f)) {
	    (*destIterator) = 0.0f;
	  } else {
	    // bayes
	    (*destIterator) = relObjProb / (relObjProb + relNonObjProb);
	  }

	  srcIterator1++;
	  srcIterator2++;
	  destIterator++;
	}
      }
    }
    
    return true;
  }
开发者ID:mvancompernolle,项目名称:ai_project,代码行数:64,代码来源:ltiProbabilityMap2D.cpp

示例2: FD_SET

void selector::add_channel(const channel & ch,
                           bool allow_outgoing_traffic, bool allow_incoming_traffic)
{
    io_descriptor_type fd;
    io_direction direction;

    ch.get_io_descriptor(fd, direction);

    if (fd > num_of_descriptors_to_test_ - 1)
    {
        num_of_descriptors_to_test_ = fd + 1;
    }

    if ((direction == input || direction == inout) && allow_incoming_traffic)
    {
        FD_SET(fd, &read_set_);
    }

    if ((direction == output || direction == inout) && allow_outgoing_traffic)
    {
        FD_SET(fd, &write_set_);
    }

    ++num_of_channels_used_;
}
开发者ID:morambro,项目名称:TrainProject,代码行数:25,代码来源:selector.cpp

示例3: get_randoms

void get_randoms(int amount, channel<int>& c) {
	int total = 0;
	for (int i=0; i<amount-1; i++) {
		total += c.recv();
	}
	std::cout << "[" << std::this_thread::get_id() << "] total is " << total << "\n";
}
开发者ID:evertheylen,项目名称:SpaceInvaders,代码行数:7,代码来源:main.cpp

示例4: sedFiltering

  void distanceTransform::sedFiltering(channel &chnl, 
                                        bool useEightSED) const {

    const float fv  = 0.0f;
    const int undef = -2;

    matrix<point> dist(chnl.size());

    int row, 
        col;

    //init
    for(row = 0; row < chnl.rows(); ++row){
      for(col = 0; col < chnl.columns(); ++col){
        if(chnl.at(row, col) == fv)
          dist.at(row, col) = point(0, 0);
        else
          dist.at(row, col) = point(undef, undef);
      }
    }

    if(useEightSED) 
      eightSEDFiltering(chnl, dist);
    else            
      fourSEDFiltering(chnl, dist);

    //set the distances 
    for(row = 0; row < chnl.rows(); ++row)
      for(col = 0; col < chnl.columns(); ++col)
        chnl.at(row, col) = static_cast<float>(dist.at(row, col).distanceSqr(point(0,0)));
  }
开发者ID:mvancompernolle,项目名称:ai_project,代码行数:31,代码来源:ltiDistanceTransform.cpp

示例5: send_as

void send_as(const actor& from, message_priority prio,
             const channel& to, Ts&&... xs) {
  if (! to) {
    return;
  }
  message_id mid;
  to->enqueue(from.address(),
              prio == message_priority::high ? mid.with_high_priority() : mid,
              make_message(std::forward<Ts>(xs)...), nullptr);
}
开发者ID:Neverlord,项目名称:boost.actor,代码行数:10,代码来源:send.hpp

示例6: apply

  bool hessianFunctor::apply(const channel& src,
                             channel& xx, channel& xy, channel& yy) const {

    bool rc = true;

    const parameters& param = getParameters();
    
    switch (param.kernelType) {
      
      case parameters::Classic:
        //call specialized member functions
        return classicHessian(src,xx,xy,yy);
        break;

      case parameters::Hessian:
        //call spezialized member function for XY
        rc = rc && convXX.apply(src,xx);
        rc = rc && classicXY(src,xy);
        rc = rc && convYY.apply(src,yy);
        break;

      default:
        // not nice but faster than putting all possibilities
        // after all this has been checked in setParameters()
        rc = rc && convXX.apply(src,xx);
        rc = rc && convXY.apply(src,xy);
        rc = rc && convYY.apply(src,yy);
        break;
    }

    if (!rc) {
      xx.clear();
      xy.clear();
      yy.clear();
      appendStatusString(convXX);
      appendStatusString(convXY);
      appendStatusString(convYY);
    }

    return rc;

  };
开发者ID:mvancompernolle,项目名称:ai_project,代码行数:42,代码来源:ltiHessianFunctor.cpp

示例7: send_tuple

void local_actor::send_tuple(message_priority prio, const channel& dest,
                             message what) {
  if (!dest) {
    return;
  }
  message_id id;
  if (prio == message_priority::high) {
    id = id.with_high_priority();
  }
  dest->enqueue(address(), id, std::move(what), host());
}
开发者ID:ariosx,项目名称:actor-framework,代码行数:11,代码来源:local_actor.cpp

示例8: getParameters

  /*
   * compute the second order.
   */
  bool harrisCorners::getSecondOrder(channel& gx,
                                     channel& gy,
                                     channel& fxy) const {

    const parameters& par = getParameters();

    fxy.resize(gx.size(),false,false);
    gaussKernel2D<float> gk(par.kernelSize,par.variance);
    convolution filter;
    convolution::parameters filterPar;
    filterPar.boundaryType = lti::Constant;
    filterPar.setKernel(gk);
    filter.setParameters(filterPar);

    channel::iterator igx=gx.begin();
    channel::iterator igxend=gx.end();
    channel::iterator igy=gy.begin();
    channel::iterator ifxy=fxy.begin();
    float tx, ty;

    while (igx!=igxend) {
      tx=(*igx);
      ty=(*igy);
      (*igx)=tx*tx;
      (*igy)=ty*ty;
      (*ifxy)=tx*ty;
      ++igx; ++igy; ++ifxy;
    }

    return (filter.apply(gx) && filter.apply(gy) && filter.apply(fxy));
  }
开发者ID:mvancompernolle,项目名称:ai_project,代码行数:34,代码来源:ltiHarrisCorners.cpp

示例9: if

  void distanceTransform::EDT_1D(channel& chnl) const {

    const float undef = -1.0f;  //means any undefined value (distance or pos)
    
    //remember: all foreground pixel are >  0.0f
    //          all background pixel are == 0.0f
    for(int y = 0; y < chnl.rows(); ++y){
      int x, pos = static_cast<int>(undef);
      //first step: forward propagation
      for(x = 0; x < chnl.columns(); ++x){
        if(chnl.at(y, x) == 0.0f){
          //found background pixel
          //now 0.0 means distance to closest background pixel
          pos = x; 
        }
        else if(pos >= 0){
          int tmp = pos - x;
          chnl.at(y, x) = static_cast<float>(tmp * tmp);
        }
        else
          chnl.at(y, x) = undef;
      }
    
      //no background pixel in row => all pixel are set to undef;
      //continue with next row
      if(pos == undef) continue;
      else{
        pos = static_cast<int>(undef);
        for(x = chnl.columns() - 1; x >= 0; --x){
          if(chnl.at(y, x) == 0){
            pos = x; //found fv
          }
          else if(pos != undef){
            int tmp = pos - x;
            tmp *=tmp;
            int ret = static_cast<int>(chnl.at(y, x));
            if(ret > tmp || ret == undef){
              chnl.at(y, x) = static_cast<float>(tmp);
            }
          }
        }
      }
    }
  }
开发者ID:mvancompernolle,项目名称:ai_project,代码行数:44,代码来源:ltiDistanceTransform.cpp

示例10: g

 void distanceTransform::voronoiEDT_2D(channel& chnl, const int j) const {
   int l = -1,
       fi;
   vector<int> g(chnl.rows()),
               h(chnl.rows());
   int x0 = j,
       x1;
 
   for(x1 = 0; x1 < chnl.rows(); ++x1){
     fi = static_cast<int>(chnl.at(x1, x0));
     if(fi >= 0.0f){  //any value below zero is undefined
       while(   l >= 1 
             && removeEDT(g.at(l - 1), g.at(l), fi, h.at(l - 1), h.at(l), x1))
         --l;
       ++l; g.at(l) = fi; h.at(l) = x1;
     }
   }
   if(l == -1) return;
   int ns = l;
   l = 0;
   for(x1 = 0; x1 < chnl.rows(); ++x1){
     int tmp0 = h.at(l) - x1,
         tmp1 = g.at(l) + tmp0 * tmp0,
         tmp2;
   
     while(true){
       if(l < ns){
         tmp2 = (h.at(l + 1) - x1);
         if(tmp1 > g.at(l + 1) + tmp2 * tmp2){
           ++l;
           tmp0 = h.at(l) - x1;
           tmp1 = g.at(l) + tmp0 * tmp0;
         }else break;
       }else break;
     }
       
     chnl.at(x1, x0) = static_cast<float>(tmp1);
   }
 }
开发者ID:mvancompernolle,项目名称:ai_project,代码行数:39,代码来源:ltiDistanceTransform.cpp

示例11: segment

 bool cwagmSegmentationEvaluation::segment(const image& img,
                                           const imatrix& prevMask,
                                           imatrix& mask,
                                           channel& certainty) {
   ivector sizes;
   if (!segmenter.apply(img,mask,sizes)) {
     _lti_debug("Error in segmenter: " << segmenter.getStatusString() <<
                std::endl);
     setStatusString(segmenter.getStatusString());
     return false;
   }
   certainty.clear(); // no certainty computation in this kind of functors.
   return true;
 }
开发者ID:mvancompernolle,项目名称:ai_project,代码行数:14,代码来源:ltiCWAGMSegmentationEvaluation.cpp

示例12: findCornerMaxima

  /*
   * find corners with maximal cornerness
   */
  bool harrisCorners::findCornerMaxima(const channel& cornerness,
                                             channel& cornersOnly,
                                             pointList& cornerMax) const {
    if (cornerness.empty()) {
      cornersOnly.clear();
      cornerMax.clear();
      return true;
    }

    const parameters& par = getParameters();

    const float corner = par.cornerValue/255.0f;
    const float noCorner = par.noCornerValue/255.0f;

    localMaxima<float> lmax;
    localMaxima<float>::parameters lmaxPar(par.localMaximaParameters);
    lmaxPar.noMaxValue = noCorner;
    lmaxPar.maxNumber = par.maximumCorners;
    lmax.setParameters(lmaxPar);

    if (lmax.apply(cornerness,cornersOnly,cornerMax)) {
      pointList::iterator it;
      int i;
      for (it=cornerMax.begin(),i=0;
           (it!=cornerMax.end());
           ++it) {
        cornersOnly.at(*it) = corner;
      }

      for (;it!=cornerMax.end();++it) {
        cornersOnly.at(*it) = noCorner;
      }

      return true;
    }
    return false;
  }
开发者ID:mvancompernolle,项目名称:ai_project,代码行数:40,代码来源:ltiHarrisCorners.cpp

示例13: is_channel_ready

bool selector::is_channel_ready(
    const channel & ch, io_direction & direction) const
{
    io_descriptor_type fd;
    io_direction dir;

    ch.get_io_descriptor(fd, dir);

    bool ready_for_reading = false;
    bool ready_for_writing = false;

    if (fd < num_of_descriptors_to_test_)
    {
        if (dir == input || dir == inout)
        {
            if (FD_ISSET(fd, &read_set_) != 0)
            {
                ready_for_reading = true;
            }
        }

        if (dir == output || dir == inout)
        {
            if (FD_ISSET(fd, &write_set_) != 0)
            {
                ready_for_writing = true;
            }
        }
    }

    if (ready_for_reading && ready_for_writing)
    {
        direction = inout;
    }
    else if (ready_for_reading)
    {
        direction = input;
    }
    else if (ready_for_writing)
    {
        direction = output;
    }

    return ready_for_reading || ready_for_writing;
}
开发者ID:morambro,项目名称:TrainProject,代码行数:45,代码来源:selector.cpp

示例14: apply

  // split image into float channels
  bool splitImageToxyY::apply(const image& img,
                              channel& c1,
                              channel& c2,
                              channel& c3) const {
    point p;             // coordinates
    rgbPixel pix;          // single Pixel Element in RGB-values...
    float Y;               // channels
    float X, XYZ;          // help variables

    // make the channels size of source image...
    c1.resize(img.rows(),img.columns(),0,false,false);
    c2.resize(img.rows(),img.columns(),0,false,false);
    c3.resize(img.rows(),img.columns(),0,false,false);

    for (p.y=0;p.y<img.rows();p.y++)
      for (p.x=0;p.x<img.columns();p.x++) {
        // take pixel at position p
        pix = img.at(p);

  // see Gonzales & Woods for explanation of magic numbers
        X   = (((float)(pix.getRed())) *0.412453f +
               ((float)(pix.getGreen())) *0.357580f +
               ((float)(pix.getBlue())) *0.180423f)/255.0f;   // x
        Y   = (((float)(pix.getRed())) *0.212671f +
               ((float)(pix.getGreen())) *0.715160f +
               ((float)(pix.getBlue())) *0.072169f)/255.0f;   // y
        XYZ = (((float)(pix.getRed())) *0.644458f +
               ((float)(pix.getGreen())) *1.191933f +
               ((float)(pix.getBlue())) *1.202819f)/255.0f;   // Y

        if (XYZ>0.0f) {
          c1.at(p) = X/XYZ;  // x
          c2.at(p) = Y/XYZ;  // y
        }
        else {
          c1.at(p) = 0;   // x
          c2.at(p) = 0;   // y
        }
        c3.at(p) = Y;     // Y
      } // loop
    return true;
  }
开发者ID:mvancompernolle,项目名称:ai_project,代码行数:43,代码来源:ltiSplitImageToxyY.cpp

示例15: send_tuple

void local_actor::send_tuple(message_priority prio, const channel& dest, any_tuple what) {
    if (!dest) return;
    message_id id;
    if (prio == message_priority::high) id = id.with_high_priority();
    dest->enqueue({address(), dest, id}, std::move(what), m_host);
}
开发者ID:ras0219,项目名称:libcppa,代码行数:6,代码来源:local_actor.cpp


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