Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not able to run simple example #1170

Open
adrien3d opened this issue Apr 20, 2024 · 1 comment
Open

Not able to run simple example #1170

adrien3d opened this issue Apr 20, 2024 · 1 comment
Labels

Comments

@adrien3d
Copy link

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
@deadprogram
Copy link
Member

Hello @adrien3d first of all, looks like you have some problem with your GTK install. That is not related to GoCV at all.

Also, the function you reference gocv.ToPixbuf(img) does not exist in GoCV. Was that error from some generative system?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants