ACAP FAQFrequently Asked Questions related to Axis camera application development
ACAP FAQ
Overview
Choosing the right programming language for ACAP application development is essential for efficiency, performance, and compatibility with Axis SDKs and APIs. Axis supports C, C++ and Shell (Sh) as seen in the Axis FAQ, the supported languages and for a while they did even support Python in some cases. But not all languages are suitable for every use case.
At FixedIT, our standard practice is to use C++ and C for production-grade native ACAP applications and Python for prototyping and development. When we want the quickest and most robust solution to an edge use case, then we make use of the FixedIT Data Agent platform and the Python-like Starlark scripting language. Below, we explore why certain languages are more suitable than others depending on your goals, camera models, and SDK version.
The first aspect to consider is what you want the ACAP application to do. In most cases, you want to use the ACAP SDK APIs, this might be e.g. to get images from the camera or to send events in the camera's event system.
These APIs are implemented using specific languages and if you are going to use them from another language you will need to create API wrappers using a foreign language interface (or similar technologies). This can be a lot of work and you will constantly need to update your wrappers to be aligned with the latest changes in the SDK APIs. At FixedIT, we are currently looking at creating a shared set of wrappers for other languages, if you are interested you are welcome to contact us to get to now more.
Most of the SDK APIs are implemented in C and available in the Native SDK (and SDK 3). This means that if you have an application that consist to a large degree of API integration, then it is easiest to write the whole application in C. It is however relatively easy to use C APIs from C++, so if you prefer C++ that is also a good choice. At FixedIT, we have created our own C++ wrappers for most C APIs that we make use of in all applications we develop. This is one of the things that makes us faster on a custom development project than other consulting companies. These wrappers are extensively tested for leaks using static analyzers and tools like valgrind to ensure robustness and security. When using C++, we can make use of modern features like smart pointers and safe memory management. In this way, we have almost eliminated the occurrence of memory leaks in code that we write.
You might ask why all Axis APIs are implemented in C, and if they will ever change to C++ or another language. It's a fair question to ask, and it might seem unorthodox at first to still use such an old language as C in a modern framework. There are, however, good reasons for this that makes is unlikely that they would ever change in to a larger extent. C interfaces are guaranteed to be stable on the ABI-level (binary level), which for example C++ is only within the same compiler version. Due to the method Axis is deploying their libraries, ABI compatibility is critical. This issue does not affect our library wrappers since we rebuild every library with every version of the AXIS SDK that we support. That way, ABI compatibility is still guaranteed.
Calling C APIs from Python is not particularly hard, there are a lot of frameworks available to make wrapping C code easy. This is made a bit more complex from a build perspective since all C-extensions in Python needs to be cross-compiled for the target architectures. In the context of ACAP applications there's also another aspect making it more complicated since the runtime for Python applications is different than the runtime for native applications. This means that you would need to make use of a combination of two or more SDKs. Learn more in this guide on selecting the right SDK for your ACAP application. But nowadays, this does not matter anymore since Axis deprecated the Python environment in the cameras…
We know that a lot of developers are more used to high-level languages such as Python. For these developers, diving into low-level programming with cross-compiled applications and C programming is a big learning curve than can delay projects for month or even more.
That's why we created the FixedIT Data Agent which is an ACAP runtime that allows you to make use of high-level languages such as the Python-like Starlark language and Shell scripts. We looked at the previous attempts from Axis to create a Python environment in the Axis cameras, took learning from the shortcomings and created a smaller, more efficient and easier to deploy solution. The FixedIT Data Agent is designed for easy deployment to large camera fleets, easy maintenance and has a wide compatibility range with most Axis cameras supported.
If you don't want to learn C programming, or if you just want to get to a working solution as quickly as possible, the FixedIT Data Agent is probably the right way for you. You can read in this case study why RackFalcon decided to go with the FixedIT Data Agent and why that might be the best solution for you too.
A few open source projects are available for developing ACAP applications in other more exotic languages such as Rust and Go. Although being an exiting evolution, you should consider that the ACAP ecosystem was not explicitly intended for these languages. Some integrations with other tools might suffer and you might find that some developer tools are not available for these languages. For individuals with an interest in these languages we would highly recommend playing around with it, but for production graded applications you should first think about if you are prepared to depend on the 3rd-party layers. Things to consider are:
Long-term support for the frame work: Who is responsible and do they commit to long-term maintenance?
API availability: Which APIs does have wrappers for the language, and how easy is it to create new wrappers?
License issues: What license and copyright does the project have and what implications does that get in your code base and your IPR strategy.
Ecosystem integration: Does the language framework require custom build tools and are they compatible with the rest of the tools in the SDK? Are the custom build tools released often enough?
Compatibility with future AXIS OS and SDK versions: Do any components depend on use of undocumented features and will they remain compatible with future releases?
Access to support: Do anyone offer support for the framework and how will it affect your ability to use the Axis support desk for Technology Integration Partners?
IT security: Is the framework secure or might it introduce new weak link that bad actors can utilize? Are security updates released frequently and are CVEs handled?
With this said, abstraction layers and 3rd party tools can give you a lot of value and make your development cycles faster. It's up to you to make an adequate risk analysis for your company and your use case. If you are not willing to do this analysis, then you should probably stay with the most mainstream option (which is C or possibly C++).
When creating a C/C++ or Shell application using the Native SDK, these applications will create an .eap package file and run directly in the camera's OS. This is the same deployment method that we use for the FixedIT Data Agent platform.
The now deprecated Axis support for Python using the AXIS Computer Vision SDK is however not supported in the Native SDK. Instead the method for using Python in applications is to use the dockerized deployment method which has now been deprecated. Some of the new cameras are powerful enough to run the Docker daemon and you can therefore deploy an isolated filesystem in a docker image. In this image you can install Python or essentially any other language you want to. The SDK does however come with a precompiled version of Python together with some APIs and common libraries.
Apart from the development aspects, the deployment aspect is important to consider from the start. Only a few cameras are capable of installing the docker runtime, this means that if you opt to implement your application in Python, the supported camera models will be a tiny subset of the available cameras. Since the Computer Vision SDK has been deprecated, updates to the SDK are rare and the lifetime of applications created with the SDK is limited.
Python based applications does normally grow large in size and does often require the camera to have an SD-card installed before the application will fit. This is often complicating the operative part of the deployment process. Python is also less efficient than C and considering the limited compute in the cameras, you will likely need to spend a lot of time optimizing your Python code for the devices. At FixedIT we have written highly optimized Python code for years, despite this we often find it to be more time intensive to optimize the python code for the devices than to write the application in a low-level language such as C++.
All these drawbacks and considerations are things that we took into account when developing the FixedIT Data Agent runtime ACAP. Deployment with that is easy and it's designed to create efficient applications due to its modularity and use of already existing plugins.
In summary, we have seen that only because a language is supported it does not mean it is a suitable choice. In many cases, C or C++ are still the best language to use for ACAP developement. All camera APIs are not available for all supported languages. Some applications are container based, but these are only supported in a small set of cameras. You can also learn more in our comprehensive guide on selecting the right SDK. You can also read in this case study why RackFalcon decided to go with the FixedIT Data Agent instead of creating their own native ACAP app from scratch.