Giter Site home page Giter Site logo

imgproc.cpp issue on MacOS about gocv HOT 24 CLOSED

hybridgroup avatar hybridgroup commented on July 17, 2024
imgproc.cpp issue on MacOS

from gocv.

Comments (24)

deadprogram avatar deadprogram commented on July 17, 2024

Hello @jkuri make sure you have set whatever needed environment vars for your config. For example, on OS X or Ubuntu you run source ./env.sh as documented here: https://github.com/hybridgroup/gocv#os-x-1

Hope that helps!

from gocv.

jkuri avatar jkuri commented on July 17, 2024

Hi Rob, thank you for your support. Now I have

ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1

My clang version is:

Apple LLVM version 9.0.0 (clang-900.0.38)
Target: x86_64-apple-darwin17.2.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin

and Xcode 9.1 (9B55). Maybe know what's wrong? Thanks again.

from gocv.

deadprogram avatar deadprogram commented on July 17, 2024

As I see you are using OS X, did you install OpenCV using Homebrew?

from gocv.

jkuri avatar jkuri commented on July 17, 2024

yes, I installed it as brew install opencv3 --with-contrib. I just also tried to reinstall whole Xcode but still same issue.

from gocv.

jkuri avatar jkuri commented on July 17, 2024

I made it work, I updated CGO flags in env.sh file to

export CGO_CPPFLAGS="-I/usr/local/Cellar/opencv/3.3.1_1/include  -I/usr/local/Cellar/opencv/3.3.1/include/opencv2"
export CGO_CXXFLAGS="--std=c++1z -stdlib=libc++"
export CGO_LDFLAGS="-L/usr/local/Cellar/opencv/3.3.1_1/lib -lopencv_core -lopencv_videoio -lopencv_imgproc -lopencv_highgui -lopencv_imgcodecs -lopencv_objdetect -lopencv_calib3d -lopencv_video"

path to OpenCV was wrong. Thanks for your support!

from gocv.

deadprogram avatar deadprogram commented on July 17, 2024

Glad you found that, the dev branch already has that change. Seems like we better release it!

from gocv.

jkuri avatar jkuri commented on July 17, 2024

yes, or maybe add condition to the env.sh for backward compatibility for users who doesn't upgrade libraries very often.

from gocv.

cskonopka avatar cskonopka commented on July 17, 2024

After following these directions I am a getting the error specified above. Has anyone else had this issue since?

from gocv.

jkuri avatar jkuri commented on July 17, 2024

@cskonopka run source ./env.sh from this repository, then you need to compile in the same terminal session.

from gocv.

cskonopka avatar cskonopka commented on July 17, 2024

@jkuri ran source ./env.sh from this repo then compiled the program again, same error. Maybe I should just re-install and that would work? Before I did this I completely uninstalled homebrew and installed it fresh so in theory this should have been fine. And for clarity this is the exact issue.

# gocv.io/x/gocv imgproc.cpp:23:26: error: expected '(' for function-style cast or type construction imgproc.cpp:25:19: error: expected '(' for function-style cast or type construction imgproc.cpp:90:28: error: expected '(' for function-style cast or type construction

from gocv.

cskonopka avatar cskonopka commented on July 17, 2024

@jkuri So I delete the repo, started from scratch again. The updated version at this point for openCV is 3.4.0_1 so I changed that in the env.sh file. I do not get the previous error but get a new one. The camera seems to turn on then off immediately and the program crashes. I've tried changing the variables above to 3.4.0 and 3.4.0_1 with no luck. Any ideas or other thread this may pertain to? Thanks for the help, very much appreciate it, really want to get this working at all costs.

start reading camera device: 0
OpenCV Error: Assertion failed (!empty()) in detectMultiScale, file /tmp/opencv-20180113-80339-d8g5mw/opencv-3.4.0/modules/objdetect/src/cascadedetect.cpp, line 1698
libc++abi.dylib: terminating with uncaught exception of type cv::Exception: /tmp/opencv-20180113-80339-d8g5mw/opencv-3.4.0/modules/objdetect/src/cascadedetect.cpp:1698: error: (-215) !empty() in function detectMultiScale

SIGABRT: abort
PC=0x7fff52822e3e m=0 sigcode=0
signal arrived during cgo execution

