<commit_before>#!/usr/bin/python

# pose related functions

import fileinput
import math

import navpy

import transformations

# a helpful constant
d2r = math.pi / 180.0

# quaternions represent a rotation from one coordinate system to
# another (i.e. from NED space to aircraft body space).  You can
# back translate a vector against this quaternion to project a camera
# vector into NED space.
#
# body angles represent the aircraft orientation
# camera angles represent the fixed mounting offset of the camera
# relative to the body
# +x axis = forward, +roll = left wing down
# +y axis = right, +pitch = nose down
# +z axis = up, +yaw = nose right


# define the image aircraft poses from Sentera meta data file
def setAircraftPoses(proj, metafile="", force=True, weight=True):
    f = fileinput.input(metafile)
    for line in f:
        line.strip()
        field = line.split(',')
        name = field[0]
        lat = float(field[1])
        lon = float(field[2])
        alt = float(field[3])
        yaw = float(field[4])
        pitch = float(field[5])
        roll = float(field[6])

        image = proj.findImageByName(name)
        if image != None:
            if force or (math.fabs(image.aircraft_lon) < 0.01 and math.fabs(image.aircraft_lat) < 0.01):
                image.set_aircraft_pose( [lat, lon,alt], [yaw, pitch, roll] )<commit_msg>Support setting poses from pix4d format meta file.<commit_after>#!/usr/bin/python

# pose related functions

import fileinput
import math
import re

import navpy

import transformations

# a helpful constant
d2r = math.pi / 180.0

# quaternions represent a rotation from one coordinate system to
# another (i.e. from NED space to aircraft body space).  You can
# back translate a vector against this quaternion to project a camera
# vector into NED space.
#
# body angles represent the aircraft orientation
# camera angles represent the fixed mounting offset of the camera
# relative to the body
# +x axis = forward, +roll = left wing down
# +y axis = right, +pitch = nose down
# +z axis = up, +yaw = nose right


# define the image aircraft poses from Sentera meta data file
def setAircraftPoses(proj, metafile="", order='ypr', force=True, weight=True):
    f = fileinput.input(metafile)
    for line in f:
        line.strip()
        if re.match('^\s*#', line):
            print "skipping comment ", line
            continue
        field = line.split(',')
        name = field[0]
        lat = float(field[1])
        lon = float(field[2])
        alt = float(field[3])
        if order == 'ypr':
            yaw = float(field[4])
            pitch = float(field[5])
            roll = float(field[6])
        elif order == 'rpy':
            roll = float(field[4])
            pitch = float(field[5])
            yaw = float(field[6])

        image = proj.findImageByName(name)
        if image != None:
            if force or (math.fabs(image.aircraft_lon) < 0.01 and math.fabs(image.aircraft_lat) < 0.01):
                image.set_aircraft_pose( [lat, lon,alt], [yaw, pitch, roll] )
{'fraction_non_alphanumeric': 0.10609037328094302, 'fraction_numerical': 0.01309757694826457, 'mean_word_length': 2.753071253071253, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2673045', 'n_tokens_mistral': 947, 'n_tokens_neox': 910, 'n_words': 328}