diff --git a/bindings/imgui_bundle/imgui_fig.py b/bindings/imgui_bundle/imgui_fig.py index ed6444c1..a22de7aa 100644 --- a/bindings/imgui_bundle/imgui_fig.py +++ b/bindings/imgui_bundle/imgui_fig.py @@ -9,7 +9,6 @@ matplotlib.use('Agg') # set the renderer to Tk from matplotlib.figure import Figure # noqa: E402 import numpy # noqa: E402 -import cv2 # noqa: E402 import matplotlib # noqa: E402 from imgui_bundle.immapp import static # noqa: E402 from imgui_bundle import immvision, ImVec2, imgui # noqa: E402 @@ -37,10 +36,8 @@ def _fig_to_image(label_id: str, figure: Figure, refresh_image: bool = False) -> w, h = figure.canvas.get_width_height() buf = numpy.fromstring(figure.canvas.tostring_rgb(), dtype=numpy.uint8) buf.shape = (h, w, 3) - if immvision.is_using_bgr_color_order(): - img = cv2.cvtColor(buf, cv2.COLOR_RGB2BGR) - else: - img = buf + + img = buf matplotlib.pyplot.close(figure) statics.fig_image_cache[fig_id] = img return statics.fig_image_cache[fig_id] @@ -78,7 +75,9 @@ def fig(label_id: str, """ image_rgb = _fig_to_image(label_id, figure, refresh_image) + immvision.push_color_order_rgb() mouse_position_tuple = immvision.image_display_resizable( label_id, image_rgb, size, refresh_image, resizable, show_options_button) + immvision.pop_color_order() mouse_position = ImVec2(mouse_position_tuple[0], mouse_position_tuple[1]) return mouse_position diff --git a/bindings/imgui_bundle/immvision.pyi b/bindings/imgui_bundle/immvision.pyi index edf9c303..ef925310 100644 --- a/bindings/imgui_bundle/immvision.pyi +++ b/bindings/imgui_bundle/immvision.pyi @@ -67,6 +67,29 @@ def is_using_bgr_color_order() -> bool: """ pass +# bool IsColorOrderUndefined(); /* original C++ signature */ +def is_color_order_undefined() -> bool: + """Returns True if the color order is undefined (i.e. UseRgbColorOrder or UseBgrColorOrder was not called) + (private API) + """ + pass + +# Temporary change of color order (useful for displaying a single image with a different color order) +# void PushColorOrderRgb(); /* original C++ signature */ +def push_color_order_rgb() -> None: + """(private API)""" + pass + +# void PushColorOrderBgr(); /* original C++ signature */ +def push_color_order_bgr() -> None: + """(private API)""" + pass + +# void PopColorOrder(); /* original C++ signature */ +def pop_color_order() -> None: + """(private API)""" + pass + class ColorMapStatsTypeId(enum.Enum): """Are we using the stats on the full image, on the Visible ROI, or are we using Min/Max values""" diff --git a/external/immvision/bindings/pybind_immvision.cpp b/external/immvision/bindings/pybind_immvision.cpp index e0db91fd..64742730 100644 --- a/external/immvision/bindings/pybind_immvision.cpp +++ b/external/immvision/bindings/pybind_immvision.cpp @@ -56,6 +56,18 @@ void py_init_module_immvision(py::module& m) m.def("is_using_bgr_color_order", ImmVision::IsUsingBgrColorOrder, " Returns True if we are using BGR color order\n(private API)"); + m.def("is_color_order_undefined", + ImmVision::IsColorOrderUndefined, " Returns True if the color order is undefined (i.e. UseRgbColorOrder or UseBgrColorOrder was not called)\n(private API)"); + + m.def("push_color_order_rgb", + ImmVision::PushColorOrderRgb, "(private API)"); + + m.def("push_color_order_bgr", + ImmVision::PushColorOrderBgr, "(private API)"); + + m.def("pop_color_order", + ImmVision::PopColorOrder, "(private API)"); + py::enum_(m, "ColorMapStatsTypeId", py::arithmetic(), "Are we using the stats on the full image, on the Visible ROI, or are we using Min/Max values") .value("from_full_image", ImmVision::ColorMapStatsTypeId::FromFullImage, "") diff --git a/external/immvision/immvision b/external/immvision/immvision index 61faf208..3d82cf33 160000 --- a/external/immvision/immvision +++ b/external/immvision/immvision @@ -1 +1 @@ -Subproject commit 61faf2087352e88526114bdbac7593484fcd3c2b +Subproject commit 3d82cf33a23c48b0bf7c66a86883e7bc9f48c4fc