本文整理汇总了C++中channel类的典型用法代码示例。如果您正苦于以下问题:C++ channel类的具体用法?C++ channel怎么用?C++ channel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了channel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: make_frames
void
make_frames(const message &msg, OutputIterator out)
{
const channel ch = msg.get_channel();
switch (msg.get_type()) {
case MSG:
{
msg_frame MSG;
MSG.channel = ch.get_number();
MSG.message = ch.get_message_number();
MSG.more = false;
MSG.sequence = ch.get_sequence_number();
MSG.payload = msg.get_payload();
*out++ = MSG;
}
break;
case RPY:
{
rpy_frame RPY;
RPY.channel = ch.get_number();
RPY.message = ch.get_message_number();
RPY.more = false;
RPY.sequence = ch.get_sequence_number();
RPY.payload = msg.get_payload();
*out++ = RPY;
}
break;
case ANS:
{
ans_frame ANS;
ANS.channel = ch.get_number();
ANS.message = ch.get_message_number();
ANS.more = false;
ANS.sequence = ch.get_sequence_number();
ANS.payload = msg.get_payload();
ANS.answer = ch.get_answer_number();
*out++ = ANS;
}
break;
case ERR:
{
err_frame ERR;
ERR.channel = ch.get_number();
ERR.message = ch.get_message_number();
ERR.more = false;
ERR.sequence = ch.get_sequence_number();
ERR.payload = msg.get_payload();
*out++ = ERR;
}
break;
case NUL:
{
nul_frame NUL;
NUL.channel = ch.get_number();
NUL.message = ch.get_message_number();
NUL.more = false;
NUL.sequence = ch.get_sequence_number();
NUL.payload = msg.get_payload();
*out++ = NUL;
}
break;
case SEQ:
default:
std::cerr << "The message has an invalid frame type.\n";
assert(false);
/// \todo throw ?
}
}
开发者ID:dancasimiro,项目名称:dcbeep,代码行数:68,代码来源:frame-generator.hpp
示例17: inverse
void fft::inverse(const channel& input, channel& output, uint16_t points) {
plan &p = prepare(points, false);
memcpy(p.input, input.data(), sizeof(fftw_complex)*points);
fftw_execute(p.plan);
memcpy(output.data(), p.output, sizeof(fftw_complex)*points);
}
开发者ID:d-b,项目名称:CSC372,代码行数:6,代码来源:signal.cpp
示例18: min
void distanceTransform::iteration4back(channel& chnl) const {
int x,y,z;
const int rowm1 = chnl.lastRow();
const int colm1 = chnl.lastColumn();
static const int deltax[6] = {1,0,-1, 0, 1,0};
static const int deltay[6] = {0,1, 0,-1, 0,1};
float minimum;
// bottom-right
if (chnl.at(rowm1,colm1) > 0) {
chnl.at(rowm1,colm1) = 1.0f+min(chnl.at(rowm1,colm1-1),
chnl.at(rowm1-1,colm1));
}
// bottom
y = rowm1;
for (x=colm1-1;x>0;--x) {
if (chnl.at(y,x) > 0) {
// valid pixel, let's check for the distance value
minimum = chnl.at(y+deltay[2],x+deltax[2]);
for (z=3;z<5;++z) {
minimum = min(minimum,chnl.at(y+deltay[z],x+deltax[z]));
}
chnl.at(y,x) = minimum+1.0f;
}
}
// bottom-left
if (chnl.at(rowm1,0) > 0) {
chnl.at(rowm1,0) = 1.0f+min(chnl.at(rowm1,1),
chnl.at(rowm1-1,0));
}
// inner of the image only...
for (y=rowm1-1;y>0;--y) {
x = colm1;
// right border
if (chnl.at(y,x) > 0) {
minimum = chnl.at(y+deltay[1],x+deltax[1]);
for (z=2;z<4;++z) {
minimum = min(minimum,chnl.at(y+deltay[z],x+deltax[z]));
}
chnl.at(y,x) = minimum+1.0f;
}
// inner of the line
for (x=colm1-1;x>0;--x) {
if (chnl.at(y,x) > 0) {
// valid pixel, let's check for the distance value
minimum = chnl.at(y+deltay[0],x+deltax[0]);
for (z=1;z<4;++z) {
minimum = min(minimum,chnl.at(y+deltay[z],x+deltax[z]));
}
chnl.at(y,x) = minimum+1.0f;
}
}
// left border
if (chnl.at(y,x) > 0) {
minimum = chnl.at(y+deltay[3],x+deltax[3]);
for (z=0;z<2;++z) {
minimum = min(minimum,chnl.at(y+deltay[z],x+deltax[z]));
}
chnl.at(y,x) = minimum+1.0f;
}
}
// upper-right
if (chnl.at(0,colm1) > 0) {
chnl.at(0,colm1) = 1.0f+min(chnl.at(0,colm1-1),
chnl.at(1,colm1));
}
// top
for (x=colm1-1;x>0;--x) {
if (chnl.at(y,x) > 0) {
// valid pixel, let's check for the distance value
minimum = chnl.at(y+deltay[0],x+deltax[0]);
for (z=1;z<3;++z) {
minimum = min(minimum,chnl.at(y+deltay[z],x+deltax[z]));
}
chnl.at(y,x) = minimum+1.0f;
}
}
// upper-left
if (chnl.at(0,0) > 0) {
//.........这里部分代码省略.........
开发者ID:mvancompernolle,项目名称:ai_project,代码行数:101,代码来源:ltiDistanceTransform.cpp
示例19: fourSEDFiltering
void distanceTransform::fourSEDFiltering(channel &chnl,
matrix<point> &dist) const {
//create all masks
point mask0[] = { point(-1, 0) };
sedMask l(mask0, 1);
point mask1[] = { point(0, -1) };
sedMask u(mask1, 1);
point mask2[] = { point(0, -1), point(-1, 0) };
sedMask ul(mask2, 2);
point mask3[] = { point(1, 0) };
sedMask r(mask3, 1);
point mask4[] = { point(0, 1) };
sedMask d(mask4, 1);
point mask5[] = { point(1, 0), point(0, 1) };
sedMask rd(mask5, 2);
point pos;
pos.y = 0;
//first line
for(pos.x = 1; pos.x < chnl.columns(); ++pos.x)
l.filter(dist, pos);
for(pos.x = chnl.columns() - 2; pos.x >= 0; --pos.x)
r.filter(dist, pos);
for(pos.y = 1; pos.y < chnl.rows(); ++pos.y){
pos.x = 0;
//step down
u.filter(dist, pos);
for(pos.x = 1; pos.x < chnl.columns(); ++pos.x)
ul.filter(dist, pos);
for(pos.x = chnl.columns() - 2; pos.x >= 0; --pos.x)
r.filter(dist, pos);
}
//and now filter the picture in the opposite direction
pos.y = chnl.rows() - 1;
//last line
for(pos.x = chnl.columns() - 2; pos.x >= 0; --pos.x)
r.filter(dist, pos);
for(pos.x = 1; pos.x < chnl.columns(); ++pos.x)
l.filter(dist, pos);
for(pos.y = chnl.rows() - 2; pos.y >= 0; --pos.y){
pos.x = chnl.columns() - 1;
//step up
d.filter(dist, pos);
for(pos.x = chnl.columns() - 2; pos.x >= 0; --pos.x)
rd.filter(dist, pos);
for(pos.x = 1; pos.x < chnl.columns(); ++pos.x)
l.filter(dist, pos);
}
}
开发者ID:mvancompernolle,项目名称:ai_project,代码行数:65,代码来源:ltiDistanceTransform.cpp
示例20: send_randoms
void send_randoms(int amount, channel<int>& c) {
for (int i=0; i<amount; i++) {
c.send(1);
}
}
开发者ID:evertheylen,项目名称:SpaceInvaders,代码行数:5,代码来源:main.cpp
注:本文中的channel类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论