
我有使用 gocv 的代码(为 opencv 提供 go 语言绑定)。 它只是在图像上绘制一些矩形并显示结果。
func main() {
resp, err := http.get("http://localhost:6060/template-match")
if err != nil {
panic(err)
}
defer resp.body.close()
body, err := ioutil.readall(resp.body)
if err != nil {
panic(err)
}
fmt.println(string(body))
var data response
err = json.unmarshal(body, &data)
if err != nil {
panic(err)
}
srcimage := gocv.imread("./images/src1.jpg", gocv.imreadcolor)
for i := 0; i < len(data.data); i++ {
gocv.rectangle(&srcimage, data.data[i], color.rgba{r: 255}, 2)
}
window := gocv.newwindow("match-result")
window.imshow(srcimage)
gocv.waitkey(0)
fmt.println(data.data, data.msg)我收到此错误:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'NSWindow drag regions should only be invalidated on the Main Thread!'
我真的很困惑,因为这个错误并不是每次都会发生
我没有使用过这个库,但看起来这是一个 已知问题 - 而且,由于您提到它只是有时发生,所以听起来该错误确实取决于线程上下文。那里的答案(来自库作者)指向 https://github.com/golang/go /wiki/lockosthread,所以你的主包应该实现类似的东西
func init() {
runtime.LockOSThread()
}
以上就是在 macOS 上使用 gocv 时间歇性出现 NSInternalInconsistencyException的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号