Exemple #1
0
    def __init__(self):
        # Variabeln für Kameraverarbeitung
        self.h_cam = ueye.HIDS(0)
        self.pitch = ueye.INT()
        self.ColorMode = ueye.IS_CM_BGRA8_PACKED
        self.nBitsPerPixel = ueye.INT(32)
        self.bytes_per_pixel = int(self.nBitsPerPixel / 8)
        self.pitch = ueye.INT()
        self.pcImageMemory = ueye.c_mem_p()
        self.rectAOI = ueye.IS_RECT()
        self.MemID = ueye.int()
        self.width = None
        self.height = None

        self.size_of_square = 3.6  # Zentimeter
        self.nx = 8
        self.ny = 6
        self.n_im = 0
        self.gray = None
        self.objectpoints = None
        self.imagepoints = None
        self.camera_matrix = None
        self.dist_coeff = None
        self.mean_error = 0

        # Pfad zum Speichern der Bilder angeben
        self.path = os.path.dirname(os.path.abspath(sys.argv[0])) + "/images/"
Exemple #2
0
    def __init__(self, camID, buffer_count=3):
        # Variables
        self.cam = ueye.HIDS(camID)
        self.sInfo = ueye.SENSORINFO()
        self.cInfo = ueye.CAMINFO()
        self.pcImageMemory = ueye.c_mem_p()
        self.MemID = ueye.int()
        self.rectAOI = ueye.IS_RECT()
        self.pitch = ueye.INT()
        self.nBitsPerPixel = ueye.INT(8)
        self.channels = 3
        self.m_nColorMode = ueye.IS_CM_SENSOR_RAW8
        self.bytes_per_pixel = int(self.nBitsPerPixel / 8)
        self.buffer_count = buffer_count
        self.img_buffer = []
        self.mode_filename = 0

        self.pixelclock = 0
        self.exposure = 0
        self.width = 0
        self.height = 0
        self.nRet = 0
        self.camID = camID
        self.current_fps = 0
        self.FPS = 0
        self.gain = 0
        self.rGain = 0
        self.bGain = 0
        self.gGain = 0
