Exemple #1
0
	def getPixelClockRange(self):
		self.PixelClockRange=[ueye.c_uint() for i in range(3)]
		self.PixelClockRange=(ueye.c_uint*3)(*self.PixelClockRange)
		if ueye.is_PixelClock(self.hcam, ueye.IS_PIXELCLOCK_CMD_GET_RANGE, self.PixelClockRange, ueye.sizeof(self.PixelClockRange)):
			_logger.error("Error retrinving pixelclock range")
			self.status=True
			return True
Exemple #2
0
    def set_pixelclock(self, pixelclock):
        """
        Set the current pixelclock.

        Params
        =======
        pixelclock: number
            Current pixelclock.
        """
        # Warning
        print('Warning: when changing pixelclock at runtime, you may need to '
              'update the fps and exposure parameters')
        # get pixelclock range
        pcrange = (ueye.c_uint * 3)()
        check(
            ueye.is_PixelClock(self.h_cam, ueye.IS_PIXELCLOCK_CMD_GET_RANGE,
                               pcrange, 12))
        pcmin, pcmax, pcincr = pcrange
        if pixelclock < pcmin:
            pixelclock = pcmin
            print(f"Pixelclock out of range [{pcmin}, {pcmax}] and set "
                  f"to {pcmin}")
        elif pixelclock > pcmax:
            pixelclock = pcmax
            print(f"Pixelclock out of range [{pcmin}, {pcmax}] and set "
                  f"to {pcmax}")
        # Set pixelclock
        pixelclock = ueye.c_uint(pixelclock)
        check(
            ueye.is_PixelClock(self.h_cam, ueye.IS_PIXELCLOCK_CMD_SET,
                               pixelclock, 4))
Exemple #3
0
 def set_pixelclock(self, pixelclock):
     """
     Get the current pixelclock.
     Returns
     =======
     pixelclock: number
         Current pixelclock.
     """
     PCrange = (ctypes.c_uint * 3)()
     self.nRet = ueye.is_PixelClock(self.cam, 
                                     ueye.IS_PIXELCLOCK_CMD_GET_RANGE, 
                                     PCrange,
                                     12)
     if self.nRet != ueye.IS_SUCCESS:
         error_log(self.nRet, "is_PixelClock")
     pcmin, pcmax, pcincr = PCrange
     if pixelclock < pcmin:
         pixelclock = pcmin
         print(f"Pixelclock out of range [{pcmin}, {pcmax}] and set "
               f"to {pcmin}")
     elif pixelclock > pcmax:
         pixelclock = pcmax
         print(f"Pixelclock out of range [{pcmin}, {pcmax}] and set "
               f"to {pcmax}")
     pixelclock = ueye.c_uint(pixelclock)
     self.nRet = ueye.is_PixelClock(self.cam, 
                                     ueye.IS_PIXELCLOCK_CMD_SET,
                                     pixelclock, 4)
     if self.nRet != ueye.IS_SUCCESS:
         error_log(self.nRet, "is_PixelClock")
Exemple #4
0
	def getPixelClock(self):
		self.pixelClock=ueye.c_uint()
		if ueye.is_PixelClock(self.hcam, ueye.IS_PIXELCLOCK_CMD_GET, self.pixelClock, ueye.sizeof(ueye.c_uint)):
			self.status=True
			_logger.error("Error retrinving PixelClock")
			return True
		return False
Exemple #5
0
def main(config_path="/home/oran/Pictures/Settings/default-camera-settings.ini"
         ):
    print(config_path)
    # we need a QApplication, that runs our QT Gui Framework
    app = PyuEyeQtApp()

    # a basic qt window
    view = PyuEyeQtView()
    view.resize(1920 / 1.5, 1080 / 1.5)
    view.show()
    #update_config_gain(update={'red': '0','green' : '0','blue':'0'},set=True)
    #update_config_exposure(update=70,set=True)
    # view.user_callback = adjust_manually
    view.user_callback = print_means
    # view.user_callback = adjust_manually
    # camera class to simplify uEye API access
    cam = Camera()
    cam.init()
    # cam.set
    cam.set_colormode(ueye.IS_CM_BGR8_PACKED)
    pParam = ueye.wchar_p()
    pParam.value = config_path
    ueye.is_ParameterSet(1, ueye.IS_PARAMETERSET_CMD_LOAD_FILE, pParam, 0)

    # cam.set(cv2.cv.CV_CAP_PROP_EXPOSURE, 10)

    # cam.__getattribute__('is_CameraStatus')
    # cam.__setattr__('GetCameraInfo',0)
    #cam.set_aoi(0,0, 1280, 1024)
    cam.set_aoi(0, 0, 4912, 3684)
    cam.alloc()
    cam.capture_video()
    ueye._is_GetError
    ueye.is_Exposure(1,
                     ueye.c_uint(1),
                     ueye.c_void_p(),
                     cbSizeOfParam=ueye.c_int(0))
    # ueye.IS_EXPOSURE_CMD_GET_FINE_INCREMENT_RANGE_MIN = 20
    # ueye.IS_EXPOSURE_CMD_GET_FINE_INCREMENT_RANGE_MAX = 21

    # a thread that waits for new images and processes all connected views
    thread = FrameThread(cam, view)
    thread.start()

    # update_config_gain()

    # cleanup
    app.exit_connect(thread.stop)
    app.exec_()

    thread.stop()
    thread.join()

    cam.stop_video()
    cam.exit()
