opencv cmake files, how to use them in iOS - ios

These stuff stuck me another 3 days to figure out.
I'm implementing opencv and I need to use xfeatures2d module in objc xcode. I previously downloaded the opencv.framework and successfully imported it in my iOS project and it works. But there is no xfeatures2d in it. So then I finally figured out that it is an extra module and it is in a package call opencv_contrib.
To make use of it, it seems like people recommend to use cmake to build the source code of opencv-master with opencv-contrib-master
I did it, and it looks build correctly. And I got lots of funky things in my folder. However, it seems like nothing I can use to #import to my .xcodeproj project. (Sorry I can't embed my screenshot yet.)
So did I do something wrong? Or,is it the correct way to build the file I need??
Please help, Thanks!

Finally I found a solution. #thachnb 's solution is referred from here. This instruction guide you to generate an opencv2.framework in use of your iOS project from the opencv-master package. If you want to use the modules in opencv_contrib, you need to physically copy the module from opencv_contrib(in my case is xfeatures2d, or you can just copy everything over), to opencv-master/module, and then use
python opencv/platforms/ios/build_framework.py ios
command to compile it. After this compilation, you will have a opencv2.framework containing everything you need. This also helps.
Thanks #thachnb !

Q1. Did you run below command?
python opencv/platforms/ios/build_framework.py ios
if yes, move to question 2
Q2. Did you see opencv.framework in ios subfolder?
if yes, move to question 3
Q3. Did you add that opencv.framework folder to your xcode project? or drag and drop it to Framework folder of your xcode project?

Related

How to properly add missing libraries and frameworks to existing Xcode project

in the past I have developed some simple iOS apps and today I saw that "phyphox", an app I would like to customize, is open source. So I downloaded the project, however it relies on some third-party libraries. Picture of the error message. I tried to compile these libraries and added the .framework files to the framework folder of the Xcode project, but the error messages wouldn't go away. What am I doing wrong?
Thanks for your help!
It sounds like you need to create a podfile to download everything properly. this video explains it really well! I've never done it the .framework way before, but I believe that podfiles will solve your problem because it's installed through your terminal and becomes a large piece of your project. I hope this helps! :)

How to add unity project in a currently existing ios project?

I have searched a lot about this. But all the answers suggest that, it is possible to add new files into unity(xcode) project but vice versa is not possible. Actually, my target is to create sdk which will be used in a cordova plugin. What should I do?
To create an iOS sdk for unity you can create a library project in xCode and import the build to unity's Assets/Plugins/iOS folder. everything in here will automatically get included in xCode project generated by Unity.
And yes, it's very hard to include unity build in your own xcode project. There have been people begging for enlightenment to integrate Unity in another app but every time the threads are stranded beyond hope. Gibberish-gibberish... It's not possible.
It's extremely frustrating but it is possible. It requires a lot of changes to the build settings and compiler settings as well as customizing the launch of Unity components.
Best place to start is to import the Classes, Libraries, and Data folders (if applicable). Data as a folder reference and not a group. I'm also assuming your Unity project output is similar to what I've been given. We've modified our main.m file to be a C++ file (main.mm) and added in the Unity initialization code. We also updated the UnityAppController.mm file to not run startUnity on launch.
If this is still something you're working on please feel free to contact me on Twitter (#Ruprect) and I can help troubleshoot.
In this repo: https://github.com/jiulongw/swift-unity you can find how to integrate Unity Project into Xcode Swift Project.

How to integrate Unity inside native iOS App?

I'm having troubles integrating a simple Unity project inside a native iOS App.
I followed this this tutorial but I think that some things have changed since it was written. I'm stuck with this error:
And thats not the only one, there are 1600 files that include include that file. The problem is that all this 1600 files have a wrong reference to il2cpp-codegen.h
This are my build settings for the Unity project:
So, after following all the tutorial, should I change all the files so that all the references would be correct? Or am I missing something else?
Thanks!
Joel
EDIT
I'm currently using Unity 5.1.1f1 Personal version.
Do you have a warning saying folder not found or something like it?
I think you didn't set the path for Libraries/libil2cpp/include in your header search paths.
You probably didn't copy the Libraries/libil2cpp folder.
That folder isn't visible inside the Xcode project but you can find it in Finder. You should try and copy that folder also and maybe add it to the Build Phases in Xcode. Not sure about this last step.

FMDatabase.h not found when using route-me library

