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

How to integrate vuforia 4-2-3 #60

Open
nguyenhoc89 opened this issue Jun 18, 2015 · 28 comments
Open

How to integrate vuforia 4-2-3 #60

nguyenhoc89 opened this issue Jun 18, 2015 · 28 comments

Comments

@nguyenhoc89
Copy link

Now, the latest version of vuforia is 4-2-3.
Can I upgrade project by override Vuforia.jar and libVufoia.so in libs and src/main/libs folder

@amol-furlenco
Copy link

I tried this but it did not work. Is there any plan to update this library to support v4 and v5 ?

@kopihao
Copy link

kopihao commented Oct 3, 2015

can you share the code pin point 3d object on an object? :)

@Hema2
Copy link

Hema2 commented Dec 3, 2015

Is there any idea to update vuforia to 5?

@mmihhailov
Copy link

Yupp. Got it working (4,5 etc). Requires some tweaking in build scripts, native files and java files. Will not post commit here just yet, because each Vuforia version requires special rebuild, but if anyone is interested, I can create instructions and post them here or send personally over the e-mail.

@migmacdev
Copy link

@mmihhailov how do you make it work I'm interested in the instructions, thanks

@mmihhailov
Copy link

With newest Rajawali, my port is not valid anymore. The video background is flipped 180 degrees on Z axis. Working on the workaround.

@RandAmro
Copy link

RandAmro commented Mar 2, 2016

@mmihhailov please I need the instructions

@mmihhailov
Copy link

OK. Actually i did port the whole thing to Java as end result, but here are the instructions in general to use original C++ code.

First:

  1. Download the latest Android NDK and Vuforia SDK
  2. copy vuforia.jar to ./libs/ folder (replace the old one)
  3. copy libVuforia.so to ./libs folder (replace the old vuforia library)

Next:
Since API has changed, you need to make the following changes in jni/RajawaliVuforia.cpp:
change all occurencies of QCAR::ImageTracker to QCAR::ObjectTracker

Next:
Changes are needed in jni/Android.mk ((change the path to your local ones, these are in my computer)
LOCAL_SRC_FILES = C:/android/vuforia-sdk-android-5-0-10/build/lib/$(TARGET_ARCH_ABI)/libVuforia.so
LOCAL_EXPORT_C_INCLUDES := C:/android/vuforia-sdk-android-5-0-10/build/include

Next:
Changes to build.gradle for rajawalivuforia module:

add

defaultConfig{
    ndk{
        moduleName "rajawalivuforia"
    }
}

and

task buildNative(type:Exec, description: 'Compile JNI with NDK'){
    def ndkDir = 'C:/android/android-ndk-r10e'
    commandLine "$ndkDir/ndk-build.cmd",
            '-C', file('src/main/jni').absolutePath,
            '-j', Runtime.runtime.availableProcessors(),
            'all'
}

task cleanNative(type:Exec, description: 'Compile JNI with NDK'){
    def ndkDir = 'C:/android/android-ndk-r10e'
    commandLine "$ndkDir/ndk-build.cmd",
            '-C', file('src/main/jni').absolutePath,
            'clean'
}

Now you have buildNative task under 'other' menu in gradle scripts. When you run that, it should compile the native part of RajawaliVuforia. Or maybe not :) Worked for me, I sure hope I remember all the steps.

... Or if you ask nicely, I can send you the Java files, where I have ported the whole thing to Java and it seems to be working just nice :). Needs a bit tweaking, but it works. And it's all java, no tricky Java -> native -> back to Java magic.

This tweaking part is the reasoning not pushing the code back to github. A bit raw for sharing with wider audience.

@rexendy
Copy link

rexendy commented Mar 8, 2016

@mmihhailov : how to do it in osx 10.9.5?

@mmihhailov
Copy link

No idea. Never worked with osx. I guess you have to follow Google instructions, how to include and compile NDK stuff under osx with Android Studio. In essence, you need to compile newest .cpp with newest libVuforia.so:

  1. Modify .cpp code to work with new libVuforia.so
  2. Compile the native part with NDK
  3. Modify JNI layer in project to work with Rajawali native part
  4. Modify the java part to work with freshly compiled native part

Mainly reading the compiler error output nad fixing :)

@rexendy
Copy link

rexendy commented Mar 8, 2016

@mmihhailov : thank you but i've encountered this error:

no method with name='registerHalCamera' signature='(IIILjava/lang/String;[I[I)I' in class Lcom/qualcomm/ar/pl/CameraPreview;

JNI WARNING: JNI function FindClass called with exception pending

in Ljava/lang/Runtime;.nativeLoad:(Ljava/lang/String;Ljava/lang/ClassLoader;Ljava/lang/String;)Ljava/lang/String; (FindClass)

@mmihhailov
Copy link

did you update vuforia.jar also in ./app/libs folder to match your libVuforia.so ?

@rexendy
Copy link

rexendy commented Mar 8, 2016

yes I've updated it in rajawalivuforia/libs and all the libVuforia.so files

@mmihhailov
Copy link

seems that you still have .jar and .so mismatch here. What happens here is that it tries to load 'registerHalCamera' from .so with the wrong signature via .jar.

You need to verify the paths:
./rajawalivuforia/libs/Vuforia.jar
./rajawalivuforia/libs/armeabi-v7a/libVuforia.so

@rexendy
Copy link

rexendy commented Mar 8, 2016

yes i already changed that and also the .so files in these paths:

