Openmvg: How to get OpenMVG build for iOS

Created on 27 Apr 2018  Â·  25Comments  Â·  Source: openMVG/openMVG

Hello everyone,

I need to build OpenMVG for iOS. Any suggestions on how to do it? Thanks a lot!

All 25 comments

You should be able to configure the ARM target under XCode.
https://github.com/openMVG/openMVG/issues/2#issuecomment-22314687

Tip: Since only libraries will be valid for iOS you can enable to build only the libraries and not the binaries by using the -DOpenMVG_BUILD_SOFTWARES=OFF in the cmake command line.
So you configure your build for a generic architecture -DTARGET_ARCHITECTURE=generic and then you configure the ARM target on XCode.

I already saw custom apps using OpenMVG to run SfM on iPhone so you there is not reason you cannot make it ;-)

Hi Pierre,

Thanks a lot for your help and information!

I tried to follow your instructions. But when I run:

cmake -DCMAKE_BUILD_TYPE=RELEASE -DOpenMVG_BUILD_TESTS=ON
-DOpenMVG_BUILD_EXAMPLES=ON -DOpenMVG_BUILD_SOFTWARES=OFF -fopenmp -G
"Xcode" . ../openMVG/src/

I get the error as below:

-- The C compiler identification is unknown

-- The CXX compiler identification is unknown

I don't understand why this happens as both are defined in my .profile file:

export CC=/usr/local/bin/gcc-7

export CXX=/usr/local/bin/c++-7

export CPP=/usr/local/bin/cpp-7

export LD=/usr/local/bin/gcc-7

export CPPFLAGS='-I/usr/local/include/c++/7.3.0'

export LDFLAGS='-L/usr/local/lib/'

Any ideas for why this happens?

Or is there anyway that I can change the architecture to arm directly in
cmake or cmakelist?

Many thanks,

Chen

On Fri, Apr 27, 2018 at 6:43 AM, Pierre Moulon notifications@github.com
wrote:

You should be able to configure the ARM target under XCode.

2 (comment)

https://github.com/openMVG/openMVG/issues/2#issuecomment-22314687

Tip: Since only libraries will be valid for iOS you can enable to build
only the libraries and not the binaries by using the
-DOpenMVG_BUILD_SOFTWARES=OFF in the cmake command line.
So you configure your build for a generic architecture
-OTARGET_ARCHITECTURE=generic and then you configure the ARM target on
XCode.

I already saw custom apps using OpenMVG to run SfM on iPhone so you there
is not reason you cannot make it ;-)

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/openMVG/openMVG/issues/1300#issuecomment-384870142,
or mute the thread
https://github.com/notifications/unsubscribe-auth/Ak3gd53cvFpPqLCcw9yCvxXzI2fZOw_Pks5tsrAMgaJpZM4TouEN
.

Hi Pierre,

Please find attached my current CMakeError.log etc files.

I have tried to use cmake-gui and specify the CMAKE_OSX_ARCHITECTURES to
$(ARCHS_UNIVERSAL_IPHONE_OS) then configure but got the same error as in
the attached files.

Many thanks,

Chen

On Fri, Apr 27, 2018 at 12:37 PM, chen davies chen.mao.davies@gmail.com
wrote:

Hi Pierre,

Thanks a lot for your help and information!

I tried to follow your instructions. But when I run:

cmake -DCMAKE_BUILD_TYPE=RELEASE -DOpenMVG_BUILD_TESTS=ON
-DOpenMVG_BUILD_EXAMPLES=ON -DOpenMVG_BUILD_SOFTWARES=OFF -fopenmp -G
"Xcode" . ../openMVG/src/

I get the error as below:

-- The C compiler identification is unknown

-- The CXX compiler identification is unknown

I don't understand why this happens as both are defined in my .profile
file:

export CC=/usr/local/bin/gcc-7

export CXX=/usr/local/bin/c++-7

export CPP=/usr/local/bin/cpp-7

export LD=/usr/local/bin/gcc-7

export CPPFLAGS='-I/usr/local/include/c++/7.3.0'

