def __init__(self, parent=None):
     self.converted_memory_pointer = ueye.c_mem_p()
     self.converted_memory_id = ueye.int()
     self.img_data = ImageData()
     self.capturing = False
     self.hCam = 0
     self.init()
     ueye.is_SetColorMode(self.hCam, ueye.IS_CM_RGB8_PACKED)
     self.alloc(self.hCam)
     self.qt_image = None
     ueye.is_CaptureVideo(self.hCam, Wait=True)
     QWidget.__init__(self, parent, flags=Qt.Widget)
     self.graphics_scene = QGraphicsScene()
     self.graphics_view = QGraphicsView(self.graphics_scene)
     self.graphics_view.setViewportUpdateMode(
         QGraphicsView.FullViewportUpdate)
     self.start_stop_button = QPushButton("start/stop")
     self.event = ueye.HANDLE(int())
     self.frame_event_id = ueye.IS_SET_EVENT_FRAME
     self.image_data_copy = None
     self.pil_image = None
     self.pix_map = None
     self.width = 0
     self.height = 0
     self.threads = []
     layout = QVBoxLayout()
     layout.addWidget(self.start_stop_button, alignment=Qt.AlignTop)
     layout.addWidget(self.graphics_view)
     self.setLayout(layout)
     self.start_stop_button.clicked.connect(self.switch_capturing)
Exemple #2
0
def init_cam(hcam):

    # get fps
    #  hcam_fps = is_GetFramesPerSecond(hcam, None)

    # set color mode
    ueye.is_SetColorMode(hcam, ueye.IS_CM_BGR8_PACKED)

    # set region of interest
    rect_aoi = ueye.IS_RECT()
    rect_aoi.s32X = ueye.int(0)
    rect_aoi.s32Y = ueye.int(0)
    rect_aoi.s32Width = ueye.int(width)
    rect_aoi.s32Height = ueye.int(height)
    ueye.is_AOI(hcam, ueye.IS_AOI_IMAGE_SET_AOI, rect_aoi,
                ueye.sizeof(rect_aoi))

    # allocate memory
    mem_ptr = ueye.c_mem_p()
    mem_id = ueye.int()

    ueye.is_AllocImageMem(hcam, width, height, bitspixel, mem_ptr, mem_id)
    ueye.is_SetImageMem(hcam, mem_ptr, mem_id)

    # continuous capture to memory
    ueye.is_CaptureVideo(hcam, ueye.IS_DONT_WAIT)

    return mem_ptr
Exemple #3
0
    def connect(self):
        """ Connects to the USB camera, creates main controlling object + prints out confirmation """
        connectRet = ueye.is_InitCamera(self.CamID, None)

        if connectRet == 0:  # on succesful connection
            self.connected = True
            self.sensorInfo = ueye.SENSORINFO()
            print('IDS camera connected.')
            ueye.is_GetSensorInfo(self.CamID, self.sensorInfo)

            self.sensorHeight_ctype, self.sensorWidth_ctype = self.sensorInfo.nMaxHeight, self.sensorInfo.nMaxWidth
            self.currentHeight, self.currentWidth = self.sensorHeight_ctype.value, self.sensorWidth_ctype.value

            # Settings block
            ueye.is_PixelClock(self.CamID, ueye.IS_PIXELCLOCK_CMD_SET,
                               ueye.c_int(self.pixelClock),
                               ueye.sizeof(ueye.c_int(self.pixelClock)))
            self.currentFPS = ueye.c_double(0)

            #ueye.is_SetFrameRate(self.CamID, ueye.c_int(self.FPS),self.currentFPS)

            ueye.is_SetDisplayMode(self.CamID, ueye.IS_SET_DM_DIB)
            ueye.is_SetColorMode(self.CamID, ueye.IS_CM_SENSOR_RAW12)

            ueye.is_SetAutoParameter(self.CamID, ueye.IS_SET_ENABLE_AUTO_GAIN,
                                     ueye.c_double(0), ueye.c_double(0))
            ueye.is_SetAutoParameter(self.CamID,
                                     ueye.IS_SET_ENABLE_AUTO_SENSOR_GAIN,
                                     ueye.c_double(0), ueye.c_double(0))
            ueye.is_SetAutoParameter(self.CamID,
                                     ueye.IS_SET_ENABLE_AUTO_SHUTTER,
                                     ueye.c_double(0), ueye.c_double(0))
            ueye.is_SetAutoParameter(self.CamID,
                                     ueye.IS_SET_ENABLE_AUTO_SENSOR_SHUTTER,
                                     ueye.c_double(0), ueye.c_double(0))
            ueye.is_SetAutoParameter(self.CamID,
                                     ueye.IS_SET_ENABLE_AUTO_WHITEBALANCE,
                                     ueye.c_double(0), ueye.c_double(0))
            ueye.is_SetAutoParameter(
                self.CamID, ueye.IS_SET_ENABLE_AUTO_SENSOR_WHITEBALANCE,
                ueye.c_double(0), ueye.c_double(0))
            ueye.is_SetHardwareGain(self.CamID, ueye.c_int(0), ueye.c_int(0),
                                    ueye.c_int(0), ueye.c_int(0))

            # Show a pattern (for testing)
            #ueye.is_SetSensorTestImage(self.CamID,ueye.IS_TEST_IMAGE_HORIZONTAL_GREYSCALE, ueye.c_int(0))

        else:
            print('Camera connecting failure...')