Exemple #3
0
def grabanimage():
    camera_port = 0
    ramp_frames = 40
    camera = cv2.VideoCapture(camera_port)

    ################## original (access camera thru cv2) ##########################

    #    def get_image():
    #        retval, im = camera.read()
    #        return im
    #
    #    for i in xrange(ramp_frames):
    #        temp = get_image()
    #    print("Taking image...")
    ## Take the actual image we want to keep
    #    camera_capture = get_image()
    #    file = "USBtemp.png"
    ## A nice feature of the imwrite method is that it will automatically choose the
    ## correct format based on the file extension you provide. Convenient!
    #    cv2.imwrite(file, camera_capture)

    ############# reading from IDS camera (added 6/1/19 by Abner) #################

    def get_image(w, h):
        im = ueye.get_data(mem_ptr, w, h, bitspixel, lineinc, copy=True)
        return im

    # init camera
    hcam = ueye.HIDS(0)
    initTrigger = ueye.is_InitCamera(hcam, None)

    # load camera parameters
    memory = ueye.int(128)
    #    cameraSettingFile = ueye.wchar_p('/media/pi/USB30FD/Frostad Research Group/Biofilm Project/Code/FINAL_Biofilm Project.ini')
    ret = ueye.is_ParameterSet(hcam, ueye.IS_PARAMETERSET_CMD_LOAD_FILE,
                               cameraSettingFile, memory)
    # set color mode
    ret = ueye.is_SetColorMode(hcam, ueye.IS_CM_BGR8_PACKED)
    # set width and height -- FIND FUNCTION TO OUTPUT IMAGE RESOLUTION
    width = 2560
    height = 1920
    # allocate memory
    mem_ptr = ueye.c_mem_p()
    mem_id = ueye.int()
    bitspixel = 24  # for colormode = IS_CM_BGR8_PACKED
    ret = ueye.is_AllocImageMem(hcam, width, height, bitspixel, mem_ptr,
                                mem_id)
    # set active memory region
    ret = ueye.is_SetImageMem(hcam, mem_ptr, mem_id)
    # continuous capture to memory
    ret = ueye.is_CaptureVideo(hcam, ueye.IS_DONT_WAIT)
    # get data from camera and display
    lineinc = width * int((bitspixel + 7) / 8)

    for i in xrange(ramp_frames):
        temp = get_image(width, height)
    print("Taking image...")
    # Take the actual image we want to keep
    camera_capture = get_image(width, height)
    file = "USBtemp.png"
    def __init__(self):
        self.hCam = ueye.HIDS(
            1
        )  # 0: first available camera;  1-254: The camera with the specified camera ID
        self.sInfo = ueye.SENSORINFO()
        self.cInfo = ueye.CAMINFO()
        self.pcImageMemory = ueye.c_mem_p()
        self.MemID = ueye.int()
        self.rectAOI = ueye.IS_RECT()
        self.pitch = ueye.INT()
        self.nBitsPerPixel = ueye.INT(
            24
        )  # 24: bits per pixel for color mode; take 8 bits per pixel for monochrome
        self.channels = 3  # 3: channels for color mode(RGB); take 1 channel for monochrome
        self.m_nColorMode = ueye.INT()  # Y8/RGB16/RGB24/REG32
        self.bytes_per_pixel = int(self.nBitsPerPixel / 8)

        self.f_length = (652.7396, 653.3803)  # FocalLength
        self.p_center = (321.8104, 259.7124)  # PrincipalPoint
        self.intrinsic = np.array(
            [[self.f_length[0], 0, self.p_center[0]],
             [0, self.f_length[1], self.p_center[1]], [0, 0, 1]],
            dtype=np.float)
        self.offset = [0, 0, 50]  #milimeter
        # ---------------------------------------------------------------------------------------------------------------------------------------
        print("In hand camera initilized")
    def __init__(self):
        self.cam = ueye.HIDS(0)
        self.cam_info = ueye.CAMINFO()
        self.sensor_info = ueye.SENSORINFO()
        self.image_memory = ueye.c_mem_p()
        self.memory_id = ueye.int()
        self.rect_aoi = ueye.IS_RECT()
        self.bits_per_pixel = ueye.INT(24)
        self.bytes_per_pixel = int(self.bits_per_pixel / 8)
        self.pitch = ueye.INT()
        self.color_mode = ueye.INT()
        self.width = 0
        self.height = 0
        self.status = 'IDLE'
        self.data = []
        self.lock = Lock()
        self.pipe = 0
        self.offset_x = 2
        self.offset_y = 2

        self.__init_camera()
        self.__get_camera_info()
        self.__get_sensor_info()
        #self.__default()
        self.__display_mode()
        self.__get_color_mode()
        self.__get_dimensions()
        self.__memory_allocation()
        self.__set_color_mode()
        self.__set_events()
        self.__mandatory_shit()

        print("Color mode {}".format(self.color_mode))
        print("Bits per pixel {}".format(self.bits_per_pixel))
        print("Bytes per pixel {}".format(self.bytes_per_pixel))
Exemple #6
0
    def __init__(self, frames_avg=1):
        """ Object constructor, called when creating instance of the BaslerCam class """

        self.CamID = ueye.HIDS(1)

        self.intTime = 15000
        self.iniFile = ""
        self.frames_avg = frames_avg
        self.connected = False
        self.binningEnabled = False

        # ctypes process parameters
        self.memPointer = ueye.c_mem_p()
        self.memID = ueye.c_int()
        self.pPitch = ueye.c_int()
        self.bitdepth = 16  #ueye.c_int(8)

        self.FPS = 8
        self.currentFPS = self.FPS
        self.pixelClock = 80

        # Sensor dimension variables: variable type in native python + fixed sensorSize in ctypes formats
        self.sensorHeight_ctype = ueye.c_int(3088)
        self.sensorWidth_ctype = ueye.c_int(2076)
        self.currentWidth = 3088
        self.currentHeight = 2076

        # Initialize camera
        self.connect()
