Source files in libcamera start by a comment block header, which includes the file name and a one-line description of the file contents. While the latter is useful to get a quick overview of the file contents at a glance, the former is mostly a source of inconvenience. The name in the comments can easily get out of sync with the file name when files are renamed, and copy & paste during development have often lead to incorrect names being used to start with. Readers of the source code are expected to know which file they're looking it. Drop the file name from the header comment block. The change was generated with the following script: ---------------------------------------- dirs="include/libcamera src test utils" declare -rA patterns=( ['c']=' \* ' ['cpp']=' \* ' ['h']=' \* ' ['py']='# ' ['sh']='# ' ) for ext in ${!patterns[@]} ; do files=$(for dir in $dirs ; do find $dir -name "*.${ext}" ; done) pattern=${patterns[${ext}]} for file in $files ; do name=$(basename ${file}) sed -i "s/^\(${pattern}\)${name} - /\1/" "$file" done done ---------------------------------------- This misses several files that are out of sync with the comment block header. Those will be addressed separately and manually. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
71 lines
2.2 KiB
Python
71 lines
2.2 KiB
Python
# SPDX-License-Identifier: BSD-2-Clause
|
|
#
|
|
# Copyright (C) 2019, Raspberry Pi Ltd
|
|
#
|
|
# camera tuning tool RANSAC selector for Macbeth chart locator
|
|
|
|
import numpy as np
|
|
|
|
scale = 2
|
|
|
|
|
|
"""
|
|
constructs normalised macbeth chart corners for ransac algorithm
|
|
"""
|
|
def get_square_verts(c_err=0.05, scale=scale):
|
|
"""
|
|
define macbeth chart corners
|
|
"""
|
|
b_bord_x, b_bord_y = scale*8.5, scale*13
|
|
s_bord = 6*scale
|
|
side = 41*scale
|
|
x_max = side*6 + 5*s_bord + 2*b_bord_x
|
|
y_max = side*4 + 3*s_bord + 2*b_bord_y
|
|
c1 = (0, 0)
|
|
c2 = (0, y_max)
|
|
c3 = (x_max, y_max)
|
|
c4 = (x_max, 0)
|
|
mac_norm = np.array((c1, c2, c3, c4), np.float32)
|
|
mac_norm = np.array([mac_norm])
|
|
|
|
square_verts = []
|
|
square_0 = np.array(((0, 0), (0, side),
|
|
(side, side), (side, 0)), np.float32)
|
|
offset_0 = np.array((b_bord_x, b_bord_y), np.float32)
|
|
c_off = side * c_err
|
|
offset_cont = np.array(((c_off, c_off), (c_off, -c_off),
|
|
(-c_off, -c_off), (-c_off, c_off)), np.float32)
|
|
square_0 += offset_0
|
|
square_0 += offset_cont
|
|
"""
|
|
define macbeth square corners
|
|
"""
|
|
for i in range(6):
|
|
shift_i = np.array(((i*side, 0), (i*side, 0),
|
|
(i*side, 0), (i*side, 0)), np.float32)
|
|
shift_bord = np.array(((i*s_bord, 0), (i*s_bord, 0),
|
|
(i*s_bord, 0), (i*s_bord, 0)), np.float32)
|
|
square_i = square_0 + shift_i + shift_bord
|
|
for j in range(4):
|
|
shift_j = np.array(((0, j*side), (0, j*side),
|
|
(0, j*side), (0, j*side)), np.float32)
|
|
shift_bord = np.array(((0, j*s_bord),
|
|
(0, j*s_bord), (0, j*s_bord),
|
|
(0, j*s_bord)), np.float32)
|
|
square_j = square_i + shift_j + shift_bord
|
|
square_verts.append(square_j)
|
|
# print('square_verts')
|
|
# print(square_verts)
|
|
return np.array(square_verts, np.float32), mac_norm
|
|
|
|
|
|
def get_square_centres(c_err=0.05, scale=scale):
|
|
"""
|
|
define macbeth square centres
|
|
"""
|
|
verts, mac_norm = get_square_verts(c_err, scale=scale)
|
|
|
|
centres = np.mean(verts, axis=1)
|
|
# print('centres')
|
|
# print(centres)
|
|
return np.array(centres, np.float32)
|