代码拉取完成,页面将自动刷新
// Do not run these tests on mac OS X. They fail with errors suggesting the GUI
// should only be touched from the main thread.
// +build !darwin
package gocv
import (
"testing"
)
func TestWindow(t *testing.T) {
window := NewWindow("test")
if window == nil {
t.Error("Unable to create Window")
}
if window.name != "test" {
t.Error("Invalid Window name")
}
val := window.WaitKey(1)
if val != -1 {
t.Error("Invalid WaitKey")
}
if !window.IsOpen() {
t.Error("Window should have been open")
}
window.SetWindowProperty(WindowPropertyFullscreen, WindowFullscreen)
prop := WindowFlag(window.GetWindowProperty(WindowPropertyFullscreen))
if prop != WindowFullscreen {
t.Error("Window property should have been fullscreen")
}
window.SetWindowTitle("My new title")
window.MoveWindow(100, 100)
window.ResizeWindow(100, 100)
window.Close()
if window.IsOpen() {
t.Error("Window should have been closed")
}
}
func TestIMShow(t *testing.T) {
window := NewWindow("imshow")
if window == nil {
t.Error("Unable to create IMShow Window")
}
img := IMRead("images/face-detect.jpg", IMReadColor)
if img.Empty() {
t.Error("Invalid Mat in IMShow")
}
defer img.Close()
// TODO: some way to determine if the call succeeded
window.IMShow(img)
val := WaitKey(1)
if val != -1 {
t.Error("Invalid for IMShow")
}
window.Close()
if window.IsOpen() {
t.Error("IMShow window should have been closed")
}
}
func TestSelectROI(t *testing.T) {
t.Skip("TODO: figure out how to implement a test that can exercise the GUI")
}
func TestSelectROIs(t *testing.T) {
t.Skip("TODO: figure out how to implement a test that can exercise the GUI")
}
func TestTrackbar(t *testing.T) {
window := NewWindow("trackbar")
defer window.Close()
tracker := window.CreateTrackbar("trackme", 100)
if tracker.GetPos() != 0 {
t.Error("Trackbar pos should have been 0")
}
tracker.SetMin(10)
tracker.SetMax(150)
tracker.SetPos(50)
if tracker.GetPos() != 50 {
t.Error("Trackbar pos should have been 50")
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。