ChitraPathak / javacv

Automatically exported from code.google.com/p/javacv
GNU General Public License v2.0
0 stars 0 forks source link

Problème with architecture (32 or 64 bits) #20

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Create new project in Eclipse for example
2. Paste the sample code Test2
3. Run

If I compile OpenCV in 32 bits
- compiling the c examples works, and they work properly
- your code example fails with the output :
Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load 
library 'cxcore': dlopen(/usr/local/lib/libcxcore.dylib, 9): no suitable image 
found.  Did find:
    /usr/local/lib/libcxcore.dylib: mach-o, but wrong architecture
    /usr/local/lib/libcxcore.dylib: mach-o, but wrong architecture
    at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:163)
    at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:236)
    at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:199)
    at name.audet.samuel.javacv.jna.Loader.load(Loader.java:44)
    at name.audet.samuel.javacv.jna.cxcore.<clinit>(cxcore.java:115)
    at name.audet.samuel.javacv.JavaCvErrorCallback.redirectError(JavaCvErrorCallback.java:95)
    at com.Test.main(Test.java:14)

If I compile OpenCV in 64 bits
- compiling the c examples fails with the output :
compiling camshiftdemo.c
ld warning: in /usr/local/lib/libml.dylib, file is not of required architecture
ld warning: in /usr/local/lib/libcvaux.dylib, file is not of required 
architecture
- compiling your code example fails with the output :
Exception in thread "main" java.lang.Exception: cvRetrieveFrame() Error: Could 
not retrieve frame.
    at name.audet.samuel.javacv.OpenCVFrameGrabber.grab(OpenCVFrameGrabber.java:149)
    at com.Test.main(Test.java:33)

What version of the product are you using? On what operating system?
Mac Os X 1.5, on Macbook bought in 2009 (so 64 bits)

Original issue reported on code.google.com by matth...@mnapoli.fr on 14 Sep 2010 at 3:40

GoogleCodeExporter commented 9 years ago
I forgot the OpenCV version : 2.1.0 (official version, NOT from SVN)

For Java I use Eclipse JDT (downloaded yesterday)
To compile the OpenCV examples, there is a script "build_all.sh" that does the 
job.

Original comment by matth...@mnapoli.fr on 14 Sep 2010 at 3:42

GoogleCodeExporter commented 9 years ago
Last detail (sorry, can't find how to edit the issue), I noticed that the 
Webcam light would turn on in the "64 bits" scenario, when lauching your test 
class. I think it is close to working, but I can't understand why OpenCV 
examples won't work (and why I have this error).

Note that I have no special webcam, just the one above the screen in the 
macbook.

I also didn't install any of the "optionnal" librairies :
    * libdc1394 2.1.2 (Linux and Mac OS X) http://sourceforge.net/projects/libdc1394/files/
    * PGR FlyCapture 1 or 2 (Windows only) http://www.ptgrey.com/products/pgrflycapture/
    * ARToolKitPlus 2.1.1c http://code.google.com/p/javacv/downloads/list
    * FFmpeg-Java http://code.google.com/p/javacv/downloads/list
    * which needs FFmpeg 0.6 or more recent:
          o Source code http://ffmpeg.org/download.html
          o Precompiled Windows DLLs http://ffmpeg.arrozcru.org/autobuilds/ 

Original comment by matth...@mnapoli.fr on 14 Sep 2010 at 3:45

GoogleCodeExporter commented 9 years ago
If your camera does not work with OpenCV, then it does not work with OpenCV.. 
Can you confirm it doesn't outside of JavaCV as well?

Original comment by samuel.a...@gmail.com on 14 Sep 2010 at 5:11

GoogleCodeExporter commented 9 years ago
Hi,

I have a PGR Dragon fly 2, The camera is fully functional as can be demostrated 
by using flycap 1.8 and 2.0

When selecting any of the frame grabbers even the PGRFrameCapture, the 
following error is given. (this error is when PGRFrameCapture is selected)

Sep 14, 2010 8:44:45 PM name.audet.samuel.procamcalib.CalibrationWorker 
doInBackground
SEVERE: Could not perform calibration
java.lang.UnsatisfiedLinkError: Unable to load library 'FlyCapture2': The 
specified module could not be found.

        at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:164)
        at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:237)
        at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:200)
        at name.audet.samuel.javacv.jna.Loader.load(Loader.java:44)
        at name.audet.samuel.javacv.jna.PGRFlyCapture.<clinit>(PGRFlyCapture.java:83)
        at name.audet.samuel.javacv.FlyCaptureFrameGrabber.tryLoad(FlyCaptureFrameGrabber.java:78)
        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 name.audet.samuel.javacv.FrameGrabber.init(FrameGrabber.java:47)
        at name.audet.samuel.procamcalib.MainFrame.main(MainFrame.java:1271)

Is seems that there is a unexplained link error when getting the library. I 
also add the specific path that point directly to the files in the folder. The 
files are there but it still gives the error. Do you know of any possible 
causes or possible solutions. 

Kind Regards,
A.

Original comment by andre01...@gmail.com on 14 Sep 2010 at 6:49

GoogleCodeExporter commented 9 years ago
Ps. I have all 32-bit software now.

Original comment by andre01...@gmail.com on 14 Sep 2010 at 6:49

GoogleCodeExporter commented 9 years ago
@samuel : No no no I wrote : "compiling the c examples works, and they work 
properly"
So OpenCV works with my webcam, wich is the one included in my macbook BTW.

So no problem on this side I guess.

Original comment by matth...@mnapoli.fr on 14 Sep 2010 at 8:03