export LDFLAGS='-L/usr/local/lib/'

Any ideas for why this happens?

Or is there anyway that I can change the architecture to arm directly in
cmake or cmakelist?

Many thanks,

Chen

On Fri, Apr 27, 2018 at 6:43 AM, Pierre Moulon notifications@github.com
wrote:

You should be able to configure the ARM target under XCode.

2 (comment)

https://github.com/openMVG/openMVG/issues/2#issuecomment-22314687

Tip: Since only libraries will be valid for iOS you can enable to build
only the libraries and not the binaries by using the
-DOpenMVG_BUILD_SOFTWARES=OFF in the cmake command line.
So you configure your build for a generic architecture
-OTARGET_ARCHITECTURE=generic and then you configure the ARM target on
XCode.

I already saw custom apps using OpenMVG to run SfM on iPhone so you there
is not reason you cannot make it ;-)

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/openMVG/openMVG/issues/1300#issuecomment-384870142,
or mute the thread
https://github.com/notifications/unsubscribe-auth/Ak3gd53cvFpPqLCcw9yCvxXzI2fZOw_Pks5tsrAMgaJpZM4TouEN
.

Hello,

Just wondering could anyone help me to identify why the configuration
issues mentioned above happen? Please also see the attached error logs. I
am using the latest development brach of openMVG.

I have been stuck on configuring and building openMVG for a while but
urgently need to use OpenMVG in my development project.

Many thanks and looking forward to your response!

On Fri, 27 Apr 2018 at 14:11, chen davies chen.mao.davies@gmail.com wrote:

Hi Pierre,

Please find attached my current CMakeError.log etc files.

I have tried to use cmake-gui and specify the CMAKE_OSX_ARCHITECTURES to
$(ARCHS_UNIVERSAL_IPHONE_OS) then configure but got the same error as in
the attached files.

Many thanks,

Chen

On Fri, Apr 27, 2018 at 12:37 PM, chen davies chen.mao.davies@gmail.com
wrote:

Hi Pierre,

Thanks a lot for your help and information!

I tried to follow your instructions. But when I run:

cmake -DCMAKE_BUILD_TYPE=RELEASE -DOpenMVG_BUILD_TESTS=ON
-DOpenMVG_BUILD_EXAMPLES=ON -DOpenMVG_BUILD_SOFTWARES=OFF -fopenmp -G
"Xcode" . ../openMVG/src/

I get the error as below:

-- The C compiler identification is unknown

-- The CXX compiler identification is unknown

I don't understand why this happens as both are defined in my .profile
file:

export CC=/usr/local/bin/gcc-7

export CXX=/usr/local/bin/c++-7

export CPP=/usr/local/bin/cpp-7

export LD=/usr/local/bin/gcc-7

export CPPFLAGS='-I/usr/local/include/c++/7.3.0'

export LDFLAGS='-L/usr/local/lib/'

Any ideas for why this happens?

Or is there anyway that I can change the architecture to arm directly in
cmake or cmakelist?

Many thanks,

Chen

On Fri, Apr 27, 2018 at 6:43 AM, Pierre Moulon notifications@github.com
wrote:

You should be able to configure the ARM target under XCode.

2 (comment)

https://github.com/openMVG/openMVG/issues/2#issuecomment-22314687

Tip: Since only libraries will be valid for iOS you can enable to build
only the libraries and not the binaries by using the
-DOpenMVG_BUILD_SOFTWARES=OFF in the cmake command line.
So you configure your build for a generic architecture
-OTARGET_ARCHITECTURE=generic and then you configure the ARM target on
XCode.

I already saw custom apps using OpenMVG to run SfM on iPhone so you
there is not reason you cannot make it ;-)

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/openMVG/openMVG/issues/1300#issuecomment-384870142,
or mute the thread
https://github.com/notifications/unsubscribe-auth/Ak3gd53cvFpPqLCcw9yCvxXzI2fZOw_Pks5tsrAMgaJpZM4TouEN
.

If you want to attach some files. Please use the online Github interface rather than the reply by email. You can just drag and drop your file in the text field.

