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

Build failed with gocv v0.38.0 #1228

Open
okieraised opened this issue Sep 20, 2024 · 1 comment
Open

Build failed with gocv v0.38.0 #1228

okieraised opened this issue Sep 20, 2024 · 1 comment

Comments

@okieraised
Copy link

okieraised commented Sep 20, 2024

Cannot build projects using gocv after upgrading to v0.38.0.

Description

When building a simple project with go using gocv v0.38.0, it returns the stack trace below:

# gocv.io/x/gocv
dnn.cpp: In function ‘Rect Net_BlobRectToImageRect(Rect, Size, double, Size, Scalar, bool, int, int, int, Scalar)’:
dnn.cpp:134:104: error: no matching function for call to ‘cv::dnn::dnn4_v20230620::Image2BlobParams::Image2BlobParams(cv::Scalar&, cv::Size&, cv::Scalar&, bool&, int&, cv::dnn::dnn4_v20230620::DataLayout&, cv::dnn::dnn4_v20230620::ImagePaddingMode&, cv::Scalar&)’
  134 |     cv::dnn::Image2BlobParams params = cv::dnn::Image2BlobParams(sf, sz, cm, swapRB, ddepth, dl, pm, bv);
      |                                                                                                        ^
In file included from /usr/local/include/opencv4/opencv2/dnn.hpp:76,
                 from /usr/local/include/opencv4/opencv2/opencv.hpp:62,
                 from dnn.h:7,
                 from dnn.cpp:1:
