diff --git a/Application/src/commons/common/file/Path.cpp b/Application/src/commons/common/file/Path.cpp index 26a64e48dd0f445e3acd311e3d04f286a1a1ea4c..98b4bae2b688378e468980083944c2ac771a75ee 100644 --- a/Application/src/commons/common/file/Path.cpp +++ b/Application/src/commons/common/file/Path.cpp @@ -246,7 +246,7 @@ std::string_view Path::filename() const { auto extensions = utils::split(utils::lowercase(filter_extension), ';'); if(path.has_extension()) { - return contains(extensions, path.extension()); + return contains(extensions, utils::lowercase((std::string)path.extension())); } return false; diff --git a/Application/src/commons/common/gui/DrawStructure.cpp b/Application/src/commons/common/gui/DrawStructure.cpp index c708c6c00a3028b881b8ea640582628667bf9941..f8b2c181ef2ca0f263bd1722ad2710153d47b038 100644 --- a/Application/src/commons/common/gui/DrawStructure.cpp +++ b/Application/src/commons/common/gui/DrawStructure.cpp @@ -90,7 +90,7 @@ namespace gui { e.update(); if(e.alpha <= 0) - error_messages.erase(error_messages.begin() + (i - 1)); + error_messages.erase(error_messages.begin() + int64_t(i - 1)); } } } @@ -437,14 +437,14 @@ namespace gui { auto it = std::find(parent->children().begin(), parent->children().end(), s); if(it != parent->children().end()) { //Debug("Section '%S' is at %lu, while index is %d/%lu in '%S'", &name, std::distance(parent->children().begin(), it), parent->_index, parent->children().size(), &parent->HasName::name()); - if(it != parent->children().begin()+parent->_index) { + if(it != parent->children().begin() + (int64_t)parent->_index) { if(parent->_index >= size_t(it - parent->children().begin())) { parent->_index--; //Debug("Decreasing index to %d, deleting and inserting element '%S'", parent->_index, &name); } parent->children().erase(it); - parent->children().insert(parent->children().begin() + parent->_index, s); + parent->children().insert(parent->children().begin() + (int64_t)parent->_index, s); #ifndef NDEBUG Debug("Moved section '%S' (%d)", &name, parent->_index); #endif @@ -732,7 +732,7 @@ namespace gui { } void DrawStructure::set_size(const Size2& size) { - _width = size.width; - _height = size.height; + _width = narrow_cast<uint16_t>(size.width); + _height = narrow_cast<uint16_t>(size.height); } } diff --git a/Application/src/commons/common/gui/IMGUIBase.cpp b/Application/src/commons/common/gui/IMGUIBase.cpp index 3cff68eb2a590b2dd6012b29566c4014ff9a9aae..d698da4f7881e9c3265a901d1695804951266900 100644 --- a/Application/src/commons/common/gui/IMGUIBase.cpp +++ b/Application/src/commons/common/gui/IMGUIBase.cpp @@ -389,18 +389,18 @@ void clear_cache() { if(width > mw) { float ratio = float(width) / float(height); width = mw; - height = width * ratio; + height = int(width * ratio); } } else { if(height > mh) { float ratio = float(width) / float(height); height = mh; - width = ratio * height; + width = int(ratio * height); } } _platform->create_window(title.c_str(), width, height); - glfwSetWindowPos(_platform->window_handle(), mx + (mw - width) * 0.5, my + (mh - height) * 0.5); + glfwSetWindowPos(_platform->window_handle(), mx + (mw - width) / 2, my + (mh - height) / 2); glfwSetDropCallback(_platform->window_handle(), [](GLFWwindow* window, int N, const char** texts){ std::vector<file::Path> _paths; @@ -482,8 +482,8 @@ void clear_cache() { glfwSetCursorPosCallback(_platform->window_handle(), [](GLFWwindow* window, double xpos, double ypos) { Event e(EventType::MMOVE); auto &io = ImGui::GetIO(); - e.move.x = xpos * io.DisplayFramebufferScale.x; - e.move.y = ypos * io.DisplayFramebufferScale.y; + e.move.x = float(xpos * io.DisplayFramebufferScale.x); + e.move.y = float(ypos * io.DisplayFramebufferScale.y); auto base = base_pointers.at(window); base->event(e); @@ -501,8 +501,8 @@ void clear_cache() { double xpos, ypos; glfwGetCursorPos(window, &xpos, &ypos); auto &io = ImGui::GetIO(); - e.mbutton.x = xpos * io.DisplayFramebufferScale.x; - e.mbutton.y = ypos * io.DisplayFramebufferScale.y; + e.mbutton.x = float(xpos * io.DisplayFramebufferScale.x); + e.mbutton.y = float(ypos * io.DisplayFramebufferScale.y); e.mbutton.button = GLFW_MOUSE_BUTTON_RIGHT == button ? 1 : 0; auto base = base_pointers.at(window); @@ -511,7 +511,7 @@ void clear_cache() { }); glfwSetScrollCallback(_platform->window_handle(), [](GLFWwindow* window, double xoff, double yoff) { Event e(EventType::SCROLL); - e.scroll.delta = yoff; + e.scroll.delta = float(yoff); auto base = base_pointers.at(window); base->event(e); @@ -519,7 +519,7 @@ void clear_cache() { }); glfwSetCharCallback(_platform->window_handle(), [](GLFWwindow* window, unsigned int c) { Event e(EventType::TEXT_ENTERED); - e.text.c = c; + e.text.c = char(c); auto base = base_pointers.at(window); base->event(e); @@ -722,8 +722,8 @@ void PolyFillScanFlood(ImDrawList *draw, std::vector<ImVec2> *poly, ImColor colo // find the orthagonal bounding box // probably can put this as a predefined if (!isMinMaxDone) { - min.x = min.y = DBL_MAX; - max.x = max.y = DBL_MIN; + min.x = min.y = FLT_MAX; + max.x = max.y = -FLT_MAX; for (auto p : *poly) { if (p.x < min.x) min.x = p.x; if (p.y < min.y) min.y = p.y; @@ -839,7 +839,7 @@ void PolyFillScanFlood(ImDrawList *draw, std::vector<ImVec2> *poly, ImColor colo max.x += 1; // Initialise our starting conditions - int y = min.y; + int y = int(min.y); // Go through each scan line iteratively, jumping by 'gap' pixels each time while (y < max.y) { @@ -923,16 +923,16 @@ void IMGUIBase::draw_element(const DrawOrder& order) { case Type::CIRCLE: { auto ptr = static_cast<Circle*>(o); - double e = 0.25; - double r = max(1, order.bounds.width * 0.5); + auto e = 0.25f; + auto r = max(1, order.bounds.width * 0.5f); auto th = acos(2 * SQR(1 - e / r) - 1); - size_t num_segments = ceil(2*M_PI/th); + int64_t num_segments = (int64_t)ceil(2*M_PI/th); if(num_segments <= 1) break; auto centre = ImVec2(order.bounds.x + o->origin().x * order.bounds.width, order.bounds.y + o->origin().y * order.bounds.height); - const float a_max = M_PI*2.0f * ((float)num_segments - 1.0f) / (float)num_segments; + const float a_max = (float)M_PI*2.0f * ((float)num_segments - 1.0f) / (float)num_segments; list->PathArcTo(centre, r, 0.0f, a_max, (int)num_segments - 1); if(ptr->fillclr() != Transparent) { @@ -1248,7 +1248,7 @@ void IMGUIBase::draw_element(const DrawOrder& order) { Warning("Trying to get line_spacing without a font loaded."); return Base::line_spacing(font); } - return font.size * _fonts.at(font.style)->FontSize / im_font_scale; + return sign_cast<uint32_t>(font.size * _fonts.at(font.style)->FontSize / im_font_scale); } void IMGUIBase::set_title(std::string title) { diff --git a/Application/src/commons/common/gui/types/Histogram.h b/Application/src/commons/common/gui/types/Histogram.h index d72b79cc42eceb1846946427bfa2f1e3278ab189..ffde921a8ddf72c9958b2b0344494d817bb1aa95 100644 --- a/Application/src/commons/common/gui/types/Histogram.h +++ b/Application/src/commons/common/gui/types/Histogram.h @@ -58,7 +58,7 @@ namespace gui { _filter(filter), _display(display), _needs_update(true), - _title_obj(title, Vec2(margin, margin), White, Font(0.7, Style::Bold)) + _title_obj(title, Vec2(margin, margin), White, Font(0.7f, Style::Bold)) { //set_background(Black.alpha(125)); set_bounds(size); @@ -316,13 +316,13 @@ namespace gui { bin_y.resize(bin_x.size()); size_t bin = 0, next = 1, end = bin_y.size(); - float border = bin_x.at(bin) + range.step * 0.5; + float border = bin_x.at(bin) + range.step * 0.5f; for(auto &v : vec) { while(next != end && v > border) { ++bin; ++next; - border = bin_x[bin] + range.step * 0.5; + border = bin_x[bin] + range.step * 0.5f; } bin_y[bin]++; } @@ -369,12 +369,12 @@ namespace gui { std::vector<Vertex> vertices; vertices.push_back({ pos + Vec2(-axes_width * 0.5f, 0), White }); vertices.push_back({ Vec2(pos.x - axes_width * 0.5f, - size.height - margin - axes_width * 0.5), White }); + size.height - margin - axes_width * 0.5f), White }); vertices.push_back({ pos + Vec2(-axes_width * 0.5f, - element.y + axes_width * 0.5), White }); + element.y + axes_width * 0.5f), White }); vertices.push_back({ Vec2(size.width - margin, - pos.y + element.y + axes_width * 0.5), White }); + pos.y + element.y + axes_width * 0.5f), White }); if(!_data.empty()) { //Vec2 pos(size.x + margin + axes_width * 0.5f, @@ -434,8 +434,8 @@ namespace gui { if(i == 0) { // label for x-axis text = new Text(Meta::toStr(v), - Vec2(bar_pos.x + element.x * 0.5, - bar_pos.y + element.y + axes_width + text_height * 0.5), + Vec2(bar_pos.x + element.x * 0.5f, + bar_pos.y + element.y + axes_width + text_height * 0.5f), White, Font(0.5, Align::Center)); @@ -445,11 +445,11 @@ namespace gui { last_text.x = text_x; // tick on x-axis - vertices.push_back({ Vec2(bar_pos.x + element.x * 0.5, - bar_pos.y + element.y + axes_width * 0.5 - 3), + vertices.push_back({ Vec2(bar_pos.x + element.x * 0.5f, + bar_pos.y + element.y + axes_width * 0.5f - 3), White }); - vertices.push_back({ Vec2(bar_pos.x + element.x * 0.5, - bar_pos.y + element.y + axes_width * 0.5 + 3), + vertices.push_back({ Vec2(bar_pos.x + element.x * 0.5f, + bar_pos.y + element.y + axes_width * 0.5f + 3), White }); } else diff --git a/Application/src/commons/common/gui/types/ScrollableList.h b/Application/src/commons/common/gui/types/ScrollableList.h index 4a785233c94a5e9f816792aa6ee7f391be85d2e3..7fbf461c5afbd36adcd1288875a7f1f50f846bba 100644 --- a/Application/src/commons/common/gui/types/ScrollableList.h +++ b/Application/src/commons/common/gui/types/ScrollableList.h @@ -2,6 +2,7 @@ #include <gui/types/Entangled.h> #include <gui/DrawSFBase.h> +#include <misc/metastring.h> namespace gui { class CustomItem { @@ -47,7 +48,7 @@ namespace gui { public: ScrollableList(const Bounds& bounds, const std::vector<T>& objs = {}, - const Font& font = Font(0.75, Align::Center), + const Font& font = Font(0.75f, Align::Center), const decltype(_on_hovered)& on_hover = [](size_t){}) : item_padding(5,5), _callback([](auto, const auto&){}), @@ -75,7 +76,7 @@ namespace gui { this->set_dirty(); if(!e.mbutton.pressed && e.mbutton.button == 0) { - size_t idx = floorf((scroll_offset().y + e.mbutton.y) / _line_spacing); + size_t idx = size_t(floorf((scroll_offset().y + e.mbutton.y) / _line_spacing)); select_item(idx); } }); @@ -188,7 +189,7 @@ namespace gui { } } - void highlight_item(float index) { + void highlight_item(long index) { float first_visible = scroll_offset().y / _line_spacing; float last_visible = (scroll_offset().y + height()) / _line_spacing; @@ -206,20 +207,20 @@ namespace gui { update(); first_visible = floorf(scroll_offset().y / _line_spacing); - last_visible = min(_items.size()-1.0, floorf((scroll_offset().y + height()) / _line_spacing)); + last_visible = min(_items.size()-1.0f, floorf((scroll_offset().y + height()) / _line_spacing)); _last_hovered_item = index; //draw_structure()->do_hover(_rects.at(index - first_visible)); if(index >= first_visible && index <= last_visible) { if(stage()) - stage()->do_hover(_rects.at(index - first_visible)); + stage()->do_hover(_rects.at(sign_cast<size_t>(index - first_visible))); } } - void select_item(size_t index) { - if(_items.size() > index && index >= 0) { - _last_selected_item = index; + void select_item(uint64_t index) { + if(_items.size() > index) { + _last_selected_item = narrow_cast<long>(index); set_content_changed(true); _callback(index, _items.at(index).value()); @@ -230,13 +231,14 @@ namespace gui { if(!stage()) return; - select_item(_last_hovered_item); + if(_last_hovered_item > 0) + select_item((uint64_t)_last_hovered_item); } private: void update_items() { const float item_height = _line_spacing; - size_t N = ceilf(height() / _line_spacing) + 1; // one item will almost always be half-visible + size_t N = size_t(ceilf(height() / _line_spacing)) + 1u; // one item will almost always be half-visible if(N != _rects.size()) { if(N < _rects.size()) { @@ -245,8 +247,8 @@ namespace gui { delete _texts.at(i); } - _rects.erase(_rects.begin() + N, _rects.end()); - _texts.erase(_texts.begin() + N, _texts.end()); + _rects.erase(_rects.begin() + int64_t(N), _rects.end()); + _texts.erase(_texts.begin() + int64_t(N), _texts.end()); } for(size_t i=0; i<_rects.size(); i++) { @@ -263,7 +265,7 @@ namespace gui { if(rect_to_idx.count(r)) { auto idx = rect_to_idx.at(r); if(_last_hovered_item != (long)idx) { - _last_hovered_item = idx; + _last_hovered_item = long(idx); _on_hovered(idx); } } @@ -295,8 +297,8 @@ namespace gui { begin(); - size_t first_visible = floorf(scroll_offset().y / _line_spacing); - size_t last_visible = floorf((scroll_offset().y + height()) / _line_spacing); + size_t first_visible = (size_t)floorf(scroll_offset().y / _line_spacing); + size_t last_visible = (size_t)floorf((scroll_offset().y + height()) / _line_spacing); //Debug("DIsplaying %lu-%lu %f %f", first_visible, last_visible, scroll_offset().y, _line_spacing); @@ -315,7 +317,7 @@ namespace gui { rect_to_idx[_rects.at(idx)] = i; if(_font.align == Align::Center) - _texts.at(idx)->set_pos(Vec2(width() * 0.5, y + _line_spacing*0.5)); + _texts.at(idx)->set_pos(Vec2(width() * 0.5f, y + _line_spacing*0.5f)); else if(_font.align == Align::Left) _texts.at(idx)->set_pos(Vec2(0, y) + item_padding); else @@ -330,7 +332,7 @@ namespace gui { const float last_y = _line_spacing * (_items.size()-1); set_scroll_limits(Rangef(), Rangef(0, - (height() < last_y ? last_y + _line_spacing - height() : 0.1))); + (height() < last_y ? last_y + _line_spacing - height() : 0.1f))); auto scroll = scroll_offset(); set_scroll_offset(Vec2()); set_scroll_offset(scroll); @@ -342,9 +344,9 @@ namespace gui { auto item = static_cast<const CustomItem*>(&_items[idx].value()); if(rect->pressed() || (_stays_toggled && (long)rect_to_idx[rect] == _last_selected_item)) - rect->set_fillclr(item->base_color().brightenHSL(0.15)); + rect->set_fillclr(item->base_color().brightenHSL(0.15f)); else if(rect->hovered()) - rect->set_fillclr(item->base_color().brightenHSL(1.25)); + rect->set_fillclr(item->base_color().brightenHSL(1.25f)); else rect->set_fillclr(item->base_color()); } @@ -352,9 +354,9 @@ namespace gui { } else { for(auto rect : _rects) { if(rect->pressed() || (_stays_toggled && (long)rect_to_idx[rect] == _last_selected_item)) - rect->set_fillclr(_item_color.brighten(0.15)); + rect->set_fillclr(_item_color.brighten(0.15f)); else if(rect->hovered()) - rect->set_fillclr(_item_color.brighten(1.25)); + rect->set_fillclr(_item_color.brighten(1.25f)); else rect->set_fillclr(Transparent); } diff --git a/Application/src/tracker/gui/DrawDataset.cpp b/Application/src/tracker/gui/DrawDataset.cpp index 6bd7bdc533d2cc12d5d8ac7ede9adc8caa5ac228..d689407588a73e6c7fe55718d28baedeac8aaadd 100644 --- a/Application/src/tracker/gui/DrawDataset.cpp +++ b/Application/src/tracker/gui/DrawDataset.cpp @@ -177,7 +177,7 @@ namespace gui { float y = 10, max_w = 0; Font font(0.75); - y += advance(new Text("Identities", Vec2(10, y), White, Font(0.8, Style::Bold)))->height(); + y += advance(new Text("Identities", Vec2(10, y), White, Font(0.8f, Style::Bold)))->height(); y += 10; for(auto && [id, tup] : _cache) { @@ -238,7 +238,7 @@ namespace gui { advance_wrap(*text); text->set_txt(ss.str()); - text->set_pos(Vec2(x, y_ + offset_y + (h - text->height()) * 0.5)); + text->set_pos(Vec2(x, y_ + offset_y + (h - text->height()) * 0.5f)); gy = text->pos().y + text->height(); if(text->pos().x + text->width() > max_w) @@ -250,11 +250,11 @@ namespace gui { }; if(_last_current_frames.start != -1 && !_meta_current.empty()) { - h = advance(new Text("Current segment "+Meta::toStr(_last_current_frames)+" ("+Meta::toStr(_current_quality)+")", Vec2(x, 10), White, Font(0.8, Style::Bold)))->height(); + h = advance(new Text("Current segment "+Meta::toStr(_last_current_frames)+" ("+Meta::toStr(_current_quality)+")", Vec2(x, 10), White, Font(0.8f, Style::Bold)))->height(); display_dataset(_meta_current, 0); if(!_meta.empty()) { - h = advance(new Text("Best segment "+Meta::toStr(_last_consecutive_frames)+" ("+Meta::toStr(_quality)+")", Vec2(x, 10 + y + 5), White, Font(0.8, Style::Bold)))->height(); + h = advance(new Text("Best segment "+Meta::toStr(_last_consecutive_frames)+" ("+Meta::toStr(_quality)+")", Vec2(x, 10 + y + 5), White, Font(0.8f, Style::Bold)))->height(); float cy = y + 5 + 10 + 10 + h; @@ -270,7 +270,7 @@ namespace gui { } } else if(!_meta.empty()) { - h = advance(new Text("Best segment "+Meta::toStr(_last_consecutive_frames)+" ("+Meta::toStr(_quality)+")", Vec2(x, 10), White, Font(0.8, Style::Bold)))->height(); + h = advance(new Text("Best segment "+Meta::toStr(_last_consecutive_frames)+" ("+Meta::toStr(_quality)+")", Vec2(x, 10), White, Font(0.8f, Style::Bold)))->height(); display_dataset(_meta, 0); } @@ -302,12 +302,12 @@ namespace gui { Vec2 pp = pos(); auto bds = global_bounds(); - if(pp.x > screen_dimensions.width + bds.width * 0.5) - pp.x = screen_dimensions.width - 10 + bds.width * 0.5; + if(pp.x > screen_dimensions.width + bds.width * 0.5f) + pp.x = screen_dimensions.width - 10 + bds.width * 0.5f; if(pp.y > screen_dimensions.height + bds.height * 0.5) - pp.y = screen_dimensions.height - 10 + bds.height * 0.5; - if(pp.x < bds.width * 0.5) - pp.x = bds.width * 0.5 + 10; + pp.y = screen_dimensions.height - 10 + bds.height * 0.5f; + if(pp.x < bds.width * 0.5f) + pp.x = bds.width * 0.5f + 10; auto &bar = GUI::instance()->timeline().bar(); auto bar_height = bar ? bar->global_bounds().y + bar->global_bounds().height + 10 : 10; diff --git a/Application/src/tracker/gui/DrawFish.cpp b/Application/src/tracker/gui/DrawFish.cpp index 7a3b2ea130e0b0de0d187beb5b63efff9dfec143..01285310b81faaba2eee0fd827f121d805be112c 100644 --- a/Application/src/tracker/gui/DrawFish.cpp +++ b/Application/src/tracker/gui/DrawFish.cpp @@ -128,7 +128,7 @@ CREATE_STRUCT(CachedGUIOptions, const auto single_identity = GUIOPTION(gui_single_identity_color); const auto properties = Tracker::properties(_idx); const auto safe_properties = Tracker::properties(_safe_idx); - const float time_fade_percent = 1.0 - (properties ? cmn::abs(properties->time - safe_properties->time) : 0) / track_max_reassign_time; + const float time_fade_percent = 1.0f - float(properties ? cmn::abs(properties->time - safe_properties->time) : 0) / track_max_reassign_time; auto &cache = GUI::instance()->cache(); auto && [basic, posture] = _obj.all_stuff(_safe_idx); @@ -148,7 +148,7 @@ CREATE_STRUCT(CachedGUIOptions, const float max_color = timeline_visible ? 255 : GUIOPTION(gui_faded_brightness); auto base_color = single_identity != Transparent ? single_identity : _obj.identity().color(); - auto clr = base_color.alpha(saturate(((cache.is_selected(_obj.identity().ID()) || hovered) ? max_color : max_color * 0.4) * time_fade_percent)); + auto clr = base_color.alpha(saturate(((cache.is_selected(_obj.identity().ID()) || hovered) ? max_color : max_color * 0.4f) * time_fade_percent)); _color = clr; auto current_time = _time; @@ -188,7 +188,7 @@ CREATE_STRUCT(CachedGUIOptions, } float r = float(rand()) / float(RAND_MAX); - _plus_angle += sinf(0.5 * (r - 0.5) * 2 * M_PI * GUI::cache().dt()); + _plus_angle += sinf(0.5f * (r - 0.5f) * 2 * float(M_PI) * GUI::cache().dt()); window.set_rotation(_plus_angle); //r = float(rand()) / float(RAND_MAX); @@ -198,7 +198,7 @@ CREATE_STRUCT(CachedGUIOptions, Vec2 distance = _position - (panic_button == 1 ? mp : Vec2()); auto CL = distance.length(); if(std::isnan(CL)) - CL = 0.0001; + CL = 0.0001f; const float stiffness = 50, spring_L = panic_button == 1 ? 2 : 0, spring_damping = 20; @@ -232,7 +232,7 @@ CREATE_STRUCT(CachedGUIOptions, _polygon->set_origin(Vec2(0.5)); } _polygon->set_vertices(points); - float size = Tracker::average().bounds().size().length() * 0.0025; + float size = Tracker::average().bounds().size().length() * 0.0025f; Vec2 scaling(SQR(offset.x / float(Tracker::average().cols)), SQR(offset.y / float(Tracker::average().rows))); _polygon->set_pos(scaling * size + fish->size() * 0.5); @@ -243,7 +243,7 @@ CREATE_STRUCT(CachedGUIOptions, // check if we actually have a tail index if(GUIOPTION(gui_show_midline) && _cached_midline && _cached_midline->tail_index() != -1) - window.entangle(new Circle(points.at(_cached_midline->tail_index()), 2, Blue.alpha(max_color * 0.3))); + window.entangle(new Circle(points.at(_cached_midline->tail_index()), 2, Blue.alpha(max_color * 0.3f))); //float right_side = outline->tail_index() + 1; //float left_side = points.size() - outline->tail_index(); diff --git a/Application/src/tracker/misc/EventAnalysis.cpp b/Application/src/tracker/misc/EventAnalysis.cpp index 64f9d484089b45d6d973e6b1f69242879aa8d4c8..575dfb1872b9a3527e6f4c69f80680a1acec9806 100644 --- a/Application/src/tracker/misc/EventAnalysis.cpp +++ b/Application/src/tracker/misc/EventAnalysis.cpp @@ -130,7 +130,7 @@ void update_settings(const sprite::Map &, const std::string &key, const sprite:: //if(std::isinf(offset)) // state.current_energy.push_back(0); //else - state.current_energy.push_back(0.5 * FAST_SETTINGS(meta_mass_mg) * SQR(offset)); + state.current_energy.push_back(0.5f * FAST_SETTINGS(meta_mass_mg) * SQR(offset)); if(cmn::isinf(offset)) { if(state.last_event_start != -1) { @@ -147,7 +147,9 @@ void update_settings(const sprite::Map &, const std::string &key, const sprite:: state.last_event_start = frame; state.current_maximum = 0; state.current_energy.clear(); - state.v_before = state.v_samples ? state.v_current / state.v_samples : Vec2(0, 0); + state.v_before = state.v_samples != 0 + ? state.v_current / state.v_samples + : Vec2(0, 0); state.v_current = Vec2(0, 0); state.v_samples = 0; } @@ -191,7 +193,7 @@ void update_settings(const sprite::Map &, const std::string &key, const sprite:: U_EXCEPTION("Energy is infinite."); map.events[state.last_event_start] = Event(state.last_event_start, state.last_event_end, energy, angle_change, acceleration, length(state.v_before), length(velocity)); - map.lengths[state.last_event_start] = len; + map.lengths[state.last_event_start] = sign_cast<size_t>(len); //Debug("%d: Adding event %d", fish->identity().ID(), state.last_event_start); } @@ -320,7 +322,7 @@ void update_settings(const sprite::Map &, const std::string &key, const sprite:: for(auto &map : individual_maps) { Debug("Erasing... %d(%d-%d): %d - %d", map.first->identity().ID(), map.first->start_frame(), map.first->end_frame(), map.second.start_frame, map.second.end_frame); if(map.second.start_frame != -1 && map.second.end_frame >= after_frame) { - size_t count = 0; + int64_t count = 0; if(map.second.start_frame >= after_frame) { count = map.second.end_frame - map.second.start_frame + 1; map.second.clear(); @@ -359,7 +361,7 @@ void update_settings(const sprite::Map &, const std::string &key, const sprite:: map.second.end_frame = map.second.start_frame = -1; } - Debug("Erased %lu events for fish %d (%d-%d).", count, map.first->identity().ID(), map.second.start_frame,map.second.end_frame); + Debug("Erased %ld events for fish %d (%d-%d).", count, map.first->identity().ID(), map.second.start_frame,map.second.end_frame); } } } diff --git a/Application/src/tracker/misc/OutputLibrary.cpp b/Application/src/tracker/misc/OutputLibrary.cpp index ab7685fb2f6b5fce747415be9847c300fc20f822..c2f4f708c5b26756cfbe8cbd9d8f84729a59877c 100644 --- a/Application/src/tracker/misc/OutputLibrary.cpp +++ b/Application/src/tracker/misc/OutputLibrary.cpp @@ -269,23 +269,23 @@ namespace Output { }); _cache_func[Functions::MIDLINE_DERIV.name()] = LIBFNC({ - float current = get("normalized_midline", info, frame); - float previous = get("normalized_midline", info, frame-1); + auto current = get("normalized_midline", info, frame); + auto previous = get("normalized_midline", info, frame-1); if(cmn::isinf(previous)) previous = 0; if(cmn::isinf(current)) return infinity<float>(); - return current - previous; + return narrow_cast<float>(current - previous); }); _cache_func[Functions::BINARY.name()] = LIBFNC({ if(frame >= fish->start_frame()+1 && frame <= fish->end_frame()-1) { //Vec2 p0(x-1, cache_access(fish, Cache::MIDLINE, x-1)); - Vec2 p1(frame, get(Functions::MIDLINE_OFFSET.name(), info, frame)); - Vec2 p2(frame+1, get(Functions::MIDLINE_OFFSET.name(), info, frame+1)); + Vec2 p1(frame, (Float2_t)get(Functions::MIDLINE_OFFSET.name(), info, frame)); + Vec2 p2(frame+1, (Float2_t)get(Functions::MIDLINE_OFFSET.name(), info, frame+1)); int c = crosses_abs_height(p1, p2, SETTING(limit).value<float>()); return c == 0 ? infinity<float>() : c; @@ -336,7 +336,7 @@ namespace Output { } } - return samples ? d / samples : infinity<float>(); + return samples > 0 ? d / samples : infinity<float>(); }); _cache_func["time"] = LIBGLFNC({ @@ -394,7 +394,7 @@ namespace Output { continue; } - oangle += M_PI * 0.5; + oangle += float(M_PI * 0.5); auto v = oh->pos(); if(length(v - a) > 100) { @@ -438,8 +438,8 @@ namespace Output { //auto angle = atan2(line.y, line.x); - Vec2 dir0(cos(a0), -sin(a0)); - Vec2 dir1(cos(a1), -sin(a1)); + Vec2 dir0((float)cos(a0), -(float)sin(a0)); + Vec2 dir1((float)cos(a1), -(float)sin(a1)); line = line / length(line); dir0 /= length(dir0); @@ -456,7 +456,8 @@ namespace Output { }); _cache_func["L_V"] = LIBFNC({ - const Vec2 v(get(Functions::VX.name(), info, frame), get(Functions::VY.name(), info, frame)); + const Vec2 v((Float2_t)get(Functions::VX.name(), info, frame), + (Float2_t)get(Functions::VY.name(), info, frame)); const auto individuals = Tracker::instance()->active_individuals(frame); float d = 0.0; @@ -466,7 +467,8 @@ namespace Output { if (other != fish && other->centroid(frame)) { info.fish = other; - const Vec2 ov(get(Functions::VX.name(), info, frame), get(Functions::VY.name(), info, frame)); + const Vec2 ov((Float2_t)get(Functions::VX.name(), info, frame), + (Float2_t)get(Functions::VY.name(), info, frame)); d += euclidean_distance(v, ov); samples++; } @@ -476,17 +478,19 @@ namespace Output { }); _cache_func["DOT_V"] = LIBFNC({ - Vec2 v(get(Functions::VX.name(), info, frame), get(Functions::VY.name(), info, frame)); + Vec2 v((Float2_t)get(Functions::VX.name(), info, frame), + (Float2_t)get(Functions::VY.name(), info, frame)); const auto individuals = Tracker::instance()->active_individuals(frame); for (auto other: individuals) { if (other != fish && other->centroid(frame)) { info.fish = other; - Vec2 ov(get(Functions::VX.name(), info, frame), get(Functions::VY.name(), info, frame)); + Vec2 ov((Float2_t)get(Functions::VX.name(), info, frame), + (Float2_t)get(Functions::VY.name(), info, frame)); float n = length(v) * length(ov); - if(!length(v) || !length(ov)) + if(length(v) > 0 || length(ov) > 0) return infinity<float>(); return cmn::abs(atan2(v.y, v.x) - atan2(ov.y, ov.x)); @@ -501,7 +505,7 @@ namespace Output { _cache_func["tailbeat_peak"] = LIBFNC( return SETTING(event_min_peak_offset).value<float>(); ); _cache_func["threshold_reached"] = LIBFNC({ - return EventAnalysis::threshold_reached(info.fish, frame) ? M_PI * 0.3 : infinity<float>(); + return EventAnalysis::threshold_reached(info.fish, frame) ? float(M_PI * 0.3) : infinity<float>(); }); _cache_func["sqrt_a"] = LIBFNC({ @@ -543,7 +547,7 @@ namespace Output { //Debug("%f", sqrt(sum) / (average * 0.05)); - return sqrt(sum) / (average * 0.5); + return sqrt(sum) / (average * 0.5f); }); _cache_func["events"] = LIBFNC({ @@ -553,7 +557,7 @@ namespace Output { for(auto &e : it->second.events) { if(e.second.begin <= frame && e.second.end >= frame) { delete events; - return M_PI * 0.25; + return float(M_PI * 0.25); } } } @@ -755,7 +759,7 @@ namespace Output { } } - if(samples) + if(samples > 0) average /= samples; return average.length(); @@ -788,7 +792,7 @@ namespace Output { } } - if(samples) + if(samples > 0) average /= samples; float distances = 0; @@ -1113,17 +1117,17 @@ namespace Output { float Library::tailbeats(long_t frame, Output::Library::LibInfo info) { auto fish = info.fish; - float right = 0; - float left = 0; - float mx = -FLT_MAX; - float mi = FLT_MAX; + double right = 0; + double left = 0; + double mx = -FLT_MAX; + double mi = FLT_MAX; for (long_t offset=0; offset<100 && frame-offset >= fish->start_frame() && frame+offset <= fish->end_frame(); offset++) { auto f_l = frame-offset; auto f_r = frame+offset; - if(!left) { + if(left == 0) { auto v_l = Library::get(Functions::BINARY.name(), info, f_l); if(!cmn::isinf(v_l)) { left = v_l; @@ -1140,7 +1144,7 @@ namespace Output { } } - if(!right && offset) { + if(right == 0 && offset) { auto v_r = Library::get(Functions::BINARY.name(), info, f_r); if(!cmn::isinf(v_r)) { right = v_r; @@ -1157,16 +1161,16 @@ namespace Output { } } - if(left && right) + if(left != 0 && right != 0) break; } auto y = Library::get("MIDLINE_OFFSET", info, frame); - if (right - && left + if (right != 0 + && left != 0 && cmn::abs(y) >= SETTING(limit).value<float>()) { - return mx; + return float(mx); } return 0; diff --git a/Application/src/tracker/misc/default_config.cpp b/Application/src/tracker/misc/default_config.cpp index ac07cf1515455e59a0008980304417ff3689a578..716a92518c8f63eb8ab8515330cc1f72f3ae7ec6 100644 --- a/Application/src/tracker/misc/default_config.cpp +++ b/Application/src/tracker/misc/default_config.cpp @@ -377,7 +377,7 @@ file::Path conda_environment_path() { CONFIG("track_do_history_split", true, "If disabled, blobs will not be split automatically in order to separate overlapping individuals. This usually happens based on their history."); CONFIG("track_end_segment_for_speed", true, "Sometimes individuals might be assigned to blobs that are far away from the previous position. This could indicate wrong assignments, but not necessarily. If this variable is set to true, consecutive frame segments will end whenever high speeds are reached, just to be on the safe side. For scenarios with lots of individuals (and no recognition) this might spam yellow bars in the timeline and may be disabled."); CONFIG("track_max_individuals", idx_t(0), "The maximal number of individual that are assigned at the same time (infinite if set to zero). If the given number is below the actual number of individual, then only a (random) subset of individual are assigned and a warning is shown."); - CONFIG("blob_size_ranges", BlobSizeRange({Rangef(0.1, 3)}), "Blobs below the lower bound are recognized as noise instead of individuals. Blobs bigger than the upper bound are considered to potentially contain more than one individual. The unit is #pixels * (`meta_real_width` / video_width)."); + CONFIG("blob_size_ranges", BlobSizeRange({Rangef(0.1f, 3)}), "Blobs below the lower bound are recognized as noise instead of individuals. Blobs bigger than the upper bound are considered to potentially contain more than one individual. The unit is #pixels * (`meta_real_width` / video_width)."); CONFIG("blob_split_max_shrink", float(0.2), "The minimum percentage of the starting blob size (after thresholding), that a blob is allowed to be reduced to during splitting. If this value is set too low, the program might start recognizing parts of individual as other individual too quickly."); CONFIG("blob_split_global_shrink_limit", float(0.2), "The minimum percentage of the minimum in `blob_size_ranges`, that a blob is allowed to be reduced to during splitting. If this value is set too low, the program might start recognizing parts of individual as other individual too quickly."); @@ -553,13 +553,13 @@ file::Path conda_environment_path() { CONFIG("gui_connectivity_matrix", std::map<long_t, std::vector<float>>(), "Internally used to store the connectivity matrix.", STARTUP); std::vector<float> buffer { - -0.2576632 , -0.19233586, 0.00245493, 0.00398822, 0.35924019 + -0.2576632f , -0.19233586f, 0.00245493f, 0.00398822f, 0.35924019f }; std::vector<float> matrix = { - 2.94508959e+03, 0.00000000e+00, 6.17255441e+02, - 0.00000000e+00, 2.94282514e+03, 6.82473623e+02, - 0.00000000e+00, 0.00000000e+00, 1.00000000e+00 + 2.94508959e+03f, 0.00000000e+00f, 6.17255441e+02f, + 0.00000000e+00f, 2.94282514e+03f, 6.82473623e+02f, + 0.00000000e+00f, 0.00000000e+00f, 1.00000000e+00f }; CONFIG("cam_undistort_vector", buffer, "");