Ok, will do. Thanks Pierre!

On Fri, May 4, 2018 at 7:34 PM, Pierre Moulon notifications@github.com
wrote:

If you want to attach some files. Please use the online Github interface
rather than the reply by email. You can just drag and drop your file in the
text field.

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/openMVG/openMVG/issues/1300#issuecomment-386694692,
or mute the thread
https://github.com/notifications/unsubscribe-auth/Ak3gd6JahbFnLVEl7WEQZppB39vEoTb-ks5tvJ9KgaJpZM4TouEN
.

@cmdavies did you solve this? If so, would you mind sharing how you solved it? If not, could you share with me the steps you took to get to this point? I would like to help and I am also trying to achieve what you are.

Hi Alberto,

No I didn’t manage to solve it still. Sure I will look into my notes and
put my current steps here shortly today. It will be great get some help to
get this sorted! Glad to hear that there are others who want to build and
use openMVG for iOS applications, we can discuss and help each other in the
future then!

On Tue, 29 May 2018 at 23:52, Alberto Taiuti notifications@github.com
wrote:

@cmdavies https://github.com/cmdavies did you solve this? If so, would
you mind sharing how you solved it? If not, could you share with me the
steps you took to get to this point? I would like to help and I am also
trying to achieve what you are.

—
You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
https://github.com/openMVG/openMVG/issues/1300#issuecomment-392973147,
or mute the thread
https://github.com/notifications/unsubscribe-auth/Ak3gd2csKL-OuEmacpEkhBW9tLLPDoYoks5t3dEegaJpZM4TouEN
.

@snowzurfer
Here are the steps I am using so far (Kindly suggested by Pierre and others):

$ git clone --recursive https://github.com/openMVG/openMVG.git -b develop

Comment out those lines for the iOS platform:
AutodetectHostArchitecture()
OptimizeForArchitecture()
https://github.com/openMVG/openMVG/blob/master/src/CMakeLists.txt#L111
https://github.com/openMVG/openMVG/blob/master/src/CMakeLists.txt#L112

$ mkdir build
$ cd build
$ cmake -DCMAKE_BUILD_TYPE=Release -GXcode . ../openMVG/src/

However, when I tried to command out the those lines as @pmoulon suggested and then try to use the same cmake command to configure again, but it was unsuccessful as it fails to generate the Xcode project file, cmake_install.cmake, and CMakeScripts.

I have asked for suggestions again in my other post:

https://github.com/openMVG/openMVG/issues/1296

Hope you could get some progress in figuring it out. Give me a shout if you'd like any more info or input from myself!

@snowzurfer how’s going with building the OpenMVG for iOS? Any progress or findings?

@cmdavies I haven't had time to look into it yet; hopefully next week I'll have more time to fix it

@snowzurfer
Sounds great, thanks! Please give me a shout if you need any more input.

@cmdavies will do, thanks. @pmoulon you mentioned that you know of apps which already do this; could you mention which ones and how you think they do it? I would imagine they re-wrote some parts in Metal to accelerate the algorithms and/or use some setting to increase performance while reducing quality.

Christopher made an iPhone app.
SCANN3D is using OpenMVG on Android. You can ask @donlk.
@Oliver001 made OpenMVG run for Android. See one PR.

Basically, you build OpenMVG libraries using arm as target. Then you build your app and use OpenMVG functions there.

@pmoulon @snowzurfer
@rperrot has suggested to configure by commenting the following line :

https://github.com/openMVG/openMVG/blob/master/src/CMakeLists.txt#L435

string(REPLACE " " ";" REPLACED_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})

It works and create the Xcode project file successfully. I will try to open the project file and change the architecture settings etc to see if I can build OpenMVG using Xcode. I will give you an update later today. Thanks a lot!

@snowzurfer Any progress in building OpenMVG for iOS? The solution that @rperrot has suggested helps to configure ok but it will fall at the build stage. Please see my updated comments in

1296

@pmoulon Any chance to look into this? Looking forward to being able to use OpenMVG in my iPhone app eventually.