GoogleCodeExporter commented 9 years ago
Have you tried to recompile without SSE instructions? In both 32-bit and 
64-bit? Some have also reported that their cameras worked in the "client" 
version of the JVM, but not the "server" one.. In any case, it's either the SSE 
problem, or it's something that Java does that your hardware does not like, and 
hardware may like better the "client" one..  But it's not a problem with JavaCV 
itself.. 

Original comment by samuel.a...@gmail.com on 15 Sep 2010 at 2:29

GoogleCodeExporter commented 9 years ago
And andre, it looks like you are trying to load 32-bit FlyCapture inside 64-bit 
Java or vice versa. Get everything in either 32-bit or everything in either 
64-bit. You cannot mix both

Original comment by samuel.a...@gmail.com on 15 Sep 2010 at 2:32

GoogleCodeExporter commented 9 years ago
Yes I compile OpenCV without SSE instructions in all cases.
Ok so maybe it is related this the "client/server" version problem. Do you know 
how I can know wich version I have ?

But why would the OpenCV example work then...

Original comment by matth...@mnapoli.fr on 15 Sep 2010 at 2:58

GoogleCodeExporter commented 9 years ago
Then do not compile with SSE instructions.

http://www.oracle.com/technetwork/java/hotspotfaq-138619.html#compiler_types

Because the compiler that they used to compile Java is not the same compiler 
that you used to compile OpenCV

Original comment by samuel.a...@gmail.com on 15 Sep 2010 at 3:10

GoogleCodeExporter commented 9 years ago
"Then do not compile with SSE instructions." > you mean OpenCV, Java or my 
program ?

Original comment by matth...@mnapoli.fr on 15 Sep 2010 at 3:15

GoogleCodeExporter commented 9 years ago
Thank you again... I just reinstalled everything and now it works, kind of.

The entire calibration runs and then when it is completed the following error 
occurs.

SEVERE: Could not perform calibration
java.lang.Exception: flycaptureConvertImage() Error 2
at 
name.samual.javacv.FlyCaptureFrameGrabber.grab(FlyCaptureFrameGrabber.java:411)

Kind regards,
A.

Original comment by andre01...@gmail.com on 15 Sep 2010 at 5:35

GoogleCodeExporter commented 9 years ago
Matthieu, I don't know what works or not on a Mac, I don't use one

Original comment by samuel.a...@gmail.com on 16 Sep 2010 at 12:57

GoogleCodeExporter commented 9 years ago
BTW, please post on the mailing list to see if anyone figured out how to make 
camera capture work under Java for Mac OS X.. There might be other people using 
Java to capture from a camera on a Mac, but I am not one of them, and no one 
else other than you and me receives messages posted here 

Original comment by samuel.a...@gmail.com on 25 Sep 2010 at 3:28

GoogleCodeExporter commented 9 years ago
Hi, I have a similar problem on Mac Os X version 10.5.8.

I programmed under Eclipse the following simple example as given in the project 
description page:

import static name.audet.samuel.javacv.jna.cxcore.*;
import static name.audet.samuel.javacv.jna.cv.*;
import static name.audet.samuel.javacv.jna.highgui.*;
import static name.audet.samuel.javacv.jna.cvaux.*;

public class Test {
    public static void main(String[] args) {
        IplImage image = cvLoadImage("test.png", 1);
        if (image == null) {
            System.err.println("Could not load image file.");
        } else {
            cvSmooth(image, image, CV_GAUSSIAN, 3, 0, 0, 0);
            // ...
        }
    }
}

I compiles fine, but when I try to run it, I get the following error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: Unable to load 
library 'cxcore': dlopen(/usr/local/lib/libcxcore.dylib, 9): no suitable image 
found.  Did find:
    /usr/local/lib/libcxcore.dylib: mach-o, but wrong architecture
    /usr/local/lib/libcxcore.dylib: mach-o, but wrong architecture
    at com.sun.jna.NativeLibrary.loadLibrary(NativeLibrary.java:163)
    at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:236)
    at com.sun.jna.NativeLibrary.getInstance(NativeLibrary.java:199)
    at name.audet.samuel.javacv.jna.Loader.load(Loader.java:44)
    at name.audet.samuel.javacv.jna.cxcore.<clinit>(cxcore.java:115)
    at name.audet.samuel.javacv.jna.highgui.<clinit>(highgui.java:73)
    at Test.main(Test.java:8)

To install OpenCV, I did as stated in the documentation:

   1. tar -xjf OpenCV-2.1.0.tar.bz2
   2. mkdir opencv.build
   3. cd opencv.build
   4. cmake [<extra_options>] ../OpenCV-2.1.0 # CMake-way
   5. make -j 2
   6. sudo make install

Everything seems to work fine during all these steps.

Maybe I need an extra option for the cmake. I tried:

cmake -D CMAKE_OSX_ARCHITECTURES=i386 -D CXX_FLAGS=-m32 -D CMAKE_C=-m32 
../OpenCV-2.1.0

But it does not seem to change anything to the way the library is compiled.

Any help would be greatly appreciated.

Thanks,
/Renaud

Original comment by Renaud.P...@gmail.com on 26 Oct 2010 at 11:42

GoogleCodeExporter commented 9 years ago
I do not use Mac OS X, but my guess is you are trying to use a 32-bit compiled 
version of OpenCV with a 64-bit JVM, or vice versa. Everything has to be either 
32 bits *or* 64 bits, you CANNOT mix them.

Anyway, you should post your question in the discussion group. In theory, I am 
the only one reading what you write here.

Original comment by samuel.a...@gmail.com on 27 Oct 2010 at 7:04