def coloured_image_from_raw(self,raw_values, image_scalar): STORED_IMAGE_NAME = "DetectionImage1.jpg" lepton_object = Lepton_interface() # Convert raw data to 8 bit image - takes 0.0008s bit8_image = lepton_object.raw_to_8bit(raw_values) bit8_image = bit8_image.astype(uint8) # Remove non-needed dimension bit8_image = bit8_image.squeeze() # Colour image takes ~0.005 coloured_image = self.colour_thermal_image(bit8_image) # Scale 8 bit coloured image # CV_INTER_CUBIC might be used - slow but looks better. INTER_NEAREST. # INTER_LINEAR takes ~0.025s INTER_CUBIC - ~0.07s. Nearest - 0.01s coloured_image = cv2.resize(coloured_image, (0,0), None, image_scalar, image_scalar, cv2.INTER_LINEAR) # Takes ~0.2s, updated one takes ~0.0001s # cv2.imwrite(STORED_IMAGE_NAME, np.uint8(coloured_image)) # Write the image to file mat_array = cv.fromarray(coloured_image) # Take the image from file as SIMPLECV image. Updated one ~0.005s simplecv_img = Image(mat_array) # simplecv_img = Image(STORED_IMAGE_NAME) return simplecv_img
def coloured_image_from_raw(self, raw_values, image_scalar): STORED_IMAGE_NAME = "DetectionImage1.jpg" lepton_object = Lepton_interface() # Convert raw data to 8 bit image - takes 0.0008s bit8_image = lepton_object.raw_to_8bit(raw_values) bit8_image = bit8_image.astype(uint8) # Remove non-needed dimension bit8_image = bit8_image.squeeze() # Colour image takes ~0.005 coloured_image = self.colour_thermal_image(bit8_image) # Scale 8 bit coloured image # CV_INTER_CUBIC might be used - slow but looks better. INTER_NEAREST. # INTER_LINEAR takes ~0.025s INTER_CUBIC - ~0.07s. Nearest - 0.01s coloured_image = cv2.resize(coloured_image, (0, 0), None, image_scalar, image_scalar, cv2.INTER_LINEAR) # Takes ~0.2s, updated one takes ~0.0001s # cv2.imwrite(STORED_IMAGE_NAME, np.uint8(coloured_image)) # Write the image to file mat_array = cv.fromarray(coloured_image) # Take the image from file as SIMPLECV image. Updated one ~0.005s simplecv_img = Image(mat_array) # simplecv_img = Image(STORED_IMAGE_NAME) return simplecv_img