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

gocv.BlobFromImage is not work well. #658

Open
knight2995 opened this issue Apr 12, 2020 · 3 comments
Open

gocv.BlobFromImage is not work well. #658

knight2995 opened this issue Apr 12, 2020 · 3 comments
Labels

Comments

@knight2995
Copy link

@knight2995 knight2995 commented Apr 12, 2020

Description

I am trying to test dnn-detection Code
. I am receiving an error message
gocv.io/x/gocv._Cfunc_Net_BlobFromImage(0x470f010, 0x3f80101010101010,...):

I think the scalefactor parameter of the BlobFromImage seems to be wrong.
Only in 1.0 does not the error occur.

Steps to Reproduce

  1. I use TensorFlow Model and pbtxt config file.

Your Environment

  • Operating System and version: Windows 10
  • OpenCV version used: 4.2.0
  • How did you install OpenCV? No
  • GoCV version used: 0.22.0
  • Go version: 1.13.5
  • Did you run the env.sh or env.cmd script before trying to go run or go build?
@deadprogram
Copy link
Member

@deadprogram deadprogram commented Apr 25, 2020

I think that the underlying API of OpenCV changed or else the model itself did, as I ran into a similar problem with scaling the input blob to a DNN recently. I will look into it further.

@knight2995
Copy link
Author

@knight2995 knight2995 commented May 2, 2020

Hi, I found this code in opencv/dnn/dnn.cpp

if (ddepth == CV_8U)  
    {
        CV_CheckEQ(scalefactor, 1.0, "Scaling is not supported for CV_8U blob depth");
        CV_Assert(mean_ == Scalar() && "Mean subtraction is not supported for CV_8U blob depth");
    }

I think this is the reason for the error.

so, I try to change CV_8U to CV_32F, this code is worked fine.

// fix code
img.ConvertTo(&img, gocv.MatTypeCV32F)

blob := gocv.BlobFromImage(img, ratio, image.Pt(300, 300), mean, swapRGB, false)
@craigske
Copy link

@craigske craigske commented Jun 11, 2020

Seeing this issue as well. Even converting doesn't work for me.
img.ConvertTo(&imgBlob, gocv.MatTypeCV32F)
blob := gocv.BlobFromImage(imgBlob, 1.0, image.Pt(imgBlob.Rows(), imgBlob.Cols()), gocv.NewScalar(104, 117, 123, 0), false, false)

gives
libc++abi.dylib: terminating with uncaught exception of type cv::Exception: OpenCV(4.3.0) /tmp/opencv-20200531-90131-i8hdtq/opencv-4.3.0/modules/dnn/src/dnn.cpp:334: error: (-215:Assertion failed) mean_ == Scalar() && "Mean subtraction is not supported for CV_8U blob depth" in function 'blobFromImages'

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

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.