Hyperlapse cross-platform mobile development with Visual C++ and Xamarin
Microsoft Hyperlapse Mobile offers the chance to turn any long video – from a bumpy bicycle ride to a family stroll in the park — into a short, distilled version that you can easily share with friends and family. That technology, which is available for Windows Phone and in beta for Android will come as a welcome relief to anyone who’s ever sat uncomfortably through a real-time video documenting those types of excursions.
For professional shooters and serious video enthusiasts, Microsoft Hyperlapse Pro can create a Hyperlapse using a Windows computer from video shot on any camera or device – including aerial footage shot with drones. It opens up possibilities that were previously difficult, if not impossible, for even serious filmmakers to achieve. This blog talks about how Hyperlapse was developed using cross-platform Visual C++ and Xamarin solutions.
How the Hyperlapse Codebase is structured
The core algorithmic portions of Hyperlapse are written in C++ for performance reasons, and over time we’ve built up a library of advanced and highly optimized computer vision algorithms. This library represents a significant investment and re-writing it would have been a large undertaking. Similarly on the managed side we’ve developed a toolkit of controls and functionality that we share across several of our apps and wanted to reuse. When we set out to build Hyperlapse we not only wanted to leverage our previous investments, but also reduce our future maintenance debt; we wanted to build a single application, but with many heads. At the same time our app needed to take advantage of the underlying hardware while keeping the distinct look and feel of each platform it was running on.
Xamarin and C++ allowed us to meet these goals: We could build the core algorithmic pieces in cross platform C++, and keep the majority of the application business logic in a .NET portable class library. We could then build thin, platform native UIs (also written in C#) over the top of our business logic that let the app feel at home on each platform, but share the majority of the under the hood implementation.
Excluding libraries our code is about 30% C++, 30% portable .NET, 20% Xamarin/Windows Phone specific UI code. Including library code heavily skews it to C++, because our C++ libraries are vast (although we don’t use all of it in Hyperlapse). The figure below illustrates how the Hyperlapse solution is structured:
The Visual Studio and Xamarin development experience
The biggest advantage of using the Visual studio integration comes from the familiarity of the tools. As a Microsoft development team, our skillset is heavily invested in Visual Studio, C++, and C#. The ability to avoid dealing with Android Studio, Eclipse and Java was a huge boost to our productivity and drastically improved our time to market.Xamarin previously allowed bringing in and consuming pre-built C++ libraries. This was not ideal as it meant using a third-party tool like Eclipse to develop the C++ library and then import into Visual Studio.
The Visual Studio cross-platform C++ integration with Xamarin closed this loop, ensuring we could edit, build, and debug C++ code in Visual Studio, as a result retiring our need of any third-party tools. Furthermore, this also allowed us to seamlessly integrate our Android app with the existing build infrastructure we have for Windows; and at the push of a button we can now generate two versioned, signed, and packaged applications ready to submit to the various app stores. To learn more about how the Xamarin-C++ integration works refer to this blog by Xamarin which talks about building and debugging C++ in Xamarin applications.
The development experience, especially considering we were working on pre-release software was extremely smooth and generally everything just worked. It was great having features light up as they became available in the various CTPs, although obviously a pain having to re-install Visual Studio quite as often as we did.
Thanks to Visual Studio and Xamarin we continue to bring our development processes and our products forward to new platforms and technologies and we look forward to applying these processes on new and exciting products.