goroutine 1 [syscall, locked to thread]:
runtime.cgocall(0x409fb40, 0xc420051dd0, 0xc420051df8)
/usr/local/go/src/runtime/cgocall.go:132 +0xe4 fp=0xc420051da0 sp=0xc420051d60 pc=0x4004ba4
gocv.io/x/gocv._Cfunc_CascadeClassifier_DetectMultiScale(0xa529fa0, 0xa5492c0, 0x0, 0x0)
gocv.io/x/gocv/_obj/_cgo_gotypes.go:674 +0x57 fp=0xc420051dd0 sp=0xc420051da0 pc=0x409b3e7
gocv.io/x/gocv.(*CascadeClassifier).DetectMultiScale.func1(0xa529fa0, 0xa5492c0, 0x0, 0x0)
/Users/io/go/src/gocv.io/x/gocv/objdetect.go:53 +0xb5 fp=0xc420051e18 sp=0xc420051dd0 pc=0x409cff5
gocv.io/x/gocv.(*CascadeClassifier).DetectMultiScale(0xc420051f20, 0xa5492c0, 0x0, 0x0, 0x0)
/Users/io/go/src/gocv.io/x/gocv/objdetect.go:53 +0x63 fp=0xc420051e90 sp=0xc420051e18 pc=0x409c6c3
main.main()
/Users/io/go/src/stuff/opencvex.go:49 +0x24b fp=0xc420051f80 sp=0xc420051e90 pc=0x409d78b
runtime.main()
/usr/local/go/src/runtime/proc.go:195 +0x226 fp=0xc420051fe0 sp=0xc420051f80 pc=0x402c206
runtime.goexit()
/usr/local/go/src/runtime/asm_amd64.s:2337 +0x1 fp=0xc420051fe8 sp=0xc420051fe0 pc=0x4054041

rax 0x0
rbx 0x7fff8b7e4340
rcx 0x7ffeefbfdd78
rdx 0x0
rdi 0x307
rsi 0x6
rbp 0x7ffeefbfddb0
rsp 0x7ffeefbfdd78
r8 0x7ffeefbfdc40
r9 0x5101
r10 0x0
r11 0x206
r12 0x307
r13 0x30
r14 0x6
r15 0x2d
rip 0x7fff52822e3e
rflags 0x206
cs 0x7
fs 0x0
gs 0x0
exit status 2

from gocv.

jkuri avatar jkuri commented on July 17, 2024

which demo are you trying to run? I just checked with the latest from go get -u -d -v gocv.io/x/gocv and demo from cmd/facedetect with a success.
I think your issue now is that you don't load cascade classifier.
Try this:

$ cd cmd/detect && go build main.go
$ ./main 0 ../../data/haarcascade_frontalface_default.xml

from gocv.

cskonopka avatar cskonopka commented on July 17, 2024

@jkuri I was trying to run my own script but then defaulted to the cmd/facedetect example and still getting the same error. Let me try what you posted above.

from gocv.

cskonopka avatar cskonopka commented on July 17, 2024

@jkuri This the response when I run go build main.go is below. Please clarify where you want me to run the second command. I run it in the same directory as specified in the first line but then says No such file or directory

# gocv.io/x/gocv
Undefined symbols for architecture x86_64:
"cv::GFTTDetector::create(int, double, double, int, bool, double)", referenced from:
_GFTTDetector_Create in features2d.cpp.o
"cv::SimpleBlobDetector::Params::Params()", referenced from:
_SimpleBlobDetector_Create in features2d.cpp.o
"cv::SimpleBlobDetector::create(cv::SimpleBlobDetector::Params const&)", referenced from:
_SimpleBlobDetector_Create in features2d.cpp.o
"cv::FastFeatureDetector::create(int, bool, int)", referenced from:
_FastFeatureDetector_Create in features2d.cpp.o
"cv::AgastFeatureDetector::create(int, bool, int)", referenced from:
_AgastFeatureDetector_Create in features2d.cpp.o
"cv::ORB::create(int, float, int, int, int, int, int, int, int)", referenced from:
_ORB_Create in features2d.cpp.o
"cv::dnn::experimental_dnn_v3::blobFromImage(cv::_InputArray const&, double, cv::Size_<int> const&, cv::Scalar_<double> const&, bool, bool)", referenced from:
_Net_BlobFromImage in dnn.cpp.o
"cv::dnn::experimental_dnn_v3::readNetFromCaffe(cv::String const&, cv::String const&)", referenced from:
_Net_ReadNetFromCaffe in dnn.cpp.o
"cv::dnn::experimental_dnn_v3::readNetFromTensorflow(cv::String const&, cv::String const&)", referenced from:
_Net_ReadNetFromTensorflow in dnn.cpp.o
"cv::dnn::experimental_dnn_v3::Net::forward(cv::String const&)", referenced from:
_Net_Forward in dnn.cpp.o
"cv::dnn::experimental_dnn_v3::Net::setInput(cv::_InputArray const&, cv::String const&)", referenced from:
_Net_SetInput in dnn.cpp.o
"cv::dnn::experimental_dnn_v3::Net::~Net()", referenced from:
_Net_Close in dnn.cpp.o
"cv::KAZE::create(bool, bool, float, int, int, int)", referenced from:
_KAZE_Create in features2d.cpp.o
"cv::MSER::create(int, int, int, double, double, int, double, double, int)", referenced from:
_MSER_Create in features2d.cpp.o
"cv::AKAZE::create(int, int, int, float, int, int, int)", referenced from:
_AKAZE_Create in features2d.cpp.o
"cv::BRISK::create(int, int, float)", referenced from:
_BRISK_Create in features2d.cpp.o
"cv::dnn::experimental_dnn_v3::Net::empty() const", referenced from:
_Net_Empty in dnn.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

from gocv.

cskonopka avatar cskonopka commented on July 17, 2024

@jkuri I just pulled the latest about 20 minutes ago, I can do it again but I'm sensing I'm gonna get the same results. Also the snippet in the beginning of the thread, the export CGO part, this, I'm assuming, I would change for the OSX version or is it for all of them? I would like clarification on this if this still applies. I'm not that experienced in that aspect of development. I wanted to prototype on my laptop before going to a board. Too frustrated and tired right now but will switch to a pi to see if I can get it going there, just confused why this keeps happening when it's a fresh install and others have fixed it/got it working with OSX.

from gocv.

jkuri avatar jkuri commented on July 17, 2024

about undefined symbols error. you need to compile OpenCV with the contribution addons, check here: https://github.com/hybridgroup/gocv/blob/master/Makefile#L13-L27.
then it should work.

from gocv.

cskonopka avatar cskonopka commented on July 17, 2024

@jkuri Thanks! I will try that, back at it today. Will probably try out the Linux side of things shortly as well. Very much appreciate all the help.

from gocv.

cskonopka avatar cskonopka commented on July 17, 2024

Right but in this file it specifies wget and I'm running OSX unless I'm missing something. Ok, I'm back at the original error, what the hell, how did that happen?????

imgproc.cpp:23:26: error: expected '(' for function-style cast or type construction

So yeah I'm convinced this may not be possible with OSX unless I'm missing something. I did brew install opencv --with-contrib and there was no change. I'm just going to boot up a Linux box and do that, really frustrated since that will cut down productivity. I'm assuming someone has gotten it working with OSX, maybe it has to do with the specific OS.

I will try two things

  1. I'm gonna wipe homebrew and opencv again, install with the contrib specifically and the extras per this website (https://www.learnopencv.com/install-opencv-3-on-yosemite-osx-10-10-x/)
  2. I'll set it up clean from linux and see what happens, I assume it will work smoothly.

Thanks for the patience with this, just super confused why I'm in this feedback loop.

from gocv.

deadprogram avatar deadprogram commented on July 17, 2024

Hi, all. Just to chime in, the standard homebrew recipe for OpenCV includes the contrib extensions:
https://github.com/Homebrew/homebrew-core/blob/master/Formula/opencv.rb

You for sure want to only have a single version of OpenCV installed, and that version should be the latest 3.4 installed by homebrew.

from gocv.

cskonopka avatar cskonopka commented on July 17, 2024

Howdy @deadprogram ! Thank you for the link. Currently I am running one version of OpenCV, that which was installed using brew install opencv without a specific version, it downloaded 3.4.0_1. Is this just because I need 3.4.0 and not 3.4.0_1? Will try this.

from gocv.

cskonopka avatar cskonopka commented on July 17, 2024

@deadprogram After a fresh install of brew again, installed openCV and inside the make file of gocv it is the exact copy of what you pasted above but it's install 3.4.0_1. Versions is deprecated with homebrew so I can't figure out how to install a different version.

from gocv.

deadprogram avatar deadprogram commented on July 17, 2024

That is the latest version of 3.4 using Homebrew's numbering system.

from gocv.

cskonopka avatar cskonopka commented on July 17, 2024

@deadprogram I get that the current release is 3.4.0 but when I install it using homebrew and inspect the folder, it is labeled 3.4.0_1, not 3.4.0. This being said, the version I currently have does not align with the document that was linked and would assume it would have to be exact for it to work properly. There is no duplicate and this has happened each time after a clean wipe of homebrew and when I tried to install this again. I just really want this to work on osx to save me a fair amount of development time. I've tried this on several OSX operating systems as well (high sierra and sierra) and I've had the same issue on separate devices.

from gocv.

deadprogram avatar deadprogram commented on July 17, 2024

What the OpenCV version calls 3.4.0 is what Homebrew installs as 3.4.0_1 but the are the same version. The env.sh script accommodates this already. Also remember that the command

source ./env.sh

needs to be run one time per session in order for the ENV varables to be set in that session to point to the OpenCV install. You should not need to change anything in order to compile, if you have installed OpenCV via homebrew, and have run the env.sh script.

Run this one time to install OpenCV, and you do not need to run again, as long as it works:

brew update opencv

then each session, run:

source ./env.sh
go run ./cmd/version/main.go

Hopefully that helps. One last thing to check, if you are still having troubles, is to make sure you do not have some other version of OpenCV installed that was installed manually not using Homebrew. GoCV is known to work on various macOS versions, I have even run it myself, so you are probably close.

from gocv.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.