本文整理汇总了C++中TemplateList类的典型用法代码示例。如果您正苦于以下问题:C++ TemplateList类的具体用法?C++ TemplateList怎么用?C++ TemplateList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TemplateList类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: pairwiseCompare
void pairwiseCompare(File targetGallery, File queryGallery, File output)
{
qDebug("Pairwise comparing %s and %s%s", qPrintable(targetGallery.flat()),
qPrintable(queryGallery.flat()),
output.isNull() ? "" : qPrintable(" to " + output.flat()));
if (distance.isNull()) qFatal("Null distance.");
if (queryGallery == ".") queryGallery = targetGallery;
QScopedPointer<Gallery> t, q;
FileList targetFiles, queryFiles;
retrieveOrEnroll(targetGallery, t, targetFiles);
retrieveOrEnroll(queryGallery, q, queryFiles);
if (t->files().length() != q->files().length() )
qFatal("Dimension mismatch in pairwise compare");
TemplateList queries = q->read();
TemplateList targets = t->read();
// Use a single file for one of the dimensions so that the output makes the right size file
FileList dummyTarget;
dummyTarget.append(targets[0]);
QScopedPointer<Output> realOutput(Output::make(output, dummyTarget, queryFiles));
realOutput->set_blockRows(INT_MAX);
realOutput->set_blockCols(INT_MAX);
realOutput->setBlock(0,0);
for (int i=0; i < queries.length(); i++)
{
float res = distance->compare(queries[i], targets[i]);
realOutput->setRelative(res, 0,i);
}
}
开发者ID:ShivaniBhardwaj,项目名称:openbr,代码行数:35,代码来源:core.cpp
示例2: project
void project(const TemplateList &src, TemplateList &dst) const
{
CascadeClassifier *cascade = cascadeResource.acquire();
foreach (const Template &t, src) {
// As a special case, skip detection if the appropriate metadata already exists
if (t.file.contains(model)) {
Template u = t;
u.file.setRects(QList<QRectF>() << t.file.get<QRectF>(model));
u.file.set("Confidence", t.file.get<float>("Confidence", 1));
dst.append(u);
continue;
}
const bool enrollAll = t.file.getBool("enrollAll");
// Mirror the behavior of ExpandTransform in the special case
// of an empty template.
if (t.empty() && !enrollAll) {
dst.append(t);
continue;
}
for (int i=0; i<t.size(); i++) {
const int maxDetections = t.file.get<int>("MaxDetections", std::numeric_limits<int>::max());
const int minSize = t.file.get<int>("MinSize", this->minSize);
const int flags = (enrollAll && (maxDetections != 1)) ? 0 : CASCADE_FIND_BIGGEST_OBJECT;
Mat m;
OpenCVUtils::cvtUChar(t[i], m);
std::vector<Rect> rects;
std::vector<int> rejectLevels;
std::vector<double> levelWeights;
if (ROCMode) cascade->detectMultiScale(m, rects, rejectLevels, levelWeights, 1.2, minNeighbors, flags | CASCADE_SCALE_IMAGE, Size(minSize, minSize), Size(), true);
else cascade->detectMultiScale(m, rects, 1.2, minNeighbors, flags, Size(minSize, minSize));
bool empty = false;
if (!enrollAll && rects.empty()) {
empty = true;
rects.push_back(Rect(0, 0, m.cols, m.rows));
}
const size_t detections = std::min(size_t(maxDetections), rects.size());
for (size_t j=0; j<detections; j++) {
Template u(t.file, m);
if (empty) {
u.file.set("Confidence",-std::numeric_limits<float>::max());
} else if (rejectLevels.size() > j)
u.file.set("Confidence", rejectLevels[j]*levelWeights[j]);
else
u.file.set("Confidence", rects[j].area());
const QRectF rect = OpenCVUtils::fromRect(rects[j]);
u.file.appendRect(rect);
u.file.set(model, rect);
dst.append(u);
}
}
}
cascadeResource.release(cascade);
}
开发者ID:ragaraam,项目名称:openbr,代码行数:60,代码来源:cascade.cpp
示例3: projectUpdate
void projectUpdate(const TemplateList &src, TemplateList &dst)
{
dst.reserve(src.size());
foreach (const Template &t, src) {
dst.append(Template());
projectUpdate(t, dst.last());
}
开发者ID:23119841,项目名称:openbr,代码行数:7,代码来源:independent.cpp
示例4: message
/*!
*/
ApiProxyResult CommandTemplateSet::execute(const TemplateList& template_configurations) {
std::auto_ptr<CDataWrapper> message(new CDataWrapper());
for(TemplateListConstIterator it = template_configurations.begin();
it != template_configurations.end();
it++) {
std::auto_ptr<CDataWrapper> template_element(new CDataWrapper());
template_element->addStringValue("template_name", (*it)->template_name);
template_element->addStringValue(BatchCommandAndParameterDescriptionkey::BC_UNIQUE_ID, (*it)->command_unique_id);
//! scan all parameter configuration
for(ParameterSetterListIterator it_param = (*it)->parameter_value_list.begin();
it_param != (*it)->parameter_value_list.end();
it_param++){
(*it_param)->setTo(*template_element);
}
template_element->addInt32Value(BatchCommandSubmissionKey::SUBMISSION_RULE_UI32, (*it)->submission_rule);
template_element->addInt32Value(BatchCommandSubmissionKey::SUBMISSION_PRIORITY_UI32, (*it)->submission_priority);
template_element->addInt64Value(BatchCommandSubmissionKey::SCHEDULER_STEP_TIME_INTERVALL_UI64, (*it)->schedule_step_delay);
template_element->addInt32Value(BatchCommandSubmissionKey::SUBMISSION_RETRY_DELAY_UI32, (*it)->submission_retry_delay);
template_element->addInt32Value(BatchCommandSubmissionKey::COMMAND_EXECUTION_CHANNEL, (*it)->execution_channel);
message->appendCDataWrapperToArray(*template_element);
}
message->finalizeArrayForKey("template_list");
//call api
return callApi(message.release());
}
开发者ID:,项目名称:,代码行数:28,代码来源:
示例5: train
void train(const TemplateList &data)
{
Mat m;
OpenCVUtils::toMat(data.data()).convertTo(m, CV_64F);
const QList<int> labels = data.indexProperty(inputVariable);
const int dims = m.cols;
std::vector<Mat> mv, av, bv;
split(m, mv);
for (size_t c = 0; c < mv.size(); c++) {
av.push_back(Mat(1, dims, CV_64FC1));
bv.push_back(Mat(1, dims, CV_64FC1));
}
QFutureSynchronizer<void> futures;
for (size_t c = 0; c < mv.size(); c++) {
for (int i=0; i<dims; i++)
futures.addFuture(QtConcurrent::run(_train, method, mv[c].col(i), labels, &av[c].at<double>(0, i), &bv[c].at<double>(0, i)));
av[c] = av[c].reshape(1, data.first().m().rows);
bv[c] = bv[c].reshape(1, data.first().m().rows);
}
futures.waitForFinished();
merge(av, a);
merge(bv, b);
a.convertTo(a, data.first().m().type());
b.convertTo(b, data.first().m().type());
OpenCVUtils::saveImage(a, Globals->property("CENTER_TRAIN_A").toString());
OpenCVUtils::saveImage(b, Globals->property("CENTER_TRAIN_B").toString());
}
开发者ID:Alive-AttemptTheLifeGangHouse,项目名称:openbr,代码行数:31,代码来源:normalize.cpp
示例6: readBlock
TemplateList readBlock(bool *done)
{
TemplateList templates;
*done = true;
// Enrolling a null file is used as an idiom to initialize an algorithm
if (file.isNull()) return templates;
// Add immediate subfolders
QDir dir(file);
QList< QFuture<TemplateList> > futures;
foreach (const QString &folder, QtUtils::naturalSort(dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot))) {
const QDir subdir = dir.absoluteFilePath(folder);
futures.append(QtConcurrent::run(&EmptyGallery::getTemplates, subdir));
}
foreach (const QFuture<TemplateList> &future, futures)
templates.append(future.result());
// Add root folder
foreach (const QString &fileName, QtUtils::getFiles(file.name, false))
templates.append(File(fileName, dir.dirName()));
if (!regexp.isEmpty()) {
QRegExp re(regexp);
re.setPatternSyntax(QRegExp::Wildcard);
for (int i=templates.size()-1; i>=0; i--) {
if (!re.exactMatch(templates[i].file.fileName())) {
templates.removeAt(i);
}
}
}
return templates;
}
开发者ID:QuickbridgeLtd,项目名称:openbr,代码行数:34,代码来源:gallery.cpp
示例7: train
void train(const TemplateList &cudaTrainingSet)
{
cublasStatus_t cublasStatus;
cudaError_t cudaError;
// put all the data into a single matrix to perform PCA
const int instances = cudaTrainingSet.size();
const int dimsIn = *(int*)cudaTrainingSet.first().m().ptr<void*>()[1]
* *(int*)cudaTrainingSet.first().m().ptr<void*>()[2];
// copy the data over
double* cudaDataPtr;
CUDA_SAFE_MALLOC(&cudaDataPtr, instances*dimsIn*sizeof(cudaDataPtr[0]), &cudaError);
for (int i=0; i < instances; i++) {
br::cuda::pca::castFloatToDouble(
(float*)(cudaTrainingSet[i].m().ptr<void*>()[0]),
1,
cudaDataPtr+i*dimsIn,
1,
dimsIn
);
}
trainCore(cudaDataPtr, dimsIn, instances);
CUDA_SAFE_FREE(cudaDataPtr, &cudaError);
}
开发者ID:13221325403,项目名称:openbr,代码行数:27,代码来源:cudapca.cpp
示例8: Simplified
static TemplateList Simplified(const TemplateList &templates)
{
TemplateList simplified;
foreach (const Template &t, templates) {
if (t.isEmpty()) {
if (!t.file.getBool("enrollAll"))
simplified.append(t);
continue;
}
const bool fte = t.file.getBool("FTE");
QList<QPointF> landmarks = t.file.landmarks();
QList<QRectF> ROIs = t.file.ROIs();
if (landmarks.size() % t.size() != 0) qFatal("TemplateList::simplified uneven landmark count.");
if (ROIs.size() % t.size() != 0) qFatal("TemplateList::simplified uneven ROI count.");
const int landmarkStep = landmarks.size() / t.size();
const int ROIStep = ROIs.size() / t.size();
for (int i=0; i<t.size(); i++) {
if (!fte || !t.file.getBool("enrollAll")) {
simplified.append(Template(t.file, t[i]));
simplified.last().file.setROIs(ROIs.mid(i*ROIStep, ROIStep));
simplified.last().file.setLandmarks(landmarks.mid(i*landmarkStep, landmarkStep));
}
}
}
return simplified;
}
开发者ID:caotto,项目名称:openbr,代码行数:28,代码来源:meta.cpp
示例9: estimate_gender
int32_t SdkEstimator::estimate_gender(const ONEFACE &input_face, int8_t &gender, double &mf)
{
TemplateList templates;
templates.append(templateFromONEFACE(input_face));
templates >> *frvt2012_gender_transform.data();
mf = gender = templates.first().file.label();
return templates.first().file.failed() ? 4 : 0;
}
开发者ID:caotto,项目名称:openbr,代码行数:8,代码来源:frvt2012.cpp
示例10: estimate_age
int32_t SdkEstimator::estimate_age(const ONEFACE &input_face, int32_t &age)
{
TemplateList templates;
templates.append(templateFromONEFACE(input_face));
templates >> *frvt2012_age_transform.data();
age = templates.first().file.label();
return templates.first().file.failed() ? 4 : 0;
}
开发者ID:caotto,项目名称:openbr,代码行数:8,代码来源:frvt2012.cpp
示例11: getTemplates
static TemplateList getTemplates(const QDir &dir)
{
const QStringList files = QtUtils::getFiles(dir, true);
TemplateList templates; templates.reserve(files.size());
foreach (const QString &file, files)
templates.append(File(file, dir.dirName()));
return templates;
}
开发者ID:QuickbridgeLtd,项目名称:openbr,代码行数:8,代码来源:gallery.cpp
示例12: project
void project(const TemplateList &src, TemplateList &dst) const
{
TemplateList partitioned = src.partition(inputVariable);
for (int i=0; i<partitioned.size(); i++) {
int partition = partitioned[i].file.get<int>("Partition", 0);
transforms[partition]->project(partitioned, dst);
}
}
开发者ID:23119841,项目名称:openbr,代码行数:9,代码来源:crossvalidate.cpp
示例13: getAllTemplates
TemplateList Manager::getTemplates(KileDocument::Type type) const {
if(type == KileDocument::Undefined) {
return getAllTemplates();
}
TemplateList toReturn;
for (KileTemplate::TemplateListConstIterator i = m_TemplateList.constBegin(); i != m_TemplateList.constEnd(); ++i) {
KileTemplate::Info info = *i;
if(info.type == type) {
toReturn.push_back(info);
}
}
return toReturn;
}
开发者ID:KDE,项目名称:kile,代码行数:14,代码来源:templates.cpp
示例14: train
void train(const TemplateList &trainingSet)
{
if (trainingSet.first().m().type() != CV_32FC1)
qFatal("PCA::train requires single channel 32-bit floating point matrices.");
originalRows = trainingSet.first().m().rows;
int dimsIn = trainingSet.first().m().rows * trainingSet.first().m().cols;
const int instances = trainingSet.size();
// Map into 64-bit Eigen matrix
Eigen::MatrixXd data(dimsIn, instances);
for (int i=0; i<instances; i++)
data.col(i) = Eigen::Map<const Eigen::MatrixXf>(trainingSet[i].m().ptr<float>(), dimsIn, 1).cast<double>();
train(data);
}
开发者ID:,项目名称:,代码行数:16,代码来源:
示例15: enroll_utemplate
static void enroll_utemplate(br_const_utemplate utemplate, br_callback_context)
{
if (utemplate->algorithmID != 3)
qFatal("Expected an encoded image.");
TemplateList templates;
templates.append(Template(imdecode(Mat(1, utemplate->size, CV_8UC1, (void*) utemplate->data), IMREAD_UNCHANGED)));
templates >> *algorithm;
foreach (const Template &t, templates) {
const Mat &m = t.m();
const uint32_t size = m.rows * m.cols * m.elemSize();
const QByteArray templateID = QCryptographicHash::hash(QByteArray((const char*) m.data, size), QCryptographicHash::Md5);
br_append_utemplate_contents(stdout, utemplate->imageID, (const int8_t*) templateID.data(), -1, size, m.data);
}
}
开发者ID:jayakumark,项目名称:openbr,代码行数:16,代码来源:br-enroll.cpp
示例16: project
void project(const TemplateList &src, TemplateList &dst) const
{
CascadeClassifier *cascade = cascadeResource.acquire();
foreach (const Template &t, src) {
const bool enrollAll = t.file.getBool("enrollAll");
for (int i=0; i<t.size(); i++) {
const Mat &m = t[i];
std::vector<Rect> rects;
std::vector<int> rejectLevels;
std::vector<double> levelWeights;
if (ROCMode) cascade->detectMultiScale(m, rects, rejectLevels, levelWeights, 1.2, 5, (enrollAll ? 0 : CASCADE_FIND_BIGGEST_OBJECT) | CASCADE_SCALE_IMAGE, Size(minSize, minSize), Size(), true);
else cascade->detectMultiScale(m, rects, 1.2, 5, enrollAll ? 0 : CASCADE_FIND_BIGGEST_OBJECT, Size(minSize, minSize));
if (!enrollAll && rects.empty())
rects.push_back(Rect(0, 0, m.cols, m.rows));
for (size_t j=0; j<rects.size(); j++) {
Template u(t.file, m);
if (rejectLevels.size() > j)
u.file.set("Confidence", rejectLevels[j]*levelWeights[j]);
else
u.file.set("Confidence", 1);
const QRectF rect = OpenCVUtils::fromRect(rects[j]);
u.file.appendRect(rect);
u.file.set(model, rect);
dst.append(u);
}
}
}
cascadeResource.release(cascade);
}
开发者ID:RoxanneGe,项目名称:openbr,代码行数:33,代码来源:cascade.cpp
示例17: train
void train(const TemplateList &_data)
{
Mat data = OpenCVUtils::toMat(_data.data());
Mat lab;
// If we are doing regression, the input variable should have float
// values
if (type == EPS_SVR || type == NU_SVR) {
lab = OpenCVUtils::toMat(File::get<float>(_data, inputVariable));
}
// If we are doing classification, we should be dealing with discrete
// values. Map them and store the mapping data
else {
QList<int> dataLabels = _data.indexProperty(inputVariable, labelMap, reverseLookup);
lab = OpenCVUtils::toMat(dataLabels);
}
trainSVM(svm, data, lab, kernel, type, C, gamma);
}
开发者ID:Alegzandra,项目名称:openbr,代码行数:17,代码来源:svm.cpp
示例18: convert_multiface_to_verification_template
int32_t convert_multiface_to_verification_template(const MULTIFACE &input_faces, uint32_t &template_size, uint8_t* proprietary_template, uint8_t &quality)
{
// Enroll templates
TemplateList templates; templates.reserve(input_faces.size());
foreach (const ONEFACE &oneface, input_faces)
templates.append(templateFromONEFACE(oneface));
templates >> *frvt2012_transform.data();
// Compute template size
template_size = templates.size() * frvt2012_template_size;
// Create proprietary template
for (int i=0; i<templates.size(); i++)
memcpy(&proprietary_template[i*frvt2012_template_size], templates[i].m().data, frvt2012_template_size);
quality = 100;
return 0;
}
开发者ID:caotto,项目名称:openbr,代码行数:18,代码来源:frvt2012.cpp
示例19:
bool
DialUpView::SaveSettings(BMessage *settings, BMessage *profile, bool saveTemporary)
{
if(!fCurrentItem || !settings || !profile)
return false;
DialUpAddon *addon;
TemplateList<DialUpAddon*> addons;
for(int32 index = 0;
fAddons.FindPointer(DUN_TAB_ADDON_TYPE, index,
reinterpret_cast<void**>(&addon)) == B_OK; index++) {
if(!addon)
continue;
int32 insertIndex = 0;
for(; insertIndex < addons.CountItems(); insertIndex++)
if(addons.ItemAt(insertIndex)->Priority() <= addon->Priority())
break;
addons.AddItem(addon, insertIndex);
}
settings->AddInt32("Interface", static_cast<int32>(fWatching));
if(fCurrentItem)
settings->AddString("InterfaceName", fCurrentItem->Label());
for(int32 index = 0; index < addons.CountItems(); index++)
if(!addons.ItemAt(index)->SaveSettings(settings, profile, saveTemporary))
return false;
return true;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:32,代码来源:DialUpView.cpp
示例20: enroll_utemplate
static void enroll_utemplate(br_const_utemplate utemplate, br_callback_context)
{
if (utemplate->algorithmID != 3)
qFatal("Expected an encoded image.");
TemplateList templates;
templates.append(Template(imdecode(Mat(1, utemplate->size, CV_8UC1, (void*) utemplate->data), IMREAD_UNCHANGED)));
templates >> *algorithm;
foreach (const Template &t, templates) {
const Mat &m = t.m();
QByteArray data((const char*) m.data, m.rows * m.cols * m.elemSize());
const QRectF frontalFace = t.file.get<QRectF>("FrontalFace");
const QPointF firstEye = t.file.get<QPointF>("First_Eye");
const QPointF secondEye = t.file.get<QPointF>("Second_Eye");
const float x = frontalFace.x();
const float y = frontalFace.y();
const float width = frontalFace.width();
const float height = frontalFace.height();
const float rightEyeX = firstEye.x();
const float rightEyeY = firstEye.y();
const float leftEyeX = secondEye.x();
const float leftEyeY = secondEye.y();
data.append((const char*)&x , sizeof(float));
data.append((const char*)&y , sizeof(float));
data.append((const char*)&width , sizeof(float));
data.append((const char*)&height , sizeof(float));
data.append((const char*)&rightEyeX, sizeof(float));
data.append((const char*)&rightEyeY, sizeof(float));
data.append((const char*)&leftEyeX , sizeof(float));
data.append((const char*)&leftEyeY , sizeof(float));
const QByteArray templateID = QCryptographicHash::hash(data, QCryptographicHash::Md5);
br_append_utemplate_contents(stdout, utemplate->imageID, (const unsigned char*) templateID.data(), -1, data.size(), (const unsigned char*) data.data());
}
}
开发者ID:DBNC,项目名称:openbr,代码行数:38,代码来源:br-enroll.cpp
注:本文中的TemplateList类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论