Exemple #4
0
def init_cam(hcam):

    # get fps
  #  hcam_fps = is_GetFramesPerSecond(hcam, None)
    
    # set color mode
    ueye.is_SetColorMode(hcam, ueye.IS_CM_BGR8_PACKED) 
    
    # set region of interest
    rect_aoi = ueye.IS_RECT()
    rect_aoi.s32X = ueye.int(0)
    rect_aoi.s32Y = ueye.int(0)
    rect_aoi.s32Width = ueye.int(width)
    rect_aoi.s32Height = ueye.int(height)
    ueye.is_AOI(hcam, ueye.IS_AOI_IMAGE_SET_AOI, rect_aoi, ueye.sizeof(rect_aoi))
#    
#    # set parameters, see ids doc for parameter setting flow chart
#    ueye.is_PixelClock(hcam, ueye.IS_PIXELCLOCK_CMD_GET, exp, ueye.sizeof(pclock))
#    pclock = ueye.int(220)
#    ueye.is_PixelClock(hcam, ueye.IS_PIXELCLOCK_CMD_GET, pclock, ueye.sizeof(pclock))
#    
#    expo_rng = ueye.is_Exposure(hcam, IS_EXPOSURE_CMD_GET_CAPS, ncap, size(ncap))
#    ftime_rng = ueye.is_GetFrameTimeRange()
#    expo_rng = (expo_rng[0], max(expo_rng[1], ftime_rng[1]))
#    
#    fps_actual = ueye.cdouble() 
#    ueye.is_SetFrameRate(hcam, ueye.cdouble(fps_set), byref(fps_actual))
#    
#    exp_cap = ueye.uint32()
#    ueye.is_Exposure(hcam, ueye.IS_EXPOSURE_GET_EXPOSURE_RANGE, ueye.byref(exp_cap), ueye.sizeof(exp_cap))
#    exp_cur = ueye.cdouble() # in s
#    ueye.is_Exposure(hcam, ueye.IS_EXPOSURE_SET_EXPOSURE, ueye.byref(exp_cur), ueye.sizeof(exp_cur))

#    ueye.is_SetGainBoost()
#    ueye.is_Gamma()
#    ueye.is_SetHWGainFactor()
#    
    
    # allocate memory
    mem_ptr = ueye.c_mem_p()
    mem_id = ueye.int()
    
    ueye.is_AllocImageMem(hcam, width, height, bitspixel, mem_ptr, mem_id)
    ueye.is_SetImageMem(hcam, mem_ptr, mem_id)
     
    # continuous capture to memory
    ueye.is_CaptureVideo(hcam, ueye.IS_DONT_WAIT)
    
    return mem_ptr
Exemple #5
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"
Exemple #6
0
    def allocateMemory(self):

        # Allocates an image memory for an image having its dimensions defined by self.width and height and its color depth defined by self.nBitsPerPixel
        nRet = ueye.is_AllocImageMem(self.hCam, self.width, self.height,
                                     self.nBitsPerPixel, self.pcImageMemory,
                                     self.MemID)
        if nRet != ueye.IS_SUCCESS:
            print("is_AllocImageMem ERROR")
        else:
            # Makes the specified image memory the active memory
            nRet = ueye.is_SetImageMem(self.hCam, self.pcImageMemory,
                                       self.MemID)
            if nRet != ueye.IS_SUCCESS:
                print("is_SetImageMem ERROR")
            else:
                # Set the desired color mode
                nRet = ueye.is_SetColorMode(self.hCam, self.m_nColorMode)

        # Activates the camera's live video mode (free run mode)
        nRet = ueye.is_CaptureVideo(self.hCam, ueye.IS_DONT_WAIT)
        if nRet != ueye.IS_SUCCESS:
            print("is_CaptureVideo ERROR")

        # Enables the queue mode for existing image memory sequences
        nRet = ueye.is_InquireImageMem(self.hCam, self.pcImageMemory,
                                       self.MemID, self.width, self.height,
                                       self.nBitsPerPixel, self.pitch)
        if nRet != ueye.IS_SUCCESS:
            print("is_InquireImageMem ERROR")
 def alloc(self, buffer_count=3):
     '''
     Initialization of the ring buffer.
     '''
     rec_aoi = self.Rect(*self.get_aoi())
     color_mode = ueye.is_SetColorMode(self.cam, ueye.IS_GET_COLOR_MODE)
     self.bpp = get_bits_per_pixel(color_mode)
     # --- freeing the memory from previous buffer --- #
     for buff in self.frame_buffer:
         hasWorked = ueye.is_FreeImageMem(self.cam, buff.mem_ptr,
                                          buff.mem_id)
         self.check(hasWorked, 'is_FreeImageMem')
     # --- allocate memory to buffer --- #
     for i in range(buffer_count):
         buff = self.ImageBuffer()
         ueye.is_AllocImageMem(self.cam, rec_aoi.width, rec_aoi.height,
                               self.bpp, buff.mem_ptr, buff.mem_id)
         hasWorked = ueye.is_AddToSequence(self.cam, buff.mem_ptr,
                                           buff.mem_id)
         self.check(hasWorked, 'is_AddToSequence')
         self.frame_buffer.append(buff)
     # ---  --- #
     hasWorked = ueye.is_InitImageQueue(
         self.cam, 0)  # init and return the success of image queued.
     self.check(hasWorked, 'is_InitImageQueue')
     # ---  --- #
     self.img_buffer = self.frame_buffer[-1]
