Shortcuts

Source code for mmrotate.datasets.pipelines.loading

# Copyright (c) OpenMMLab. All rights reserved.
import mmcv
import numpy as np
from mmdet.datasets.pipelines import LoadImageFromFile

from ..builder import ROTATED_PIPELINES


[docs]@ROTATED_PIPELINES.register_module() class LoadPatchFromImage(LoadImageFromFile): """Load an patch from the huge image. Similar with :obj:`LoadImageFromFile`, but only reserve a patch of ``results['img']`` according to ``results['win']``. """ def __call__(self, results): """Call functions to add image meta information. Args: results (dict): Result dict with image in ``results['img']``. Returns: dict: The dict contains the loaded patch and meta information. """ img = results['img'] x_start, y_start, x_stop, y_stop = results['win'] width = x_stop - x_start height = y_stop - y_start patch = img[y_start:y_stop, x_start:x_stop] if height > patch.shape[0] or width > patch.shape[1]: patch = mmcv.impad(patch, shape=(height, width)) if self.to_float32: patch = patch.astype(np.float32) results['filename'] = None results['ori_filename'] = None results['img'] = patch results['img_shape'] = patch.shape results['ori_shape'] = patch.shape results['img_fields'] = ['img'] return results
Read the Docs v: v0.3.2
Versions
latest
stable
v0.3.2
v0.3.1
v0.3.0
v0.2.0
v0.1.1
v0.1.0
main
dev
Downloads
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.