@pmoulon @rperrot @snowzurfer Just wondering if there is any updates on building OpenMVG for iOS?

I have built a simple SFM which is very primitive and no where near the quality and speed the 3D scanning result from OpenMVG. And my SFM lib struggles to scan smooth and lack of feature object too. I am working on an iPhone app to help mums to learn to breastfeed, which involves 3D scanning the breast hence needing to use the OpenMVG library. Any suggestions on what feature detector, descriptor, and matcher to use or other tricks to get the decent scanning result for these types of objects are also very much appreciated.

The project urgently needs to get pass the 3D scanning development phase to move onto the next challenge. It would be great if the developers and contributors here could shed some lights on how to build OpenMVG successfully for iOS platform because it is not going to benefit my own individual project but also to benefit many other iOS developers who plan to exploit the state-of-art technology and features of OpenMVG in many other iOS applications.

Many thanks in advance for your advice and support!

The issues related to the building process are only due to the fact that iOS applications could not be console application, so you have to disable all the samples.

Just tested now :

git clone --recursive https://github.com/openMVG/openMVG.git -b develop

edit the file openMVG/src/third_party/vectorGraphics/CMakeLists.txt and comment the two last lines :

CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
#ADD_EXECUTABLE(main_svgSample main.cpp)
#SET_PROPERTY(TARGET main_svgSample PROPERTY FOLDER OpenMVG/Samples)

edit the file openMVG/src/CMakeLists.txt and comment this two line:

#AutodetectHostArchitecture()
#OptimizeForArchitecture()

then go back to the build process as usual :

mkdir build
cd build/
cmake -GXcode -DCMAKE_BUILD_TYPE=Release -DOpenMVG_BUILD_EXAMPLES=OFF -DOpenMVG_BUILD_SOFTWARES=OFF -DOpenMVG_BUILD_GUI_SOFTWARES=OFF . ../openMVG/src/
open openMVG.xcodeproj/

Set the build settings globally ( Base SDK and Build Active Architecture Only ) :

capture d ecran 2018-06-22 a 22 14 39

There's a remaining issue related to graph_graphviz_export.hpp (in src/openMVG/graph) that fails to build for the same reason (you could not use std::system or commandline tools on iOS), so just comment the lines 80 and 81 to disable the call to std::system

//Use Graphviz
const std::string cmd = "neato -Tsvg -O -Goverlap=scale -Gsplines=false " + sfile;
// const int ret = std::system(cmd.c_str());
//(void)ret;

And finally the library builds with success and you could integrate it to your project.

@pmoulon We may control the build of svgSample executable using OpenMVG_BUILD_EXAMPLES flag, isn't it ?

@rperrot Thanks a lot for your reply.

I followed all your steps above, all went well. However, when I try to build (Product->Destination->Chen's iPhone then build), I get the

clang: error: the clang compiler does not support '-march=broadwell'

screenshot 2018-06-22 22 26 44

again. Do you see this error @rperrot when you are building?

I was previously advised by @pmoulon to comment out:

AutodetectHostArchitecture()
OptimizeForArchitecture()
https://github.com/openMVG/openMVG/blob/master/src/CMakeLists.txt#L111
https://github.com/openMVG/openMVG/blob/master/src/CMakeLists.txt#L112

to solve this issue. If I comment out those lines and run cmake, the cmake fails with the following errors:

CMakeError.log
CMakeOutput.log

Any ideas for how to get around it as this was my previous issue when I try to build?

@rperrot maybe we can run a TeamView session so you can see the issue better on my Mac?

Sorry, I forgot the Architecture's cmake things.

Comment the lines as stated by @pmoulon and replace the line 424 with that (ie: add quotes around ${CMAKE_CXX_FLAGS} ) :

string(REPLACE " " ";" REPLACED_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" )

And set the Build Active Architecture Only option to yes in XCode to prevent building x86_64 architectures.

@pmoulon Note: the issue is because CMAKE_CXX_FLAGS are empty here, just setting quotes makes an empty string (instead of a null one) and solve the "string sub-command REPLACE requires at least four arguments." issue.

EDIT: Make sure you have cleaned your build directory before restarting a new "cmake -G ..." command

EDIT2 : Make sure the options Base SDK and Build Active Architecture Only are set project-wide and not only for one sub library.

@rperrot The configuration and build finally work! Thank you so much for your information and support!

1) Now I can see the built static libs in my ..OpenMVG/build/Darwin-x86_64-Release/debug folder as below. But I couldn't find a top-level openMVG lib such as libopenMVG.a
screenshot 2018-06-23 07 53 25

Do I need to change the build locations to have the libs built into the Xcode/DerivedData folder? The current build location in the OpenMVG project settings is set to be /Users/chendavies/Documents/Dev/OpenMVG/build/build
However, I cannot find the build folder in the specified location.

2) Is there any documentation for the steps to follow to set up for the simplest structure from motion using OpenMVG (given an input image directory of input images) to output the 3D reconstructed points and camera transforms?