/usr/local/include/opencv4/opencv2/dnn/dnn.hpp:1218:17: note: candidate: ‘cv::dnn::dnn4_v20230620::Image2BlobParams::Image2BlobParams(const Scalar&, const Size&, const Scalar&, bool, int, cv::dnn::dnn4_v20230620::DataLayout, cv::dnn::dnn4_v20230620::ImagePaddingMode)’
 1218 |         CV_WRAP Image2BlobParams(const Scalar& scalefactor, const Size& size = Size(), const Scalar& mean = Scalar(),
      |                 ^~~~~~~~~~~~~~~~
/usr/local/include/opencv4/opencv2/dnn/dnn.hpp:1218:17: note:   candidate expects 7 arguments, 8 provided
/usr/local/include/opencv4/opencv2/dnn/dnn.hpp:1217:17: note: candidate: ‘cv::dnn::dnn4_v20230620::Image2BlobParams::Image2BlobParams()’
 1217 |         CV_WRAP Image2BlobParams();
      |                 ^~~~~~~~~~~~~~~~
/usr/local/include/opencv4/opencv2/dnn/dnn.hpp:1217:17: note:   candidate expects 0 arguments, 8 provided
/usr/local/include/opencv4/opencv2/dnn/dnn.hpp:1215:32: note: candidate: ‘cv::dnn::dnn4_v20230620::Image2BlobParams::Image2BlobParams(const cv::dnn::dnn4_v20230620::Image2BlobParams&)’
 1215 |     struct CV_EXPORTS_W_SIMPLE Image2BlobParams
      |                                ^~~~~~~~~~~~~~~~
/usr/local/include/opencv4/opencv2/dnn/dnn.hpp:1215:32: note:   candidate expects 1 argument, 8 provided
/usr/local/include/opencv4/opencv2/dnn/dnn.hpp:1215:32: note: candidate: ‘cv::dnn::dnn4_v20230620::Image2BlobParams::Image2BlobParams(cv::dnn::dnn4_v20230620::Image2BlobParams&&)’
/usr/local/include/opencv4/opencv2/dnn/dnn.hpp:1215:32: note:   candidate expects 1 argument, 8 provided
dnn.cpp:136:29: error: ‘struct cv::dnn::dnn4_v20230620::Image2BlobParams’ has no member named ‘blobRectToImageRect’
  136 |     cv::Rect bRect = params.blobRectToImageRect(cv::Rect(rect.x, rect.y, rect.width, rect.height), cv::Size(originalSize.width, originalSize.height));
      |                             ^~~~~~~~~~~~~~~~~~~
dnn.cpp: In function ‘Rects Net_BlobRectsToImageRects(Rects, Size, double, Size, Scalar, bool, int, int, int, Scalar)’:
dnn.cpp:160:104: error: no matching function for call to ‘cv::dnn::dnn4_v20230620::Image2BlobParams::Image2BlobParams(cv::Scalar&, cv::Size&, cv::Scalar&, bool&, int&, cv::dnn::dnn4_v20230620::DataLayout&, cv::dnn::dnn4_v20230620::ImagePaddingMode&, cv::Scalar&)’
  160 |     cv::dnn::Image2BlobParams params = cv::dnn::Image2BlobParams(sf, sz, cm, swapRB, ddepth, dl, pm, bv);
      |                                                                                                        ^
In file included from /usr/local/include/opencv4/opencv2/dnn.hpp:76,
                 from /usr/local/include/opencv4/opencv2/opencv.hpp:62,
                 from dnn.h:7,
                 from dnn.cpp:1:
/usr/local/include/opencv4/opencv2/dnn/dnn.hpp:1218:17: note: candidate: ‘cv::dnn::dnn4_v20230620::Image2BlobParams::Image2BlobParams(const Scalar&, const Size&, const Scalar&, bool, int, cv::dnn::dnn4_v20230620::DataLayout, cv::dnn::dnn4_v20230620::ImagePaddingMode)’
 1218 |         CV_WRAP Image2BlobParams(const Scalar& scalefactor, const Size& size = Size(), const Scalar& mean = Scalar(),
      |                 ^~~~~~~~~~~~~~~~
/usr/local/include/opencv4/opencv2/dnn/dnn.hpp:1218:17: note:   candidate expects 7 arguments, 8 provided
/usr/local/include/opencv4/opencv2/dnn/dnn.hpp:1217:17: note: candidate: ‘cv::dnn::dnn4_v20230620::Image2BlobParams::Image2BlobParams()’
 1217 |         CV_WRAP Image2BlobParams();
      |                 ^~~~~~~~~~~~~~~~
/usr/local/include/opencv4/opencv2/dnn/dnn.hpp:1217:17: note:   candidate expects 0 arguments, 8 provided
/usr/local/include/opencv4/opencv2/dnn/dnn.hpp:1215:32: note: candidate: ‘cv::dnn::dnn4_v20230620::Image2BlobParams::Image2BlobParams(const cv::dnn::dnn4_v20230620::Image2BlobParams&)’
 1215 |     struct CV_EXPORTS_W_SIMPLE Image2BlobParams
      |                                ^~~~~~~~~~~~~~~~
/usr/local/include/opencv4/opencv2/dnn/dnn.hpp:1215:32: note:   candidate expects 1 argument, 8 provided
/usr/local/include/opencv4/opencv2/dnn/dnn.hpp:1215:32: note: candidate: ‘cv::dnn::dnn4_v20230620::Image2BlobParams::Image2BlobParams(cv::dnn::dnn4_v20230620::Image2BlobParams&&)’
/usr/local/include/opencv4/opencv2/dnn/dnn.hpp:1215:32: note:   candidate expects 1 argument, 8 provided
dnn.cpp:163:12: error: ‘struct cv::dnn::dnn4_v20230620::Image2BlobParams’ has no member named ‘blobRectsToImageRects’
  163 |     params.blobRectsToImageRects(_cRects, detected, cv::Size(originalSize.width, originalSize.height));
      |            ^~~~~~~~~~~~~~~~~~~~~
dnn.cpp: In function ‘cv::Mat* Net_BlobFromImageWithParams(Mat, double, Size, Scalar, bool, int, int, int, Scalar)’:
dnn.cpp:192:104: error: no matching function for call to ‘cv::dnn::dnn4_v20230620::Image2BlobParams::Image2BlobParams(cv::Scalar&, cv::Size&, cv::Scalar&, bool&, int&, cv::dnn::dnn4_v20230620::DataLayout&, cv::dnn::dnn4_v20230620::ImagePaddingMode&, cv::Scalar&)’
  192 |     cv::dnn::Image2BlobParams params = cv::dnn::Image2BlobParams(sf, sz, cm, swapRB, ddepth, dl, pm, bv);
      |                                                                                                        ^
In file included from /usr/local/include/opencv4/opencv2/dnn.hpp:76,
                 from /usr/local/include/opencv4/opencv2/opencv.hpp:62,
                 from dnn.h:7,
                 from dnn.cpp:1:
/usr/local/include/opencv4/opencv2/dnn/dnn.hpp:1218:17: note: candidate: ‘cv::dnn::dnn4_v20230620::Image2BlobParams::Image2BlobParams(const Scalar&, const Size&, const Scalar&, bool, int, cv::dnn::dnn4_v20230620::DataLayout, cv::dnn::dnn4_v20230620::ImagePaddingMode)’
 1218 |         CV_WRAP Image2BlobParams(const Scalar& scalefactor, const Size& size = Size(), const Scalar& mean = Scalar(),
      |                 ^~~~~~~~~~~~~~~~
/usr/local/include/opencv4/opencv2/dnn/dnn.hpp:1218:17: note:   candidate expects 7 arguments, 8 provided
/usr/local/include/opencv4/opencv2/dnn/dnn.hpp:1217:17: note: candidate: ‘cv::dnn::dnn4_v20230620::Image2BlobParams::Image2BlobParams()’
 1217 |         CV_WRAP Image2BlobParams();
      |                 ^~~~~~~~~~~~~~~~
/usr/local/include/opencv4/opencv2/dnn/dnn.hpp:1217:17: note:   candidate expects 0 arguments, 8 provided
/usr/local/include/opencv4/opencv2/dnn/dnn.hpp:1215:32: note: candidate: ‘cv::dnn::dnn4_v20230620::Image2BlobParams::Image2BlobParams(const cv::dnn::dnn4_v20230620::Image2BlobParams&)’
 1215 |     struct CV_EXPORTS_W_SIMPLE Image2BlobParams
      |                                ^~~~~~~~~~~~~~~~
/usr/local/include/opencv4/opencv2/dnn/dnn.hpp:1215:32: note:   candidate expects 1 argument, 8 provided
/usr/local/include/opencv4/opencv2/dnn/dnn.hpp:1215:32: note: candidate: ‘cv::dnn::dnn4_v20230620::Image2BlobParams::Image2BlobParams(cv::dnn::dnn4_v20230620::Image2BlobParams&&)’
/usr/local/include/opencv4/opencv2/dnn/dnn.hpp:1215:32: note:   candidate expects 1 argument, 8 provided
dnn.cpp: In function ‘void Net_BlobFromImagesWithParams(Mats, Mat, double, Size, Scalar, bool, int, int, int, Scalar)’:
dnn.cpp:226:104: error: no matching function for call to ‘cv::dnn::dnn4_v20230620::Image2BlobParams::Image2BlobParams(cv::Scalar&, cv::Size&, cv::Scalar&, bool&, int&, cv::dnn::dnn4_v20230620::DataLayout&, cv::dnn::dnn4_v20230620::ImagePaddingMode&, cv::Scalar&)’
  226 |     cv::dnn::Image2BlobParams params = cv::dnn::Image2BlobParams(sf, sz, cm, swapRB, ddepth, dl, pm, bv);
      |                                                                                                        ^
In file included from /usr/local/include/opencv4/opencv2/dnn.hpp:76,
                 from /usr/local/include/opencv4/opencv2/opencv.hpp:62,
                 from dnn.h:7,
                 from dnn.cpp:1:
/usr/local/include/opencv4/opencv2/dnn/dnn.hpp:1218:17: note: candidate: ‘cv::dnn::dnn4_v20230620::Image2BlobParams::Image2BlobParams(const Scalar&, const Size&, const Scalar&, bool, int, cv::dnn::dnn4_v20230620::DataLayout, cv::dnn::dnn4_v20230620::ImagePaddingMode)’
 1218 |         CV_WRAP Image2BlobParams(const Scalar& scalefactor, const Size& size = Size(), const Scalar& mean = Scalar(),
      |                 ^~~~~~~~~~~~~~~~
/usr/local/include/opencv4/opencv2/dnn/dnn.hpp:1218:17: note:   candidate expects 7 arguments, 8 provided
/usr/local/include/opencv4/opencv2/dnn/dnn.hpp:1217:17: note: candidate: ‘cv::dnn::dnn4_v20230620::Image2BlobParams::Image2BlobParams()’
 1217 |         CV_WRAP Image2BlobParams();
      |                 ^~~~~~~~~~~~~~~~
/usr/local/include/opencv4/opencv2/dnn/dnn.hpp:1217:17: note:   candidate expects 0 arguments, 8 provided
/usr/local/include/opencv4/opencv2/dnn/dnn.hpp:1215:32: note: candidate: ‘cv::dnn::dnn4_v20230620::Image2BlobParams::Image2BlobParams(const cv::dnn::dnn4_v20230620::Image2BlobParams&)’
 1215 |     struct CV_EXPORTS_W_SIMPLE Image2BlobParams
      |                                ^~~~~~~~~~~~~~~~
/usr/local/include/opencv4/opencv2/dnn/dnn.hpp:1215:32: note:   candidate expects 1 argument, 8 provided
/usr/local/include/opencv4/opencv2/dnn/dnn.hpp:1215:32: note: candidate: ‘cv::dnn::dnn4_v20230620::Image2BlobParams::Image2BlobParams(cv::dnn::dnn4_v20230620::Image2BlobParams&&)’
/usr/local/include/opencv4/opencv2/dnn/dnn.hpp:1215:32: note:   candidate expects 1 argument, 8 provided

Steps to Reproduce

  1. Open new project and create a main.go file:
package main

import (
	"fmt"
	"gocv.io/x/gocv"
	"io"
	"os"
)

func main() {
	f, err := os.Open("/path/to/an/image")
	if err != nil {
		fmt.Println(err)
		return
	}
	defer f.Close()

	content, err := io.ReadAll(f)
	if err != nil {
		fmt.Println(err)
		return
	}

	dstMat := gocv.NewMat()
	srcMat, err := gocv.IMDecode(content, gocv.IMReadColor)
	if err != nil {
		fmt.Println(err)
		return
	}

	gocv.CvtColor(srcMat, &dstMat, gocv.ColorBGRToRGB)
	return
}
  1. Build it with:
go build .

It failed.

Your Environment

  • Operating System and version: Ubuntu 20.04.6 LTS
  • OpenCV version used: 4.10.0
  • How did you install OpenCV? pip3 install --upgrade opencv-python
  • GoCV version used: v0.38.0
  • Go version: 1.23.1
  • Did you run the env.sh or env.cmd script before trying to go run or go build? No
@deadprogram
Copy link
Member

That sounds like an incompatible version of OpenCV being installed by python, or installed missing required module.

Perhaps you can check pkg-config command output. In any case, the only tested installation for Linux is installing OpenCV from source.

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

No branches or pull requests

2 participants