Exemple #8
0
    def setMemroyForVideoCapture(self):
        nRet = ueye.is_AllocImageMem(self.hCam, self.width, self.height,
                                     self.nBitsPerPixel, self.pcImageMemory,
                                     self.MemID)
        if nRet != ueye.IS_SUCCESS:
            print("is_AllocImageMem ERROR")
        else:
            # Makes the specified image memory the active memory
            nRet = ueye.is_SetImageMem(self.hCam, self.pcImageMemory,
                                       self.MemID)
            if nRet != ueye.IS_SUCCESS:
                print("is_SetImageMem ERROR")
            else:
                # Set the desired color mode
                nRet = ueye.is_SetColorMode(self.hCam, self.m_nColorMode)

        # Activates the camera's live video mode (free run mode)
        nRet = ueye.is_CaptureVideo(self.hCam, ueye.IS_DONT_WAIT)
        if nRet != ueye.IS_SUCCESS:
            print("is_CaptureVideo ERROR")

        # Enables the queue mode for existing image memory sequences
        nRet = ueye.is_InquireImageMem(self.hCam, self.pcImageMemory,
                                       self.MemID, self.width, self.height,
                                       self.nBitsPerPixel, self.pitch)
        if nRet != ueye.IS_SUCCESS:
            print("is_InquireImageMem ERROR")
        else:
            print("Press q to leave the programm")
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 #10
0
    def show_image(self):
        nRet = ueye.is_InitCamera(self.h_cam, None)
        nRet = ueye.is_SetDisplayMode(self.h_cam, ueye.IS_SET_DM_DIB)
        nRet = ueye.is_AOI(self.h_cam, ueye.IS_AOI_IMAGE_GET_AOI, self.rectAOI,
                           ueye.sizeof(self.rectAOI))

        self.width = self.rectAOI.s32Width
        self.height = self.rectAOI.s32Height

        nRet = ueye.is_AllocImageMem(self.h_cam, self.width, self.height,
                                     self.nBitsPerPixel, self.pcImageMemory,
                                     self.MemID)
        nRet = ueye.is_SetImageMem(self.h_cam, self.pcImageMemory, self.MemID)
        nRet = ueye.is_SetColorMode(self.h_cam, self.ColorMode)
        nRet = ueye.is_CaptureVideo(self.h_cam, ueye.IS_DONT_WAIT)
        nRet = ueye.is_InquireImageMem(self.h_cam, self.pcImageMemory,
                                       self.MemID, self.width, self.height,
                                       self.nBitsPerPixel, self.pitch)

        while nRet == ueye.IS_SUCCESS:
            array = ueye.get_data(self.pcImageMemory,
                                  self.width,
                                  self.height,
                                  self.nBitsPerPixel,
                                  self.pitch,
                                  copy=False)
            frame = np.reshape(
                array,
                (self.height.value, self.width.value, self.bytes_per_pixel))
            frame = cv2.resize(frame, (0, 0), fx=0.5, fy=0.5)
            size = (self.height, self.width)
            new_camera_matrix, roi = cv2.getOptimalNewCameraMatrix(
                self.camera_matrix, self.dist_coeff, size, 1, size)
            dst = cv2.undistort(frame, self.camera_matrix, self.dist_coeff,
                                None, new_camera_matrix)
            x, y, w, h = roi
            self.dst = dst[y:y + h, x:x + w]

            self.detect_colors()

            self.extrinsic_calibration()

            cv2.imshow("camera", self.dst)

            if cv2.waitKey(1) & 0xFF == ord('q'):
                break

            elif cv2.waitKey(1) & 0xFF == ord('t'):
                cv2.imwrite("/home/lennart/dorna/camera/images/gps.bmp",
                            self.dst)

            elif cv2.waitKey(100) & 0xFF == ord('l'):
                self.found_container = False
                self.container_world_position.clear()
                print("Behälterposition zurückgesetzt")

        ueye.is_FreeImageMem(self.h_cam, self.pcImageMemory, self.MemID)
        ueye.is_ExitCamera(self.h_cam)
        cv2.destroyAllWindows()
Exemple #11
0
 def __init__(self, h_cam, img_buff):
     self.h_cam = h_cam
     self.img_buff = img_buff
     self.mem_info = MemoryInfo(h_cam, img_buff)
     self.color_mode = ueye.is_SetColorMode(h_cam, ueye.IS_GET_COLOR_MODE)
     self.bits_per_pixel = get_bits_per_pixel(self.color_mode)
     self.array = ueye.get_data(self.img_buff.mem_ptr, self.mem_info.width,
                                self.mem_info.height, self.mem_info.bits,
                                self.mem_info.pitch, True)
