mirror of
https://github.com/hybridgroup/gocv
synced 2025-08-25 08:41:04 +08:00
Can delete a named Window
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
10
highgui.cpp
10
highgui.cpp
@@ -5,9 +5,13 @@ void Window_New(const char* winname, int flags) {
|
||||
cv::namedWindow(winname, flags);
|
||||
}
|
||||
|
||||
// void Window_Delete(const char* winname) {
|
||||
// cv::destroyWindow(winname);
|
||||
// }
|
||||
void Window_Delete(const char* winname) {
|
||||
cv::destroyWindow(winname);
|
||||
}
|
||||
|
||||
void Window_IMShow(const char* winname, MatVec3b mat) {
|
||||
cv::imshow(winname, *mat);
|
||||
}
|
||||
|
||||
int Window_WaitKey(int delay = 0) {
|
||||
return cv::waitKey(delay);
|
||||
|
21
highgui.go
21
highgui.go
@@ -15,15 +15,32 @@ type Window struct {
|
||||
}
|
||||
|
||||
// NewWindow creates a new named cv window
|
||||
func NewWindow(name string) Window {
|
||||
func NewWindow(name string) *Window {
|
||||
cName := C.CString(name)
|
||||
defer C.free(unsafe.Pointer(cName))
|
||||
|
||||
C.Window_New(cName, 1)
|
||||
|
||||
return Window{name: name}
|
||||
return &Window{name: name}
|
||||
}
|
||||
|
||||
// Delete a specific Window
|
||||
func (w *Window) Delete() {
|
||||
cName := C.CString(w.name)
|
||||
defer C.free(unsafe.Pointer(cName))
|
||||
|
||||
C.Window_Delete(cName)
|
||||
}
|
||||
|
||||
// IMShow takes an image Mat and displays it in the Window
|
||||
func (w *Window) IMShow(img MatVec3b) {
|
||||
cName := C.CString(w.name)
|
||||
defer C.free(unsafe.Pointer(cName))
|
||||
|
||||
C.Window_IMShow(cName, img.p)
|
||||
}
|
||||
|
||||
// WaitKey waits for keyboard input
|
||||
func WaitKey(delay int) int {
|
||||
return int(C.Window_WaitKey(C.int(delay)))
|
||||
}
|
||||
|
@@ -10,9 +10,11 @@ extern "C" {
|
||||
|
||||
// Window
|
||||
void Window_New(const char* winname, int flags);
|
||||
//void Window_Delete(const char* winname);
|
||||
void Window_Delete(const char* winname);
|
||||
void Window_IMShow(const char* winname, MatVec3b mat);
|
||||
int Window_WaitKey(int);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user