feat(pipeline-b): ajout de relative_coordinates_conversion, coordonnées relatives au plus grand côté de l'image
This commit is contained in:
1 parent
8f8518320b
commit
bff07da132
1 file changed
+13
-1
@@ -28,4 +28,16 @@ def blob_detector(picture):
|
|||||||
detector = cv2.SimpleBlobDetector.create(params)
|
detector = cv2.SimpleBlobDetector.create(params)
|
||||||
stars = detector.detect(picture)
|
stars = detector.detect(picture)
|
||||||
result = [star.pt for star in stars]
|
result = [star.pt for star in stars]
|
||||||
return result
|
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
|
||||||
Reference in new issue
Block a user