Exemple #12
0
    def set_colormode(self, colormode):
        """
        Set the colormode.

        Parameters
        ==========
        colormode: pyueye color mode
            Colormode, as 'pyueye.IS_CM_BGR8_PACKED' for example.
        """
        check(ueye.is_SetColorMode(self.h_cam, colormode))
    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 init_acquisition(self):
        """
        Allocate the computer memory according to the size of the image and 
        start the acquisition.

        """

        # Allocate memory for the acquisition
        # -----------------------------------

        self.width = self.rectAOI.s32Width
        self.height = self.rectAOI.s32Height
        Allocate_memory = ueye.is_AllocImageMem(self.hcam, self.width,
                                                self.height,
                                                self.nBitsPerPixel,
                                                self.pcImageMemory, self.MemID)

        if Allocate_memory != ueye.IS_SUCCESS:
            print("is_AllocImageMem ERROR")
            return
        else:
            # Makes the specified image memory the active memory
            Allocate_memory = ueye.is_SetImageMem(self.hcam,
                                                  self.pcImageMemory,
                                                  self.MemID)
            if Allocate_memory != ueye.IS_SUCCESS:
                print("is_SetImageMem ERROR")
                return
            else:
                # Set the desired color mode
                Color_mode = ueye.is_SetColorMode(self.hcam, self.m_nColorMode)

        # Activates the camera's live video mode (free run mode)
        # ------------------------------------------------------

        Launch_capture = ueye.is_CaptureVideo(self.hcam, ueye.IS_DONT_WAIT)
        if Launch_capture != ueye.IS_SUCCESS:
            print("is_CaptureVideo ERROR")
            return

        # Enables the queue mode for existing image memory sequences
        nRet = ueye.is_InquireImageMem(self.hcam, self.pcImageMemory,
                                       self.MemID, self.width, self.height,
                                       self.nBitsPerPixel, self.pitch)
        if nRet != ueye.IS_SUCCESS:
            print("is_InquireImageMem ERROR")
            return

        # Launch the live acquisition
        # ---------------------------

        self.acquire()
Exemple #15
0
    def getdata(self, img_buff):

        if(self.mem_info is None) or (self.color_mode is None) or (self.bits_per_pixel is None):
            self.mem_info = MemoryInfo(self.h_cam, img_buff)
            self.color_mode = ueye.is_SetColorMode(self.h_cam, ueye.IS_GET_COLOR_MODE)
            self.bits_per_pixel = get_bits_per_pixel(self.color_mode)

        self.array = ueye.get_data(self.img_buff.mem_ptrlast,
                                   self.mem_info.width,
                                   self.mem_info.height,
                                   self.mem_info.bits,
                                   self.mem_info.pitch,
                                   True)
Exemple #16
0
 def update_image_memory(self):
     # Allocates an image memory for an image having its dimensions defined by width and height and its color depth defined by nBitsPerPixel
     nRet = ueye.is_AllocImageMem(self.hCam, self.width, self.height, self.nBitsPerPixel, self.pcImageMemory, self.MemID)
     if nRet != ueye.IS_SUCCESS:
         print("is_AllocImageMem ERROR")
     else:
         # Makes the specified image memory the active memory
         nRet = ueye.is_SetImageMem(self.hCam, self.pcImageMemory, self.MemID)
         if nRet != ueye.IS_SUCCESS:
             print("is_SetImageMem ERROR")
         else:
             # Set the desired color mode
             nRet = ueye.is_SetColorMode(self.hCam, self.m_nColorMode)
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 setmemory(self):
     self.ret = ueye.is_AllocImageMem(self.hcam, self.width, self.height,
                                      self.nBitsPerPixel,
                                      self.pcImageMemory, self.MemID)
     if self.ret != ueye.IS_SUCCESS:
         print("is_AllocImageMem ERROR")
     else:
         # Makes the specified image memory the active memory
         self.ret = ueye.is_SetImageMem(self.hcam, self.pcImageMemory,
                                        self.MemID)
         if self.ret != ueye.IS_SUCCESS:
             print("is_SetImageMem ERROR")
         else:
             # Set the desired color mode
             self.ret = ueye.is_SetColorMode(self.hcam, self.m_nColorMode)