Exemple #7
0
    def __init__(self, cam_id=0, width=2048, height=1088):
        """
        Opens the camera connection and prepares the device for taking images.
        """
        self.image_data = None
        self._color_mode = None
        self._width = width
        self._height = height
        self._ppc_img_mem = None
        self._mem_id = None
        self._pitch = None
        self._c_width = None
        self._c_height = None
        self._c_pixel_bits = None
        self._bytes_per_pixel = 0
        self._video_capture = False

        if pue is None:
            raise RuntimeError(
                'uEye library could not be loaded, check the PYUEYE_DLL_PATH:'
                f' "{os.environ.get("PYUEYE_DLL_PATH", "")}"')

        self._cam = pue.HIDS(cam_id)
        self._connect()
        self._configure_camera()
        self._set_color_mode('rgb8')
        self._allocate_memory()
Exemple #8
0
 def __init__(self, graphic=None, mainf=None):
     self.camera = False
     self.graphic = graphic
     self.mainf = mainf
     self.detected_devices = {}
     self.nRet = None
     try:
         self.hid = ueye.HIDS()
         self.sinfo = ueye.SENSORINFO()
         self.hwnd = ueye.HWND()
         self.width = ueye.INT()
         self.height = ueye.INT()
         self.psize = None
         self.bitspixel = ueye.INT(24)
         self.bytesppixel = int(self.bitspixel / 8)
         self.ppcImgMem = ueye.c_mem_p()
         self.pid = ueye.INT()
         self.MemID = ueye.INT()
         self.colorm = ueye.INT()
         self.pitch = ueye.INT()
         self.rect = ueye.IS_RECT()
         self.maxExp = ueye.double()
         self.minExp = ueye.double()
         self.Exp = ueye.double()
     except:
         return
    def __init__(self):
        # Variabeln für Kameraverarbeitung
        self.h_cam = ueye.HIDS(0)
        self.pitch = ueye.INT()
        self.ColorMode = ueye.IS_CM_BGRA8_PACKED
        self.nBitsPerPixel = ueye.INT(32)
        self.bytes_per_pixel = int(self.nBitsPerPixel / 8)
        self.pitch = ueye.INT()
        self.pcImageMemory = ueye.c_mem_p()
        self.rectAOI = ueye.IS_RECT()
        self.MemID = ueye.int()
        self.width = None
        self.height = None
        self.dst = None
        self.path_images = os.path.dirname(os.path.abspath(
            sys.argv[0])) + "/images/"

        # laden der intrinsischen Kalibriermatrix
        self.load_calibration_config()

        # Variabeln zur Farberkennung
        self.found_container = False
        self.contours_rectangle = []
        blue_lower = [50, 0, 0]
        blue_upper = [255, 75, 75]
        self.boundaries = [(blue_lower, blue_upper)]
        self.cX = None
        self.cY = None
        self.cX_container = None
        self.cY_container = None

        # Variablen zur Positionsbestimmung
        self.container_world_position = []
        self.ball_position = []
        self.container_position = []
        self.qr_centres = []
        self.world_points = []
        self.qr_codes = None
        self.image_points_of_qr_codes = None
        self.localization_qr_codes = []
        self.world_localization_qr_codes = []
        self.increment = 0.25
        self.results = 0

        # Wahl des Ansatzes
        self.method = 0
        while self.method <= 0 or self.method >= 4:
            try:
                self.method = eval(
                    input(
                        "Mit welchem Ansatz sollen die Positionen ermittelt werden?\n (1) GPS-Ansatz\n "
                        "(2) Vergleichsansattz\n (3) Berechnen der Weltkoordinaten\n"
                    ))
            except NameError:
                self.method = 0
            except SyntaxError:
                self.method = 0
            except TypeError:
                self.method = 0
