Pix4Dengine Quick-Start

Prerequisites

The use of the Pix4Dengine requires some familiarity with the Python programming language.

Installation requirements

The list of currently supported platforms can be found in the latest Release notes.

Installation

Linux/Ubuntu 18.04

Pix4Dengine can be obtained as a Debian software package from its download page.

It is installed system-wide by executing in a terminal:

sudo apt-get update
sudo apt-get install ./python3-pix4dengine_1.0.0_amd64.deb

Note that sudo privileges are needed to run these commands. If not already installed, the correct version of Python will be automatically installed.

Windows

Pix4Dengine can be obtained as a wheel package from its download page.

Before installing it, make sure Python 3.6 (including pip) is installed. Install Pix4Dengine by executing in a command interpreter:

pip install pix4dengine_1.0.0-cp36-cp36m-win_amd64.whl

Docker Installation

Pix4Dengine can be run within Docker.

A simple example of a Dockerfile is shown below that installs Pix4Dengine then prints the installed version as a check.

FROM ubuntu:18.04

ARG engine_deb
ADD ${engine_deb} /tmp/${engine_deb}

RUN apt-get -q -y update && \
    apt-get -q -y upgrade && \
    apt-get -q -y install /tmp/${engine_deb} && \
    rm -f /tmp/${engine_deb}

RUN python3.6 -c "import pix4dengine;print('Installed Pix4Dengine version %s' % pix4dengine.__version__)"

Create your Dockerfile from the above code snippet, then download the Pix4Dengine *.deb to the same directory as the Dockerfile.

Then to build the docker run the following script:

#!/bin/bash

set -e

ENGINE_DEB="$(find . -type f -iname '*.deb')"

docker build . --build-arg engine_deb=${ENGINE_DEB}

Basic usage of the Pix4Dengine Python SDK

The code sample below shows the simplest case of processing using Pix4Dengine. The code ensures Pix4Dengine is authorised by Pix4D license server, creates a project with default parameters and calibrates the cameras in the project. The calibration quality report is then loaded, and the quality status summary is printed.

from pix4dengine import create_project, login_seat
from pix4dengine.pipeline import Pipeline
from pix4dengine.constants.processing import ProcessingStep
from pix4dengine.exports import get_report

# Acquire the authorization to use Pix4Dengine from the Pix4D licensing system
login_seat(<youremail>, <yourpassword>)


# Acquire the authorization to use Pix4Dengine from the Pix4D licensing system
# using a specific license. This is useful if you have more than one license.
login_seat(<youremail>, <yourpassword>, <license key>)

# Create a project
project = create_project("test_survey",
                         images_dir="/path/to/images")

# Calibrate the cameras in the project
pipeline = Pipeline(project, algos=("CALIB"))
pipeline.run()

# Access the calibration quality report
quality_report = get_report(project)
print(quality_report.calibration_quality_status())

Logging system

Pix4Dengine is using python’s built-in logging module. If you want to see detailed messages from the Python SDK then you have to configure the logging for your application.

For a number of recipes related to logging please visit Python logging cookbook.

Example of configuration:

"""Module setting up the logging infrastructure."""
import logging
from logging.config import dictConfig


LOGGING_CONFIG = dict(
    version=1,
    formatters={"f": {"format": "%(asctime)s %(name)-26s %(levelname)-8s %(message)s"}},
    handlers={"h": {"class": "logging.StreamHandler", "formatter": "f", "level": logging.INFO}},
    root={"handlers": ["h"], "level": logging.INFO},
)

dictConfig(LOGGING_CONFIG)

Thread safety

The SDK does not guarantee thread safety. If the code that uses the SDK is multi-threaded, it is the user’s responsibility to ensure thread safety of the code.