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

added window WaitKeyEx support #1195

Merged
merged 4 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions highgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ int Window_WaitKey(int delay = 0) {
return cv::waitKey(delay);
}

int Window_WaitKeyEx(int delay = 0) {
return cv::waitKeyEx(delay);
}

void Window_Move(const char* winname, int x, int y) {
cv::moveWindow(winname, x, y);
}
Expand Down
10 changes: 10 additions & 0 deletions highgui.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,16 @@ func (w *Window) WaitKey(delay int) int {
return int(C.Window_WaitKey(C.int(delay)))
}

// WaitKeyEx Similar to waitKey, but returns full key code.
// Note
// Key code is implementation specific and depends on used backend: QT/GTK/Win32/etc
//
// For further details, please see:
// https://docs.opencv.org/4.x/d7/dfc/group__highgui.html#gafa15c0501e0ddd90918f17aa071d3dd0
func (w *Window) WaitKeyEx(delay int) int {
return int(C.Window_WaitKey(C.int(delay)))
}

// MoveWindow moves window to the specified position.
//
// For further details, please see:
Expand Down
1 change: 1 addition & 0 deletions highgui_gocv.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ double Window_GetProperty(const char* winname, int flag);
void Window_SetProperty(const char* winname, int flag, double value);
void Window_SetTitle(const char* winname, const char* title);
int Window_WaitKey(int);
int Window_WaitKeyEx(int);
void Window_Move(const char* winname, int x, int y);
void Window_Resize(const char* winname, int width, int height);
struct Rect Window_SelectROI(const char* winname, Mat img);
Expand Down
10 changes: 10 additions & 0 deletions highgui_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,13 @@ func TestTrackbarWithValue(t *testing.T) {
t.Error("Trackbar pos should have been 50")
}
}

func TestWaitKeyEx(t *testing.T) {

w := NewWindow("wait")
defer w.Close()

if w.WaitKeyEx(1) != -1 {
t.Error("WaitKeyEx failed!")
}
}
Loading