Exemple #10
0
 def __init__(self):
     self.hcam = ueye.HIDS(0)
     self.membuf = ueye.c_mem_p()
     self.memid = ueye.int()
     self.pitch = -1
     self.framerate = -1
     self.imgwidth = None
     self.imgheight = None
Exemple #11
0
    def __init__(self, device_id=0):
        self.h_cam = ueye.HIDS(device_id)
        self.h_wnd = ueye.HWND()
        self.img_buffers = []

        # indicator for live mode
        self.live_on = False
        # trigger counter
        self.trigger_events = 0
Exemple #12
0
 def __init__(self, cam_id=0):
     '''
     Opens the camera connection and prepares the device for taking images.
     '''
     self.cam = pue.HIDS(cam_id)
     self.connect()
     self.configure_camera()
     self.set_color_mode('rgb8')
     self.allocate_memory()
    def __init__(self):
        super(CamDialog, self).__init__()
        loadUi('cam.ui', self)
        self.image=None
        self.roi_color=None
        self.startButton.clicked.connect(self.start_webcam)
        self.stopButton.clicked.connect(self.stop_webcam)
#        self.detectButton.setCheckable(True)
#        self.detectButton.toggled.connect(self.detect_webcam_face)
        self.face_Enabled=False
        self.faceCascade=cv2.CascadeClassifier('haarcascade_frontalface_default.xml')

        self.hCam = ueye.HIDS(0)  # 0: first available camera;  1-254: The camera with the specified camera ID
        self.sInfo = ueye.SENSORINFO()
        self.cInfo = ueye.CAMINFO()
        self.pcImageMemory = ueye.c_mem_p()
        self.MemID = ueye.int()
        self.rectAOI = ueye.IS_RECT()
        self.pitch = ueye.INT()
        self.nBitsPerPixel = ueye.INT(24)  # 24: bits per pixel for color mode; take 8 bits per pixel for monochrome
        self.channels = 3  # 3: channels for color mode(RGB); take 1 channel for monochrome
        self.m_nColorMode = ueye.INT()  # Y8/RGB16/RGB24/REG32
        self.bytes_per_pixel = int(self.nBitsPerPixel / 8)

        self.nRet = ueye.is_InitCamera(self.hCam, None)
        self.nRet = ueye.is_GetCameraInfo(self.hCam, self.cInfo)
        self.nRet = ueye.is_GetSensorInfo(self.hCam, self.sInfo)
        self.nRet = ueye.is_ResetToDefault(self.hCam)
        self.nRet = ueye.is_SetDisplayMode(self.hCam, ueye.IS_SET_DM_DIB)
        ueye.is_GetColorDepth(self.hCam, self.nBitsPerPixel, self.m_nColorMode)
        self.nRet = ueye.is_AOI(self.hCam, ueye.IS_AOI_IMAGE_GET_AOI, self.rectAOI, ueye.sizeof(self.rectAOI))
        self.width = self.rectAOI.s32Width
        self.height = self.rectAOI.s32Height
        self.nRet = ueye.is_AllocImageMem(self.hCam, self.width, self.height, self.nBitsPerPixel, self.pcImageMemory, self.MemID)
        self.nRet = ueye.is_SetImageMem(self.hCam, self.pcImageMemory, self.MemID)
        self.nRet = ueye.is_SetColorMode(self.hCam, self.m_nColorMode)
        self.nRet = ueye.is_CaptureVideo(self.hCam, ueye.IS_DONT_WAIT)
        self.nRet = ueye.is_InquireImageMem(self.hCam, self.pcImageMemory, self.MemID, self.width, self.height, self.nBitsPerPixel, self.pitch)
        self.xp=[]
        self.yp=[]
        self.lxp=[]
        self.lyp = []
        self.rxp = []
        self.ryp = []
        self.sx = 200
        self.sy = 150
        self.endx = 600
        self.endy = 450

   #     self.avgx = 0
    #    self.avgy = 0
        self.holeflag = 0
        self.lflag = 0
        self.rflag = 0
    def get_camera_status(self, n_device_id=5):
        print_style("Camera Status", color="blue")
        for i in range(n_device_id):
            hcam = ueye.HIDS(i)
            ret = ueye.is_InitCamera(hcam, None)

            self.cam_status[i] = not bool(ret)
            if ret == ueye.IS_SUCCESS:
                print_style("Camera ID:", i, " Available", color="green")
            else:
                print_style("Camera ID:", i, " Unavailable", color="red")
