本文整理汇总了C++中MLSignal::getHeight方法的典型用法代码示例。如果您正苦于以下问题:C++ MLSignal::getHeight方法的具体用法?C++ MLSignal::getHeight怎么用?C++ MLSignal::getHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MLSignal
的用法示例。
在下文中一共展示了MLSignal::getHeight方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: srcRect
// add the entire signal b to this signal, at the subpixel destination offset.
//
void MLSignal::add2D(const MLSignal& b, const Vec2& destOffset)
{
MLSignal& a = *this;
Vec2 iDestOffset, fDestOffset;
destOffset.getIntAndFracParts(iDestOffset, fDestOffset);
int destX = iDestOffset[0];
int destY = iDestOffset[1];
float srcPosFX = fDestOffset[0];
float srcPosFY = fDestOffset[1];
MLRect srcRect(0, 0, b.getWidth() + 1, b.getHeight() + 1); // add (1, 1) for interpolation
MLRect destRect = srcRect.translated(iDestOffset).intersect(getBoundsRect());
for(int j=destRect.top(); j<destRect.bottom(); ++j)
{
for(int i=destRect.left(); i<destRect.right(); ++i)
{
a(i, j) += b.getInterpolatedLinear(i - destX - srcPosFX, j - destY - srcPosFY);
}
}
setConstant(false);
}
示例2: rmsDifference2D
// a simple pixel-by-pixel measure of the distance between two signals.
//
float rmsDifference2D(const MLSignal& a, const MLSignal& b)
{
int w = min(a.getWidth(), b.getWidth());
int h = min(a.getHeight(), b.getHeight());
float sum = 0.;
float d;
for(int j=0; j<h; ++j)
{
for(int i=0; i<w; ++i)
{
d = a(i, j) - b(i, j);
sum += d*d;
}
}
sum /= w*h;
sum = sqrtf(sum);
return sum;
}
示例3:
void TouchTracker::Calibrator::setCalibration(const MLSignal& v)
{
if((v.getHeight() == kTemplateSize) && (v.getWidth() == kTemplateSize))
{
mCalibrateSignal = v;
mHasCalibration = true;
}
else
{
MLConsole() << "TouchTracker::Calibrator::setCalibration: bad size, restoring default.\n";
mHasCalibration = false;
}
}
示例4: setFrame
// setFrame() - set the 2D frame i to the incoming signal.
void MLSignal::setFrame(int i, const MLSignal& src)
{
// only valid for 3D signals
assert(is3D());
// source must be 2D
assert(src.is2D());
// src signal should match our dimensions
if((src.getWidth() != mWidth) || (src.getHeight() != mHeight))
{
return;
}
MLSample* pDestFrame = mDataAligned + plane(i);
const MLSample* pSrc = src.getConstBuffer();
std::copy(pSrc, pSrc + src.getSize(), pDestFrame);
}
示例5: updateTouches
// expire or move existing touches based on new signal input.
//
void TouchTracker::updateTouches(const MLSignal& in)
{
// copy input signal to border land
int width = in.getWidth();
int height = in.getHeight();
mTemp.copy(in);
mTemplateMask.clear();
// sort active touches by Z
// copy into sorting container, referring back to unsorted touches
int activeTouches = 0;
for(int i = 0; i < mMaxTouchesPerFrame; ++i)
{
Touch& t = mTouches[i];
if (t.isActive())
{
t.unsortedIdx = i;
mTouchesToSort[activeTouches++] = t;
}
}
std::sort(mTouchesToSort.begin(), mTouchesToSort.begin() + activeTouches, compareTouchZ());
// update active touches in sorted order, referring to existing touches in place
for(int i = 0; i < activeTouches; ++i)
{
int refIdx = mTouchesToSort[i].unsortedIdx;
Touch& t = mTouches[refIdx];
Vec2 pos(t.x, t.y);
Vec2 newPos = pos;
float newX = t.x;
float newY = t.y;
float newZ = in.getInterpolatedLinear(pos);
// if not preparing to remove, update position.
if (t.releaseCtr == 0)
{
Vec2 minPos(0, 0);
Vec2 maxPos(width, height);
int ix = floor(pos.x() + 0.5f);
int iy = floor(pos.y() + 0.5f);
// move to any higher neighboring integer value
Vec2 newPeak;
newPeak = adjustPeak(mTemp, ix, iy);
Vec2 newPeakI, newPeakF;
newPeak.getIntAndFracParts(newPeakI, newPeakF);
int newPx = newPeakI.x();
int newPy = newPeakI.y();
// get exact location and new key
Vec2 correctPos = mTemp.correctPeak(newPx, newPy);
newPos = correctPos;
int newKey = getKeyIndexAtPoint(newPos);
// move the touch.
if((newKey == t.key) || !keyIsOccupied(newKey))
{
// This must be the only place a touch can move from key to key.
pos = newPos;
newX = pos.x();
newY = pos.y();
t.key = newKey;
}
}
// look for reasons to release
newZ = in.getInterpolatedLinear(newPos);
bool thresholdTest = (newZ > mOffThreshold);
float inhibit = getInhibitThreshold(pos);
bool inhibitTest = (newZ > inhibit);
t.tDist = mCalibrator.differenceFromTemplateTouchWithMask(mTemp, pos, mTemplateMask);
bool templateTest = (t.tDist < mTemplateThresh);
bool overrideTest = (newZ > mOverrideThresh);
t.age++;
// handle release
// TODO get releaseDetect: evidence that touch has been released.
// from matching release curve over ~ 50 samples.
if (!thresholdTest || (!templateTest && !overrideTest) || (!inhibitTest))
{
/* debug
if(!thresholdTest && (t.releaseCtr == 0))
{
debug() << refIdx << " REL thresholdFail: " << newZ << " at " << pos << "\n";
}
if(!inhibitTest && (t.releaseCtr == 0))
{
debug() << refIdx << " REL inhibitFail: " << newZ << " < " << inhibit << "\n";
}
if(!templateTest && (t.releaseCtr == 0))
{
debug() << refIdx << " REL templateFail: " << t.tDist << " at " << pos << "\n";
}
*/
if(t.releaseCtr == 0)
//.........这里部分代码省略.........
示例6: adjustPeak
// if any neighbors of the input coordinates are higher, move the coordinates there.
//
Vec2 TouchTracker::adjustPeak(const MLSignal& in, int xp, int yp)
{
int width = in.getWidth();
int height = in.getHeight();
int x = clamp(xp, 1, width - 2);
int y = clamp(yp, 1, height - 2);
float t = 0.0;
int rx = x;
int ry = y;
float a = in(x - 1, y - 1);
float b = in(x, y - 1);
float c = in(x + 1, y - 1);
float d = in(x - 1, y);
float e = in(x, y);
float f = in(x + 1, y);
float g = in(x - 1, y + 1);
float h = in(x, y + 1);
float i = in(x + 1, y + 1);
float fmax = e;
if (y > 0)
{
if (a > fmax + t)
{
// debug() << "<^ ";
fmax = a; rx = x - 1; ry = y - 1;
}
if (b > fmax + t)
{
// debug() << "^ ";
fmax = b; rx = x; ry = y - 1;
}
if (c > fmax + t)
{
// debug() << ">^ ";
fmax = c; rx = x + 1; ry = y - 1;
}
}
if (d > fmax + t)
{
// debug() << "<- ";
fmax = d; rx = x - 1; ry = y;
}
if (f > fmax + t)
{
// debug() << "-> ";
fmax = f; rx = x + 1; ry = y;
}
if (y < in.getHeight() - 1)
{
if (g > fmax + t)
{
// debug() << "<_ ";
fmax = g; rx = x - 1; ry = y + 1;
}
if (h > fmax + t)
{
// debug() << "_ ";
fmax = h; rx = x; ry = y + 1;
}
if (i > fmax + t)
{
// debug() << ">_ ";
fmax = i; rx = x + 1; ry = y + 1;
}
}
return Vec2(rx, ry);
}
示例7: b
float TouchTracker::Calibrator::differenceFromTemplateTouchWithMask(const MLSignal& in, Vec2 pos, const MLSignal& mask)
{
static float maskThresh = 0.001f;
static MLSignal a2(kTemplateSize, kTemplateSize);
static MLSignal b(kTemplateSize, kTemplateSize);
static MLSignal b2(kTemplateSize, kTemplateSize);
float r = 0.f;
int height = in.getHeight();
int width = in.getWidth();
MLRect boundsRect(0, 0, width, height);
// use linear interpolated z value from input
float linearZ = in.getInterpolatedLinear(pos)*getZAdjust(pos);
linearZ = clamp(linearZ, 0.00001f, 1.f);
float z1 = 1./linearZ;
const MLSignal& a = getTemplate(pos);
// get normalized input values surrounding touch
int tr = kTemplateRadius;
b.clear();
for(int j=0; j < kTemplateSize; ++j)
{
for(int i=0; i < kTemplateSize; ++i)
{
Vec2 vInPos = pos + Vec2((float)i - tr,(float)j - tr);
if (boundsRect.contains(vInPos) && (mask.getInterpolatedLinear(vInPos) < maskThresh))
{
float inVal = in.getInterpolatedLinear(vInPos);
inVal *= z1;
b(i, j) = inVal;
}
}
}
int tests = 0;
float sum = 0.;
// add differences in z from template
a2.copy(a);
b2.copy(b);
a2.partialDiffX();
b2.partialDiffX();
for(int j=0; j < kTemplateSize; ++j)
{
for(int i=0; i < kTemplateSize; ++i)
{
if(b(i, j) > 0.)
{
float d = a2(i, j) - b2(i, j);
sum += d*d;
tests++;
}
}
}
// get RMS difference
if(tests > 0)
{
r = sqrtf(sum / tests);
}
return r;
}