Exemple #19
0
    def run(self):

        a = ueye.is_InitCamera(self.hCam, None)
        b = ueye.is_GetCameraInfo(self.hCam, self.cInfo)
        c = ueye.is_GetSensorInfo(self.hCam, self.sInfo)

        d = ueye.is_ResetToDefault(self.hCam)
        e = ueye.is_SetDisplayMode(self.hCam, ueye.IS_SET_DM_DIB)

        g = 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

        h = ueye.is_AllocImageMem(self.hCam, self.width, self.height,
                                  self.nBitsPerPixel, self.pcImageMemory,
                                  self.MemID)
        i = ueye.is_SetImageMem(self.hCam, self.pcImageMemory, self.MemID)
        f = ueye.is_SetColorMode(self.hCam, ueye.IS_CM_MONO12)

        ueye.is_CaptureVideo(self.hCam, ueye.IS_WAIT)

        j = ueye.is_InquireImageMem(self.hCam, self.pcImageMemory, self.MemID,
                                    self.width, self.height,
                                    self.nBitsPerPixel, self.pitch)
        self.IMAGE_FILE_PARAMS = ueye.IMAGE_FILE_PARAMS(
            self.pcImageMemory, self.MemID)
        self.IMAGE_FILE_PARAMS.nFileType = ueye.IS_IMG_PNG
        self.k = ueye.sizeof(self.IMAGE_FILE_PARAMS)

        # ueye.is_AutoParameter(self.hCam, ueye.IS_AES_CMD_SET_ENABLE, self.autoParameter, ueye.sizeof(self.autoParameter))

        while self.flag:
            self.data = np.ctypeslib.as_array(
                ctypes.cast(self.pcImageMemory,
                            ctypes.POINTER(ctypes.c_ubyte)),
                (self.height * self.pitch, ))
            self.data.dtype = 'uint16'

            self.CameraSignal.emit(self.data)
            time.sleep(0.1)

        ueye.is_FreeImageMem(self.hCam, self.pcImageMemory, self.MemID)
        ueye.is_ExitCamera(self.hCam)
Exemple #20
0
    def allocate_memory(self):
        """Allocates an image memory for an image having its dimensions
        defined by width and height and its color depth defined by nBitsPerPixel.
        """
        nRet = ueye.is_AOI(self.hCam, ueye.IS_AOI_IMAGE_GET_AOI, self.rectAOI, ueye.sizeof(self.rectAOI))
        if nRet != ueye.IS_SUCCESS:
            print("is_AOI ERROR")

        nRet = ueye.is_AllocImageMem(self.hCam, self.rectAOI.s32Width, self.rectAOI.s32Height,
                                     self.nBitsPerPixel, self.pcImageMemory, self.MemID)
        if nRet != ueye.IS_SUCCESS:
            print("is_AllocImageMem ERROR")
        else:
            # Makes the specified image memory the active memory
            nRet = ueye.is_SetImageMem(self.hCam, self.pcImageMemory, self.MemID)
            if nRet != ueye.IS_SUCCESS:
                print("is_SetImageMem ERROR")
            else:
                # Set the desired color mode
                nRet = ueye.is_SetColorMode(self.hCam, self.m_nColorMode)
Exemple #21
0
    def __init__(self, device_number=0, nbits=8):
        Camera.__init__(self)

        self.initialized = False

        if nbits not in (8, 10, 12):
            raise RuntimeError(
                'Supporting only 8, 10 or 12 bit depth, requested %d bit' %
                (nbits))
        self.nbits = nbits

        self.h = ueye.HIDS(device_number)

        self.check_success(ueye.is_InitCamera(self.h, None))
        self.initialized = True

        # get chip size
        sensor_info = ueye.SENSORINFO()
        self.check_success(ueye.is_GetSensorInfo(self.h, sensor_info))

        self._chip_size = (sensor_info.nMaxWidth, sensor_info.nMaxHeight)
        self.sensor_type = sensor_info.strSensorName.decode().split(
            'x')[0] + 'x'

        self.SetROI(0, 0, self._chip_size[0], self._chip_size[1])

        self.check_success(
            ueye.is_SetColorMode(self.h,
                                 getattr(ueye, 'IS_CM_MONO%d' % self.nbits)))
        self.SetAcquisitionMode(self.MODE_CONTINUOUS)
        self._buffers = []
        self.full_buffers = queue.Queue()
        self.free_buffers = None

        self.n_full = 0

        self.n_accum = 1
        self.n_accum_current = 0

        self.SetIntegTime(0.1)
        self.Init()
Exemple #22
0
 def initialize_memory(self):
     '''
     Allocates image memory.
     Sets:
         self.mem_id
         self.mem_image
     '''
     mem_id = ueye.int()
     mem_image = ueye.c_mem_p()
     nRet = ueye.is_AllocImageMem(self.input, self.width, self.height, self.bits_per_pixel, mem_image, mem_id)
     if nRet != ueye.IS_SUCCESS:
         log.error("is_AllocImageMem ERROR")
     else:
         # Makes the specified image memory the active memory
         nRet = ueye.is_SetImageMem(self.input, mem_image, mem_id)
         if nRet != ueye.IS_SUCCESS:
             log.error("is_SetImageMem ERROR")
         else:
             # Set the desired color mode
             nRet = ueye.is_SetColorMode(self.input, self.m_nColorMode)
     self.mem_id = mem_id
     self.mem_image = mem_image
Exemple #23
0
import ctypes
import numpy as np
from pyueye import ueye
import copy
import time

uEyeDll = ctypes.cdll.LoadLibrary(r"C:\Windows\System32\uEye_api_64.dll")