So im trying to use the route-me widget in my app, but xcode keeps complaining that it cant find FMDatabase.h, yet its included in the project (albeit under a different project that is included into my project). I've copied how a sample app has been made yet the sample project doesnt get this error. The RMDBMapSource.h file is contained within the MapView project, so i shouldn't need to include the fmdb stuff myself (and because the sample project doesn't do that)
Surely if the files are under compile sources / copy headers under build phases, that means it should be able to find the file? This is a pretty lackluster explanation of my problem, but if anyone has used the route-me library before maybe they have had the same problem and can point me in the right direction
Resolved my own mistake. First off in the build settings of the main project, the 'search for header paths' was not set correctly, it was set to /MapView/ instead of /MapView/** that resolved the FMDatabase.h missing error.
Then in case someone else had a linker error like i did after i resolved the first issue, make sure you have libMapView.a included in your link binary with libraries section. (i had it their before, but during a version control commit, somehow our project file decided to not add that library anymore and i had totally forgotten about it, so took me quite a while to find out that it was missing)

Setting up Bullet Physics for iOS in XCode 4

So, I have downloaded the latest Bullet Physics package (2.78) and I have read the "Getting Started" documentation, which even includes an article on setting up a project in XCode from scratch (but not targeted at iOS nor XCode 4, which is what I'm using). Even so, I am still not able to set this up.
The following are the steps I'm currently taking:
I'm adding the Bullet Physics "src"
folder in the classes of the Xcode
I'm including the Bullet Physics
"src" folder path in the debug and
release "Header Search Paths" in
XCode
I add #include
"btBulletDynamicsCommon.h" to the
file where I want to use Bullet
Physics
I change the Objective-C file to
Objective-C++ by changing its file
extension from "m" to "mm". This is
the file where the
"btBulletDynamicsCommon.h" is
included
After I follow these steps, the compiler complaints about missing files (first few errors, there are 999+ errors shown when I try to build).
These are the first few headers missing in the btSoftBodySolverVertexBuffer_DX11.h:
#include <windows.h>
#include <crtdbg.h>
#include <d3d11.h>
#include <d3dx11.h>
#include <d3dcompiler.h>
Now, I'm pretty new with XCode and iOS, so the fact that these are missing doesn't really tell me much on how to solve this issue, and it makes me even wonder if they are at all needed for iOS development given the appended "DX11" on the file name that is having this issue.
So, what I would appreciate is either information on what's possibly wrong, or information on how to set up Bullet Physics to be used with iOS in XCode 4, from scratch.
Thanks.
Update: I have completely removed the DX11 and OpenCL and I'm now able to compile after step 4 above. I have not yet actually tested the Bullet Physics framework to see if it works without issues. But this now leads me to ask:
What are the specific source files/folders that are strictly necessary to run Bullet Physics in iOS?
There is a tutorial with step by step instruction for integrating Bullet Physics with iOS and Apple's GLKit framework http://www.informit.com/articles/article.aspx?p=1914612
The example code downloadable with the tutorial will get you started quickly and produces an interesting simulation.
How to insert Bullet Physics into iOS: iOS OpenGL BulletPhysics Sample Code
Download the sample code or follow on a new project form Xcode with iOS openGL template:
Download bullet physics... put it into a folder like the following:
*(notice that there is a folder for the project that contains the Xcode project file)
/MyProjectFolder/bullet-2.78/
/MyProjectFolder/MyProject/MyProject.xcproj
1.5. Run CMake in the physics directory to compile the frameworks (assuming you installed cmake already CMake) This step is optional with the sample code I uploaded since it already included the compiled frameworks in it....that made the file 100 megs but what is 100 megs these days anyway?
cmake . -G "Unix Makefiles" -DINSTALL_LIBS=ON -DBUILD_SHARED_LIBS=ON -DFRAMEWORK=ON -DCMAKE_OSX_ARCHITECTURES='i386;x86_64' -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=/Library/Frameworks -DCMAKE_INSTALL_NAME_DIR=/Library/Frameworks -DBUILD_DEMOS:BOOL=OFF
make -j4
sudo make install
Goto your MyProject.xcproj and open in Xcode...
in XCode goto any file you wish to add the physics code to... you must understand that cpp files are c++ and .m .h files are generally cocoa. You must change the Class you wish to add the physics engine code to have a .mm extension signifying it should be compiled as Objective-C++ code...
In the particular class you want to add the physics which is now an Objective-C++ file or a cpp file, add the line
#include "btBulletDynamicsCommon.h"
and you should compile...the error is that the file is not found...
Next goto the MyProjectFolder/bullet-2.78/src and drag the src folder into your project.
Delete the folder named BulletMultiThread...it will eliminate the error of trying to compile some openCL (.cl) files
Last step, copy the following frameworks from the src folder of your bullet physics installation into your project:
/MyProjectFolder/bullet-2.78/LinearMath/LinearMath.framework
/MyProjectFolder/bullet-2.78/BulletCollision/BulletCollision.framework
/MyProjectFolder/bullet-2.78/LinearMath/LinearMath.framework
Build and Run... should compile smoothly to iOS and Mac now...
i found Orbitus007's answer a little miss leading. You can just add the bullet physics frameworks to the project instead of adding the whole src folder to your project. adding the src folder gave me errors and just adding the frameworks made my project compile
should look something like this http://imgur.com/CINtb
you can then just go
#import "BulletDynamics/btBulletDynamicsCommon.h"
you will still need to have your file with the .mm extension
also, i found that i got an error when trying to use cmake saying something about xcode-select. if you get it try run this command in the terminal, then try again
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
but other than that, his answer helped me get it working
OK, so as an update and to answer my own question:
I ended up deleting the folders DX11 and OpenCL and their content. This has so far allowed me to run a few Hello World tests.
I still welcome more assertive answers, given it seems strange to me that I can't find any documentation covering this for iOS usage.

Resources