JeVoisBase  1.22
JeVois Smart Embedded Machine Vision Toolkit Base Modules
Share this page:
Loading...
Searching...
No Matches
recognition.py
Go to the documentation of this file.
1import os
2
3import numpy as np
4import cv2 as cv
5
6from .base_dataloader import _BaseImageLoader
7from ..factory import DATALOADERS
8
9@DATALOADERS.register
11 def __init__(self, **kwargs):
12 super().__init__(**kwargs)
13
14 self._labels = self._load_label()
15
16 def _load_label(self):
17 labels = dict.fromkeys(self._files, None)
18 for filename in self._files:
19 labels[filename] = np.loadtxt(os.path.join(self._path, '{}.txt'.format(filename[:-4])), ndmin=2)
20 return labels
21
22 def __iter__(self):
23 for filename in self._files:
24 image = cv.imread(os.path.join(self._path, filename))
25 if [0, 0] in self._sizes:
26 yield filename, image, self._labels[filename]
27 else:
28 for size in self._sizes:
29 image_r = cv.resize(image, size)
30 yield filename, image_r, self._labels[filename]