kopia lustrzana https://github.com/OpenDroneMap/ODM
Use max_dimension instead of output_resolution
rodzic
3296aa7a51
commit
270da0b757
|
|
@ -24,7 +24,10 @@ class Parameters:
|
|||
if not os.path.exists(args["output"]):
|
||||
os.makedirs(args["output"])
|
||||
|
||||
self.input = args["input"].split(",")
|
||||
self.input = args["input"]
|
||||
if isinstance(self.input, str):
|
||||
self.input = [self.input]
|
||||
|
||||
self.output = args["output"]
|
||||
self.start = args.get("start", 0)
|
||||
self.end = args.get("end", None)
|
||||
|
|
@ -35,10 +38,7 @@ class Parameters:
|
|||
self.pixel_black_threshold = args.get("pixel_black_threshold", None)
|
||||
self.use_srt = "use_srt" in args
|
||||
self.frame_format = args.get("frame_format", "jpg")
|
||||
|
||||
# TODO: use max dimension
|
||||
self.output_resolution = None
|
||||
#self.output_resolution = tuple(map(int, args["output_resolution"].split("x"))) if args["output_resolution"] else None
|
||||
self.max_dimension = args.get("max_dimension", None)
|
||||
|
||||
self.stats_file = args.get("stats_file", None)
|
||||
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ class Video2Dataset:
|
|||
self.f.close()
|
||||
|
||||
if self.parameters.limit is not None and self.global_idx >= self.parameters.limit:
|
||||
print("Limit of {} frames reached, trimming dataset to {} frames".format(self.parameters.limit, self.global_idx))
|
||||
print("Limit of {} frames reached, trimming dataset".format(self.parameters.limit))
|
||||
limit_files(output_file_paths, self.parameters.limit)
|
||||
|
||||
end = time.time()
|
||||
|
|
@ -183,9 +183,13 @@ class Video2Dataset:
|
|||
return res
|
||||
|
||||
def SaveFrame(self, frame, video_info, srt_parser: SrtFileParser):
|
||||
|
||||
if (self.parameters.output_resolution is not None):
|
||||
frame = cv2.resize(frame, self.parameters.output_resolution)
|
||||
max_dim = self.parameters.max_dimension
|
||||
if max_dim is not None:
|
||||
h, w, _ = frame.shape
|
||||
if max_dim < w or max_dim < h:
|
||||
m = max(w, h)
|
||||
factor = max_dim / m
|
||||
frame = cv2.resize(frame, (int(ceil(w * factor)), int(ceil(h * factor))))
|
||||
|
||||
path = os.path.join(self.parameters.output,
|
||||
"frame_{}_{}.{}".format(self.global_idx, self.frame_index, self.parameters.frame_format))
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue