本文整理汇总了C++中Dims::w方法的典型用法代码示例。如果您正苦于以下问题:C++ Dims::w方法的具体用法?C++ Dims::w怎么用?C++ Dims::w使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dims
的用法示例。
在下文中一共展示了Dims::w方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
// ######################################################################
void NeoBrain::init(Dims imageDims, int nPoints, int wz )
{
win_size = wz;
#ifdef HAVE_OPENCV
MAX_COUNT = nPoints;
count = 0;
points[0] = (CvPoint2D32f*)cvAlloc(MAX_COUNT*sizeof(points[0][0]));
points[1] = (CvPoint2D32f*)cvAlloc(MAX_COUNT*sizeof(points[0][0]));
prev_grey = Image<byte>(imageDims, ZEROS);
pyramid = cvCreateImage( cvSize(imageDims.w(), imageDims.h()), 8, 1 );
prev_pyramid = cvCreateImage( cvSize(imageDims.w(), imageDims.h()), 8, 1 );
status = (char*)cvAlloc(MAX_COUNT);
#endif
flags = 0;
itsState = CHECK_TARGET;
itsImageDims = imageDims;
itsTracking = false;
if (itsSpeakSaliency.getVal())
{
itsSpeechSynth->sendCommand("(lex.add.entry '(\"bigpause\" n (((pau) 1) ((pau) 1) ((pau) 1) ((pau) 1))))\n", -10, true);
itsSpeechSynth->sendCommand("(set! daisy (wave.load \"daisy.wav\"))",
-10, true);
itsSpeechSynth->sendCommand("(set! headinfo (wave.load \"headInfo.wav\"))",
-10, true);
}
}
示例2: drawOutline
void BitObject::drawOutline(Image<T_or_RGB>& img,
const T_or_RGB& color,
float opacity)
{
ASSERT(isValid());
ASSERT(img.initialized());
float op2 = 1.0F - opacity;
Dims d = img.getDims();
Image<byte> mask = getObjectMask();
// rescale if needed
if (d != itsImageDims)
mask = rescaleNI(mask, d.w(), d.h());
// object-shaped drawing
int thick = 1;
Image<byte> om(mask);
om = contour2D(om); // compute binary contour image
const int w = img.getWidth();
const int h = img.getHeight();
Point2D<int> ppp;
for (ppp.j = 0; ppp.j < h; ppp.j ++)
for (ppp.i = 0; ppp.i < w; ppp.i ++)
if (om.getVal(ppp.i, ppp.j)) // got a contour point -> draw here
drawDisk(img, ppp, thick, T_or_RGB(img.getVal(ppp) * op2 + color * opacity)); // small disk for each point
} // end drawOutline
示例3: if
// ######################################################################
Image<float> downSizeClean(const Image<float>& src, const Dims& new_dims,
const int filterWidth)
{
GVX_TRACE(__PRETTY_FUNCTION__);
if (src.getDims() == new_dims) return src;
ASSERT(new_dims.isNonEmpty());
ASSERT(filterWidth >= 1);
Image<float> result = src;
while (result.getWidth() > new_dims.w() * 2 &&
result.getHeight() > new_dims.h() * 2)
{
if (filterWidth == 1)
{
result = decX(result);
result = decY(result);
}
else if (filterWidth == 2)
{
result = quickLocalAvg2x2(result);
}
else
{
result = decX(lowPassX(filterWidth, result));
result = decY(lowPassY(filterWidth, result));
}
}
return rescaleBilinear(result, new_dims);
}
示例4: getVideoFileInfoFromFilename
VideoFileInfo getVideoFileInfoFromFilename(const std::string& fname)
{
VideoFileInfo result;
std::string base;
std::string ext = nodotExtension(fname, &base);
LDEBUG("ext is %s", ext.c_str());
if (ext.compare("gz") == 0)
{
ext = nodotExtension(base, &base);
LDEBUG("new ext is %s", ext.c_str());
result.ctype = COMP_GZIP;
}
else if (ext.compare("bz2") == 0)
{
ext = nodotExtension(base, &base);
LDEBUG("new ext is %s", ext.c_str());
result.ctype = COMP_BZIP2;
}
else
{
result.ctype = COMP_NONE;
}
const std::string dimsstr = nodotExtension(base);
LDEBUG("dimsstr is '%s'", dimsstr.c_str());
if (dimsstr.size() == 0)
{
LERROR("no <width>x<height> specification found in '%s'; "
"assuming default dims of %dx%d instead",
fname.c_str(), defaultDims.w(), defaultDims.h());
result.dims = defaultDims;
// we didn't get explicit dims, so let's be picky about the
// file size matching the defaultDims (--yuv-dims), unless the
// user also requests loose matching (--yuv-dims-loose)
result.beStrict = strictLength;
}
else
{
result.dims = fromStr<Dims>(dimsstr);
LDEBUG("parsed dims as %dx%d",
result.dims.w(), result.dims.h());
// OK, the user gave us some explicit dims, so let's not be
// picky about whether the file size matches the
// dims+pixformat
result.beStrict = false;
}
result.format = fromStr<VideoFormat>(ext);
return result;
}
示例5: saveSingleEventFrame
void Logger::saveSingleEventFrame(MbariImage< PixRGB<byte> >& img,
int frameNum,
MbariVisualEvent::VisualEvent *event) {
ASSERT(event->frameInRange(frameNum));
// create the file stem
string evnum;
if (itsSaveEventFeatures.getVal().length() > 0)
evnum = sformat("%s_evt%04d_", itsSaveEventFeatures.getVal().c_str(), event->getEventNum() );
else
evnum = sformat("evt%04d_", event->getEventNum());
Dims maxDims = event->getMaxObjectDims();
Dims d((float)maxDims.w()*itsScaleW, (float)maxDims.h()*itsScaleH);
// compute the correct bounding box and cut it out
Rectangle bbox1 = event->getToken(frameNum).bitObject.getBoundingBox();
Rectangle bbox = Rectangle::tlbrI(bbox1.top()*itsScaleH, bbox1.left()*itsScaleW,
bbox1.bottomI()*itsScaleH, bbox1.rightI()*itsScaleW);
//Point2D cen = event.getToken(frameNum).bitObject.getCentroid();
// first the horizontal direction
int wpad = (d.w() - bbox.width()) / 2;
int ll = bbox.left() - wpad;
//int ll = cen.i - d.w() / 2;
int rr = ll + d.w();
if (ll < 0) {
rr -= ll;
ll = 0;
}
if (rr >= img.getWidth()) {
rr = img.getWidth() - 1;
ll = rr - d.w();
}
// now the same thing with the vertical direction
int hpad = (d.h() - bbox.height()) / 2;
int tt = bbox.top() - hpad;
//int tt = cen.j - d.h() / 2;
int bb = tt + d.h();
if (tt < 0) {
bb -= tt;
tt = 0;
}
if (bb >= img.getHeight()) {
bb = img.getHeight() - 1;
tt = bb - d.h();
}
Rectangle bboxFinal = Rectangle::tlbrI(tt, ll, bb, rr);
bboxFinal = bboxFinal.getOverlap(Rectangle(Point2D<int>(0, 0), img.getDims() - 1));
// scale if needed and cut out the rectangle and save it
Image< PixRGB<byte> > cut = crop(img, bboxFinal);
itsOfs->writeFrame(GenericFrame(cut), evnum, FrameInfo(evnum, SRC_POS));
}
示例6: inputFrame
// ######################################################################
void TaskRelevanceMapSocial::inputFrame(const InputFrame& f)
{
const Dims mapdims = f.getDims();
const int sml = itsLevelSpec.getVal().mapLevel();
const float EyeVal = 128.0F, MouthVal = 64.0F, FaceVal = 32.0F, BodyVal = 16.0F, PersonVal = 4.0F, BkgdVal = 1.0F;
Image<float> BigMap;
BigMap.resize(mapdims, true);
BigMap.clear(1.0F);
Scene sceneData =
itsObjectsInfo->getSceneData(itsFrame);
// loop through all the regions on a given frame and assign z-stack order
std::vector<float> weights(itsNumObjects, 1.0F);
for (std::vector<Object>::iterator itrObject = sceneData.objects.begin(); itrObject != sceneData.objects.end(); itrObject++) {
uint idx = (*itrObject).id;
std::string ObjName = toLowerCase(itsObjectsNames[idx]);
if (ObjName.find("eye") != std::string::npos) {weights[idx] = EyeVal;}
else if (ObjName.find("mouth") != std::string::npos) {weights[idx] = MouthVal;}
else if (ObjName.find("head") != std::string::npos ||
ObjName.find("face") != std::string::npos) {weights[idx] = FaceVal;}
else if (ObjName.find("body") != std::string::npos) {weights[idx] = BodyVal;}
else if (ObjName.find("person") != std::string::npos ||
ObjName.find("people") != std::string::npos ||
ObjName.find("man") != std::string::npos ||
ObjName.find("woman") != std::string::npos) {weights[idx] = PersonVal;}
else {weights[idx] = BkgdVal;}
}
uint i,j,tmp;
// sort z-stack weights
const uint numInScene = sceneData.objects.size();
std::vector<uint> zorder(numInScene);
for (i = 0; i < numInScene; i++) zorder[i] = i;
for (i = 0; i < numInScene; i++)
for (j = 0; j < numInScene-i-1; j++)
if(weights[sceneData.objects[zorder[j]].id] >
weights[sceneData.objects[zorder[j+1]].id]) {
tmp = zorder[j];
zorder[j] = zorder[j+1];
zorder[j+1] = tmp;
}
// fill BigMap from bottom of z-stack to top
// todo: enforce C0/C1 continuity by some poisson problem?
for (i = 0; i < numInScene; i++) {
Object iObj = sceneData.objects[zorder[i]];
drawFilledPolygon(BigMap, iObj.polygon, weights[iObj.id]);
}
itsMap = rescale(BigMap, mapdims.w() >> sml, mapdims.h() >> sml);
itsFrame++;
}
示例7: getMapDims
// ######################################################################
Dims ForegroundDetectionChannel::getMapDims() const
{
if (!this->hasInput())
LFATAL("Oops! I haven't received any input yet");
const Dims indims = this->getInputDims();
return Dims(indims.w() >> itsLevelSpec.getVal().mapLevel(),
indims.h() >> itsLevelSpec.getVal().mapLevel());
}
示例8: transformDims
// ######################################################################
Dims ResizeSpec::transformDims(const Dims& in)
{
switch (itsMethod)
{
case NOOP:
return in;
break;
case FIXED:
return itsNewDims;
break;
case SCALE_UP:
// if a scale factor is 0, then that dimension just passes
// through untouched
return Dims(itsFactorW > 0.0
? int(0.5 + in.w() * itsFactorW)
: in.w(),
itsFactorH > 0.0
? int(0.5 + in.h() * itsFactorH)
: in.h());
break;
case SCALE_DOWN:
// if a scale factor is 0, then that dimension just passes
// through untouched
return Dims(itsFactorW > 0.0
? int(0.5 + in.w() / itsFactorW)
: in.w(),
itsFactorH > 0.0
? int(0.5 + in.h() / itsFactorH)
: in.h());
break;
}
// we should never get here, because even if the user gave bogus
// input, we should have caught that in convertFromString() or
// wherever, so that once we have a ResizeSpec object, it should be
// guaranteed to have a valid itsMethod value:
ASSERT(0); /* can't happen */ return Dims();
}
示例9: Rectangle
// ######################################################################
Button::Button(Point2D<int> topLeft,Dims dims )
{
itsTopLeftPoint = topLeft;
itsCenterPoint = Point2D<int>(topLeft.i+dims.w()/2,topLeft.j+dims.h()/2);
itsDims = dims;
itsRectangle = Rectangle(topLeft,dims);
itsBgColor = PixRGB<byte>(0,255,0);
itsBorderColor = PixRGB<byte>(255,255,255);
itsLabelColor = PixRGB<byte>(255,255,255);
itsFontSize = 20;
itsBorderThickness = 0;
}
示例10: drawShape
void BitObject::drawShape(Image<T_or_RGB>& img,
const T_or_RGB& color,
float opacity)
{
ASSERT(isValid());
ASSERT(img.initialized());
Dims d = img.getDims();
Image<byte> mask = itsObjectMask;
Rectangle bbox = itsBoundingBox;
// rescale if needed
if (d != itsImageDims) {
float scaleW = (float) d.w() / (float) itsImageDims.w();
float scaleH = (float) d.h() / (float) itsImageDims.h();
int i = (int) ((float) bbox.left() * scaleW);
int j = (int) ((float) bbox.top() * scaleH);
int w = (int) ((float) bbox.width() * scaleW);
int h = (int) ((float) bbox.height() *scaleH);
const Point2D<int> topleft(i,j);
bbox = Rectangle(topleft, Dims(w,h));
mask = rescaleNI(mask, d.w(), d.h());
}
int w = img.getWidth();
float op2 = 1.0F - opacity;
typename Image<T_or_RGB>::iterator iptr, iptr2;
Image<byte>::const_iterator mptr = mask.begin();
iptr2 = img.beginw() + bbox.top() * w + bbox.left();
for (int y = bbox.top(); y <= bbox.bottomI(); ++y)
{
iptr = iptr2;
for (int x = bbox.left(); x <= bbox.rightI(); ++x)
{
if (*mptr > 0) *iptr = T_or_RGB(*iptr * op2 + color * opacity);
++iptr; ++mptr;
}
iptr2 += w;
}
}
示例11: if
void NeuralSimModule<T>::setModel(const std::string& model_name, const Dims& dims, const SimTime& starttime)
{
//set our border policy based on wether we are using space variant boundaries or not
BorderPolicy bp = (itsUseSpaceVariantBoundary.getVal()) ? CROSS_HEMI : NONE;
//change any factory parameters
uint w = dims.w(); uint h = dims.h();
nsu::setParameter(nsu::SimStructure::Factory::instance(), bp, itsSCtimestep.getVal(), w, h);
//reset the module
LINFO("model type: %s", model_name.c_str());
itsStructure.reset(nsu::SimStructure::Factory::instance().createConvert<T*>(model_name));
itsStructure->setTime(starttime);
//setup plotting range
nsu::NormalizeType ntype;
Range<double> itsRange = itsDisplayRange.getVal();
if ((itsRange.min() < 0) && (itsRange.max() < 0))//if both are less than 0 scale
{
ntype = nsu::SCALE;
itsRange = Range<double>(0.0,0.0);
}
else if ((itsRange.min() == 0) && (itsRange.max() == 0))//set to min/max of data
ntype = nsu::RANGE;
else //set to auto scale at each time
ntype = nsu::SET_RANGE;
//set a decode if desired and initialize plotting
if (itsDecoderType.getVal().compare("None") != 0)
{
nsu::NeuralDecoder* nd = nsu::NeuralDecoder::Factory::instance().create(itsDecoderType.getVal());
itsPlot.reset(new nsu::StructurePlot(*itsStructure, *nd, its2DPlotDepth.getVal(), ntype,
itsRange.min(), itsRange.max()));
delete nd;
}
else
itsPlot.reset(new nsu::StructurePlot(*itsStructure, its2DPlotDepth.getVal(), ntype,
itsRange.min(), itsRange.max()));
//update our probe position and set sampling rate for display text
itsPlot->setSamplingRate(itsStructure->getTimeStep());
nsu::Location location(itsProbe.getVal());
itsPlot->setProbe(location);
//setup image set to hold input
const uint depth = (itsStructure->numSubs() < 1) ? 2 : itsStructure->numSubs()+1;
itsInput = ImageSet<double>(depth);
itsInputGain = std::vector<double>(depth, 1.0);
}
示例12: mapdims
// ######################################################################
void TaskRelevanceMapAdapter::
onSimEventRetinaImage(SimEventQueue& q, rutz::shared_ptr<SimEventRetinaImage>& e)
{
const Dims d = e->frame().colorByte().getDims();
const int sml = itsLevelSpec.getVal().mapLevel();
const Dims mapdims(d.w() >> sml, d.h() >> sml);
// great, here is a new input image. Initialize our map if needed:
if (itsMap.getDims() != mapdims)
{
itsMap.resize(mapdims,true);
itsMap.clear(1.0F); // neutral relevance
}
// now do any implementation-specific processing:
this->inputFrame(e->frame());
}
示例13: drawBoundingBox
void BitObject::drawBoundingBox(Image<T_or_RGB>& img,
const T_or_RGB& color,
float opacity)
{
ASSERT(isValid());
ASSERT(img.initialized());
Rectangle bbox = itsBoundingBox;
// rescale if needed
if (img.getDims() != itsImageDims) {
Dims d = img.getDims();
float scaleW = (float) d.w() / (float) itsImageDims.w();
float scaleH = (float) d.h() / (float) itsImageDims.h();
int i = (int) ((float) bbox.left() * scaleW);
int j = (int) ((float) bbox.top() * scaleH);
int w = (int) ((float) bbox.width() * scaleW);
int h = (int) ((float) bbox.height() *scaleH);
const Point2D<int> topleft(i,j);
bbox = Rectangle(topleft, Dims(w,h));
}
float op2 = 1.0F - opacity;
int t = bbox.top();
int b = bbox.bottomI();
int l = bbox.left();
int r = bbox.rightI();
for (int x = l; x <= r; ++x)
{
Point2D<int> p1(x,t), p2(x,b);
img.setVal(p1,img.getVal(p1) * op2 + color * opacity);
img.setVal(p2,img.getVal(p2) * op2 + color * opacity);
}
for (int y = t+1; y < b; ++y)
{
Point2D<int> p1(l,y), p2(r,y);
img.setVal(p1,img.getVal(p1) * op2 + color * opacity);
img.setVal(p2,img.getVal(p2) * op2 + color * opacity);
}
}
示例14: initialize
void DetectionParametersSingleton::initialize(DetectionParameters &p, const Dims &dims, const int foaRadius) {
DetectionParametersSingleton *dp = instance();
// calculate cost parameter from other derived values
// initialize parameters
const int maxDist = dims.w() / MAX_DIST_RATIO;
float maxAreaDiff = maxDist * maxDist / 4.0F;
float maxDistFloat = (float) maxDist;
if (p.itsTrackingMode == TMKalmanFilter || p.itsTrackingMode == TMKalmanHough || p.itsTrackingMode == TMHough )
p.itsMaxCost = pow(maxDistFloat,2.0F);
else
p.itsMaxCost = maxDist;
p.itsMaxDist = maxDist;
if (p.itsMinEventArea == 0)
p.itsMinEventArea = foaRadius;
if (p.itsMaxEventArea == 0)
p.itsMaxEventArea = foaRadius * MAX_SIZE_FACTOR;
dp->itsParameters = p;
}
示例15: initTracker
void VisualTracker::initTracker(Dims imageDims)
{
#ifdef HAVE_OPENCV
itsMaxNumPoints = 1;
itsCurrentNumPoints = 0;
itsCurrentPoints = (CvPoint2D32f*)cvAlloc(itsMaxNumPoints*sizeof(itsCurrentPoints));
itsPreviousPoints = (CvPoint2D32f*)cvAlloc(itsMaxNumPoints*sizeof(itsPreviousPoints));
itsPreviousGreyImg = Image<byte>(imageDims, ZEROS);
itsCurrentPyramid = cvCreateImage( cvSize(imageDims.w(), imageDims.h()), 8, 1 );
itsPreviousPyramid = cvCreateImage( cvSize(imageDims.w(), imageDims.h()), 8, 1 );
itsTrackStatus = (char*)cvAlloc(itsMaxNumPoints);
itsTrackError = (float*)cvAlloc(itsMaxNumPoints);
if (itsUseKalman)
{
itsKalman = cvCreateKalman(4, //Dim of state vector x,y,dx,dy
2); //dim of mesurment vector x,y
//State transition matrix
//x y dx dy
const float A[] = { 1, 0, 1, 0,
0, 1, 0, 1,
0, 0, 1, 0,
0, 0, 0, 1};
//Observation matrix
const float H[] = { 1, 0, 0, 0,
0, 1, 0, 0};
//set the transition and mesurment matrix
memcpy( itsKalman->transition_matrix->data.fl, A, sizeof(A));
memcpy( itsKalman->measurement_matrix->data.fl, H, sizeof(H));
//Set the process and measurment noise
cvSetIdentity( itsKalman->process_noise_cov, cvRealScalar(1e-5) );
cvSetIdentity( itsKalman->measurement_noise_cov, cvRealScalar(1e-1) );
/*posteriori error estimate covariance matrix (P(k)): P(k)=(I-K(k)*H)*P'(k) */
cvSetIdentity( itsKalman->error_cov_post, cvRealScalar(1));
cvZero(itsKalman->state_post); /* corrected state (x(k)): x(k)=x'(k)+K(k)*(z(k)-H*x'(k)) */
cvZero(itsKalman->state_pre); /* predicted state (x'(k)): x(k)=A*x(k-1)+B*u(k) */
}
// //camshift
// int hdims = 16;
// float hranges_arr[] = {0,180};
// float* hranges = hranges_arr;
//
// itsObjectHist = cvCreateHist( 1, &hdims, CV_HIST_ARRAY, &hranges, 1 );
// itsBackproject = cvCreateImage( cvSize(imageDims.w(), imageDims.h()), 8, 1 );
itsTrackFlags = 0;
#endif
itsInitTracker = false;
}