./rajawalivuforia/src/main/libs/armeabi-v7a
./rajawalivuforia/src/main/obj/local/armeabi-v7a

@MasDennis
Copy link
Member

Sorry that you have to go through all this trouble to update to the latest Vuforia! I'll have a look at this myself when I find the time. Its been a while since the Vuforia version was updated.

@rexendy
Copy link

rexendy commented Mar 8, 2016

okay, Im currently using sdk vuforia 5-0-10

@mmihhailov
Copy link

Well, in this case it would be feasible to port it all to Java. Did it for test purposes and seems to work just fine.

Took the 'hammer' approach: Created class RajawaliVuforiaManager and ported all native code to Java to this class and then used this static class from RajawaliVuforiaRenderer and RajawaliVuforiaActivity.

Haven't found the time to get rid of the RajawaliVuforiaActivity yet :) But this is next in my task list.

@RandAmro
Copy link

RandAmro commented Mar 8, 2016

@mmihhailov hello again! thank you a lot for your help.
I do follow all your instructions but when I try to build it in the final step I found this error :

Error:(152, 21) error: method setInitParameters in class QCAR cannot be applied to given types;
required: Activity,int,String
found: RajawaliVuforiaActivity,int
reason: actual and formal argument lists differ in length

And there is no buildNative task under 'other' menu in gradle scripts actually there is no other menu in gradle scripts. can you please help me in that ?

And I will be so grateful if you send me the java files! Thank you again.

@rexendy
Copy link

rexendy commented Mar 8, 2016

@mmihhailov thank you again. I would like to look at your java files also. I will be grateful if you could send me those. thank you!

@mmihhailov
Copy link

Will take a look, change few things. Currently performance is quite poor on weaker devices, like Samsung GT-I9100. Skips at least 3rd of frames. I suspect it has something to do with the fact that both, Vuforia and Rajawali try to use OpenGL at the same time and there is some kind of race condition. Also I suspect that the surface (video coming from camera) is rendered twice: first by Vuforia and then again by Rajawali, using each frame as texture on ScreenQuad.

@RandAmro
Copy link

RandAmro commented Mar 8, 2016

@mmihhailov what about the error I had ? Do you know any solution for that ?

@mmihhailov
Copy link

@RandAmro There are few things that you need to do also in Java code. Vuforia API has changed a lot since 3.. For example, all QCAR. has changed to Vuforia.*.

If you take a look at the Java reference at developer.vuforia.com, you see that setInitParameters() signature has changed. Now it also requires the vuforia license key to be given as parameter. You can retrieve this when you register at developer.vuforia.com and ask in the License Manager section for a new key.

C'mon guys, you can figure out those simple things yourselves ;)

@rexendy
Copy link

rexendy commented Mar 13, 2016

@mmihhailov : how to handle this issue?

java.lang.UnsatisfiedLinkError: Native method not found: com.qualcomm.ar.pl.CameraPreview.newFrameAvailable:(IIII[BJ)V
at com.qualcomm.ar.pl.CameraPreview.newFrameAvailable(Native Method)
at com.qualcomm.ar.pl.CameraPreview.onPreviewFrame(CameraPreview.java:913)

@eracorpuz
Copy link

Hi @mmihhailov thank you for the brief explanation. But I don't quiet understand where to put this script:

task buildNative(type:Exec, description: 'Compile JNI with NDK'){
def ndkDir = 'F:\Android[COBA2]\RajawaliVuforia-master\vuforia-sdk-android-5-5-9'
commandLine "$ndkDir/ndk-build.cmd",
'-C', file('src/main/jni').absolutePath,
'-j', Runtime.runtime.availableProcessors(),
'all'
}

task cleanNative(type:Exec, description: 'Compile JNI with NDK'){
def ndkDir = 'F:\Android[COBA2]\RajawaliVuforia-master\vuforia-sdk-android-5-5-9'
commandLine "$ndkDir/ndk-build.cmd",
'-C', file('src/main/jni').absolutePath,
'clean'
}

under 'other' menu in gradle scripts? in the build.gradle for rajawalivuforia module?
is it inside the android blocks?

Sorry for the dummy question. Thank you

@aalices
Copy link

aalices commented Nov 22, 2016

Has anyone fully succeeded in the integration? I think I have done what @mmihhailov was telling to do by my own, anyway I had some problems with background rendering, now it is okay but the model is floating around the target. It is not situated in the center but when I move the device, the model also moves more than it should. Are there any changes needed in calculating projectionMatrix or something else?

@shadracktaeli
Copy link

@mmihhailov thanks for instructions. Can you please send the java file, having a problem with native methods

@ushang000
Copy link

@mmihhailov thanks for you help, use latest Vuforia SDK generate libRajawaliVuforia.so file . but when i run rajawalivuforiaexample get error log as below:
com.example.rajawalivuforiaexample I/Rajawali: Native library libVuforia.so loaded
com.example.rajawalivuforiaexample E/Rajawali: The library libRajawaliVuforia.so could not be loaded
com.example.rajawalivuforiaexample E/art: No implementation found for void org.rajawali3d.vuforia.RajawaliVuforiaActivity.setActivityPortraitMode(boolean) (tried Java_org_rajawali3d_vuforia_RajawaliVuforiaActivity_setActivityPortraitMode and Java_org_rajawali3d_vuforia_RajawaliVuforiaActivity_setActivityPortraitMode__Z)
i don't know the reason,can you disabuse for me or send cpp file and java file to me .
very grateful !

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