Example #1
0
 def initCamera(self):
     self.icic = IC_ImagingControl()
     self.icic.init_library()
     cam_names = self.icic.get_unique_device_names()
     self.camName = cam_names[0]
     self.cam = self.icic.get_device(self.camName)
     self.cam.open()
     self.cam.set_video_norm('PAL_B')
     self.imgHeight = self.cam.get_video_format_height()
     self.imgWidth = self.cam.get_video_format_width()
     self.imgDepth = 3  # 3 colours for RGB
     self.bufferSize = self.imgHeight * self.imgWidth * self.imgDepth * sizeof(
         c_uint8)
     self.cam.enable_trigger(True)
     if not self.cam.callback_registered:
         self.cam.register_frame_ready_callback()
     self.cam.enable_continuous_mode(True)
     self.cam.start_live(show_display=False)  # start imaging
     print("Camera %s initialised. Resolution is %d x %d" %
           (self.camName, self.imgWidth, self.imgHeight))
Example #2
0
class ImagingSourceImager(LifetimeImager):
    def __init__(self):
        super(ImagingSourceImager, self).__init__()
        self.trim = 5
        self.doTrim = True
        self.doBadPixles = True
        self.badPixels = [(142, 15), (142, 16), (142, 17), (264, 320),
                          (264, 321), (264, 322), (264, 323), (264, 324),
                          (264, 325)]

    def initCamera(self):
        self.icic = IC_ImagingControl()
        self.icic.init_library()
        cam_names = self.icic.get_unique_device_names()
        self.camName = cam_names[0]
        self.cam = self.icic.get_device(self.camName)
        self.cam.open()
        self.cam.set_video_norm('PAL_B')
        self.imgHeight = self.cam.get_video_format_height()
        self.imgWidth = self.cam.get_video_format_width()
        self.imgDepth = 3  # 3 colours for RGB
        self.bufferSize = self.imgHeight * self.imgWidth * self.imgDepth * sizeof(
            c_uint8)
        self.cam.enable_trigger(True)
        if not self.cam.callback_registered:
            self.cam.register_frame_ready_callback()
        self.cam.enable_continuous_mode(True)
        self.cam.start_live(show_display=False)  # start imaging
        print("Camera %s initialised. Resolution is %d x %d" %
              (self.camName, self.imgWidth, self.imgHeight))

    def closeCamera(self):
        self.cam.stop_live()
        self.icic.close_library()

    def captureFrame(self):
        self.cam.reset_frame_ready()
        self.cam.wait_til_frame_ready(3000)

        img_ptr = self.cam.get_buffer()
        img_data = cast(img_ptr, POINTER(c_ubyte * self.bufferSize))

        arr = np.ndarray(buffer=img_data.contents,
                         dtype=np.uint8,
                         shape=(self.imgHeight, self.imgWidth, self.imgDepth))
        arr = arr[:, :, 0]
        arr = np.rot90(arr, 2)
        arr = arr.astype(np.uint8)
        if (self.doTrim):
            arr = arr[self.trim:arr.shape[0] - self.trim,
                      self.trim:arr.shape[1] - self.trim]
        if (self.doBadPixels):
            for (x, y) in self.badPixels:
                arr[x, y] = arr[x - 1, y]
        if (self.doBlur):
            arr = cv2.blur(arr, (self.blurSize, self.blurSize))

        return arr
Example #3
0
 def getCamera(self):
     if (self.imager == None):
         icic = IC_ImagingControl()
         icic.init_library()
         if (len(icic.get_unique_device_names()) > 0):
             print("Imaging Source camera found")
             icic.close_library()
             self.imager = ImagingSourceImager()
         else:
             raise Exception(
                 "Cannot instantiate a camera. Imaging Source not detected. Opticstar nonfunctional."
             )
     return self.imager
Example #4
0
	def getCamera(self):
		if (self.imager == None):
			icic = IC_ImagingControl()
			icic.init_library()
			if (len(icic.get_unique_device_names()) > 0):
				print("Imaging Source camera found")
				icic.close_library()
				self.imager = ImagingSourceImager()
			else:
				raise Exception("Cannot instantiate a camera. Imaging Source not detected. Opticstar nonfunctional.")
		return self.imager
Example #5
0
class ImagingSourceImager(LifetimeImager):
	def __init__(self):
		super(ImagingSourceImager, self).__init__()
		self.trim = 5
		self.doTrim = True
		self.doBadPixles = True
		self.badPixels = [(142,15),(142,16),(142,17),
                                  (264,320),(264,321),(264,322),
                                  (264,323),(264,324),(264,325)]
	
	def initCamera(self):
		self.icic = IC_ImagingControl()
		self.icic.init_library()
		cam_names = self.icic.get_unique_device_names()
		self.camName = cam_names[0]
		self.cam = self.icic.get_device(self.camName)
		self.cam.open()
		self.cam.set_video_norm('PAL_B')
		self.imgHeight = self.cam.get_video_format_height()
		self.imgWidth = self.cam.get_video_format_width()
		self.imgDepth = 3 # 3 colours for RGB
		self.bufferSize = self.imgHeight * self.imgWidth * self.imgDepth * sizeof(c_uint8)
		self.cam.enable_trigger(True)
		if not self.cam.callback_registered:
			self.cam.register_frame_ready_callback()
		self.cam.enable_continuous_mode(True)
		self.cam.start_live(show_display=False) # start imaging
		print("Camera %s initialised. Resolution is %d x %d" % (self.camName, self.imgWidth, self.imgHeight))
		
	def closeCamera(self):
		self.cam.stop_live()
		self.icic.close_library()
	
	def captureFrame(self):
		self.cam.reset_frame_ready();
		self.cam.wait_til_frame_ready(3000);

		img_ptr = self.cam.get_buffer()
		img_data = cast(img_ptr, POINTER(c_ubyte * self.bufferSize))

		arr = np.ndarray(buffer = img_data.contents, dtype = np.uint8, shape = (self.imgHeight, self.imgWidth, self.imgDepth))
		arr = arr[:,:,0]
		arr = np.rot90(arr, 2)
		arr = arr.astype(np.uint8)
		if (self.doTrim):
			arr = arr[self.trim:arr.shape[0]-self.trim,self.trim:arr.shape[1]-self.trim]
		if (self.doBadPixels):
			for (x,y) in self.badPixels:
				arr[x,y] = arr[x-1,y]
		if (self.doBlur):
			arr = cv2.blur(arr,(self.blurSize,self.blurSize))
			
		return arr
Example #6
0
	def initCamera(self):
		self.icic = IC_ImagingControl()
		self.icic.init_library()
		cam_names = self.icic.get_unique_device_names()
		self.camName = cam_names[0]
		self.cam = self.icic.get_device(self.camName)
		self.cam.open()
		self.cam.set_video_norm('PAL_B')
		self.imgHeight = self.cam.get_video_format_height()
		self.imgWidth = self.cam.get_video_format_width()
		self.imgDepth = 3 # 3 colours for RGB
		self.bufferSize = self.imgHeight * self.imgWidth * self.imgDepth * sizeof(c_uint8)
		self.cam.enable_trigger(True)
		if not self.cam.callback_registered:
			self.cam.register_frame_ready_callback()
		self.cam.enable_continuous_mode(True)
		self.cam.start_live(show_display=False) # start imaging
		print("Camera %s initialised. Resolution is %d x %d" % (self.camName, self.imgWidth, self.imgHeight))