def get_sensor_last_image(id): processor = ImageProcessor() print(f'requesting last image with id={id}') scaled_up = request.args.get('scale_up') scaled_up = 1 if scaled_up is None else int(scaled_up) interpolate = request.args.get('interpolate') interpolate = True if interpolate == "1" else False simulated = request.args.get('simulate') simulated = True if simulated == "1" else False if simulated: last_result = Measurement_test.query.filter( Measurement_test.sensor_id == id).order_by( Measurement_test.timestamp.desc()).first() else: last_result = Measurement.query.filter( Measurement.sensor_id == int(id)).order_by( Measurement.timestamp.desc()).first() #get processed frame processor.process(last_result.data) cv2_data = processor.plot_frame() img = fast_thermal_image(cv2_data, scale=scaled_up) return Response(img)
def get_last_thermal_image(): scaled_up = request.args.get('scale_up') scaled_up = 1 if scaled_up is None else int(scaled_up) interpolate = request.args.get('interpolate') interpolate = True if interpolate == "1" else False simulated = request.args.get('simulate') simulated = True if simulated == "1" else False print(scaled_up, interpolate) if simulated: last_result = Measurement_test.query.order_by( Measurement_test.timestamp.desc()).first() else: last_result = Measurement.query.order_by( Measurement.timestamp.desc()).first() img = fast_thermal_image(32, 24, last_result.data) print(f'Retrieved image from: {last_result.timestamp}') return serve_pil_image(img)
def _get_smooth_img(self): img = self.get_scaled(self.smooth_data, self.scale_imgs) return fast_thermal_image(img, deltas=self.deltas, dim=img.shape)
FPS = 20 amount_sensors = len(sensor_ids) amount_extra_webcams = 1 start_index = 424 frame_time_increase = timedelta(milliseconds=1000/FPS) cur_time = start_time + start_index * frame_time_increase for extra_time in range(start_index, time_diff * FPS): print(extra_time) cur_time += frame_time_increase cur_indices = [find_closest_time(meas, cur_time, cur_index) for meas, cur_index in zip(measurements, cur_indices)] raw_imgs = [fast_thermal_image(meas[index].data, smooth=False, side=False) for meas, index in zip(measurements, cur_indices)] smooth_imgs = [fast_thermal_image(meas[index].data, smooth=True, side=False) for meas, index in zip(measurements, cur_indices)] proc_imgs = [processed_color_plot(meas[index].data, mtplotlib=False, to_pil=True) for meas, index in zip(measurements, cur_indices)] webcam_imgs = [get_webcam_img(meas[index]) for meas, index in zip(measurements, cur_indices)] extra_webcams = [get_webcam_img(meas[index], sensor_id=-1) for meas, index in zip(measurements, cur_indices)] extra_webcam = None rescaled_webcam = [img.resize((320, 180)) if img is not None else None for img in webcam_imgs] for webcam in extra_webcams: if webcam is not None: extra_webcam = webcam break img_width = 1244 + amount_sensors * 340
def get_scaled_img(self): img = self.get_scaled(self.scaled_data, self.scale_imgs) return fast_thermal_image(img, dim=img.shape)