cam = ctypes.c_uint32(0)
hWnd = ctypes.c_voidp()
msg = uEyeDll.is_InitCamera(ctypes.byref(cam), hWnd)
uEyeDll.is_EnableAutoExit(cam, ctypes.c_uint(1))
col = ueye.c_int(0)
mod = ueye.c_int(0)
ueye.is_GetColorDepth(cam, col, mod)
ueye.is_SetColorMode(cam, ueye.IS_CM_MONO8)
imageSize = ueye.IS_SIZE_2D()
imageSize.s32Width = ueye.c_int(224)
imageSize.s32Height = ueye.c_int(224)
ueye.is_AOI(cam, ueye.IS_AOI_IMAGE_SET_SIZE, imageSize, ueye.sizeof(imageSize))
width_py = imageSize.s32Width
height_py = imageSize.s32Height
pixels_py = 8
width = width_py
height = height_py
bitspixel = ctypes.c_int(pixels_py)
pcImgMem = ctypes.c_char_p()
pid = ctypes.c_int()
uEyeDll.is_AllocImageMem(cam, width, height, bitspixel, ctypes.byref(pcImgMem),
                         ctypes.byref(pid))
uEyeDll.is_SetImageMem(cam, pcImgMem, pid)
Exemple #24
0
 def set_colormode(self, colormode):
     check(ueye.is_SetColorMode(self.h_cam, colormode))
Exemple #25
0
 def get_colormode(self):
     ret = ueye.is_SetColorMode(self.h_cam, ueye.IS_GET_COLOR_MODE)
     return ret
    def grab(self):
        """
        Grabs live image from camera feed. 
        """
           
        # init camera
        self.hcam = ueye.HIDS(0)
        self.initTrigger = ueye.is_InitCamera(self.hcam, None)

        # set color mode
        ret = ueye.is_SetColorMode(self.hcam, ueye.IS_CM_BGR8_PACKED)

        # set region of interest
        rect_aoi = ueye.IS_RECT()
        rect_aoi.s32X = ueye.int(0)
        rect_aoi.s32Y = ueye.int(0)
        rect_aoi.s32Width = ueye.int(self.width)
        rect_aoi.s32Height = ueye.int(self.height)
        ueye.is_AOI(self.hcam, ueye.IS_AOI_IMAGE_SET_AOI, rect_aoi, ueye.sizeof(rect_aoi))
     
        # allocate memory
        mem_ptr = ueye.c_mem_p()
        mem_id = ueye.int()
        bitspixel = 24 # for colormode = IS_CM_BGR8_PACKED
        ret = ueye.is_AllocImageMem(self.hcam, self.width, self.height, bitspixel,
                                    mem_ptr, mem_id)
      
        # set active memory region
        ret = ueye.is_SetImageMem(self.hcam, mem_ptr, mem_id)
    
        # continuous capture to memory
        ret = ueye.is_CaptureVideo(self.hcam, ueye.IS_DONT_WAIT)
       
        # get data from camera and display
        lineinc = self.width * int((bitspixel + 7) / 8)
        
        #initialize counter
        j = 1     
              
        while(self.running):
            
            frame = {} 

            if j == 1:
                
                startTime = time.time()       
            
            endTime = time.time()            
            
            img = ueye.get_data(mem_ptr, self.width, self.height, bitspixel, lineinc, copy=True)
            
            img = np.reshape(img, (self.height, self.width, 3))
            
            blkImg = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
            
            #Check for edge detector toggle state
            if self.outline:
                
                img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
                
                #create threshold on image to detect edges
                ret,thresh = cv2.threshold(img,0,255,cv2.THRESH_BINARY+cv2.THRESH_OTSU)    
                edges = cv2.findContours(thresh,cv2.RETR_EXTERNAL,cv2.CHAIN_APPROX_SIMPLE)[0]
                
                if edges:
                    #change to size based on contour area
                    contour = max(edges,key=cv2.contourArea)  
                
                else:
                    
                    contour = None
                    
                img = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)
                
                if contour is not None:
                               
                    cv2.drawContours(img,contour,-1,(0,255,0),6)

            #Check for event - taking capillary image
            if self.capillary:
                
                # load capillary image and store in dictionary
                self.capImage = copy.copy(blkImg)
                self.data['capImage'] = self.capImage
                
                # toggle capillary capture off
                self.capillary = False

            #Check for event - gather droplet data (volume and bond number)       
            if self.dropletAnalysis:
                
                # load drop image 
                self.dropImage = copy.copy(blkImg)  

                vals = np.array([self.deltaRho,self.capillaryDiameter,self.thermalExpCoeff,
                           self.trueSyringeRotation,self.deltaT])
                
                ret = dropletQuickAnalysis.get_droplet_geometry(vals,self.capImage,self.dropImage) 
                
                # output droplet geometry parameters 
                self.vol = ret[0]
                self.bond = ret[1]

            if self.recording:
    
                # grab timestamp
                timeVal = endTime - startTime
                
                # output droplet images and timestamp and store in dictionary
                self.data['dropImage'][j] = self.dropImage
                self.data['time'][j] = timeVal
                           
                j=j+1
            
            # write image to frame dictionary
            frame['img'] = img
    
            # sleep command to avoid build up in queue
            time.sleep(0.01)
            
            # write image to frame
            if self.q.qsize() < 10:
                self.q.put(frame)

            if self.save:
                
                saveFile = self.folderName + '/outputData.pickle'
                
                with open(saveFile, 'wb') as handle:
                    pkl.dump(self.data, handle)
print()

