Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
17f5bf8a9f | ||
|
|
bff07da132 | ||
|
|
8f8518320b | ||
|
|
75911c8a49 | ||
|
|
6af462858b | ||
|
|
d9c59b6edc | ||
|
|
3031f8e0ac |
No files matched your search
@@ -0,0 +1,4 @@
|
|||||||
|
venv/
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
.pytest_cache/
|
||||||
+32
-1
@@ -92,7 +92,7 @@ Objectif : déterminer si une image donnée, cadrée sur un objet du ciel profon
|
|||||||
| `ra_deg` | float | Ascension droite, en degrés décimaux (converti depuis le format heures/minutes/secondes natif : 1h = 15°) |
|
| `ra_deg` | float | Ascension droite, en degrés décimaux (converti depuis le format heures/minutes/secondes natif : 1h = 15°) |
|
||||||
| `dec_deg` | float | Déclinaison, en degrés décimaux (-90 à +90) |
|
| `dec_deg` | float | Déclinaison, en degrés décimaux (-90 à +90) |
|
||||||
| `magnitude` | float | Magnitude apparente (échelle inversée : plus la valeur est basse, plus l'objet est brillant) |
|
| `magnitude` | float | Magnitude apparente (échelle inversée : plus la valeur est basse, plus l'objet est brillant) |
|
||||||
| `proper_name` | string ou NULL | Nom propre de l'étoile si disponible (absent pour la grande majorité des entrées du catalogue) |
|
| `proper_name` | string ou NULL | Nom propre de l'étoile si disponible (absent pour la grande majorité des entrées du catalogue) |
|
||||||
|
|
||||||
Exemple de ligne (Sirius / Alpha Canis Majoris) :
|
Exemple de ligne (Sirius / Alpha Canis Majoris) :
|
||||||
|
|
||||||
@@ -130,6 +130,37 @@ L'identifiant `id` suit la nomenclature standardisée de l'Union Astronomique In
|
|||||||
]
|
]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Arborescence du projet
|
||||||
|
|
||||||
|
```
|
||||||
|
data/
|
||||||
|
pictures_test/ # images de test, Pipeline B
|
||||||
|
messier_classifier/ # dataset C0/C1/C2
|
||||||
|
manifest.csv # colonnes : nom;label (label = "messier" ou "ngc")
|
||||||
|
dataset_hipparcos.csv
|
||||||
|
dataset_constellations.json
|
||||||
|
pipeline_a/
|
||||||
|
skymap_generator.py
|
||||||
|
pipeline_b/
|
||||||
|
star_detector.py
|
||||||
|
pipeline_c/
|
||||||
|
c0_dataset_acquisition.py
|
||||||
|
c1_model_training.py
|
||||||
|
c2_operational_model.py
|
||||||
|
tests/
|
||||||
|
tests_pipeline_a.py
|
||||||
|
tests_pipeline_b.py
|
||||||
|
tests_pipeline_c0.py
|
||||||
|
tests_pipeline_c1.py
|
||||||
|
tests_pipeline_c2.py
|
||||||
|
app.py
|
||||||
|
CONTRIBUTING.md
|
||||||
|
ARCHITECTURE.md
|
||||||
|
README.md
|
||||||
|
```
|
||||||
|
|
||||||
|
Chaque pipeline (A/B/C) vit dans son propre dossier, reflétant l'indépendance actée en phase de Découpage. Le pipeline C conserve la séparation C0/C1/C2 jusque dans les fichiers de test, ces trois sous-étapes ayant des natures très différentes (scraping, entraînement, inférence). Pas de fichier `utils.py` créé par anticipation : le code partagé entre pipelines, s'il s'avère nécessaire, sera extrait au moment où un besoin concret de duplication apparaîtra, plutôt que par anticipation.
|
||||||
|
|
||||||
## Décisions techniques actées
|
## Décisions techniques actées
|
||||||
|
|
||||||
- Catalogue source : Hipparcos, pré-traité offline via `astropy` en CSV propre (RA, Dec, magnitude, nom) plutôt que parsé à la volée dans l'application
|
- Catalogue source : Hipparcos, pré-traité offline via `astropy` en CSV propre (RA, Dec, magnitude, nom) plutôt que parsé à la volée dans l'application
|
||||||
|
|||||||
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
@@ -0,0 +1,43 @@
|
|||||||
|
import numpy as np # Je le laisse pour plus tard
|
||||||
|
import cv2
|
||||||
|
import os
|
||||||
|
|
||||||
|
def reading_picture(path):
|
||||||
|
if not os.path.exists(path):
|
||||||
|
raise FileNotFoundError(f"{path} n'existe pas.")
|
||||||
|
pic = cv2.imread(path, cv2.IMREAD_GRAYSCALE)
|
||||||
|
if pic is None:
|
||||||
|
raise ValueError(f"{path} est corrompu ou n'est pas une image valide.")
|
||||||
|
return pic
|
||||||
|
|
||||||
|
def blob_detector(picture):
|
||||||
|
params = cv2.SimpleBlobDetector_Params()
|
||||||
|
params.minThreshold = 10
|
||||||
|
params.maxThreshold = 200
|
||||||
|
params.filterByArea = True
|
||||||
|
params.minArea = 4
|
||||||
|
params.filterByCircularity = True
|
||||||
|
params.minCircularity = 0.1
|
||||||
|
params.filterByConvexity = True
|
||||||
|
params.minConvexity = 0.87
|
||||||
|
params.filterByInertia = True
|
||||||
|
params.minInertiaRatio = 0.01
|
||||||
|
params.filterByColor = True
|
||||||
|
params.blobColor = 255
|
||||||
|
# TODO: valeurs provisoires, à recalibrer avec de vraies images de test
|
||||||
|
detector = cv2.SimpleBlobDetector.create(params)
|
||||||
|
stars = detector.detect(picture)
|
||||||
|
result = [star.pt for star in stars]
|
||||||
|
return result
|
||||||
|
|
||||||
|
def relative_coordinates_conversion(coordinates: list[tuple], picture_size: tuple) -> list[tuple] :
|
||||||
|
if picture_size[0] <= 0 or picture_size[1] <= 0:
|
||||||
|
raise ValueError(f"({picture_size[0]}, {picture_size[1]}) n'est pas une taille d'image valide.")
|
||||||
|
denominator = max(picture_size[0], picture_size[1])
|
||||||
|
converted = []
|
||||||
|
for i in range(len(coordinates)):
|
||||||
|
converted.append((
|
||||||
|
coordinates[i][0] / denominator,
|
||||||
|
coordinates[i][1] / denominator
|
||||||
|
))
|
||||||
|
return converted
|
||||||
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
Binary file not shown.
Whitespace-only changes.
@@ -0,0 +1,64 @@
|
|||||||
|
import pytest
|
||||||
|
import cv2
|
||||||
|
import numpy as np
|
||||||
|
from pipeline_b import star_detector
|
||||||
|
import re
|
||||||
|
|
||||||
|
def test_file_exists_and_is_an_image(tmp_path):
|
||||||
|
file = tmp_path / "image.jpg"
|
||||||
|
tableau_image = np.random.randint(0, 256, (64, 64), dtype=np.uint8)
|
||||||
|
cv2.imwrite(str(file), tableau_image)
|
||||||
|
assert isinstance(star_detector.reading_picture(file), np.ndarray)
|
||||||
|
|
||||||
|
def test_file_exists_not_an_image(tmp_path):
|
||||||
|
file = tmp_path / "file.txt"
|
||||||
|
file.write_text("Not an image.")
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
star_detector.reading_picture(file)
|
||||||
|
|
||||||
|
def test_file_does_not_exists(tmp_path):
|
||||||
|
with pytest.raises(FileNotFoundError):
|
||||||
|
star_detector.reading_picture(tmp_path/"do_I_exist.txt")
|
||||||
|
|
||||||
|
def test_blob_detector_actually_detects_a_blob():
|
||||||
|
tableau_image = np.zeros((64,64), dtype=np.uint8)
|
||||||
|
cv2.circle(tableau_image, center=(23, 31), radius = 5, color= 255, thickness=-1)
|
||||||
|
assertion = (star_detector.blob_detector(tableau_image) != [])
|
||||||
|
for star in star_detector.blob_detector(tableau_image):
|
||||||
|
if abs(star[0] - 23) > 0.001 or abs(star[1] - 31) > 0.001:
|
||||||
|
assertion = False
|
||||||
|
assert assertion == True
|
||||||
|
|
||||||
|
def test_relative_single_point():
|
||||||
|
assert star_detector.relative_coordinates_conversion([(23, 31)], (64, 64)) == [(23/64, 31/64)]
|
||||||
|
|
||||||
|
def test_relative_several_points_keep_order():
|
||||||
|
points = [(0, 0), (32, 16), (64, 64)]
|
||||||
|
assert star_detector.relative_coordinates_conversion(points, (64, 64)) == [(0.0, 0.0), (0.5, 0.25), (1.0, 1.0)]
|
||||||
|
|
||||||
|
def test_relative_empty_list():
|
||||||
|
assert star_detector.relative_coordinates_conversion([], (64, 64)) == []
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("size", [(32, 64), (64, 32)])
|
||||||
|
def test_relative_uses_longest_side_whatever_the_order(size):
|
||||||
|
# paysage et portrait : même repère (64), donc même résultat
|
||||||
|
assert star_detector.relative_coordinates_conversion([(16, 16)], size) == [(0.25, 0.25)]
|
||||||
|
|
||||||
|
def test_relative_keeps_geometry_on_non_square_image():
|
||||||
|
# même écart en pixels sur x et y -> même écart en relatif (un cercle reste un cercle)
|
||||||
|
(x, y), = star_detector.relative_coordinates_conversion([(10, 10)], (32, 64))
|
||||||
|
assert x == y
|
||||||
|
|
||||||
|
def test_relative_non_exact_division_uses_tolerance():
|
||||||
|
result = star_detector.relative_coordinates_conversion([(100, 250)], (500, 1000))
|
||||||
|
assert result[0] == pytest.approx((0.1, 0.25))
|
||||||
|
|
||||||
|
@pytest.mark.parametrize("size", [(0, 0), (0, 100), (100, 0), (-10, -20), (-1, 64)])
|
||||||
|
def test_relative_invalid_size_raises_value_error(size):
|
||||||
|
expected = re.escape(f"({size[0]}, {size[1]})")
|
||||||
|
with pytest.raises(ValueError, match=expected):
|
||||||
|
star_detector.relative_coordinates_conversion([(5, 5)], size)
|
||||||
|
|
||||||
|
def test_relative_invalid_size_wins_over_empty_list():
|
||||||
|
with pytest.raises(ValueError):
|
||||||
|
star_detector.relative_coordinates_conversion([], (0, 0))
|
||||||
Whitespace-only changes.
Whitespace-only changes.
Whitespace-only changes.
Reference in new issue
Block a user