-
Hello, I was wondering if it was possible to move the label_id that is displayed during immvision.image_display to the right side of the image. Here is short code snippet showing what I mean: import cv2
import numpy as np
from imgui_bundle import hello_imgui, imgui, immapp, immvision
from imgui_bundle.demos_python import demo_utils
immvision.use_bgr_color_order()
def panel_gui():
imgui.button("Test panel")
def image_gui(img: np.ndarray):
# this will display the image "img" with a gray outline around the image
# on the left-most side of the outline, the label_id "test img" will be written
# my question is, how can I move this text to the right most side of the image
# Ideally, I still want the text to be part of the outline of the image
# but I want it on the right side of the image instead of left side
immvision.image_display("test img", img, (500, 428))
def runner_params_setup(img: np.ndarray):
runner_params = hello_imgui.RunnerParams()
runner_params.app_window_params.window_geometry.size = (650, 500)
runner_params.app_window_params.resizable = False
imgui_window_type = hello_imgui.DefaultImGuiWindowType.provide_full_screen_dock_space
runner_params.imgui_window_params.default_imgui_window_type = imgui_window_type
dock_node_flags = imgui.DockNodeFlags_.no_resize | imgui.DockNodeFlags_.auto_hide_tab_bar
runner_params.docking_params.main_dock_space_node_flags = dock_node_flags
split = hello_imgui.DockingSplit(initial_dock_ = "MainDockSpace",
direction_ = imgui.Dir.left,
ratio_ = 0.1,
new_dock_ = "NewDockSpace",
)
runner_params.docking_params.docking_splits = [split]
image_window = hello_imgui.DockableWindow(label_ = "image",
dock_space_name_="MainDockSpace",
gui_function_ = lambda: image_gui(img),
can_be_closed_= False
)
runner_params.docking_params.dockable_windows = [image_window]
immapp.run(runner_params)
def main():
img_path = demo_utils.demos_assets_folder() + "/images/house.jpg"
img = cv2.imread(img_path)
img = cv2.resize(img, dsize=None, fx=0.5, fy=0.5)
runner_params_setup(img)
if __name__ == '__main__':
main() |
Beta Was this translation helpful? Give feedback.
Answered by
pthom
Jan 3, 2025
Replies: 1 comment
-
The way the label is displayed is not configurable. immvision.image_display("##test img", img, (500, 428)) This way the label and the surrounding frame are hidden, and then you can render a label + frame yourself in whichever way you like. For example: immvision.image_display("##test img", img, (500, 428))
# Ugly manual rendering. Up to you to improve on it
p0 = imgui.get_item_rect_min()
p1 = imgui.get_item_rect_max()
margin = 0.5
p0 = p0 - hello_imgui.em_to_vec2(margin, margin)
p1 = p1 + hello_imgui.em_to_vec2(margin, margin)
color = imgui.color_convert_float4_to_u32((0.5, 0.5, 0.5, 1.0))
imgui.get_window_draw_list().add_rect(p0, p1, color)
imgui.get_window_draw_list().add_text(p0, color, "BLAH") |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
angecide
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The way the label is displayed is not configurable.
However, you may use a hidden label:
This way the label and the surrounding frame are hidden, and then you can render a label + frame yourself in whichever way you like.
For example: