If you do get OpenCV installed, quite likely you might need to copy the files the installation steps put in the /opt/local/lib....
I'm guessing they might be cv.dmg highgui.dmg cxcore.dmg cvaux.dmg cxcore.dmg. They might be mangled with version too (2.1)
At some point I will be trying this on a Mac as soon as I can get my hands on one. Do you think this is something you can try yourself?
GroG.
1. Easy build via MacPorts
For Snow Leopard users, you can build OpenCV 2.1.0 and above via MacPorts as a 64-bit library with support of QTKit video I/O and Cocoa GUI.
to update the MacPorts base and the port tree. Then, simply:
sudo port install opencv
to build OpenCV 2.1.0 in 64-bit.
If you encounter errors, try installing its dependents with +universal whenever possible.
sudo port -v install opencv +python26
to use with Python 2.6 bindings or
sudo port -v install opencv +python27
to use with Python 2.7 bindings
By default OpenCV is installed to /opt/local/ according to MacPorts conventions. The opencv_xxxx utilities are located in /opt/local/bin/, the dynamic libraries in /opt/local/lib/ and the header files in /opt/local/include/opencv/.
To use the libraries, include the required files with standard includes. For example:
#include <cv.h>
#include <highgui.h>
If you use Xcode, the instructions are similar to the ones in method 3. It only differs that /usr/local becomes /opt/local.
which starts myrobotlab with 2 running services an Invoker Service and a GUIService
the -Djava.library.path=./bin is a directive to tell mrl where native libraries are located
I'm guessing you should be able to copy the opencv dynamic library files into the /myrobotlab-0002/bin directory.
On my Linux/PC system the files are named like this
I forgot something.. The terminal outputs following when i try to connect cam:
java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at com.myrobotlab.framework.Service.invoke(Service.java:690) at com.myrobotlab.framework.Service.invoke(Service.java:639) at com.myrobotlab.framework.Service.invoke(Service.java:569) at com.myrobotlab.framework.Service.process(Service.java:233) at com.myrobotlab.framework.Service.run(Service.java:215) at java.lang.Thread.run(Thread.java:680) Caused by: java.lang.NoClassDefFoundError: Could not initialize class com.googlecode.javacv.jna.highgui at com.myrobotlab.service.OpenCV.capture(OpenCV.java:454) ... 10 more
I tried to do a manual install of opencv 2.0 which succeeded and my missing dylibs files appeared, but the application is still looking in the wrong directory
Caused by: java.lang.UnsatisfiedLinkError: Unable to load library 'cxcore': dlopen(/usr/lib/libcxcore.dylib, 9): no suitable image found. Did find:
/usr/lib/libcxcore.dylib: mach-o, but wrong architecture
I get a bad feeling when i read the error above, but its pointing in the wrong directory (/usr/lib/*) should be
Hi samuel,
I want to suggest you to add the path "/opt/local/lib" in the cxcore class for those who installed opencv via
Macports (that's the default installation directory) to avoid the first error discussed in this thread.
ps. thanks for the great work
I dont exactly understand how to change that path?
It looks as if Samuel has fixed it, I assume in his latest release...
I'm guessing that if you download and replace the myrobotlab-0002/lib/javacv.jar it might work now?
If it does, I'm not sure why/how the path is hardcoded in javacv ? Samuel is an excellent developer, I would be very surprised if he has hardcoded paths... :P
I'm going to get the latest release from JavaCV and check to make sure it works on my system. So for you the OpenCV service will load in version 0001 but not 0002? Any error info?
I think we are getting closer visionHead..
previously I had builds/binaries for Linux & windows from opencv 2.1
I see a considerable amount of change between 2.1 and 2.2
Some of the differences besides actual code changes is the binary names...
previously opencv would produce shared libraries like libcv.so,
now they have shared objects like libopencv_core.so.2.2
Also, JavaCV has changed considerably - Samuel is now release many jars - some look like they distinguish between 32 and 64 bit...
I am now in the process of syncing up... starting with opencv builds - I have just successfully built the Linux versions of opencv 2.2 .. after that I will build the windows version... and after that I'll get the latest JavaCV verify that it works and bundle it all up...
I'm sure that this was some of the root cause of the problem as the MacPort installs 2.2 and MRL came with 2.1..
After I synch up Linux, windows & JavaCV, I'll notify you...
My preference is to have MRL run with a local copy of the binaries... this guarantees compatibility.. and if the command line is done correctly - the user can install any version of OpenCV on their system, which MRL will NOT be dependent on... So, when we get it working on your system can you send me the shared libraries you have from the MacPort so I can bundle those?
I just downloaded it, but what bothers me is that there is no reaction in the terminal anymore.. I get no error or anything.. But sadly, still no webcam view!
I believe we need to start with very small steps to see where the issue is.
I have compiled one of JavaCV's samples "MotionDetector" - Strangely, the other two samples "HoughLines and OpticalFlowTracker" do not work on my system.. I'll be investigating the details and possibly submitting bugs to Samuel Audet @ JavaCV
You should be able to launch the MotionDetector through a terminal...
cd to the myrobotlab-0003/lib directory and run the following command:
java -classpath $CLASSPATH:javacpp.jar:javacv.jar:javacv-macosx-x86_64.jar -Djava.library.path=/<absolute location of the libopencv_*2.2.0.dylibs> MotionDetector
A Canvas Frame with hardware acceleration should come up, and your camera should turn on -
It will be black but when you move it should detect it. It "should" look like this when you move
If it does work YAY - 1 small step
If it does not work:
I will need any error information which comes back.
Sadly im running out of time in my project. So im curious about the possibilities with importing an image into OpenCV in myrobotlab and just ignoring the camera function for while.
If image importing is not possible, then AVI-file import. If you have a guide i would appreciate it highly!
I did a opencv 2.2 build and loaded Samuel's javacv libs...
My Eclipse editor has lit up like a Christmas Tree with all the errors ... this will take a little time to correct..
Most of it looks pretty easy like, import path changes from jna to cpp and from .core to .opencv_core
If you do get OpenCV installed, quite likely you might need to copy the files the installation steps put in the /opt/local/lib.... I'm guessing they might be cv.dmg highgui.dmg cxcore.dmg cvaux.dmg cxcore.dmg. They might be mangled with version too (2.1)
Im not quite sure if i got this wrong, but did you mean that i should copy the files else where? If so, where should i place them?
That reply thread was getting squished, so I started another one....
The error you reported
java -classpath $CLASSPATH:javacpp.jar:javacv.jar:javacv-macosx-x86_64.jar -Djava.library.path=/opt/local/lib MotionDetector Exception in thread "main" java.lang.NoClassDefFoundError: MotionDetector Caused by: java.lang.ClassNotFoundException: MotionDetector at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:307) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
It looks as if it can't find the MotionDetector class - which can be caused by not getting the -classpath correct...
Event on a Linux machine I find the weird and slightly different notation of the -classpath directive frustrating..
For example
I dont really use that, i use basic functions to track a object. My project is up running, but its a pain in the ass adjusting the HSV and testing filters, which is a great benefit using your application. Is there no way to import af AVI or IMAGE to the application instead of camera streaming?
You can load the pyramid down filter which will reduce the size of the frames.
When you load a filter it must be a unique name. But, you can load as meaning filters as you want. Meaning you can load PyramidDown twice with 2 unique names, and your image size will be 1/4 the original.
That helped alot. Now i have a mysterious question! Why does the InRange act different in the myrobotlab gui compared to InRange directly in my OpenCV project? I cant seem to take the HSV values directly from the simulation in my myrobotlab and use them in the project?! :-/
Hello visionHead
And Welcome !
I have not run the opencv service with myrobotlab on a Mac yet, but I'm sure we can figure it out.
A quick look on the web revealed the following (see below) - taken from http://opencv.willowgarage.com/wiki/Mac_OS_X_OpenCV_Port
If you do get OpenCV installed, quite likely you might need to copy the files the installation steps put in the /opt/local/lib....
I'm guessing they might be cv.dmg highgui.dmg cxcore.dmg cvaux.dmg cxcore.dmg. They might be mangled with version too (2.1)
At some point I will be trying this on a Mac as soon as I can get my hands on one. Do you think this is something you can try yourself?
GroG.
1. Easy build via MacPorts
For Snow Leopard users, you can build OpenCV 2.1.0 and above via MacPorts as a 64-bit library with support of QTKit video I/O and Cocoa GUI.
Assuming MacPorts installed, first use:
sudo port selfupdate
to update the MacPorts base and the port tree. Then, simply:
sudo port install opencv
to build OpenCV 2.1.0 in 64-bit.
If you encounter errors, try installing its dependents with +universal whenever possible.
sudo port -v install opencv +python26
to use with Python 2.6 bindings or
sudo port -v install opencv +python27
to use with Python 2.7 bindings
By default OpenCV is installed to /opt/local/ according to MacPorts conventions. The opencv_xxxx utilities are located in /opt/local/bin/, the dynamic libraries in /opt/local/lib/ and the header files in /opt/local/include/opencv/.
To use the libraries, include the required files with standard includes. For example:
#include <cv.h> #include <highgui.h>
If you use Xcode, the instructions are similar to the ones in method 3. It only differs that /usr/local becomes /opt/local.
Dear Grog, Thank you for
Dear Grog,
Thank you for your reply.
I already have OpenCV installed by using Mac Ports and it is working quite well.
Theres lots of opencv *.dylib files in the /opt/local/lib so i assume thats alright.
The *.dmg files you are mentioning are disk manage files, somewhat like a ISO file.
Great visionHead !
You can tell how Mac-ignorant I am. Thanks for the distinction.
If you've downloaded and unzipped the latest version of myrobolab you should have a directory structure like this:
/myrobotlab-0002
/myrobotlab-0002/bin
/myrobotlab-0002/lib
the myrobotlab.sh file calls b.sh
it has the following shell script line
java -d32 -Djava.library.path=./bin org.myrobotlab.service.Invoker -service Invoker services GUIService gui > log.txt
which starts myrobotlab with 2 running services an Invoker Service and a GUIService
the -Djava.library.path=./bin is a directive to tell mrl where native libraries are located
I'm guessing you should be able to copy the opencv dynamic library files into the /myrobotlab-0002/bin directory.
On my Linux/PC system the files are named like this
visionHead wrote ....
I forgot something.. The terminal outputs following when i try to connect cam:
java.lang.reflect. InvocationTargetException NativeMethodAccessorImpl. invoke0(Native Method) NativeMethodAccessorImpl. invoke( NativeMethodAccessorImpl.java: 39) DelegatingMethodAccessorImpl. invoke( DelegatingMethodAccessorImpl. java:25) invoke(Method.java:597) Service.invoke(Service.java: 690) Service.invoke(Service.java: 639) Service.invoke(Service.java: 569) Service.process(Service.java: 233) Service.run(Service.java:215) java:680) NoClassDefFoundError: Could not initialize class com.googlecode.javacv.jna. highgui capture(OpenCV.java:454)
at sun.reflect.
at sun.reflect.
at sun.reflect.
at java.lang.reflect.Method.
at com.myrobotlab.framework.
at com.myrobotlab.framework.
at com.myrobotlab.framework.
at com.myrobotlab.framework.
at com.myrobotlab.framework.
at java.lang.Thread.run(Thread.
Caused by: java.lang.
at com.myrobotlab.service.OpenCV.
... 10 more
The Java looks OK
It just looks like the application can't find the binaries...
Can you give me the list of names of the binaries now in the bin folder which came from the MacPort install?
Also, what "is" working with OpenCV - where there executables in the MacPort install?
Currently i have these files
Currently i have these files (links) in the myrobot*/bin library:
???
I'm not sure... I don't believe there is direct references anywhere to a 2.1.0 but I'll need to check...
What about changing the -Djava.library.path=./bin in myrobotlab-0002/b.sh file
to
-Djava.library.path=<absolute path>/opencv2.2/lib ?
I changed it to
I changed it to following
java -Djava.library.path=/opt/local/var/macports/build/_opt_local_var_macports_sources_rsync.macports.org_release_ports_graphics_opencv/work/OpenCV-2.2.0/lib -cp "myrobotlab.jar;lib/*" com.myrobotlab.service.Invoker -service Invoker invoker GUIService gui > log.txt
I still seem to get the errors:
this error makes good sense, theres no such file!
something must be totally wrong, i cannot seem to find any the libcxcore.dylib anywhere?
Very strange....
That is strange, it exists on my system !?!? Most of the OpenCV samples use it too....?
I tried to do a manual
I tried to do a manual install of opencv 2.0 which succeeded and my missing dylibs files appeared, but the application is still looking in the wrong directory
Try changing it to absolute path...
Try changing it to absolute path... perhaps?
e.g. -Djava.library.path=/home/me/mydirectory/myrobotlab-0002/bin ?
I have changed the path, its
I have changed the path, its still looking in /usr/lib
I saw this link:
http://code.google.com/p/javacv/issues/detail?id=3
Someone replied:
Hi samuel, I want to suggest you to add the path "/opt/local/lib" in the cxcore class for those who installed opencv via Macports (that's the default installation directory) to avoid the first error discussed in this thread. ps. thanks for the great work I dont exactly understand how to change that path?
Excellent Find visionHead !
It looks as if Samuel has fixed it, I assume in his latest release...
I'm guessing that if you download and replace the myrobotlab-0002/lib/javacv.jar it might work now?
If it does, I'm not sure why/how the path is hardcoded in javacv ? Samuel is an excellent developer, I would be very surprised if he has hardcoded paths... :P
I just realised that i was
I just realised that i was running the version 0001 of myrobotlab. Just downloaded the latest 0002 and now i cannot add OpenCV in services.
Time to synch up
I'm going to get the latest release from JavaCV and check to make sure it works on my system. So for you the OpenCV service will load in version 0001 but not 0002? Any error info?
This is odd. I tried to
This is odd. I tried to reinstall the macport for opencv, now i can suddenly use 0002 with OpenCV.. But no webcam view.
Oh and this time theres no error in the terminal!
Great...
I think we are getting closer visionHead..
previously I had builds/binaries for Linux & windows from opencv 2.1
I see a considerable amount of change between 2.1 and 2.2
Some of the differences besides actual code changes is the binary names...
previously opencv would produce shared libraries like libcv.so,
now they have shared objects like libopencv_core.so.2.2
Also, JavaCV has changed considerably - Samuel is now release many jars - some look like they distinguish between 32 and 64 bit...
I am now in the process of syncing up... starting with opencv builds - I have just successfully built the Linux versions of opencv 2.2 .. after that I will build the windows version... and after that I'll get the latest JavaCV verify that it works and bundle it all up...
I'm sure that this was some of the root cause of the problem as the MacPort installs 2.2 and MRL came with 2.1..
After I synch up Linux, windows & JavaCV, I'll notify you...
My preference is to have MRL run with a local copy of the binaries... this guarantees compatibility.. and if the command line is done correctly - the user can install any version of OpenCV on their system, which MRL will NOT be dependent on... So, when we get it working on your system can you send me the shared libraries you have from the MacPort so I can bundle those?
Regards,
GroG
Things make much more sense.
Things make much more sense. Ofcourse i can send the files to you! No problem..
I've done a massive update...
I've done a massive update... upgraded to opencv 2.2 and the latest javacv - corrected all the compiling issues
There are new downloads now
http://code.google.com/p/myrobotlab/downloads/list
you should only need myrobotlab-0003.zip
give it a try...
I just downloaded it, but
I just downloaded it, but what bothers me is that there is no reaction in the terminal anymore.. I get no error or anything.. But sadly, still no webcam view!
Smaller steps
Hello visionHead,
I believe we need to start with very small steps to see where the issue is.
I have compiled one of JavaCV's samples "MotionDetector" - Strangely, the other two samples "HoughLines and OpticalFlowTracker" do not work on my system.. I'll be investigating the details and possibly submitting bugs to Samuel Audet @ JavaCV
Please download the class file MotionDetector.class from http://code.google.com/p/myrobotlab/downloads/list
put it in the myrobotlab-0003/lib directory
You should be able to launch the MotionDetector through a terminal...
cd to the myrobotlab-0003/lib directory and run the following command:
java -classpath $CLASSPATH:javacpp.jar:javacv.jar:javacv-macosx-x86_64.jar -Djava.library.path=/<absolute location of the libopencv_*2.2.0.dylibs> MotionDetector
A Canvas Frame with hardware acceleration should come up, and your camera should turn on -
It will be black but when you move it should detect it. It "should" look like this when you move
If it does work YAY - 1 small step
If it does not work:
I will need any error information which comes back.
I downloaded the 0003 and the
I downloaded the 0003 and the MotionDetector.class file as described..
Unfortunately no positive result:
I tried following: java
I tried following:
java -classpath ":./javacv.jar" -Djava.library.path=/opt/local/lib MotionDetector
It gives med only:
Sadly im running out of time
Sadly im running out of time in my project. So im curious about the possibilities with importing an image into OpenCV in myrobotlab and just ignoring the camera function for while.
If image importing is not possible, then AVI-file import. If you have a guide i would appreciate it highly!
Thanks in advance.
Wow...
I did a opencv 2.2 build and loaded Samuel's javacv libs...
My Eclipse editor has lit up like a Christmas Tree with all the errors ... this will take a little time to correct..
Most of it looks pretty easy like, import path changes from jna to cpp and from .core to .opencv_core
I am currently developing
I am currently developing with OpenCV, so i assume its running hence it works :o)
binaries in
binaries in opencv/bin:
myrobotlab uses JavaCV
myrobotlab uses JavaCV to interface with the OpenCV binaries -
http://code.google.com/p/javacv/
Samuel states Java 6 SE is needed - the link he posted is here :
Java SE 6 for Mac OS X http://developer.apple.com/java/ etc.
Can you confirm you have Java SE 6 ?
Are you getting any output? Any errors?
When you say you have opencv working, in what context do you have it working? The sample .c examples which ship with OpenCV?
Regards,
GroG
java -version java
If you do get
Im not quite sure if i got this wrong, but did you mean that i should copy the files else where? If so, where should i place them?
Thanks in advance.
More info
That reply thread was getting squished, so I started another one....
java -classpath $CLASSPATH:javacpp.jar:javacv. jar:javacv-macosx-x86_64.jar -Djava.library.path=/opt/ local/lib MotionDetector Exception in thread "main" java.lang. NoClassDefFoundError: MotionDetector Caused by: java.lang. ClassNotFoundException: MotionDetector at java.net.URLClassLoader$1.run( URLClassLoader.java:202) at java.security. AccessController.doPrivileged( Native Method) at java.net.URLClassLoader. findClass(URLClassLoader.java: 190) at java.lang.ClassLoader. loadClass(ClassLoader.java: 307) at sun.misc.Launcher$ AppClassLoader.loadClass( Launcher.java:301) at java.lang.ClassLoader. loadClass(ClassLoader.java: 248)
It looks as if it can't find the MotionDetector class - which can be caused by not getting the -classpath correct...
Event on a Linux machine I find the weird and slightly different notation of the -classpath directive frustrating..
For example
works for me on Fedora 13
But,
Fixed the comments problem
I've started to install MacPorts, OpenCV and all the dependencies on my borrowed mac...
Have you tried downloading and installing JavaCV's samples? MotionDetector was one of them.
Have you tested your
Have you tested your application? :o)
I dont really use that, i use
I dont really use that, i use basic functions to track a object. My project is up running, but its a pain in the ass adjusting the HSV and testing filters, which is a great benefit using your application. Is there no way to import af AVI or IMAGE to the application instead of camera streaming?
I got it running !
I downloaded myrobotlab-0005.zip
I loaded OpenCV 2.2 from MacPorts
Ba-bing ! - http://myrobotlab.org/node/93
See if you get lucky with the latest (myrobotlab-0005.zip) - if not send me the log.txt
Good Luck.
It works now! But the frames
It works now! But the frames are EXTREMELY slow, i get this output in terminal.
Great progress!!
New observation. I connected
New observation. I connected my firewire cam it has no lagging problem!
I just realised its
I just realised its impossible using the gui on a 13" screen :o) Damn.
Have you tried the PyramidDown Filter?
You can load the pyramid down filter which will reduce the size of the frames.
When you load a filter it must be a unique name. But, you can load as meaning filters as you want. Meaning you can load PyramidDown twice with 2 unique names, and your image size will be 1/4 the original.
That helped alot. Now i have
That helped alot. Now i have a mysterious question! Why does the InRange act different in the myrobotlab gui compared to InRange directly in my OpenCV project? I cant seem to take the HSV values directly from the simulation in my myrobotlab and use them in the project?! :-/
I have not seen you project,
I have not seen you project, So its hard for me to say...
This is a link to the inRange filter I created for mrl.
You can quickly find who/which is reporting correctly by taking some samples of colors and plot what values they should have.