Many thanks!

Is there any documentation for the steps to follow to set up for the simplest structure from motion using OpenMVG (given an input image directory of input images) to output the 3D reconstructed points and camera transforms?

You could follow the python pipelines they list all the steps used to take images to a 3d model.
(see the doc here : https://openmvg.readthedocs.io/en/latest/software/SfM/SfM/) Note however that they work with command line tools and since they are not build in iOS you will have to code all the steps (most of the code will stay the same, the main issue is related to I/O and you may prefer an in memory pipeline instead of a set of individual tools).

Now I can see the built static libs in my ..OpenMVG/build/Darwin-x86_64-Release/debug folder as below. But I couldn't find a top-level openMVG lib such as libopenMVG.a

OpenMVG provide a set of tiny libraries and not a single library (@pmoulon maybe a thing to add in the TODO ?) you will have to link with the tools you use. If you configure a install path, you could also use openMVG as a cmake project (using find_package)

That’s great thanks a lot for your information and support Romuald!! I will
give these a try and let you know if I have any more questions:-)

On Sat, 23 Jun 2018 at 10:09, Romuald Perrot notifications@github.com
wrote:

Is there any documentation for the steps to follow to set up for the
simplest structure from motion using OpenMVG (given an input image
directory of input images) to output the 3D reconstructed points and camera
transforms?

You could follow the python pipelines they list all the steps used to take
images to a 3d model.
(see the doc here :
https://openmvg.readthedocs.io/en/latest/software/SfM/SfM/) Note however
that they work with command line tools and since they are not build in iOS
you will have to code all the steps (most of the code will stay the same,
the main issue is related to I/O and you may prefer an in memory pipeline
instead of a set of individual tools).

Now I can see the built static libs in my
..OpenMVG/build/Darwin-x86_64-Release/debug folder as below. But I couldn't
find a top-level openMVG lib such as libopenMVG.a

OpenMVG provide a set of tiny libraries and not a single library (@pmoulon
https://github.com/pmoulon maybe a thing to add in the TODO ?) you will
have to link with the tools you use. If you configure a install path, you
could also use openMVG as a cmake project (using find_package)

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/openMVG/openMVG/issues/1300#issuecomment-399655538,
or mute the thread
https://github.com/notifications/unsubscribe-auth/Ak3gd8NU_kOesw_GL-WXdgPd-5GHldNkks5t_gXAgaJpZM4TouEN
.

I tried those @rperrot suggested steps and it worked nice for me.

Now you need to build your IPhone app and link the OpenMVG library and add the appropriate include folder and you will be all set.

@pmoulon @rperrot Yes, the solution listed in this issue work nicely and I am trying to link the OpenMVG libraries with my iPhone app. I will close this issue now, thanks a lot for all your help and responses!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

autosquid picture autosquid  Â·  4Comments

glbsalazar picture glbsalazar  Â·  7Comments

treyfortmuller picture treyfortmuller  Â·  5Comments

yonelay11 picture yonelay11  Â·  5Comments

itsdsk picture itsdsk  Â·  6Comments