Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed [Environment] OpenCV NULL guiReceiver error during pre-commit #231

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/utils/interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ def show(name, origin, pause=1, resize=False, reset_pos=None, config=None):
else:
img = origin

if not is_window_available(name):
cv2.namedWindow(name)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add this for the cv2.moveWindow() as well?

Copy link
Author

@Princekumarofficial Princekumarofficial Oct 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Udayraj123 Its not needed separately for the same, We can do that but it does not affect anything as we are already handling the case when we don't have window here, so no need to do it again.


cv2.imshow(name, img)

if reset_pos:
Expand Down Expand Up @@ -92,3 +95,13 @@ def wait_q():
while cv2.waitKey(1) & 0xFF not in [ord("q"), esc_key]:
pass
cv2.destroyAllWindows()


def is_window_available(name: str) -> bool:
"""Checks if a window is available"""
try:
cv2.getWindowProperty(name, cv2.WND_PROP_VISIBLE)
return True
except Exception as e:
print(e)
return False