#---------------------------------------------------------------------------------------------------------------------------------------

# Allocates an image memory for an image having its dimensions defined by width and height and its color depth defined by nBitsPerPixel
nRet = ueye.is_AllocImageMem(hCam, width, height, nBitsPerPixel, pcImageMemory, MemID)
if nRet != ueye.IS_SUCCESS:
    print("is_AllocImageMem ERROR")
else:
    # Makes the specified image memory the active memory
    nRet = ueye.is_SetImageMem(hCam, pcImageMemory, MemID)
    if nRet != ueye.IS_SUCCESS:
        print("is_SetImageMem ERROR")
    else:
        # Set the desired color mode
        nRet = ueye.is_SetColorMode(hCam, m_nColorMode)



# Activates the camera's live video mode (free run mode)

# Enables the queue mode for existing image memory sequences
nRet = ueye.is_InquireImageMem(hCam, pcImageMemory, MemID, width, height, nBitsPerPixel, pitch)
if nRet != ueye.IS_SUCCESS:
    print("is_InquireImageMem ERROR")
else:
    print("Press q to leave the program")
a=20


    def __init__(self, deviceID):
        self.deviceID = deviceID

        DeviceID = self.deviceID | ueye.IS_USE_DEVICE_ID
        self.hCam = ueye.HIDS(DeviceID)
        self.sensorInfo = ueye.SENSORINFO()
        self.camInfo = ueye.CAMINFO()
        self.pcImageMemory = ueye.c_mem_p()
        self.MemID = ueye.int()
        rectAOI = ueye.IS_RECT()
        self.pitch = ueye.INT()
        self.nBitsPerPixel = 10  #24: bits per pixel for color mode; take 8 bits per pixel for monochrome
        channels = 1  #3: channels for color mode(RGB); take 1 channel for monochrome
        m_nColorMode = ueye.IS_CM_MONO10  # Y8/RGB16/RGB24/REG32
        bytes_per_pixel = int(self.nBitsPerPixel / 8)
        #nColorMode = IS_CM_MONO10;
        #self.nBitsPerPixel = 10;
        # Starts the driver and establishes the connection to the camera
        nRet = ueye.is_InitCamera(self.hCam, None)
        if nRet != ueye.IS_SUCCESS:
            print("is_InitCamera ERROR")

        # Reads out the data hard-coded in the non-volatile camera memory and writes it to the data structure that self.camInfo points to
        nRet = ueye.is_GetCameraInfo(self.hCam, self.camInfo)
        if nRet != ueye.IS_SUCCESS:
            print("is_GetCameraInfo ERROR")

        # You can query additional information about the sensor type used in the camera
        nRet = ueye.is_GetSensorInfo(self.hCam, self.sensorInfo)
        if nRet != ueye.IS_SUCCESS:
            print("is_GetSensorInfo ERROR")

        nRet = ueye.is_ResetToDefault(self.hCam)
        if nRet != ueye.IS_SUCCESS:
            print("is_ResetToDefault ERROR")

        # Set display mode to DIB
        nRet = ueye.is_SetDisplayMode(self.hCam, ueye.IS_SET_DM_DIB)

        if int.from_bytes(self.sensorInfo.nColorMode.value,
                          byteorder='big') == ueye.IS_COLORMODE_MONOCHROME:
            # for color camera models use RGB32 mode
            m_nColorMode = ueye.IS_CM_MONO10
            self.nBitsPerPixel = ueye.INT(10)
            self.bytes_per_pixel = int(self.nBitsPerPixel / 7) + 1
            print("IS_COLORMODE_MONOCHROME: ", )
            print("\tm_nColorMode: \t\t", m_nColorMode)
            print("\tnBitsPerPixel: \t\t", self.nBitsPerPixel)
            print("\tbytes_per_pixel: \t\t", self.bytes_per_pixel)
            print()

        else:
            # for monochrome camera models use Y8 mode
            m_nColorMode = ueye.IS_CM_MONO8
            self.nBitsPerPixel = ueye.INT(8)
            self.bytes_per_pixel = int(self.nBitsPerPixel / 8) + 1
            print("else")

        # Can be used to set the size and position of an "area of interest"(AOI) within an image
        nRet = ueye.is_AOI(self.hCam, ueye.IS_AOI_IMAGE_GET_AOI, rectAOI,
                           ueye.sizeof(rectAOI))
        if nRet != ueye.IS_SUCCESS:
            print("is_AOI ERROR")

        self.width = rectAOI.s32Width
        self.height = rectAOI.s32Height

        # Prints out some information about the camera and the sensor
        print("Camera model:\t\t",
              self.sensorInfo.strSensorName.decode('utf-8'))
        print("Camera serial no.:\t", self.camInfo.SerNo.decode('utf-8'))
        print("Maximum image self.width:\t", self.width)
        print("Maximum image self.height:\t", self.height)
        print()

        #---------------------------------------------------------------------------------------------------------------------------------------

        # Allocates an image memory for an image having its dimensions defined by self.width
        # and self.height and its color depth defined by self.nBitsPerPixel
        nRet = ueye.is_AllocImageMem(self.hCam, self.width, self.height,
                                     self.nBitsPerPixel, self.pcImageMemory,
                                     self.MemID)
        if nRet != ueye.IS_SUCCESS:
            print("is_AllocImageMem ERROR")
        else:
            # Makes the specified image memory the active memory
            nRet = ueye.is_SetImageMem(self.hCam, self.pcImageMemory,
                                       self.MemID)
            if nRet != ueye.IS_SUCCESS:
                print("is_SetImageMem ERROR")
            else:
                # Set the desired color mode
                nRet = ueye.is_SetColorMode(self.hCam, m_nColorMode)
    def configure_device(self):
        """
        Configure camera.
        
        """
        

        self.nRet = ueye.is_ResetToDefault(self.hid)
        if self.nRet != ueye.IS_SUCCESS:
            print('Reset ERROR')

        ueye.is_Exposure(self.hid, ueye.IS_EXPOSURE_CMD_GET_EXPOSURE_RANGE_MIN, self.minExp, 8)
        ueye.is_Exposure(self.hid, ueye.IS_EXPOSURE_CMD_GET_EXPOSURE_RANGE_MAX, self.maxExp, 8)

        self.nRet = ueye.is_SetDisplayMode(self.hid, ueye.IS_SET_DM_DIB)
        if self.nRet != ueye.IS_SUCCESS:
            print('Display Mode ERROR')
        ueye.is_Exposure(self.hid, ueye.IS_EXPOSURE_CMD_SET_EXPOSURE, self.minExp, 8 )
        ueye.is_Exposure(self.hid, ueye.IS_EXPOSURE_CMD_GET_EXPOSURE, self.Exp, 8 )
        # Set the right color mode
        if int.from_bytes(self.sinfo.nColorMode.value, byteorder='big') == ueye.IS_COLORMODE_BAYER:
            # setup the color depth to the current windows setting
            ueye.is_GetColorDepth(self.hid, self.bitspixel, self.colorm)
            self.bytesppixel = int(self.bitspixel / 8)

        elif int.from_bytes(self.sinfo.nColorMode.value, byteorder='big') == ueye.IS_COLORMODE_CBYCRY:
            # for color camera models use RGB32 mode
            self.colorm = ueye.IS_CM_BGRA8_PACKED
            self.bitspixel = ueye.INT(32)
            self.bytesppixel = int(self.bitspixel / 8)

        elif int.from_bytes(self.sinfo.nColorMode.value, byteorder='big') == ueye.IS_COLORMODE_MONOCHROME:
            # for color camera models use RGB32 mode
            self.colorm = ueye.IS_CM_MONO8
            self.bitspixel = ueye.INT(8)
            self.bytesppixel = int(self.bitspixel / 8)
        else:
            # for monochrome camera models use Y8 mode
            self.colorm = ueye.IS_CM_MONO8
            self.bitspixel = ueye.INT(8)
            self.bytesppixel = int(self.bitspixel / 8)

        self.nRet = ueye.is_AOI(self.hid, ueye.IS_AOI_IMAGE_GET_AOI, self.rect,
                           ueye.sizeof(self.rect))
        self.width = self.rect.s32Width
        self.height = self.rect.s32Height
        self.pixelSizeMicron = self.sinfo.wPixelSize.value / 100

        if self.nRet != ueye.IS_SUCCESS:
            print('AOI ERROR')
        self.nRet = ueye.is_AllocImageMem(self.hid, self.width, self.height,
                                     self.bitspixel, self.ppcImgMem,
                                     self.MemID)
        if self.nRet != ueye.IS_SUCCESS:
            print('AllocImageMem ERROR')
        else:
            self.nRet = ueye.is_SetImageMem(self.hid, self.ppcImgMem, self.MemID)
            if self.nRet != ueye.IS_SUCCESS:
                print('SetImageMem ERROR')
            else:
                self.nRet = ueye.is_SetColorMode(self.hid, self.colorm)

        self.nRet = ueye.is_CaptureVideo(self.hid, ueye.IS_DONT_WAIT)
        #if self.nRet != ueye.IS_SUCCESS:
            #print('CaptureVideo ERROR')
        self.nRet = ueye.is_InquireImageMem(self.hid, self.ppcImgMem, self.MemID,
                                       self.width, self.height, self.bitspixel,
                                       self.pitch)
        if self.nRet != ueye.IS_SUCCESS:
            print('InquireImageMem ERROR')
Exemple #30
0
    return blue_pos, blue_angle, green_pos, green_angle


if __name__=="__main__":
    #Clear error
    cmd.event("clr", 1)
    time.sleep(0.1)

    cmd.event("init_pos")

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

    #Set color mode
    ueye.is_SetColorMode(hcam, ueye.IS_CM_BGR8_PACKED)

    #Set camera resolution
    width = 1280
    height = 720

    #Allocate memory
    mem_ptr = ueye.c_mem_p()
    mem_id = ueye.int()

    #For colormode = IS_CM_BGR8_PACKED
    bitspixel = ueye.INT(24)
    ueye.is_AllocImageMem(hcam, width, height, bitspixel, mem_ptr, mem_id)

    #Set active memory region
    ueye.is_SetImageMem(hcam, mem_ptr, mem_id)