Skip to content

Commit

Permalink
build: add function camera
Browse files Browse the repository at this point in the history
  • Loading branch information
ACornuIGN committed Dec 22, 2023
1 parent c62596e commit eacc882
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
19 changes: 10 additions & 9 deletions pink_lady.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import argparse
import importlib
from src.reader.orientation.manage_reader import reader_orientation
from src.writer.writer_opk import to_opk
from src.reader.camera.reader_camera import read_camera

parser = argparse.ArgumentParser(description='photogrammetric site conversion'
+ ' and manipulation software')
Expand All @@ -18,7 +18,7 @@
type=str, choices=['opk'],
help='Worksite output file format')
parser.add_argument('-pr', '--pathreturn',
type=str, default="test/tmp/", nargs=1,
type=str, default="", nargs=1,
help='Conversion path ex:"test/tmp/"')
parser.add_argument('-c', '--camera',
type=list, default=[], nargs='*',
Expand All @@ -34,12 +34,13 @@
print("The access road to the photogrammetric site is missing")

# Reading camera file


if args.camera != []:
read_camera(args.camera, work)

# Writing data
try:
my_module = importlib.import_module("src.reader.reader_" + args.writer.lower())
work = my_module.write(args.pathreturn, work)
except ModuleNotFoundError as e:
raise ValueError(f"{args.writer} file is not taken into account !!!") from e
if args.pathreturn != "":
try:
my_module = importlib.import_module("src.reader.reader_" + args.writer.lower())
work = my_module.write(args.pathreturn, work)
except ModuleNotFoundError as e:
raise ValueError(f"{args.writer} file is not taken into account !!!") from e
11 changes: 8 additions & 3 deletions src/reader/camera/reader_camera.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"""
Script to read camera file txt or xml
"""
import xml.etree.ElementTree as ET
from src.datastruct.worksite import Worksite


def reader_camera(files: list, work: Worksite) -> None:
def read_camera(files: list, work: Worksite) -> None:
"""
Manage file in list files to read
Expand All @@ -28,7 +29,12 @@ def camera_xml(file: str, work: Worksite) -> None:
files (list): path list of files cameras
work (Worksite): Worksite which needs camera data
"""
pass
projet = ET.parse(file).getroot()
focal = projet.find("focal").find("pt3d")
work.add_camera(projet.find("name").text.strip(),
float(focal.find("x").text.strip()),
float(focal.find("y").text.strip()),
float(focal.find("z").text.strip()))


def camera_txt(file: str, work: Worksite) -> None:
Expand All @@ -47,4 +53,3 @@ def camera_txt(file: str, work: Worksite) -> None:
# Add to worksite
work.add_camera(name_cam, float(o_info[2]), float(o_info[5]), float(o_info[8]))
file_cam.close()

0 comments on commit eacc882

Please sign in to comment.