-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from ACornuIGN/camera
Add reading and writing camera file
- Loading branch information
Showing
24 changed files
with
331 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
python3 -m pytest -s ./test/test_reader.py -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
python3 -m pytest -s ./test/test_struct.py -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
python3 -m pytest -s ./test/test_writer.py -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
name: pink_lady | ||
dependencies: | ||
- python | ||
- numpy | ||
- pip | ||
- pip: | ||
- -r requirements.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
""" | ||
Camera data class module | ||
""" | ||
from dataclasses import dataclass | ||
|
||
|
||
@dataclass | ||
class Camera: | ||
""" | ||
Shot class definition | ||
Args: | ||
name_camera (str): Name of the camera. | ||
ppax (float): Center of distortion in x. | ||
ppay (float): Center of distortion in y. | ||
focal (float): Focal of the camera. | ||
""" | ||
name_camera: str | ||
ppax: float | ||
ppay: float | ||
focal: float |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
""" | ||
Script to read camera file txt or xml | ||
""" | ||
import xml.etree.ElementTree as ET | ||
from src.datastruct.worksite import Worksite | ||
|
||
|
||
def read_camera(files: list, work: Worksite) -> None: | ||
""" | ||
Manage file in list files to read | ||
Args: | ||
files (list): path list of files cameras | ||
work (Worksite): Worksite which needs camera data | ||
""" | ||
for file in files: | ||
ext = file.split('.')[-1].lower() | ||
if ext == 'xml': | ||
camera_xml(file, work) | ||
if ext == 'txt': | ||
camera_txt(file, work) | ||
|
||
|
||
def camera_xml(file: str, work: Worksite) -> None: | ||
""" | ||
Read xml file camera | ||
Args: | ||
files (list): path list of files cameras | ||
work (Worksite): Worksite which needs camera data | ||
""" | ||
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: | ||
""" | ||
Read txt file camera | ||
Args: | ||
files (list): path list of files cameras | ||
work (Worksite): Worksite which needs camera data | ||
""" | ||
with open(file, 'r', encoding="utf-8") as file_cam: | ||
# Recover the info line and take name camera | ||
name_cam, o_info = file_cam.readlines()[0].split(" / ") | ||
# Take information ppa focal | ||
o_info = o_info.split(" : ")[-1].split(" ") | ||
# Add to worksite | ||
work.add_camera(name_cam, float(o_info[2]), float(o_info[5]), float(o_info[8])) | ||
file_cam.close() |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
UCE-M3-f120-s06 / 431S61699X311363-f120-s06 : PPAx = 13210.00 PPAy = 8502.00 f = 30975.00 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<sensor> | ||
<name> UCE-M3-f120-s07 </name> | ||
<objectif> 123.9mm </objectif> | ||
<origine> UCE-M3-f120-s07 </origine> | ||
<argentique> 0 </argentique> | ||
<calibration-date> 06-07-2020 </calibration-date> | ||
<serial-number> 431S72800X219308-f120 </serial-number> | ||
<usefull-frame> | ||
<rect> | ||
<x> 0 </x> | ||
<y> 0 </y> | ||
<w> 26460 </w> | ||
<h> 17004 </h> | ||
</rect> | ||
</usefull-frame> | ||
<dark-frame> | ||
<rect> | ||
<x> 0 </x> | ||
<y> 0 </y> | ||
<w> 0 </w> | ||
<h> 0 </h> | ||
</rect> | ||
</dark-frame> | ||
<focal> | ||
<pt3d> | ||
<x> 13230 </x> | ||
<y> 8502 </y> | ||
<z> 30975 </z> | ||
</pt3d> | ||
</focal> | ||
<pixel_size> 0.000004 </pixel_size> | ||
<orientation> 0 </orientation> | ||
</sensor> |
Oops, something went wrong.