Exemple #15
0
    def return_devices(self, variable):

        cam_num = ueye.INT()
        ueye.is_GetNumberOfCameras(cam_num)
        for i in range(cam_num.value):
            hid = ueye.HIDS(cam_num)
            s = ueye.is_InitCamera(self.hid, self.hwnd)
            r = ueye.is_GetSensorInfo(self.hid, self.sinfo)
            sname = self.sinfo.strSensorName.decode('UTF-8')
            self.detected_devices[sname] = i + 1
            variable.insert('end', sname)
            ueye.is_ExitCamera(self.hid)
Exemple #16
0
 def __init__(self, cam_ID = 0):
     # Several parameters are unused, but may be needed in the future
     self.hCam = ueye.HIDS(cam_ID)
     self.sInfo = ueye.SENSORINFO()
     self.cInfo = ueye.CAMINFO()
     self.pcImageMemory = ueye.c_mem_p()
     self.MemID = ueye.int()
     self.rectAOI = ueye.IS_RECT()
     self.pitch = ueye.INT()
     self.nBitsPerPixel = ueye.INT(32)  # 32 bits for color camera
     self.channels = 3  # 3: channels for color mode(RGB); take 1 channel for monochrome
     self.m_nColorMode = ueye.IS_CM_BGRA8_PACKED  # RGB32
     self.bytes_per_pixel = int(self.nBitsPerPixel / 8)
Exemple #17
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 #18
0
    def initCamera(self):
        try:
            self.hcam = ueye.HIDS(0)
            self.pccmem = ueye.c_mem_p()
            self.memID = ueye.c_int()
            self.hWnd = ctypes.c_voidp()
            ueye.is_InitCamera(self.hcam, self.hWnd)
            ueye.is_SetDisplayMode(self.hcam, 0)
            self.sensorinfo = ueye.SENSORINFO()
            ueye.is_GetSensorInfo(self.hcam, self.sensorinfo)

            return self.OP_OK
        except:
            return self.OP_ERR
Exemple #19
0
    def __init__(self, cam_id, name):

        self._cam = ueye.HIDS(cam_id)
        self._cam_name = name
        self._sInfo = ueye.SENSORINFO()
        self._sFPS = ueye.DOUBLE()
        self._connect()

        # Query additional information about the sensor type used in the camera
        err = ueye.is_GetSensorInfo(self._cam, self._sInfo)
        if err != ueye.IS_SUCCESS:
            raise CameraException(self._cam, 'ueye>close>GetSensorInfo>', err)

        # Reset camera to default settings
        err = ueye.is_ResetToDefault(self._cam)
        if err != ueye.IS_SUCCESS:
            raise CameraException(self._cam, 'ueye>close>ResetToDefault>', err)

        # Set display mode to DIB
        err = ueye.is_SetDisplayMode(self._cam, ueye.IS_SET_DM_DIB)
        if err != ueye.IS_SUCCESS:
            raise CameraException(self._cam, 'ueye>close>SetDisplayMode>', err)

        # Core Camera Variables
        self._width = ueye.INT(self._sInfo.nMaxWidth.value)
        self._height = ueye.INT(self._sInfo.nMaxHeight.value)
        self._pitch = ueye.INT()
        self._ppc_img_mem = ueye.c_mem_p()
        self._mem_id = ueye.INT()
        self._nBitsPerPixel = ueye.INT()
        self._m_nColorMode = ueye.INT()
        self._bytes_per_pixel = ueye.INT()
        self._video_capture = False
        self._done_saving = True

        # Allicate memory for frames
        self._allocate_memory()

        # Start collection of frames
        self.start_video_capture()

        # Get frames per second
        err = ueye.is_GetFramesPerSecond(self._cam, self._sFPS)
        if err != ueye.IS_SUCCESS:
            raise CameraException(self._cam, 'ueye>close>GetFramesPerSecond>',
                                  err)

        # Start new thread to save frame
        threading.Thread(target=self._update).start()
 def initialize(self):
     # --- using pyueye --- #
     self.cam = ueye.HIDS(self.cam_id)
     self.frame_buffer = []
     # ---  --- #
     ret = ueye.is_InitCamera(
         self.cam,
         None)  # init camera and return 0,1 according to if it worked
     if ret != ueye.IS_SUCCESS:
         self.cam = None
         self.addToLog('Camera initation: failed.')
         self.isCameraInit = False
         self.close_camera()
         return None
     self.isCameraInit = True
