Skip to content

Commit

Permalink
added window WaitKeyEx support (#1195)
Browse files Browse the repository at this point in the history
highgui: added window WaitKeyEx support
  • Loading branch information
diegohce authored Aug 14, 2024
1 parent 0ba962c commit 41b95a2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
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!")
}
}

0 comments on commit 41b95a2

Please sign in to comment.