diff --git a/script/device/Image.py b/script/device/Image.py index 4b16d81..b3772f5 100644 --- a/script/device/Image.py +++ b/script/device/Image.py @@ -79,20 +79,28 @@ class Image(DeviceBase, Readable): tmp_file = self.pixel.image_root_folder + "tmp/spec_image_info.dat" copyfile(filename, tmp_file) - ret = img_get_int(tmp_file, threshold1, threshold2, threshold3, threshold4, \ + try: + ret = img_get_int(tmp_file, threshold1, threshold2, threshold3, threshold4, \ self.pixel.IMAGE_HEADER_LENGTH, self.pixel.PIX_XDIM, self.pixel.PIX_YDIM,self.pixel.PIX_COLOR_DEPTH, \ self.roi[0], self.roi[1], self.roi[2], self.roi[3], self.broi[0], self.broi[1], self.broi[2], self.broi[3]) - + except: + log("Error calculating intensity: " + str(filename) + " - " + str(sys.argv[1]), False) + ret = None self.setCache(ret, None) return ret def get_image(self, filename = None): if filename is None: filename = self.pixel.get_image_filename() - if str(filename) == str(self.last_filename): + filename = str(filename) + if filename == self.last_filename: return self.last_image print "Reading image : " + filename - ret = img_read(filename, self.pixel.IMAGE_HEADER_LENGTH, self.pixel.PIX_XDIM, self.pixel.PIX_YDIM,self.pixel.PIX_COLOR_DEPTH) + try: + ret = img_read(filename, self.pixel.IMAGE_HEADER_LENGTH, self.pixel.PIX_XDIM, self.pixel.PIX_YDIM,self.pixel.PIX_COLOR_DEPTH) + except: + log("Error reading data file: " + str(filename) + " - " + str(sys.argv[1]), False) + return None ret = Convert.reshape(ret, self.pixel.PIX_YDIM, self.pixel.PIX_XDIM) self.last_filename = filename self.last_image = ret