diff --git a/tools/python/src/gui.cpp b/tools/python/src/gui.cpp index e28a2506c..e03bee5bc 100644 --- a/tools/python/src/gui.cpp +++ b/tools/python/src/gui.cpp @@ -90,6 +90,23 @@ void add_overlay_line ( win.add_overlay(l,color); } +void add_overlay_pylist ( + image_window& win, + const py::list& objs, + const rgb_pixel& color +) +{ + std::vector rects; + for (auto& obj : objs) + { + try { rects.push_back(obj.cast()); continue; } catch(py::cast_error&) { } + try { rects.push_back(obj.cast()); continue; } catch(py::cast_error&) { } + try { win.add_overlay(obj.cast(), color); continue; } catch(py::cast_error&) { } + add_overlay_parts(win, obj.cast(), color); + } + win.add_overlay(rects, color); +} + template void add_overlay_circle ( image_window& win, @@ -221,6 +238,8 @@ void bind_gui(py::module& m) "Add circle to the image window.") .def("add_overlay_circle", add_overlay_circle, py::arg("center"), py::arg("radius"), py::arg("color")=rgb_pixel(255, 0, 0), "Add circle to the image window.") + .def("add_overlay", add_overlay_pylist, py::arg("objects"), py::arg("color")=rgb_pixel(255,0,0), + "Adds all the overlayable objects, uses the given color.") .def("wait_until_closed", &type::wait_until_closed, "This function blocks until the window is closed."); }