def get_env(self): now = datetime.datetime.now() uptime = now - self.launch_time days = uptime.days minutes, seconds = divmod(uptime.seconds, utilities.SECONDS_PER_MINUTE) hours, minutes = divmod(minutes, utilities.MINUTES_PER_HOUR) s = (''' Smart Module Status Software Version v{version} Running on: {platform} Encoding: {encoding} Python Information - Executable: {executable} - v{sys_version} - location: {executable} Timestamp: {timestamp} Uptime: This Smart Module has been online for: {days} days, {hours} hours, {minutes} minutes and {seconds} seconds. ''').format( version=utilities.VERSION, platform=sys.platform, encoding=sys.getdefaultencoding(), executable=sys.executable, sys_version=sys.version.split()[0], timestamp=now.strftime('%Y-%m-%d %H:%M:%S'), days=days, hours=hours, minutes=minutes, seconds=seconds, ) s = utilities.trim(s) + '\n' try: self.comm.send("ENV/RESPONSE", s) except Exception as excpt: Log.exception("Error getting environment data: %s.", excpt)
def preprocess_data(img, dim=100): ''' this function preprocesses and augments the image Args: img: image data dim (int): dimension the image should be reduced to Returns: img (np.array): preprocessed image ''' img = crop_center(img) img = cv2.resize(img, (dim, dim)) img_seg = segmentation(img) img_seg = trim(img_seg) img_seg = cv2.resize(img_seg, (dim, dim)) img_gaus = cv2.GaussianBlur(img, (5, 5), 0) img_gaus = cv2.cvtColor(img_gaus, cv2.COLOR_RGB2BGR) img_hog = hog_features(img) img_hu = hu_moments(img) img_col = col_histogram(img) img = np.hstack([img_seg.flatten(), img_hog, img_hu, img_col]) return img
def get_allowed_in_square_of(self, x, y): xs = trim(x, self._step) ys = trim(y, self._step) n2 = self._step vals = [ self._board.get(i+xs,k+ys) for i in range(n2) for k in range(n2) ] return self._missing(vals)