本文整理汇总了C++中idx::get_idxdim方法的典型用法代码示例。如果您正苦于以下问题:C++ idx::get_idxdim方法的具体用法?C++ idx::get_idxdim怎么用?C++ idx::get_idxdim使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类idx
的用法示例。
在下文中一共展示了idx::get_idxdim方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
bool tracking_thread<Tnet>::get_data(vector<bbox*> &bboxes2,
idx<ubyte> &frame2, idx<ubyte> &tpl2) {
// lock data
pthread_mutex_lock(&mutex_out);
// only read data if it has been updated
if (!out_updated) {
// unlock data
pthread_mutex_unlock(&mutex_out);
return false;
}
// clear bboxes
for (ibox = bboxes2.begin(); ibox != bboxes2.end(); ++ibox) {
if (*ibox)
delete *ibox;
}
bboxes2.clear();
// copy bboxes pointers (now responsible for deleting them).
for (ibox = bboxes.begin(); ibox != bboxes.end(); ++ibox) {
bboxes2.push_back(*ibox);
}
// check frame is correctly allocated, if not, allocate.
if (frame2.order() != frame.order())
frame2 = idx<ubyte>(frame.get_idxdim());
else if (frame2.get_idxdim() != frame.get_idxdim())
frame2.resize(frame.get_idxdim());
// copy frame
idx_copy(frame, frame2);
// check tpl is correctly allocated, if not, allocate.
if (tpl2.order() != tpl.order())
tpl2 = idx<ubyte>(tpl.get_idxdim());
else if (tpl2.get_idxdim() != tpl.get_idxdim())
tpl2.resize(tpl.get_idxdim());
// copy tpl
idx_copy(tpl, tpl2);
// reset updated flag
out_updated = false;
// unlock data
pthread_mutex_unlock(&mutex_out);
// confirm that we copied data.
return true;
}
示例2: read_cast_matrix
void matlab::read_cast_matrix(mxArray *var, idx<T> &m) {
#ifdef __MATLAB__
// allocate a temporary matrix with same type as original matrix type
idx<Tmatlab> tmp(m.get_idxdim());
// load data
void *data = mxGetData(var);
// copy to idx
memcpy(m.idx_ptr(), (Tmatlab*) data, m.nelements() * sizeof (Tmatlab));
// copy-cast
idx_copy(tmp, m);
#endif
}
示例3: if
bool detection_thread<T>::set_data(idx<ubyte> &frame2,
std::string &fullname,
std::string &name, uint id) {
// lock data (non blocking)
if (!mutex_in.trylock())
return false;
// check frame is correctly allocated, if not, allocate.
if (frame2.order() != uframe.order())
uframe = idx<ubyte>(frame2.get_idxdim());
else if (frame2.get_idxdim() != uframe.get_idxdim())
uframe.resize(frame2.get_idxdim());
idx_copy(frame2, uframe); // copy frame
frame_loaded = true; // frame is loaded
frame_fullname = fullname;
frame_name = name; // copy name
frame_id = id; // copy frame_id
in_updated = true; // reset updated flag
bavailable = false; // declare thread as not available
bfed = true; // data has been fed at least once
mutex_in.unlock(); // unlock data
return true; // confirm that we copied data.
}
示例4: mirror
void padder<T>::pad(idx<T> &in, idx<T> &out) {
// allocate padded buffer
idxdim d = in;
d.setdim(1, d.dim(1) + nrow + nrow2);
d.setdim(2, d.dim(2) + ncol + ncol2);
if (out.get_idxdim() != d)
out.resize(d);
idx_clear(out);
// copy in to padded buffer
idx<T> tmp = out.narrow(1, in.dim(1), nrow);
tmp = tmp.narrow(2, in.dim(2), ncol);
idx_copy(in, tmp);
if (bmirror)
mirror(in, out);
}
示例5: read_cast_matrix
void read_cast_matrix(FILE *fp, idx<T2> &out) {
idx<T> m(out.get_idxdim());
read_matrix_body(fp, m);
idx_copy(m, out);
}
示例6: d
void class_answer<T, Tds1, Tds2>::fprop1(idx<T> &in, idx<T> &out)
{
// resize out if necessary
idxdim d(in);
d.setdim(0, 2); // 2 outputs per pixel: class,confidence
idx<T> outx = out;
idx<T> inx = in;
if (resize_output)
{
if (d != out.get_idxdim())
{
out.resize(d);
outx = out;
}
}
else // if not resizing, narrow to the number of targets
{
if (outx.dim(0) != targets.dim(0))
outx = outx.narrow(0, targets.dim(0), 0);
}
// apply tanh if required
if (apply_tanh)
{
mtanh.fprop1(in, tmp);
inx = tmp;
}
// loop on features (dimension 0) to set class and confidence
int classid;
T conf, max2 = 0;
idx_1loop2(ii, inx, T, oo, outx, T, {
if (binary_target)
{
T t0 = targets.gget(0);
T t1 = targets.gget(1);
T a = ii.gget();
if (std::fabs((double)a - t0) < std::fabs((double)a - t1))
{
oo.set((T)0, 0); // class 0
oo.set((T)(2 - std::fabs((double)a - t0)) / 2, 1); // conf
}
else
{
oo.set((T)1, 0); // class 1
oo.set((T)(2 - std::fabs((double)a - t1)) / 2, 1); // conf
}
}
else if (single_output >= 0)
{
oo.set((T)single_output, 0); // all answers are the same class
oo.set((T)((ii.get(single_output) - target_min) / target_range), 1);
}
else // 1-of-n target
{ // set class answer
if (force_class >= 0) classid = force_class;
else classid = idx_indexmax(ii);
oo.set((T)classid, 0);
// set confidence
intg p;
bool ini = false;
switch (conf_type)
{
case confidence_sqrdist: // squared distance to target
target = targets.select(0, classid);
conf = (T)(1.0 - ((idx_sqrdist(target, ii) - conf_shift)
/ conf_ratio));
oo.set(conf, 1);
break;
case confidence_single: // simply return class' out (normalized)
conf = (T)((ii.get(classid) - conf_shift) / conf_ratio);
oo.set(conf, 1);
break;
case confidence_max: // distance with 2nd max answer
conf = std::max(target_min, std::min(target_max, ii.get(classid)));
for (p = 0; p < ii.dim(0); ++p)
{
if (p != classid)
{
if (!ini)
{
max2 = ii.get(p);
ini = true;
}
else
{
if (ii.get(p) > max2)
max2 = ii.get(p);
}
}
}
max2 = std::max(target_min, std::min(target_max, max2));
oo.set((T)(((conf - max2) - conf_shift) / conf_ratio), 1);
break;
default:
eblerror("confidence type " << conf_type << " undefined");
}
}
});