Exemple #6
0
	def setPixelClock(self, value):
		self.getPixelClockRange()
		if (value<self.PixelClockRange[0].value) & (value>self.PixelClockRange[1].value):
			self.status=True
			return True

		ran=np.arange(self.PixelClockRange[0].value, self.PixelClockRange[1].value, self.PixelClockRange[2].value)
		nwv=ueye.c_uint(ran[np.abs(ran-value).argmin()])
		if ueye.is_PixelClock(self.hcam, ueye.IS_PIXELCLOCK_CMD_SET, nwv, ueye.sizeof(nwv)):
			self.status=True
			return True
		return False
Exemple #7
0
    def get_pixelclock(self):
        """
        Get the current pixelclock.

        Returns
        =======
        pixelclock: number
            Current pixelclock.
        """
        pixelclock = ueye.c_uint()
        check(ueye.is_PixelClock(self.h_cam, ueye.IS_PIXELCLOCK_CMD_GET,
                                 pixelclock, 4))
        return pixelclock
Exemple #8
0
    def Camera_Initialization(self):
        self.hcam = ueye.HIDS(0)
        self.ret = ueye.is_InitCamera(self.hcam, None)
        self.ret = ueye.is_SetColorMode(self.hcam, ueye.IS_CM_MONO12)
        self.IDS_FPS = float(50)
        self.newrate = ueye.DOUBLE(self.IDS_FPS)
        self.rate = ueye.DOUBLE(self.IDS_FPS)
        self.IDS_exposure = float(20)

        self.width = 2056
        self.height = 1542
        self.rect_aoi = ueye.IS_RECT()
        self.rect_aoi.s32X = ueye.int(0)
        self.rect_aoi.s32Y = ueye.int(0)
        self.rect_aoi.s32Width = ueye.int(self.width)
        self.rect_aoi.s32Height = ueye.int(self.height)
        ueye.is_AOI(self.hcam, ueye.IS_AOI_IMAGE_SET_AOI, self.rect_aoi,
                    ueye.sizeof(self.rect_aoi))

        self.mem_ptr = ueye.c_mem_p()
        self.mem_id = ueye.int()
        self.bitspixel = 16
        self.ret = ueye.is_AllocImageMem(self.hcam, self.width, self.height,
                                         self.bitspixel, self.mem_ptr,
                                         self.mem_id)

        self.ret = ueye.is_SetImageMem(self.hcam, self.mem_ptr, self.mem_id)
        self.ret = ueye.is_CaptureVideo(self.hcam, ueye.IS_DONT_WAIT)
        #self.lineinc = self.width * int((self.bitspixel + 7) / 8)
        self.lineinc = self.width * int(self.bitspixel / 8)

        self.nRet = ueye.is_SetFrameRate(self.hcam, self.rate, self.newrate)
        self.expms = ueye.DOUBLE(self.IDS_exposure)
        self.nRet = ueye.is_Exposure(self.hcam,
                                     ueye.IS_EXPOSURE_CMD_SET_EXPOSURE,
                                     self.expms, ueye.sizeof(self.expms))

        self.pixelclock = ueye.c_uint(197)
        self.nRet = ueye.is_PixelClock(self.hcam, ueye.IS_PIXELCLOCK_CMD_SET,
                                       self.pixelclock, 4)
        #pixelclock = ueye.c_uint()
        #ueye.is_PixelClock(hcam, ueye.IS_PIXELCLOCK_CMD_GET, pixelclock, 4)

        self.nRet = ueye.is_SetHardwareGain(self.hcam, 100,
                                            ueye.IS_IGNORE_PARAMETER,
                                            ueye.IS_IGNORE_PARAMETER,
                                            ueye.IS_IGNORE_PARAMETER)
        #gg = ueye.c_uint()
        #ueye.is_SetHWGainFactor(hcam, ueye.IS_GET_MASTER_GAIN_FACTOR, gg)
        self.nRet = ueye.is_SetHardwareGamma(self.hcam,
                                             ueye.IS_SET_HW_GAMMA_ON)
Exemple #9
0
 def capture_status(self):
     """
     Check capture status.
     Returns
     =======
     nRet: integer
         Capture status.
     """
     info = ueye.c_uint()
     nRet = ueye.is_CaptureStatus(self.cam, 
                                       ueye.IS_CAPTURE_STATUS_INFO_CMD_GET,
                                       info,
                                       ueye.sizeof(info))
     return nRet
Exemple #10
0
 def get_pixelclock(self):
     """
     Get the current pixelclock.
     Returns
     =======
     pixelclock: number
         Current pixelclock.
     """
     pixelclock = ueye.c_uint()
     self.nRet = ueye.is_PixelClock(self.cam, ueye.IS_PIXELCLOCK_CMD_GET,
                                     pixelclock, 4)
     if self.nRet != ueye.IS_SUCCESS:
         error_log(self.nRet, "is_PixelClock")
     return pixelclock
Exemple #11
0
 def setPixelClock(self, mhz):
     px_old = ueye.c_uint(0)
     ueye.is_PixelClock(self.hCam, ueye.IS_PIXELCLOCK_CMD_GET, px_old, ueye.sizeof(px_old))
     px = ueye.c_uint(mhz)
     rv = ueye.is_PixelClock(self.hCam, ueye.IS_PIXELCLOCK_CMD_SET, px, ueye.sizeof(px))