本文整理汇总了C++中TLFImage::CalcLnSum方法的典型用法代码示例。如果您正苦于以下问题:C++ TLFImage::CalcLnSum方法的具体用法?C++ TLFImage::CalcLnSum怎么用?C++ TLFImage::CalcLnSum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TLFImage
的用法示例。
在下文中一共展示了TLFImage::CalcLnSum方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Features
//-------------------------------TLFEmptyAverageNNPredictor----------------------
TLFDblVector* TLFEmptyAverageNNPredictor::Features(ILFDetectEngine* engine, TLFRect* rect, int id)
{
if (engine == NULL || rect == NULL)
return NULL;
ILFObjectDetector* d = engine->GetDetector(0);
if (d == NULL)
return NULL;
TLFImage* img = d->GetImage();
if (img == NULL)
return NULL;
TLFDblVector* data = new TLFDblVector(id);
double w = (double)rect->Width() / 8;
double h = (double)rect->Height() /8;
double s = w*h;
for (int y = 0; y < 8; y++)
{
int yy = (int)floor(rect->Top() + y*w + 0.5);
for (int x = 0; x < 8 ; x++)
{
int xx = (int)floor(rect->Left() + x*w + 0.5);
double value = img->CalcLnSum(xx, yy, (int)w, (int)h)/s;
data->AddValue(value);
}
}
return data;
}
示例2: Predict
TLFRect* TLFIntegralImagePredictor::Predict(ILFDetectEngine* engine)
{
TLFFGEngine* e = dynamic_cast<TLFFGEngine*>(engine);
if (e == NULL)
return NULL;
if (m_pPredicted != NULL)
{
delete m_pPredicted;
m_pPredicted = NULL;
}
TLFImage* fg = e->GetForegroundImage();
double max_s = 0;
double value;
double overlap;
double s;
int idx = -1;
for (int i = 0; i < m_scanner->GetFragmentsCount(); i++)
{
awpRect rect = m_scanner->GetFragmentRect(i);
s = (rect.right - rect.left)*(rect.bottom - rect.top);
overlap = m_rect.RectOverlap(rect);
if (overlap > 0.5)
{
value = pow(1.1,overlap)*fg->CalcLnSum(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top) /s;
if (value > max_s)
{
max_s = value;
idx = i;
}
}
}
if (idx < 0)
{
m_pPredicted = NULL;
return NULL;
}
else
{
TLFRect* r_result = new TLFRect();
r_result->SetRect(m_scanner->GetFragmentRect(idx));
awpRect rr = r_result->GetRect();
//awpFillRect(e->GetForeground(), &rr, 0, 0);
m_pPredicted = r_result;
m_rect.SetRect(r_result->GetRect());
return r_result;
}
}
示例3: Features
TLFDescriptor* TLFAverageNNTracker::Features(ILFDetectEngine* engine, TLFRect* rect, int id)
{
if (engine == NULL || rect == NULL)
return NULL;
TSCObjectDetector* d = dynamic_cast<TSCObjectDetector*>(engine->GetDetector(0));
if (d == NULL)
return NULL;
TLFImage* img = d->GetImage();
if (img == NULL || img->GetImage() == NULL)
return NULL;
//
int idx = d->GetStagesCount() - 1;
TLFObjectList* stages = d->GetStrongs();
TCSStrong* s = dynamic_cast<TCSStrong*>(stages->Get(idx));
if (s == NULL)
return NULL;
double* data = (double*)malloc(s->GetCount()*sizeof(double));
int width = rect->Width();
double scale_coef = (double)width / (double)d->GetBaseWidth();
TLFRect fragment;
for (int i = 0; i < s->GetCount(); i++)
{
ILFWeak * weak = s->GetWeak(i);
if (weak != NULL)
{
TCSSensor* sensor = dynamic_cast<TCSSensor*>(weak->Fetaure());
awpRect Fragment = sensor->GetRect();
fragment.SetRect(Fragment);
fragment.Scale(scale_coef);
fragment.Shift(rect->Left(), rect->Top());
Fragment = fragment.GetRect();
double s = fragment.Width()*fragment.Height();
double value = img->CalcLnSum(Fragment.left, Fragment.top, fragment.Width(), fragment.Height());
value /= s;
data[i] = value;
}
}
TLFDescriptor* dscr = new TLFDescriptor(s->GetCount(), id, data);
free(data);
return dscr;
}