func main() { fmt.Println("Hello World!") text := C.CString("Hello World!") defer C.free(unsafe.Pointer(text)) C.cvNamedWindow(text, 1) img := unsafe.Pointer(C.cvCreateImage(C.cvSize(640, 480), C.IPL_DEPTH_8U, 1)) C.cvSet(img, C.cvScalar(0, 0, 0, 0), nil) var font C.CvFont C.cvInitFont(&font, C.CV_FONT_HERSHEY_SIMPLEX|C.CV_FONT_ITALIC, 1.0, 1.0, 0, 1, 8) C.cvPutText(img, text, C.cvPoint(200, 400), &font, C.cvScalar(255, 255, 0, 0)) C.cvShowImage(text, img) C.cvWaitKey(0) }
/* create window */ func NewWindow(name string, flags ...int) *Window { win_flags := C.int(CV_WINDOW_AUTOSIZE) if len(flags) > 0 { win_flags = C.int(flags[0]) } win := &Window{ name: name, name_c: C.CString(name), flags: win_flags, trackbarHandle: make(map[string]TrackbarFunc, 50), trackbarMax: make(map[string]int, 50), trackbarVal: make(map[string]int, 50), trackbarName: make(map[string](*C.char), 50), trackbarParam: make(map[string]([]interface{}), 50), } C.cvNamedWindow(win.name_c, win.flags) C.SetMouseCallback(win.name_c) allWindows[win.name] = win return win }