File sharing between android and opencv - android

I am trying to invoke opencv library from my android code.
I previously stored my haar xml under the /data/data/org.siprop.opencv/files/ directory and passed this file path (i.e. /data/data/org.siprop.opencv/files/haarcascade_frontalface_alt.xml) to the opencv library. This xml was successfully read by the opencv code.
But I noticed that these xml files were not packaged in the .apk file which meant I would have a problem when distributing the same.
I hence tried storing these haar xmls in the assets/files folder. Now the files were included in the .apk file but i could not locate this in the emulator via the DDMS file explorer. So not sure what file path can I pass back to the opencv library.
Can you please let me know where am i going wrong?

Related

Android how to extract *.so file during execution

I have one android myLibrary.jar file. But myLibrary.jar file will load the native 3 different so file. I have a.so, b.so and c.so.
When i using in my own application, it just simply put the jar file to the Android Dependencies and all 3 so files put in the libs/armeabi of the main application package.
When deploy and install on the device, these so file will be in the data/data/my-appname/lib/*.so.
Now i need to provide the sdk solution. The user side doesn't want the main application. They just want the myLibrary.jar. So i am considering about packing all 3 *.so files to the jar. I searched for the how to add to the so files to myLibrary.jar. But i still don't understand.
In this following post:
[Ant]How to add .so file into a jar and use it within jar(set the java.library.path)?
It mentioned about adding the so file to the jar and extract at runtime. But i still don't understand how to achieve that.
After trying that mentioned in the following post:
Creating a product SDK: How do I add a native lib (.so) and a jar with the SDK I am creating?
After my sample application reference the the compiled jar that included the .so file. After installing to the device, the libs/armeabi/xxx is not unpacked on the install. So i would like to know how to extract them dynamically and save them to data/data/my-appname/lib/ so that i can use with System.loadlibary(.so).
Thanks a lot.

How can we know which .so file a particular cpp file is in? (in Android rom)

I found some modified code in a cpp file in android to protect smartphone from stagefright vulnerability.
I want to change it with original cpp file and rebuild to a new android ROM file.
The problem is,
I downloaded an android factory image from google developer forum and
I unpacked it with android kitchen tool.
Now I can see its contents but I couldnt find the file, I wanted to modify, "/media/libstagefright/MPEGExtractor.cpp".
There are only some .so files in system/lib/ folders.
I heard it's almost impossible to decompile those .so files.
I tried googling to find out which .so files have "MPEGExtractor.cpp", so that I would be able to compile some files including that cpp file into a .so file, and change it, and rebuild it a new ROM.. but I couldn't find out.
What should I do to rebuild it with some code to be changed?
Thank you for reading
SO(Shared Object) are files that are compiled from source. By definition they do not contain the symbol information you are asking for.

Using resource files in NDK

I have an NDK library that I am creating that needs to contain and access a binary data file (.dat extension). I am having trouble getting the compiled library to see this file. To make things a little more difficult, I am doing this within a library package.
I think it would work if, during my Android.mk file, I copy this .dat file to my app's resources folder, and then access that from within the app, but I feel like there must be a better way.
Any suggestions?
Instead of resources, put it in the assets folder; NDK provides API to access assets from native code.
Often, we unpack some "files" from the resources or assets to the file system (e.g. /sdcard) on the first run of the app after install. This approach works best when the files must be used by external apps and libs (e.g. to play sounds), or when these files will be changing.
Finally, you can link the data into your .so during ndk-build. This will resolve the question how the .dat file will be copied into the app folder, but reading it may be tricky, and modifying - impossible. You don't need to create a huge library. You can create a mock-up library that contains the data. If I understand correctly, you can ignore the file structure, headers, etc. You only need a file named lib something .so in your libs/armeabi (or other) folder.

How to add a file path for a file input stream in eclipse

I am using eclipse with the android adt. I am trying to initialize a file input stream, the file is in the workspace folder in the folder of my project. Now I have no idea what eclipse assumes to be the root of the project. I keep getting the file not found exception. I put the file in the src folder also and then in the src/com/.... in the folder with all the activity java files but in vain. I also tried giving the absolute path but i get an error:
/C:/Users/hp/Desktop/events.ics: open failed
I read similar questions but somehow, its not working. Any help is deeply appreciated.
I am trying to initialize a file input stream, the file is in the workspace folder in the folder of my project.
Your development machine is not an Android device. Hence, the file is not going to be in the filesystem of an Android device.
If you wish to package files with your app, you can do so as an asset or as a raw resource. You can read more about the assets/ and res/raw/ project directories in the documentation.

Read txt file in res/raw/ within Android NDK

I have a file within my application that I want to have included within the .apk for my android app that is a .txt file. My application is almost entirely written in C through the use of the NDK, using OpenGL as well. I know I can bundle the txt file by placing it in /res/raw/, but is there anyway I can access this within the android NDK?
-Thanks
See the native-audio sample in the NDK. This has code that reads from the assets folder.

Categories

Resources