Skip to content

Commit

Permalink
removed warnings about signed and unsigned numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
aaalgo committed Jun 23, 2018
1 parent a9f9d9a commit 326200a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 23 deletions.
2 changes: 1 addition & 1 deletion picpac-image.h
Expand Up @@ -319,8 +319,8 @@ namespace picpac {
string transforms;
Config ()
: channels(-1), // unchanged
images{0},
dtype(CV_32F),
images{0},
annotate(false),
transforms("[]")

Expand Down
8 changes: 4 additions & 4 deletions picpac.cpp
Expand Up @@ -226,7 +226,7 @@ namespace picpac {
out_ptr += sz;
}
}
CHECK(out_ptr - &new_data[0] == new_data.size());
CHECK(unsigned(out_ptr - &new_data[0]) == new_data.size());
data.swap(new_data);
meta_ptr = new_meta;
CHECK((meta_ptr == reinterpret_cast<Meta *>(&data[0]))
Expand Down Expand Up @@ -410,7 +410,7 @@ namespace picpac {
std::shuffle(g.index.begin(), g.index.end(), rng);
}
}
unsigned K = config.split;
int K = config.split;
vector<unsigned> keys;
if (config.split_keys.size()) {
CHECK(config.split_fold < 0) << "Cannot use keys and fold simultaneously.";
Expand All @@ -419,14 +419,14 @@ namespace picpac {
}
else {
// setup k-fold cross validation
for (unsigned k = 0; k < K; ++k) {
for (int k = 0; k < K; ++k) {
if (k != config.split_fold) keys.push_back(k);
}
}
if (config.split_negate) {
std::set<unsigned> excl(keys.begin(), keys.end());
keys.clear();
for (unsigned k = 0; k < K; ++k) {
for (int k = 0; k < K; ++k) {
if (excl.count(k) == 0) {
keys.push_back(k);
}
Expand Down
8 changes: 4 additions & 4 deletions python-api.cpp
Expand Up @@ -225,7 +225,7 @@ class PyImageStream: public ImageStream {
vector<int32_t> ids;
vector<float> labels;
vector<list> raw_fields;
for (auto const &x: ImageLoader::config.raw) {
for (unsigned i = 0; i < ImageLoader::config.raw.size(); ++i) {
raw_fields.push_back(list());
}
vector<unique_ptr<FacetData>> data;
Expand Down Expand Up @@ -288,7 +288,7 @@ class PyImageStream: public ImageStream {
break;
}
}
npy_intp dims[1] = {labels.size()};
npy_intp dims[1] = {int(labels.size())};
PyObject *pyids = PyArray_SimpleNew(1, dims, NPY_INT32);
CHECK(pyids);
PyObject *pylabels = PyArray_SimpleNew(1, dims, NPY_FLOAT32);
Expand Down Expand Up @@ -440,7 +440,7 @@ class Writer: public FileWriter {
};

class Reader: public IndexedFileReader {
int _next;
unsigned _next;
object ctor;
public:
Reader (string const &path): IndexedFileReader(path), _next(0) {
Expand Down Expand Up @@ -669,7 +669,7 @@ namespace {
CHECK(prob.rows == params.rows);
CHECK(prob.cols == params.cols);
//CHECK(prob.channels() == 1);
CHECK(params.channels() == SHAPE::PARAMS * prob.channels());
CHECK(params.channels() == int(SHAPE::PARAMS * prob.channels()));
vector<Shape> all;
int priors = prob.channels();
for (int y = 0; y < prob.rows; ++y) {
Expand Down
23 changes: 9 additions & 14 deletions transforms.cpp
Expand Up @@ -47,7 +47,7 @@ namespace picpac {
index = spec.value<int>("index", -1);
}
virtual size_t apply (Sample *sample, void const *) const {
auto &ref_image = sample->facets[ref].image;
//auto &ref_image = sample->facets[ref].image;
int idx = index;
if (idx < 0) { // add image
sample->facets.emplace_back();
Expand Down Expand Up @@ -126,7 +126,7 @@ namespace picpac {
}
else {
if (facet.image.data) {
true;
;
}
else {
facet.image = cv::Mat(facet.annotation.size, type, cv::Scalar(0,0,0,0));
Expand Down Expand Up @@ -355,9 +355,9 @@ namespace picpac {
size(spec.value<int>("size", 0)),
min(spec.value<int>("min", size ? size : 0)),
max(spec.value<int>("max", size ? size : numeric_limits<int>::max())),
round(spec.value<int>("round", 0)),
width(spec.value<int>("width", 0)),
height(spec.value<int>("height", 0)),
round(spec.value<int>("round", 0)),
min_width(spec.value<int>("min_width", min)),
max_width(spec.value<int>("max_width", max)),
min_height(spec.value<int>("min_height", min)),
Expand Down Expand Up @@ -928,15 +928,10 @@ namespace picpac {
static void init_prior(float *params, json const &p) {
CHECK(p.is_array());
CHECK(p.size() == 2);
float sz = p.at(0);
float ratio = p.at(1);
ratio = std::sqrt(ratio);
// x / y = ratio
// x * y = sz * sz
// x = sz * sqrt(ratio)
// y = sz / sqrt(ratio)
params[0] = sz * ratio;
params[1] = sz / ratio;
float w = p.at(0);
float h = p.at(1);
params[0] = w;
params[1] = h;
LOG(WARNING)<< "prior w:" << params[0] << " h:" << params[1];
}

Expand Down Expand Up @@ -1135,8 +1130,8 @@ namespace picpac {
if (params_default != 0) {
float *b = params.ptr<float>(0);
float *e = b + params.total() * params.channels();
CHECK(params.total() == sz.area());
CHECK(params.channels() == priors.rows * ANCHOR::PARAMS);
CHECK(params.total() == int(sz.area()));
CHECK(params.channels() == int(priors.rows * ANCHOR::PARAMS));
std::fill(b, e, params_default);
}

Expand Down

0 comments on commit 326200a

Please sign in to comment.