本文整理汇总了C++中idx::get方法的典型用法代码示例。如果您正苦于以下问题:C++ idx::get方法的具体用法?C++ idx::get怎么用?C++ idx::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类idx
的用法示例。
在下文中一共展示了idx::get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: set
void jitter::set(const idx<t_jitter> &j) {
s = j.get(0);
h = (int) j.get(1);
w = (int) j.get(2);
r = j.get(3);
idx_copy(j, jitts);
}
示例2: pairs
//! Return an idx of dimensions Nx2 containing all possible N similar pairs.
idx<int> make_pairs(idx<int> &labels) {
// allocate maximum number of pairs
idx<int> pairs((labels.dim(0) * (labels.dim(0) - 1)) / 2, 2);
int n = 0, r = 0;
// for each label, loop over all following labels to find pairs
for (int i = 0; i < labels.dim(0) - 1; ++i) {
for (int j = i + 1; j < labels.dim(0); ++j) {
if (labels.get(i) == labels.get(j)) {
r = drand(0.0, 1.0); // randomize distribution as 1st or 2nd element
pairs.set(i, n, (r > 0.5) ? 0 : 1);
pairs.set(j, n, (r > 0.5) ? 1 : 0);
n++;
}
}
}
pairs.resize(n, pairs.dim(1));
return pairs;
}
示例3: process_dir
//! Recursively goes through dir, looking for files matching extension ext.
void process_dir(const char *dir, const char *ext, const char* leftp,
const char *rightp, unsigned int width,
unsigned int fwidth, idx<float> &images,
idx<int> &labels, int label, bool silent, bool display,
bool *binocular,
const int channels_mode, const int channels_size,
idx<ubyte> &classes, unsigned int &counter,
idx<unsigned int> &counters_used, idx<int> &ds_assignment,
unsigned int fkernel_size, int deformations,
idx<int> &deformid, int &ndefid,
idx<ubyte> &ds_names) {
regex eExt(ext);
string el(".*");
idx<float> limg(1, 1, 1);
idx<float> rimg(1, 1, 1);
idx<float> tmp, left_images;
idx<int> current_labels;
idx<int> current_deformid;
idx<float> tmp2;
int current_ds;
unsigned int current_used;
if (leftp) {
el += leftp;
el += ".*";
}
regex eLeft(el);
cmatch what;
path p(dir);
if (!exists(p))
return ;
directory_iterator end_itr; // default construction yields past-the-end
for (directory_iterator itr(p); itr != end_itr; ++itr) {
if (is_directory(itr->status())) {
process_dir(itr->path().string().c_str(), ext, leftp, rightp, width,
fwidth, images, labels, label, silent, display, binocular,
channels_mode, channels_size, classes, counter,
counters_used, ds_assignment, fkernel_size, deformations,
deformid, ndefid, ds_names);
} else if (regex_match(itr->leaf().c_str(), what, eExt)) {
if (regex_match(itr->leaf().c_str(), what, eLeft)) {
current_ds = ds_assignment.get(counter);
if (current_ds != -1) {
current_used = counters_used.get(current_ds);
// found left image
// increase example number
labels.set(label, current_ds, counters_used.get(current_ds));
// check for right image
if (rightp != NULL) {
regex reg(leftp);
string rp(rightp);
string s = regex_replace(itr->leaf(), reg, rp);
string sfull = itr->path().branch_path().string();
sfull += "/";
sfull += s;
path r(sfull);
if (exists(r)) {
// found right image
*binocular = true;
if (image_read_rgbx(r.string().c_str(), rimg)) {
// resize stereo dimension to twice the channels_size
if (images.dim(3) == channels_size)
images.resize(images.dim(0), images.dim(1),
images.dim(2), images.dim(3) * 2);
// take the right most square of the image
if (rimg.dim(0) <= rimg.dim(1))
rimg = rimg.narrow(1, rimg.dim(0),
rimg.dim(1) - rimg.dim(0));
else
rimg = rimg.narrow(0, rimg.dim(1),
rimg.dim(0) - rimg.dim(1));
// resize image to target width
rimg = image_resize(rimg, width, width, 1);
tmp = images[current_ds];
tmp = tmp[counters_used.get(current_ds)];
tmp = tmp.narrow(2, channels_size, channels_size);
// finally copy right images to idx
convert_image(rimg, tmp, channels_mode, fkernel_size);
}
if (!silent)
cout << "Processing (right): " << sfull << endl;
}
}
if (!silent) {
cout << counter << "/" << ds_assignment.dim(0) << ": ";
cout << itr->path().string().c_str() << endl;
}
// process left image
if (image_read_rgbx(itr->path().string().c_str(), limg)) {
// take the left most square of the image
int h = limg.dim(0), w = limg.dim(1), newh, neww;
if (h > w) {
newh = width;
neww = (newh / (float) h) * w;
} else {
neww = width;
newh = (neww / (float) w) * h;
}
// resize image to target width
limg = image_resize(limg, neww, newh, 1);
//.........这里部分代码省略.........