Skip to content
Snippets Groups Projects
Commit 21c83af9 authored by Anjith GEORGE's avatar Anjith GEORGE
Browse files

Resixe option

parent 2150f0ab
No related branches found
No related tags found
No related merge requests found
Pipeline #38139 failed
...@@ -436,25 +436,32 @@ class FaceCropAlign(Preprocessor): ...@@ -436,25 +436,32 @@ class FaceCropAlign(Preprocessor):
""" """
Resizes a grayscale/RGB/MC image image with self.scale Resizes a grayscale/RGB/MC image image with self.scale
""" """
print("Image shape: {}. scale: {}".format(image.shape,self.scale))
if len(image.shape) == 2: if len(image.shape) == 2:
rimg=cv2.resize(image, None, fx=self.scale, fy=self.scale, interpolation=cv2.INTER_LINEAR) rimg=cv2.resize(image, None, fx=self.scale, fy=self.scale, interpolation=cv2.INTER_LINEAR)
else: # TODO This part else: # TODO This part
rimg=[] rimg=[]
for channel in image: for channel in image:
timg=cv2.resize(image, None, fx=self.scale, fy=self.scale, interpolation=cv2.INTER_LINEAR) timg=cv2.resize(channel, None, fx=self.scale, fy=self.scale, interpolation=cv2.INTER_LINEAR)
rimg.append(timg) rimg.append(timg)
rimg=np.stack(rimg) rimg=np.stack(rimg)
return rimg return rimg
def scale_annotations(self, frame_annotations): def scale_annotations(self, frame_annotations, down=True):
scaled_annotations = {} scaled_annotations = {}
if down:
scale=self.scale
else:
scale=1.0/self.scale
for key in frame_annotations.keys(): for key in frame_annotations.keys():
if key!='quality': if key!='quality':
scaled_annotations[key]=(int(frame_annotations[key][0]*self.scale),int(frame_annotations[key][1]*self.scale)) scaled_annotations[key]=(int(frame_annotations[key][0]*scale),int(frame_annotations[key][1]*scale))
else: else:
scaled_annotations[key]=int(frame_annotations[key]) scaled_annotations[key]=int(frame_annotations[key])
...@@ -564,11 +571,13 @@ class FaceCropAlign(Preprocessor): ...@@ -564,11 +571,13 @@ class FaceCropAlign(Preprocessor):
# TODO: Scale the image and annotations here # TODO: Scale the image and annotations here
print("Image shape: {}. scale: {}".format(image.shape,self.scale))
if self.scale!=1.0: if self.scale!=1.0:
image = self.scale_image(image) image = self.scale_image(image)
annotations = self.scale_annotations(annotations) annotations = self.scale_annotations(annotations, down=True)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment