def restorelastuseddevices():
    ''' Restore the last used devices
    '''
    ic.IC_LoadDeviceStateFromFile(LeftCamera, tis.T("left.xml"))
    if ic.IC_IsDevValid(LeftCamera):
        startCamera(LeftUserData, LeftCamera)

    ic.IC_LoadDeviceStateFromFile(RightCamera, tis.T("right.xml"))
    if ic.IC_IsDevValid(RightCamera):
        startCamera(RightUserData, RightCamera)
    def showDeviceSelectionDlg(self):
        ic.IC_StopLive(self.hGrabber)
        self.hGrabber = ic.IC_ShowDeviceSelectionDialog(None)

        if ic.IC_IsDevValid(self.hGrabber):
            self.startCamera()
            ic.IC_SaveDeviceStateToFile(
                self.hGrabber,
                tis.T("camera{}.xml".format(self.userdata.index)))
def SelectRightDevice():
    global RightCamera

    ic.IC_StopLive(RightCamera)

    RightCamera = ic.IC_ShowDeviceSelectionDialog(None)

    if ic.IC_IsDevValid(RightCamera):
        ic.IC_SetHWnd(RightCamera, RightVideo.winId())
        startCamera(LeftUserData, RightCamera)
        ic.IC_SaveDeviceStateToFile(RightCamera, tis.T("right.xml"))
예제 #4
0
import ctypes 
import tisgrabber as tis
import time
import os.path

ic = ctypes.cdll.LoadLibrary("./tisgrabber_x64.dll")

tis.declareFunctions(ic)

ic.IC_InitLibrary(0)

hGrabber = tis.openDevice(ic)

if(ic.IC_IsDevValid(hGrabber)):
    # Set a "big" video format
    ic.IC_SetVideoFormat(hGrabber, tis.T("Y800 (1024x768)"))
    ic.IC_SetFrameRate(hGrabber, ctypes.c_float(30.0))

    ic.IC_StartLive(hGrabber, 1)
    ic.IC_MsgBox(tis.T("Click OK to to use a smaller format"),
                 tis.T("ROI Demo"))
    ic.IC_StopLive(hGrabber)

    # Set a an ROI on the sensor. Make sure, the width and height are valid
    #  for the used camera!
    ic.IC_SetVideoFormat(hGrabber, tis.T("Y800 (640x480)"))
    ic.IC_SetFrameRate(hGrabber, ctypes.c_float(30.0))

    # Moving the ROI on the sensor need to disable the Partial Scan Auto Center
    # property:
    ic.IC_SetPropertySwitch(hGrabber, tis.T("Partial scan"),
import ctypes
import tisgrabber as tis
import time

ic = ctypes.cdll.LoadLibrary("./tisgrabber_x64.dll")
tis.declareFunctions(ic)

ic.IC_InitLibrary(0)

hGrabber = ic.IC_CreateGrabber()

ic.IC_OpenVideoCaptureDevice(hGrabber, tis.T("DMK 33UX290"))

if ic.IC_IsDevValid(hGrabber):
    inn = ctypes.c_long()
    while True:
        ic.IC_PropertyOnePush(hGrabber, tis.T("GPIO"), tis.T("Read"))
        ic.IC_GetPropertyValue(hGrabber, tis.T("GPIO"), tis.T("GP In"), inn)
        print(inn.value)
        time.sleep(1)

else:
    ic.IC_MsgBox(tis.T("No device opened"), tis.T("Simple Live Video"))

ic.IC_ReleaseGrabber(hGrabber)
"""
This sample shows, how to create an XML configuration file 
for a video capture device.
"""

import ctypes
import tisgrabber as tis

ic = ctypes.cdll.LoadLibrary("./tisgrabber_x64.dll")
tis.declareFunctions(ic)

ic.IC_InitLibrary(0)

hGrabber = ic.IC_ShowDeviceSelectionDialog(None)

if (ic.IC_IsDevValid(hGrabber)):
    ic.IC_SaveDeviceStateToFile(hGrabber, tis.T("device.xml"))
else:
    ic.IC_MsgBox(tis.T("No device opened"), tis.T("Simple Live Video"))

ic.IC_ReleaseGrabber(hGrabber)
예제 #7
0
import tisgrabber as tis

ic = ctypes.cdll.LoadLibrary("./tisgrabber_x64.dll")

tis.declareFunctions(ic)

ic.IC_InitLibrary(0)

hGrabber = tis.openDevice(ic)

if (ic.IC_IsDevValid(hGrabber)):
    ic.IC_StartLive(hGrabber, 1)
    key = ""
    while key != "q":
        print("s: Save an image")
        print("q: End program")
        key = input('Enter your choice:')
        if key == "s":
            if ic.IC_SnapImage(hGrabber, 2000) == tis.IC_SUCCESS:
                ic.IC_SaveImage(hGrabber, tis.T("test.jpg"),
                                tis.ImageFileTypes['JPEG'], 90)
                print("Image saved.")
            else:
                print("No frame received in 2 seconds.")

    ic.IC_StopLive(hGrabber)
else:
    ic.IC_MsgBox(tis.T("No device opened"), tis.T("Simple Live Video"))

ic.IC_ReleaseGrabber(hGrabber)
print("Available Frame Filters")
for filter in Filterlist:
    print(tis.D(filter))

# Create the handle of one frame filter, we want to use.
FilterHandle = tis.HFRAMEFILTER()
'''
For using the Rotate Flip frame filter, please refer to
https://www.theimagingsource.com/support/documentation/ic-imaging-control-cpp/stdfilterRotateFlip.htm

For frame filter parameter types see FRAMEFILTER_PARAM_TYPE class in
tisgrabber.py
'''

# Create the frame filter and list its parameters
if ic.IC_CreateFrameFilter(tis.T("Rotate Flip"),
                           FilterHandle) == tis.IC_SUCCESS:
    print("Frame filter loaded. Available Parameters are:")
    for i in range(0, FilterHandle.ParameterCount):
        print("Name: {}, Type: {}".format(FilterHandle.Parameters[i].Name,
                                          FilterHandle.Parameters[i].Type))
else:
    print("Frame filter load failed")
    quit()

hGrabber = ic.IC_ShowDeviceSelectionDialog(None)

if (ic.IC_IsDevValid(hGrabber)):
    # Add the frame filter to our hGrabber.
    ic.IC_AddFrameFilterToDevice(hGrabber, FilterHandle)
import ctypes 
import tisgrabber as tis

ic = ctypes.cdll.LoadLibrary("./tisgrabber_x64.dll")
tis.declareFunctions(ic)

ic.IC_InitLibrary(0)

hGrabber = ic.IC_ShowDeviceSelectionDialog(None)

if(ic.IC_IsDevValid(hGrabber)):
    exposureauto = ctypes.c_long()
    ic.IC_SetPropertySwitch(hGrabber, tis.T("Exposure"), tis.T("Auto"),
                            exposureauto)
    print("Exposure Auto is {0}".format(exposureauto.value))

    ic.IC_SetPropertySwitch(hGrabber, tis.T("Exposure"), tis.T("Auto"), 0)
    ic.IC_SetPropertyAbsoluteValue(hGrabber, tis.T("Exposure"), tis.T("Value"),
                                   ctypes.c_float(0.0303))

    expmin = ctypes.c_float()
    expmax = ctypes.c_float()
    exposure = ctypes.c_float()
    ic.IC_GetPropertyAbsoluteValue(hGrabber, tis.T("Exposure"), tis.T("Value"),
                                   exposure)
    ic.IC_GetPropertyAbsoluteValueRange(hGrabber, tis.T("Exposure"), tis.T("Value"),
                                        expmin, expmax)
    print("Exposure is {0}, range is {1} - {2}".format(exposure.value,
                                                       expmin.value, expmax.value))

    gainmin = ctypes.c_long()
def ShowLeftProperties():
    global LeftCamera

    if ic.IC_IsDevValid(LeftCamera):
        ic.IC_ShowPropertyDialog(LeftCamera)
        ic.IC_SaveDeviceStateToFile(LeftCamera, tis.T("left.xml"))
예제 #11
0

# Manage the callbacks
# Create the function pointer.
frameReadyCallbackfunc = ic.FRAMEREADYCALLBACK(frameReadyCallback)
userdata = CallbackUserdata()
devicelostcallbackfunc = ic.DEVICELOSTCALLBACK(deviceLostCallback)

hGrabber = ic.IC_ShowDeviceSelectionDialog(None)

if ic.IC_IsDevValid(hGrabber):
    userdata.devicename = ic.IC_GetDeviceName(hGrabber).decode(
        'utf-8', 'ignore')
    userdata.connected = True

    ic.IC_SetCallbacks(hGrabber, frameReadyCallbackfunc, None,
                       devicelostcallbackfunc, userdata)

    ic.IC_StartLive(hGrabber, 1)
    print("Disconnect camera now!")

    # Wait for disconnect
    while (userdata.connected):
        time.sleep(0.5)

    ic.IC_StopLive(hGrabber)
else:
    ic.IC_MsgBox(tis.T("No device opened"), tis.T("Device Lost Example"))

ic.IC_ReleaseGrabber(hGrabber)
 def showPropertyDlg(self):
     if ic.IC_IsDevValid(self.hGrabber):
         ic.IC_ShowPropertyDialog(self.hGrabber)
         ic.IC_SaveDeviceStateToFile(
             self.hGrabber,
             tis.T("camera{}.xml".format(self.userdata.index)))
 def loadDeviceState(self):
     if os.path.exists("camera{}.xml".format(self.userdata.index)):
         ic.IC_LoadDeviceStateFromFile(
             self.hGrabber,
             tis.T("camera{}.xml".format(self.userdata.index)))
         self.startCamera()
        cvMat = np.ndarray(buffer=image.contents,
                           dtype=np.uint8,
                           shape=(Height.value, Width.value, bpp))

        # Do something with cvMat here.


# Manage the callbacks
# Create the function pointer.
frameReadyCallbackfunc = ic.FRAMEREADYCALLBACK(frameReadyCallback)
userdata = CallbackUserdata()

hGrabber = ic.IC_ShowDeviceSelectionDialog(None)

if ic.IC_IsDevValid(hGrabber):
    ic.IC_SetFrameReadyCallback(hGrabber, frameReadyCallbackfunc, userdata)
    ic.IC_SetContinuousMode(hGrabber, 0)
    ic.IC_SetPropertySwitch(hGrabber, tis.T("Trigger"), tis.T("Enable"), 1)
    ic.IC_StartLive(hGrabber, 1)
    ic.IC_MsgBox(tis.T("Click OK to trigger"), tis.T("Simple Live Video"))
    ic.IC_PropertyOnePush(hGrabber, tis.T("Trigger"),
                          tis.T("Software Trigger"))

    ic.IC_MsgBox(tis.T("Click OK to stop"), tis.T("Simple Live Video"))
    ic.IC_StopLive(hGrabber)
else:
    ic.IC_MsgBox(tis.T("No device opened"), tis.T("Simple Live Video"))

ic.IC_ReleaseGrabber(hGrabber)
'''
This sample demonstrates, how to open a camera by its model name
set a video format and frame rate and show a live video stream.
Needed DLLs for 64 bit environment are
- tisgrabber_x64.dll
- TIS_UDSHL11_x64.dll
'''
import ctypes
import tisgrabber as tis

ic = ctypes.cdll.LoadLibrary("./tisgrabber_x64.dll")
tis.declareFunctions(ic)

ic.IC_InitLibrary(0)

hGrabber = ic.IC_CreateGrabber()

ic.IC_OpenVideoCaptureDevice(hGrabber, tis.T("DFK Z30GP031"))

if (ic.IC_IsDevValid(hGrabber)):
    ic.IC_SetVideoFormat(hGrabber, tis.T("RGB32 (640x480)"))
    ic.IC_SetFrameRate(hGrabber, ctypes.c_float(30.0))

    ic.IC_StartLive(hGrabber, 1)
    ic.IC_MsgBox(tis.T("Click OK to stop"), tis.T("Simple Live Video"))
    ic.IC_StopLive(hGrabber)
else:
    ic.IC_MsgBox(tis.T("No device opened"), tis.T("Simple Live Video"))

ic.IC_ReleaseGrabber(hGrabber)
def ShowRightProperties():
    global RightCamera

    if ic.IC_IsDevValid(RightCamera):
        ic.IC_ShowPropertyDialog(RightCamera)
        ic.IC_SaveDeviceStateToFile(RightCamera, tis.T("right.xml"))
                buffer_size = Width.value * Height.value * BitsPerPixel.value

                # Get the image data
                imagePtr = ic.IC_GetImagePtr(hGrabber)

                imagedata = ctypes.cast(
                    imagePtr, ctypes.POINTER(ctypes.c_ubyte * buffer_size))

                # Create the numpy array
                image = np.ndarray(buffer=imagedata.contents,
                                   dtype=np.uint8,
                                   shape=(Height.value, Width.value, bpp))

                # Apply some OpenCV functions on the image
                image = cv2.flip(image, 0)
                image = cv2.erode(image, np.ones((11, 11)))

                cv2.imshow('Window', image)
                cv2.waitKey(10)
            else:
                print("No frame received in 2 seconds.")

    ic.IC_StopLive(hGrabber)

    cv2.destroyWindow('Window')

else:
    ic.IC_MsgBox(tis.T("No device opened"), tis.T("Simple Live Video"))

ic.IC_ReleaseGrabber(hGrabber)
Pause and unpause AVI capture
"""

import ctypes
import tisgrabber as tis

ic = ctypes.cdll.LoadLibrary("./tisgrabber_x64.dll")

tis.declareFunctions(ic)

ic.IC_InitLibrary(0)

hGrabber = tis.openDevice(ic)

if (ic.IC_IsDevValid(hGrabber)):
    codec = ic.IC_Codec_Create(tis.T("MJPEG Compressor"))
    """ Show the codec's property page, if it has one. """
    if ic.IC_Codec_hasDialog(codec):
        ic.IC_Codec_showDialog(codec)

    ic.IC_SetCodec(hGrabber, codec)  # Assign the selected codec to the grabber
    ic.IC_SetAVIFileName(hGrabber, tis.T("test.avi"))  # Assign file name
    ic.IC_enableAVICapturePause(hGrabber, 1)  # Pause avi capture.

    if ic.IC_StartLive(hGrabber, 1) == tis.IC_SUCCESS:

        ic.IC_MsgBox(tis.T("Click to start capture"), tis.T("AVI Capture"))
        ic.IC_enableAVICapturePause(hGrabber, 0)  # Unpause avi capture.

        ic.IC_MsgBox(tis.T("Click to stop capture"), tis.T("AVI Capture"))
        ic.IC_StopLive(hGrabber)