Exemple #21
0
    def __init__(self):
        # Variabeln für Kameraverarbeitung
        self.h_cam = ueye.HIDS(0)
        self.pitch = ueye.INT()
        self.ColorMode = ueye.IS_CM_BGRA8_PACKED
        self.nBitsPerPixel = ueye.INT(32)
        self.bytes_per_pixel = int(self.nBitsPerPixel / 8)
        self.pitch = ueye.INT()
        self.pcImageMemory = ueye.c_mem_p()
        self.rectAOI = ueye.IS_RECT()
        self.MemID = ueye.int()
        self.width = None
        self.height = None
        self.dst = None
        self.path_images = os.path.dirname(os.path.abspath(
            sys.argv[0])) + "/images/"

        # laden der intrinsischen Kalibriermatrix
        self.load_calibration_config()

        # Variabeln zur Farberkennung
        blue_lower = [50, 0, 0]
        blue_upper = [255, 75, 75]
        red_lower = [0, 0, 100]
        red_upper = [50, 50, 255]
        green_lower = [0, 75, 50]
        green_upper = [50, 255, 150]
        self.blue_boundaries = [(blue_lower, blue_upper)]
        self.red_boundaries = [(red_lower, red_upper)]
        self.green_boundaries = [(green_lower, green_upper)]

        # Variablen zur Positionsbestimmung
        self.found_blue_container = False
        self.found_red_container = False
        self.found_green_container = False
        self.qr_centres = []
        self.world_points = []
        self.localization_qr_codes = []
        self.world_localization_qr_codes = []
        self.results = 0

        # Farbbereiche
        self.blue = Color(self.blue_boundaries, "blue")
        self.red = Color(
            self.red_boundaries,
            "red",
        )
        self.green = Color(self.green_boundaries, "green")
    def init(self):

        h_cam = ueye.HIDS(0 | ueye.IS_USE_DEVICE_ID)
        ret = ueye.is_InitCamera(h_cam, None)

        if ret != ueye.IS_SUCCESS:
            error_message = QMessageBox()
            result = QMessageBox.critical(error_message,
                                          'Error',
                                          "Invalid device id!",
                                          buttons=QMessageBox.Ok)
            if result == QMessageBox.Ok:
                exit()

        self.hCam = h_cam
        return h_cam
