AR frameworks for iOS: which one to choose?

image
Many developers have long used AR in their applications. Good help for this is third-party solutions like OpenCV or Wikitude. With the release of iOS 11, the ARKit system framework has become available to programmers. Let's see how good these libraries are and which ones should be used for your next project with augmented reality.

ARKit


The undoubted advantages of ARKit include its native nature. Integration and configuration takes only a few minutes. Xcode kindly does half of the necessary operations for you, after which the framework "just works." It is very easy to organize the interaction between ARKit and other system frameworks (SpriteKit, SceneKit, Metal, CoreLocation, etc.).

The library is well optimized and uses the hardware capabilities of the latest iPhone and iPad models to the maximum. A huge number of calculations that occur under the hood, almost no effect on the UX. Pleases the accuracy with which the framework recognizes the plane and markers. Neither illumination nor abrupt movement of the device interfere with this. Thanks to the VIO (Visual Inertial Odometry) and IMU (Inertial Measurement Unit) technologies that complement each other, which form the basis of ARKit, the guys from Apple managed to minimize calculation errors.

Not without cost, of course, without flaws. Firstly, ARKit is available only on devices with iOS 11+, it is supported only on iPhone 6s and under, iPad Pro (9.7, 10.5 or 12.9). Unfortunately, this can alienate customers who are afraid of losing part of the target audience.

ARKit is designed in such a way that information about the objects of the world and the position of the device in it is constantly calibrated. Because of this, at the beginning of the session, as long as the data are not sufficiently accurate, a feeling of “instability” of work is created, which cannot be eliminated yet. In addition, if the session is long enough, seemingly small errors in sensor performance will accumulate and become more and more noticeable.

When recognizing images, there are problems with the positioning of the AR-object, the object floats, is not fixed clearly at the specified point. A similar behavior is observed in the example published by Apple . However, an object placed at a given point in space practically does not move.

In some cases (small black-and-white images of not very good quality) marker recognition occurs, but the system incorrectly determines its coordinates. As a result, an AR object is drawn in the wrong place.

ARKit is very easy to learn. To get started, you need a minimum amount of knowledge. A sufficiently large number of training articles and code samples have already been published on the Web, and the community is large and responsive, so finding answers to questions arising in the process of writing code will be easy.

Opencv


The OpenCV library written in C ++ is free of charge and gives you the opportunity to download the iOS SDK from the official site or compile it yourself.

Already at the stage of implementation, Swift fans are waiting for a fascinating quest to eliminate compilation errors, which threatens to take several hours. Fortunately, step-by-step instructions are available on the Web, published by our comrades who have already overcome an intractable framework (for example, OpenCV with Swift - step by step ).

After you manage to finally launch the project with the connected library, the question will arise what to do next. Perhaps you decide to look for tutorials on the official site. There, iOS developers will have to wait for three examples of using the old version of the framework in projects focused on iOS 8. There are not so many modern articles on mobile development with OpenCV. Apparently, this is due to the fact that everyone who wanted to learn this library a long time ago did this and no longer needs clarification.

However, newcomers still have a chance to master this, no doubt, a powerful tool. However, it will take a lot of time and effort. Like any other low-level library, OpenCV requires in-depth thoughtful study, detailed documentation analysis, sifting thousands of discussions on forums in search of an answer to your question and endless experiments.

By the way, do not forget to add to this the time for restoring the memory of the university mathematics course, because OpenCV will not display the formulas for you.

Wikitude


Let's start with the fact that Wikitude is a paid and not a cheap framework. The free version contains watermarks, so you cannot use it for release build.

Nevertheless, the library is worth the money. Unlike ARKit, it supports even older devices and system versions. The product is well documented, has many articles, lessons and code examples, so the integration and implementation of the simplest tasks for an unprepared programmer will take only a few hours.

The main use of the library is the recognition of markers. As the latter, any images without an alpha channel can be used. However, Wikitude works only with native formats. Images of markers have to be packaged in .wtc format, 3D-models are converted into .wt3-files. In fairness, it should be noted that Wikitude provides the means to convert on its website.

In general, the framework copes well with its task: markers are recognized, AR-objects are placed where you have planned, do not float when the viewing angle changes or the camera moves. Post a picture, video or 3D-model is not difficult, as well as to ensure their interactivity. Simultaneous work with several markers is supported, but when configuring library classes, it is better to limit their number to improve performance.

I note, however, that in case of poor lighting, as well as inaccurate movement of the device, there are problems with recognizing markers even if high-quality original images were used to create them.

Wikitude supports JS and native SDK versions.

If you choose to integrate the JS version, get ready to reject the convenient Swift or sweetheart Objective-C and concentrate on writing JavaScript code. And since the latter is quite painful when working in Xcode, install Sublime or one of its substitutes at the same time. And try to write right at once, because the process of debugging and fixing errors will not be easy.

Another note concerns optimization. With any long-term interaction with AR objects, the JS version of the framework begins to slow down noticeably, fps sags heavily, which, incidentally, is not surprising.

The native version of the SDK, for all its friendliness, is almost devoid of "magic." In fact, it only notifies you that the marker is recognized, reports its identifier and coordinates in space, and then passes the flag to you. Then you are free to use your favorite tool, for example, OpenGL, to draw AR objects.

Conclusion


So, if you are a beginner who decided to try his hand in the field of augmented reality, it all depends on your customer and his needs. If the client is not sorry to spend several thousand euros on a quality paid framework, and you are not afraid of JavaScript or OpenGL, take Wikitude. Otherwise, start with ARKit. Thanks to numerous examples and community support, you will be able to quickly implement simple tasks and “feel” this technology. Then, when you begin to understand what's what, and get a little comfortable, you can storm the low-level OpenCV and conquer the previously inaccessible peaks.

Source: https://habr.com/ru/post/413401/


All Articles