assignment-a3: adds code
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import glob
|
||||
import os
|
||||
from typing import List
|
||||
import numpy as np
|
||||
|
||||
@@ -6,22 +8,31 @@ class AnnotationRect:
|
||||
"""Exercise 3.1"""
|
||||
|
||||
def __init__(self, x1, y1, x2, y2):
|
||||
raise NotImplementedError()
|
||||
self.x1 = x1
|
||||
self.x2 = x2
|
||||
self.y1 = y1
|
||||
self.y2 = y2
|
||||
|
||||
def area(self):
|
||||
raise NotImplementedError()
|
||||
return (self.x2 - self.x1) * (self.y2 - self.y1)
|
||||
|
||||
def __array__(self) -> np.ndarray:
|
||||
raise NotImplementedError()
|
||||
return np.array([self.x1, self.y1, self.x2, self.y2])
|
||||
|
||||
@staticmethod
|
||||
def fromarray(arr: np.ndarray):
|
||||
raise NotImplementedError()
|
||||
return AnnotationRect(arr[0], arr[1], arr[2], arr[3])
|
||||
|
||||
|
||||
def read_groundtruth_file(path: str) -> List[AnnotationRect]:
|
||||
"""Exercise 3.1b"""
|
||||
raise NotImplementedError()
|
||||
annotationRects = []
|
||||
with open(path, 'r') as file:
|
||||
for line in file:
|
||||
if line.strip():
|
||||
values = line.strip().split()
|
||||
annotationRects.append(AnnotationRect(float(values[0]), float(
|
||||
values[1]), float(values[2]), float(values[3])))
|
||||
return annotationRects
|
||||
|
||||
|
||||
# put your solution for exercise 3.1c wherever you deem it right
|
||||
|
||||
Reference in New Issue
Block a user