Exemple #23
0
    def __init__(self, id=0, config={}):
        if ueye is None:
            raise ImportError('Ueye failed to import. Ueye camera initialization failed.')

        defaults = {
            'fps': 60,
            'exposure': 60,
            'autofocus': 1,
            'autogain': 1,
            'format': 'rawvideo',
            'focus_min': None,
            'focus_max': None,
        }
        Input.__init__(self, id=id, config=config, defaults=defaults)

        self.input = ueye.HIDS(self.id)
    def __init__(self, _camID):
        self.camID=_camID
        self.vc = ueye.HIDS(_camID)
        if not (ueye.is_InitCamera(self.vc, None)==0):
            raise ValueError('Failed to open camera')


        #reserve memory
        self.mem_size = self.getMaxSize()
        ueye.is_AllocImageMem(self.vc, self.mem_size[0], self.mem_size[1],24,self.mem_ptr, self.mem_id)
        
        #set active memory region
        ueye.is_SetImageMem(self.vc, self.mem_ptr, self.mem_id)
 
        #continuous capture to memory
        ueye.is_CaptureVideo(self.vc, ueye.IS_DONT_WAIT)
    def __init__(self, camID):
        super().__init__()

        # Define the variables that will be used to retrieve the properties
        # of the camera (generic dictionnaries from ueye)
        # -----------------------------------------------

        self.hcam = ueye.HIDS(
            camID
        )  # 0 for the first available camera - 1-254 when we already have a specified ID
        self.sensor_info = ueye.SENSORINFO()
        self.cam_info = ueye.CAMINFO()
        self.rectAOI = ueye.IS_RECT()
        self.pcImageMemory = ueye.c_mem_p()
        self.MemID = ueye.int()
        self.pitch = ueye.INT()
def Init_Cam(width=640, heigth=480, gain_boost=1):
    """inits the uEye camera"""
    # inits next available cam
    cam = ueye.HIDS(0)
    ueye.is_InitCamera(cam, None)

    ueye.is_EnableAutoExit(cam, ueye.IS_ENABLE_AUTO_EXIT)

    # sets the Colourmode of the camera
    ueye.is_SetColorMode(cam, ueye.IS_CM_SENSOR_RAW8)

    # sets the trigger
    ret = ueye.is_SetExternalTrigger(cam, ueye.IS_SET_TRIGGER_SOFTWARE)
    mode = ueye.int(0)

    # sets the blacklevel
    ueye.is_Blacklevel(cam, ueye.IS_BLACKLEVEL_CMD_SET_MODE, mode,
                       ueye.sizeof(mode))

    # sets the size of the image
    rectAOI = ueye.IS_RECT()
    rectAOI.s32X = 44
    rectAOI.s32Y = 0
    rectAOI.s32Width = 480
    rectAOI.s32Height = 480
    ueye.is_AOI(cam, ueye.IS_AOI_IMAGE_SET_AOI, rectAOI, ueye.sizeof(rectAOI))

    # allocates memory with given size
    width = ueye.int(width)
    heigth = ueye.int(heigth)
    bitspixel = ueye.int(8)
    pcImgMem = ueye.c_mem_p()
    pid = ueye.int()
    ueye.is_AllocImageMem(cam, 480, heigth, bitspixel, pcImgMem, pid)

    # sets the image memory as active
    ueye.is_SetImageMem(cam, pcImgMem, pid)

    # activates video mode
    ueye.is_CaptureVideo(cam, ueye.IS_DONT_WAIT)

    # sets gain boost mode
    if gain_boost == 1:
        ueye.is_SetGainBoost(cam, ueye.IS_SET_GAINBOOST_ON)
    else:
        ueye.is_SetGainBoost(cam, ueye.IS_SET_GAINBOOST_OFF)
    return cam, ret, pcImgMem, pid
