gocv icon indicating copy to clipboard operation
gocv copied to clipboard

Not able to run simple example

Open adrien3d opened this issue 2 months ago • 1 comments

Description

On macOS 14.4.1, I am able to run go run ./cmd/version/main.go, as well as the face detect example. But not the following code:

Steps to Reproduce

package main

import (
	"image/color"

	"github.com/mattn/go-gtk/gtk"
	"gocv.io/x/gocv"
)

func main() {
	// Load face detection model
	classifier := gocv.NewCascadeClassifier()
	classifier.Load("haarcascade_frontalface_default.xml")
	defer classifier.Close()

	// Read input image
	img := gocv.IMRead("input.jpg", gocv.IMReadColor)
	defer img.Close()

	// Perform face detection
	rects := classifier.DetectMultiScale(img)

	// Draw bounding boxes around detected faces
	for _, r := range rects {
		gocv.Rectangle(img, r, color.RGBA{255, 0, 0, 0}, 3)
	}

	// Display the output
	window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL)
	window.SetTitle("Face Detection")
	window.Connect("destroy", gtk.MainQuit)

	image := gtk.NewImageFromPixbuf(gocv.ToPixbuf(img))
	window.Add(image)

	window.SetDefaultSize(img.Cols(), img.Rows())
	window.ShowAll()

	gtk.Main()
}

Your Environment

export CGO_CXXFLAGS="--std=c++11" export CGO_CPPFLAGS="-I/opt/homebrew/Cellar/opencv/4.9.0_7/include/opencv4"

  • Operating System and version: macOS 14.4.1
  • OpenCV version used: 4.9.0
  • How did you install OpenCV? homebrew
  • GoCV version used: 0.36.1
  • Go version: 1.22.2
  • Did you run the env.sh or env.cmd script before trying to go run or go build? Appears to be no longer necessary, so no

Error

# github.com/mattn/go-gtk/glib
In file included from _cgo_export.c:4:
In file included from glib.go:5:
../../../../pkg/mod/github.com/mattn/[email protected]/glib/glib.go.h:183:28: warning: 'GThreadFunctions' is deprecated [-Wdeprecated-declarations]
/opt/homebrew/Cellar/glib/2.80.0_2/include/glib-2.0/glib/deprecated/gthread.h:57:51: note: 'GThreadFunctions' has been explicitly marked deprecated here
/opt/homebrew/Cellar/glib/2.80.0_2/include/glib-2.0/glib/glib-visibility.h:145:38: note: expanded from macro 'GLIB_DEPRECATED_TYPE_IN_2_32'
/opt/homebrew/Cellar/glib/2.80.0_2/include/glib-2.0/glib/gmacros.h:1324:30: note: expanded from macro 'GLIB_DEPRECATED_TYPE'
/opt/homebrew/Cellar/glib/2.80.0_2/include/glib-2.0/glib/gmacros.h:1263:37: note: expanded from macro 'G_DEPRECATED'
# github.com/mattn/go-gtk/glib
In file included from ../../../../pkg/mod/github.com/mattn/[email protected]/glib/glib.go:5:
../../../../pkg/mod/github.com/mattn/[email protected]/glib/glib.go.h:183:28: warning: 'GThreadFunctions' is deprecated [-Wdeprecated-declarations]
/opt/homebrew/Cellar/glib/2.80.0_2/include/glib-2.0/glib/deprecated/gthread.h:57:51: note: 'GThreadFunctions' has been explicitly marked deprecated here
/opt/homebrew/Cellar/glib/2.80.0_2/include/glib-2.0/glib/glib-visibility.h:145:38: note: expanded from macro 'GLIB_DEPRECATED_TYPE_IN_2_32'
/opt/homebrew/Cellar/glib/2.80.0_2/include/glib-2.0/glib/gmacros.h:1324:30: note: expanded from macro 'GLIB_DEPRECATED_TYPE'
/opt/homebrew/Cellar/glib/2.80.0_2/include/glib-2.0/glib/gmacros.h:1263:37: note: expanded from macro 'G_DEPRECATED'
cgo-gcc-prolog:193:3: warning: 'GThreadFunctions' is deprecated [-Wdeprecated-declarations]
/opt/homebrew/Cellar/glib/2.80.0_2/include/glib-2.0/glib/deprecated/gthread.h:57:51: note: 'GThreadFunctions' has been explicitly marked deprecated here
/opt/homebrew/Cellar/glib/2.80.0_2/include/glib-2.0/glib/glib-visibility.h:145:38: note: expanded from macro 'GLIB_DEPRECATED_TYPE_IN_2_32'
/opt/homebrew/Cellar/glib/2.80.0_2/include/glib-2.0/glib/gmacros.h:1324:30: note: expanded from macro 'GLIB_DEPRECATED_TYPE'
/opt/homebrew/Cellar/glib/2.80.0_2/include/glib-2.0/glib/gmacros.h:1263:37: note: expanded from macro 'G_DEPRECATED'
# github.com/mattn/go-gtk/gdk
# [pkg-config --cflags  -- gdk-2.0 gthread-2.0 gdk-2.0 gthread-2.0]
Package gdk-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gdk-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gdk-2.0' found
Package gdk-2.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `gdk-2.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gdk-2.0' found

adrien3d avatar Apr 20 '24 08:04 adrien3d