本文整理汇总了C++中TLFImage::GetImage方法的典型用法代码示例。如果您正苦于以下问题:C++ TLFImage::GetImage方法的具体用法?C++ TLFImage::GetImage怎么用?C++ TLFImage::GetImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TLFImage
的用法示例。
在下文中一共展示了TLFImage::GetImage方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Predict
TLFRect* TLFMomentsPredictor::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();
if (fg != NULL)
{
SLFBinaryMoments m;
TLFThresholdProc* proc = e->GetThresholdProc();
if (e != NULL)
{
TLFRect r;
r.SetRect(m_rect.GetRect());
r.Inflate(2,2);
proc->ProcessMoments(r, m);
if (m.area > 0)
{
awpRect o_rect;
o_rect.left = (AWPSHORT)GetMinMomnetsX(m); if (o_rect.left < 0) o_rect.left = 0;
o_rect.top = (AWPSHORT)GetMinMomnetsY(m); if (o_rect.top < 0) o_rect.top = 0;
o_rect.right = (AWPSHORT)GetMaxMomnetsX(m); if (o_rect.right >= fg->GetImage()->sSizeX) o_rect.right = fg->GetImage()->sSizeX - 1;
o_rect.bottom = (AWPSHORT)GetMaxMomnetsY(m); if (o_rect.bottom >= fg->GetImage()->sSizeY) o_rect.bottom = fg->GetImage()->sSizeY - 1;
double w = o_rect.right - o_rect.left;
double h = o_rect.bottom - o_rect.top;
double s = (o_rect.right - o_rect.left)*(o_rect.bottom - o_rect.top);
double s1 = fg->GetImage()->sSizeX*fg->GetImage()->sSizeY;
if (m.area/s > 0)
{
TLFRect* r_result = new TLFRect();
r_result->SetRect(o_rect);
r_result->Inflate(2,2);
m_pPredicted = r_result;
m_rect.SetRect(r_result->GetRect());
return r_result;
}
else
return NULL;
}
else
return NULL;
}
else
return NULL;
}
else
return NULL;
}
示例2: CFSaveToDump
// запись растрового изображения в неструктурированную память
CF_ERROR __EXPORT_TYPE CFSaveToDump(CF_IMAGE hImage, CF_WORD* pWidth, CF_WORD* pHeight, CF_WORD* pBpp, CF_BYTE* buffer)
{
CF_ERROR status = CF_SUCCESS;
// проверим входные параметры дескриптора изображения
TLFImage* image = (TLFImage*)hImage;
if(image == NULL)
{
status = CFF_INVALID_HANDLE;
return status;
}
awpImage* pImage = NULL;
pImage = image->GetImage();
if (awpCheckImage(pImage) != AWP_OK)
{
status = CFF_INVALID_HANDLE;
return status;
}
// проверим возможность конвертации изображения
//проверим остальные параметры
if (pWidth == NULL || pHeight == NULL || pBpp == NULL || buffer == NULL)
{
return CFF_INVALID_PARAM;
}
// выполним копирование
*pWidth = pImage->sSizeX;
*pHeight= pImage->sSizeY;
*pBpp = 8*pImage->bChannels;
int bufsize = pImage->sSizeX*pImage->sSizeY*pImage->bChannels;
CF_BYTE* b = (CF_BYTE*)pImage->pPixels;
memcpy(buffer, b, bufsize);
return status;
}
示例3: CFGetImageParams
CF_ERROR __EXPORT_TYPE CFGetImageParams(CF_IMAGE hImage, CF_IMAGE_PARAMS* pParams)
{
CF_ERROR status = CF_SUCCESS;
// проверим входные параметры
if (pParams == NULL)
{
return CFF_INVALID_PARAM;
}
TLFImage* image = (TLFImage*)hImage;
if(image == NULL)
{
status = CFF_INVALID_HANDLE;
return status;
}
awpImage* pImage = NULL;
pImage = image->GetImage();
if (awpCheckImage(pImage) != AWP_OK)
{
status = CFF_INVALID_HANDLE;
return status;
}
pParams->width = pImage->sSizeX;
pParams->height = pImage->sSizeY;
switch(pImage->bChannels)
{
case 1:
pParams->bpp = 8;
break;
case 3:
pParams->bpp = 24;
break;
}
return status;
}
示例4: CFDIBSize
/*
Функция:
CFDIBSize
Цель:
Возвращает размер буфера, необходимый для сохранения
изображения в формате DIB
Параметры:
[ in ] hImage - дескриптор изображения
[ out ] pSize - указатель на переменную, в которой будет сохранено
значение размера буфера.
Возвращаемые заначения:
CF_SUCCESS - Переменная pSize cодержит значение размера буфера
в противном случае возвращает код ошибки.
*/
CF_ERROR __EXPORT_TYPE CFDIBSize(CF_IMAGE hImage, int* pSize)
{
CF_ERROR status = CF_SUCCESS;
// проверим входные параметры
if (pSize == NULL)
{
return CFF_INVALID_PARAM;
}
TLFImage* image = (TLFImage*)hImage;
if(image == NULL)
{
status = CFF_INVALID_HANDLE;
*pSize = 0;
return status;
}
*pSize = 0;
awpImage* pImage = NULL;
pImage = image->GetImage();
if (awpCheckImage(pImage) != AWP_OK)
{
status = CFF_INVALID_HANDLE;
*pSize = 0;
return status;
}
int dib_width = ((pImage->sSizeX*24 + 31)/32) * 4; /* aligned to 4 bytes */
*pSize = dib_width*pImage->sSizeY;
return status;
}
示例5: CFSaveToDIB
/*
Функция:
CFSaveToDIB
Цель:
Сохраняет изображение в формате DIB
Параметры:
[ in ] hImage - дескриптор изображения
[ out ] info - указатель на заголовок DIB
[ out ] DIBPixels - указатель на пиксели изображения
Возвращаемые заначения:
CF_SUCCESS - данные изображения успешно записаны в память.
в противном случае возвращает код ошибки.
Замечания:
Функция всегда записывает любое изображение hImage в формате
DIB, который имеет глубину цвета 3 байта
*/
CF_ERROR __EXPORT_TYPE CFSaveToDIB( CF_IMAGE hImage, CF_BMP* info, BYTE* DIBPixels )
{
CF_ERROR status = CF_SUCCESS;
if(info == NULL)
{
status = CFF_INVALID_DIB;
return status;
}
TLFImage* image = (TLFImage*)hImage;
if(image == NULL)
{
status = CFF_INVALID_HANDLE;
return status;
}
BITMAPINFO lInfo;
memcpy( &lInfo, info, sizeof( BITMAPINFO ) );
bool flag = DIBPixels == NULL? false : true;
if(awpImageToDIB( image->GetImage(), &lInfo, (void**)(&DIBPixels), flag )!=AWP_OK)
{
status = CFF_INVALID_DIB;
return status;
}
memcpy( info, &lInfo, sizeof( BITMAPINFO ) );
return status;
}
示例6: 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;
}
示例7: Features
TLFDblVector* TLFAverageNNPredictor::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();
img->GetIntegralImage();
if (img == NULL || img->GetImage() == NULL)
return NULL;
//
int idx = d->GetStagesCount() - 1;
TLFObjectList* stages = d->GetStrongs();
ILFStrong* s = dynamic_cast<TCSStrong*>(stages->Get(idx));
if (s == NULL)
return NULL;
int width = rect->Width();
double scale_coef = (double)width / (double)d->GetBaseWidth();
TLFRect fragment;
TLFDblVector* data = new TLFDblVector(id);
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->AddValue(value);
}
}
return data;
}
示例8: CFGetDumpSize
CF_ERROR __EXPORT_TYPE CFGetDumpSize(CF_IMAGE hImage, CF_DWORD* pDumpSize)
{
CF_ERROR status = CF_SUCCESS;
TLFImage* image = (TLFImage*)hImage;
if(image == NULL)
{
status = CFF_INVALID_HANDLE;
return status;
}
awpImage* pImage = NULL;
pImage = image->GetImage();
if (awpCheckImage(pImage) != AWP_OK)
{
status = CFF_INVALID_HANDLE;
return status;
}
if (pDumpSize == NULL)
return CFF_INVALID_PARAM;
//todo: здесь мы предполагаем, что изображения могут быть либо
//полутоновыми, либо цветными, пиксели содержат только 1 байт на цвет
*pDumpSize = pImage->sSizeX*pImage->sSizeY*(pImage->bChannels == 1?1:3);
return status;
}
示例9: Process
void TLFTriangleList::Process(TLFImage& img)
{
Process(img.GetImage());
}
示例10: _tmain
int _tmain(int argc, _TCHAR* argv[])
{
if (argc < 2)
{
Usage();
return 1;
}
// main program
TiXmlDocument doc;
if (!doc.LoadFile(argv[1]))
{
printf("error: cannot load configuration.\n");
return 1;
}
TiXmlHandle hDoc(&doc);
TiXmlElement* pElem = NULL;
pElem = hDoc.FirstChildElement().Element();
if (!pElem)
{
printf("error: invalid configuration file.\n");
return 1;
}
const char* name = pElem->Value();
if (strcmp(name, "resize") != 0)
{
printf("error: invalid configuration file.\n");
return 1;
}
string path = pElem->Attribute("in_database");
string ext = pElem->Attribute("format");
g_path = pElem->Attribute("out");
pElem->QueryIntAttribute("width", &g_width);
pElem->QueryIntAttribute("height", &g_height);
printf("params:\n");
printf("input database: %s\n", path.c_str());
printf("output database: %s\n", g_path.c_str());
printf("output images format: %s\n", ext.c_str());
printf("out width %i\n", g_width);
printf("out height %i:\n",g_height);
if (!LFDirExist(g_path.c_str()))
LFCreateDir(g_path.c_str());
_finddata_t filesInfo;
int num_images = 0;
long handle = 0;
if ( (handle = _findfirst( (char*)((path+"*.awp").c_str()), &filesInfo)) != -1 )
{
do
{
string name = path + filesInfo.name;
TLFImage image;
if (!image.LoadImage((char*)name.c_str()))
{
printf("cannot load image %s \n", name.c_str());
continue;
}
num_images++;
awpImage* img = image.GetImage();
awpResize(img, g_width, g_height);
std::string FileName = g_path;
FileName += LFIntToStr(num_images);
FileName += ext;
image.SaveImage(FileName.c_str());
if (num_images % 100 == 0)
printf(">");
}while(!_findnext( handle, &filesInfo ));
}
_findclose( handle );
printf("\nprocessed %i images\n", num_images);
printf("done.\n");
return 0;
}
示例11: _tmain
int _tmain(int argc, _TCHAR* argv[])
{
if (argc < 2)
{
Usage();
return 1;
}
// main program
TiXmlDocument doc;
if (!doc.LoadFile(argv[1]))
{
printf("error: cannot load configuration.\n");
return 1;
}
TiXmlHandle hDoc(&doc);
TiXmlElement* pElem = NULL;
pElem = hDoc.FirstChildElement().Element();
if (!pElem)
{
printf("error: invalid configuration file.\n");
return 1;
}
const char* name = pElem->Value();
if (strcmp(name, "fvcccheck") != 0)
{
printf("error: invalid configuration file.\n");
return 1;
}
string path = pElem->Attribute("in_database");
string outName = pElem->Attribute("out_name");
string tmplName = pElem->Attribute("tmpl_name");
printf("params:\n");
printf("input database: %s\n", path.c_str());
printf("out name: %s\n", outName.c_str());
printf("tmpl name: %s\n", tmplName.c_str());
FvcTemplate* tmpl = NULL;
if (fvcLoadTemplate(tmplName.c_str(), &tmpl) != FVC_OK)
{
printf("error: cannot load template.\n");
return 1;
}
printf("template width %i:\n", tmpl->nVectorWidth);
printf("template height %i:\n", tmpl->nVectorHeight);
printf("template num vectors %i:\n", tmpl->nNumVectors);
_finddata_t filesInfo;
int num_images = 0;
long handle = 0;
FILE* f = fopen(outName.c_str(), "w+t");
if ( (handle = _findfirst( (char*)((path+"*.awp").c_str()), &filesInfo)) != -1 )
{
do
{
string name = path + filesInfo.name;
TLFImage image;
if (!image.LoadImage((char*)name.c_str()))
{
printf("cannot load image %s \n", name.c_str());
continue;
}
num_images++;
double ro = 0;
awpImage* img = image.GetImage();
awpConvert(img, AWP_CONVERT_TO_FLOAT);
fvcCompare(img, tmpl, &ro, FVC_COMPARE_EUCLID);
float ro1 = ro;
fprintf(f, "%s\t%f\n", filesInfo.name, ro1);
/* awpImage* rec = NULL;
if (fvcGetReconstruction(tmpl, img, &rec) != FVC_OK)
printf("reconstruction error.\n");
if (rec != NULL)
{
awpImage* norm = NULL;
awpNormalize(rec, &norm, AWP_NORM_L2);
awpConvert(norm, AWP_CONVERT_TO_FLOAT);
//
double ro = 0;
if (awpDistance(img, rec, AWP_DIST_L2 ,&ro) != AWP_OK)
printf("distance error.\n");
float ro1 = ro;
fprintf(f, "%s\t%f\n", filesInfo.name, ro1);
awpReleaseImage(&rec);
awpReleaseImage(&norm);
}*/
if (num_images % 100 == 0)
printf(">");
}while(!_findnext( handle, &filesInfo ));
}
_findclose( handle );
//.........这里部分代码省略.........
示例12: DoSegmentation
/*
Image segmentation main function
*/
bool DoSegmentation(awpImage* input, TSegmentationOptions& options, TLFObjectList* list)
{
bool result = false;
if (input == NULL || list == NULL)
return result;
// cluster sgments
if (options.segmentationType == 0)
return result;
TLFImage source;
awpImage* tmp = NULL;
double alfa = 1;
if (options.needResize)
{
int w = options.imageWidth;
int h = w*input->sSizeY / input->sSizeX;
awpResizeNip(input, &tmp, w,h);
}
else
awpCopyImage(input, &tmp);
awpConvert(tmp, AWP_CONVERT_3TO1_BYTE);
source.SetImage(tmp);
TLFTileScanner scanner;
scanner.SetBaseHeight(options.baseHeight);
scanner.SetBaseWidth(options.baseWidth);
scanner.GetParameter(0)->SetValue(options.tileOverlap);
scanner.Scan(source.GetImage()->sSizeX, source.GetImage()->sSizeY);
//
list->Clear();
if (scanner.GetFragmentsCount() > 0)
{
for (int i = 0; i < scanner.GetFragmentsCount(); i++)
{
awpRect rect = scanner.GetFragmentRect(i);
TLFSegmentationResult* sr = CreateFeature(options.baseFeature, &rect);
if (sr != NULL)
{
sr->Process(&source);
if (options.needResize)
{
alfa = (double)input->sSizeX / (double)options.imageWidth;
sr->GetRect()->Scale(alfa);
}
list->Add(sr);
}
}
}
// filtering
if (options.selectionCriteria == 0)
{
for (int i = list->GetCount() - 1; i >= 0; i--)
{
TLFSegmentationResult* sr = (TLFSegmentationResult*)list->Get(i);
if (sr->Value() < options.moreThen)
list->Delete(i);
}
}
else if (options.selectionCriteria == 1)
{
for (int i = list->GetCount() - 1; i >= 0; i--)
{
TLFSegmentationResult* sr = (TLFSegmentationResult*)list->Get(i);
if (sr->Value() > options.lessThen)
list->Delete(i);
}
}
else
{
for (int i = list->GetCount() - 1; i >= 0; i--)
{
TLFSegmentationResult* sr = (TLFSegmentationResult*)list->Get(i);
if (sr->Value() < options.minValue || sr->Value() > options.maxValue)
list->Delete(i);
}
}
_AWP_SAFE_RELEASE_(tmp)
result = true;
return result;
}