Exemple #27
0
    def __init__(self):
        rospy.init_node("coordinates_publisher")
        self.coordinates_pub = rospy.Publisher("/coordinates",
                                               Coordinates,
                                               queue_size=1)
        self.coordinates_msg = Coordinates()

        self.h_cam = ueye.HIDS(0)
        self.pitch = ueye.INT()
        self.ColorMode = ueye.IS_CM_BGRA8_PACKED
        self.nBitsPerPixel = ueye.INT(32)
        self.bytes_per_pixel = int(self.nBitsPerPixel / 8)
        self.pitch = ueye.INT()
        self.pcImageMemory = ueye.c_mem_p()
        self.rectAOI = ueye.IS_RECT()
        self.MemID = ueye.int()
        self.width = None
        self.height = None
        self.dst = None

        self.load_calibration_config()

        self.found_container = False
        self.contours_rectangle = []
        blue_lower = [51, 0, 0]
        blue_upper = [255, 62, 62]
        self.boundaries = [(blue_lower, blue_upper)]
        self.cX = None
        self.cY = None
        self.cX_container = None
        self.cY_container = None

        self.container_world_position = []
        self.ball_position = []
        self.container_position = []
        self.qr_centres = []
        self.world_points = []
        self.qr_codes = None
        self.image_points_of_qr_codes = None
        self.localization_qr_codes = []
        self.world_localization_qr_codes = []
        self.increment = 0.25
    def return_devices(self):
        """ 
        Return list of connected camera.
        
        """
        
        varOut = []

        cam_num = ueye.INT()
        ueye.is_GetNumberOfCameras(cam_num)
        for i in range(cam_num.value):
            hid = ueye.HIDS(cam_num)
            s = ueye.is_InitCamera(self.hid, self.hwnd)
            r = ueye.is_GetSensorInfo(self.hid, self.sinfo)
            sname = self.sinfo.strSensorName.decode('UTF-8')
            self.detected_devices[sname] = i+1
            varOut.append(sname)
            ueye.is_ExitCamera(self.hid)
            
        return varOut
Exemple #29
0
    def initialize(self):
        self.hcam = ueye.HIDS(self.cam_num)
        self.sInfo = ueye.SENSORINFO()
        self.cInfo = ueye.CAMINFO()
        self.pcImageMemory = ueye.c_mem_p()
        self.MemID = ueye.int()
        self.rectAOI = ueye.IS_RECT()
        self.pitch = ueye.INT()
        self.nBitsPerPixel = ueye.INT(24)  # 8 bit for monochrome 24 for color
        self.channels = 3  # 3: for color mode(RGB); 1 channel for monochrome
        self.m_nColorMode = ueye.INT(24)  # Y8/RGB16/RGB24/REG32
        self.bytes_per_pixel = int(self.nBitsPerPixel / 8)

        self.ret = ueye.is_InitCamera(self.hcam, None)
        if self.ret != ueye.IS_SUCCESS:
            print("is_InitCamera ERROR")

        self.setAOI()
        self.setmemory()
        self.acquireimage()
Exemple #30
0
	def __init__(self, serial):
		nc=ueye.c_int()
		self.status=True
		self._bgImage=0
		self.bg=0
		if ueye.is_GetNumberOfCameras(nc):
			_logger.error("Error Wrong number of cameras")			
			return 
		lst=ueye.UEYE_CAMERA_LIST((ueye.UEYE_CAMERA_INFO*nc.value))
		lst.dwCount=nc.value
		ueye.is_GetCameraList(lst)
		index=None
		for i in range(nc.value):
			_logger.info("Got the following ccd: %s"%lst.uci[i].SerNo)
			if (lst.uci[i].SerNo==serial):
				index=i
				break
		if index is None:
			_logger.error("SerNo %s not found."%serial)
			return 			
			
		if lst.uci[index].dwStatus:
			_logger.error("Camera %d is already busy."%index)

		self.hcam=ueye.HIDS(index)
		if ueye.is_InitCamera(self.hcam, None):
			_logger.error("Error inializating camera.")
			self.status=True
			return
		self.bufCount=0
		self.bitsPixel=8
		self.Imgs=None
		self.LastSeqBuf1=ueye.c_mem_p(1)
		self.acq=False
		self.grabbingCB=dummy
		self.grabbing=False
		self.setColorMode(ueye.IS_CM_MONO8)
		if self.LoadSettings():
			_logger.error("error laoding camera settings")
			sys.exit()
		self.status=False