Coder Social home page Coder Social logo

theimagingsource / ic-imaging-control-samples Goto Github PK

View Code? Open in Web Editor NEW
88.0 10.0 50.0 25.68 MB

Windows Sample in C#, C++, Python, LabVIEW and Java

C++ 4.76% C 11.82% Inno Setup 0.21% C# 51.22% Python 7.64% Smarty 7.25% MATLAB 0.15% Visual Basic .NET 14.76% Java 2.16% Batchfile 0.03%
ic imaging control samples python labview java

ic-imaging-control-samples's Introduction

ic-imaging-control-samples's People

Contributors

natanbagrov avatar nexus1203 avatar tis-stefan avatar tis-tim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ic-imaging-control-samples's Issues

Creating overlays for Python NET

Based on qt5-imageprocessing.py and Display Image Processing Result in Overlay for C# I figured that overlays might be added to the buffer through the similar function calls,

Overlay = ic.OverlayBitmapAtPath[TIS.Imaging.PathPositions.Display]
Overlay.Enable = True
Overlay.DrawText(Color.Red, 10, 10, "TEST")

and the path to add the overlay,

ic.OverlayBitmapPosition = TIS.Imaging.PathPositions.Display

So far adding these lines to qt5-imageprocessing.py did not give errors, but the overlays are not copied to the display buffer either.
I tried to edit the image with QPainter in DisplayBuffer.Copy(), but that caused the application to crash.

How can I add overlays like coordinate planes described in the .NET User's Guide to the Python NET app?
Thank you in advance for the support.

Python Expsoure times limited

I am using a DMK UX183 which supports exposure times from 1us to 30s which works well in IC Capture. But when using python, more concretely
Camera.SetPropertyAbsoluteValue("Exposure","Value",2) to set e.g. a 2s exposure time the image returned is only 0s.
Same for exposure times <0.001.

Monochrome formats (Y800 and Y16) still returing 3 bytes per pixel

Using the 32-trigger-callback.py application with a 33GP006 camera and driver version 3.7.1.4512 if you select Y800 or Y16 format types the image size description:

ic.IC_GetImageDescription(hGrabber, Width, Height, BitsPerPixel,
                          colorformat)

# Calculate the buffer size
bpp = int(BitsPerPixel.value/8.0)

still returns 3 bytes per pixel which causes higher than expected memory use. Is there a way to end up with 1 or 2 bytes (Y800 / Y16) as expected?

Is there any plan to support RGB64?

Hello. For now, the SnapImage() function can only capture RGB32 and Y16 formats. Is there any way to get 12bit RGB images? For example, can I decode the buffer to a 12bit RGB format in the FrameReadyCallback() function?

Thank you!

Camera.close() missing leading to memory leak

When constructing the Camera object in some subfunction and grabbing images there, Python will not garbage collect the function since no Camera.close() was ever performed. This rapidly leads to an OutOfMemory Error in Pyton.

Windows Error 0xe06d7363 (WinError -529697949) when setting gain (Python sample code on Windows)

Hi,

Thanks for providing the sample code like this!
I am trying to run tis-OpenCV.py, but the script keeps shutting down at line 79 (Python raises an OSError, with the error code as shown above):

Camera.SetPropertyValue("Gain", "Value", 1)

When I comment the line out, everything else works out as expected, up to the point when I hit Ctrl-C.

Do you have any idea about what is going on?

In case, below is the description of my environment:

  • Windows 10 (probably the latest build as of July 2021)
  • Anaconda
    • Python 3.8.10
    • NumPy 1.20.3
    • OpenCV 4.0.1
  • IC-Imaging-Control-Samples bb2368
  • Camera: DMK 33UP1300 (Driver version: 5.0.1.1607), through a USB3 cable

EDITED: forgot to mention about the acquisition configs. I tried several grayscale settings (Y16, full HD or 640p) with some frame rates (~30 fps, ~50 fps or ~60 fps), and obtained the same results.

Thanks,
Keisuke

Get property nama

Hi
I'm using tissgraber.py on python 3
I want to know if it is possible to have all the property name available for one camer. Especially I need to have the range of Exposure and gain available (like getRangeMin('Exposure')
Thank to help me

Access camera frames without ICImagingControl (.netcore)

Hi,

I'd like to be able to access camera frames without explicitly initializing an ICImagingControl in .NET. I have succcesfully created an ASPCore web server to serve camera frames, however it is reliant on this Windows.Forms control.

The ability to access frames without the overhead of the UI component would allow running a "headless" containerized server to serve frames. Is this possible now?

Thanks,
Aaron

Capturing a bust of images upon hardware trigger

Hi,

I would like to capture and save a finite number of frames at a specified frame rate when a physical trigger is received by the camera. For example, when a hardware trigger is received, 75 frames should be acquired at 25fps over 3 seconds.

All I've been able to do with the library here is "turn on" the live stream when the hardware trigger is received (see code below). Is there no way to also return each frame by using GetImage, for example?

import tisgrabber as IC
cam = IC.TIS_CAM()
cam.ShowDeviceSelectionDialog() # configure trigger, burst count, fps
cam.StartLive(1) # livestream window opens, but displays nothing
# send physical trigger
# livestream window starts showing video, then stops after burst_count frames have been collected

I am using the DFK 33UX273, Python 3.5, Windows 10.

Thanks.

Capture 16 bit greyscale imaging

The SnapImage() function seems to be hardcoded to return 8bit images, even if run in Y16 Video Format. Is there a way to grab a 16bit image in Python?

Cpp OpenCV windows examples

Hello there,

I can see that there are OpenCV examples on the Linux SDK branch, but I was not able to find any over on this branch.
Can you please guide me on how I can interface this SDK to get images in OpenCV?

Thanks in advance

IoT Application - XAML

Hello, I'm trying to generate and IoT app and use an imaging source camera in it.

I'm using the TIS.Imaging.ICImagingControl34 library but it's work with Windows Form and in an IoT app those can't be used.

Did you try something like this or can you give me some advice?

sometimes get NULL point from tisgrabber.GetImage.GetImagePtr()

Hello,
We use DMK 33UX226 camera, and use python code to init camera and get image. We init camera sample code in below.
After init camera, we call Getimage() to get the image data, but sometimes we get NULL point when we call Getimage.getimagePtr().
I would appreciate it if you could give some help to us.

#-------------------------------------------
    def Init_camera():
        lWidth = C.c_long()
        lHeight = C.c_long()
        iBitsPerPixel = C.c_int()
        COLORFORMAT = C.c_int()
        #--------------------------
        # Create the camera object.
        #--------------------------
        Camera = IC.TIS_CAM()
    
        #-------------------------------------------
        # List availabe devices as uniqe names. This is a combination of camera name and serial number
        #-------------------------------------------
        Devices = Camera.GetDevices()
        for i in range(len( Devices )):
            print( str(i) + " : " + str(Devices[i]))
    
        #-------------------------------------------
        # Open a device with hard coded unique name:
        #-------------------------------------------
        Camera.open(bytes.decode(Devices[i]))
        if Camera.IsDevValid() == 1:
            system_log.error("device be found")
    
            #--------------------------------
            # Load default of Camera property
            #--------------------------------
            #Camera.SaveDeviceStateToFile('camera_property.txt')
            with open('camera_property_read.txt','rt',encoding="utf-8") as myfile:
                data = myfile.read()
            with open('camera_property_write.txt','wt',encoding="utf-8") as myfile:
                print(data.replace('DMK 33UX226 31914288', bytes.decode(Devices[i])))
                myfile.write(data.replace('DMK 33UX226 31914288', bytes.decode(Devices[i])))
            Camera.LoadDeviceStateFromFile('camera_property_write.txt')
    
            #-------------------
            # Set a video format
            #-------------------
            Camera.SetVideoFormat("Y800 (4000x3000)")
    
            #-----------------------------------------
            # Set a frame rate of 30 frames per second
            #-----------------------------------------
            Camera.SetFrameRate(5.0)
    
            #--------------------------
            # set iBytesPerPixel=8  (1)
            #--------------------------
            Camera.SetFormat(IC.SinkFormats.Y800)
    
            ExposureAuto = [1]
    
            Camera.GetPropertySwitch("Exposure","Auto",ExposureAuto)
            print("Exposure auto : ", ExposureAuto[0])
            #------------------------------------------------------------------------------------------
            # In order to set a fixed exposure time, the Exposure Automatic must be disabled first.
            # Using the IC Imaging Control VCD Property Inspector, we know, the item is "Exposure", the
            # element is "Auto" and the interface is "Switch". Therefore we use for disabling:
            #------------------------------------------------------------------------------------------
            Camera.SetPropertySwitch("Exposure", "Auto", 0)
            ## "0" is off, "1" is on.
    
            ExposureTime=[0]
            Camera.GetPropertyAbsoluteValue("Exposure","Value",ExposureTime)
            print("Exposure time abs: ", ExposureTime[0])
    
            #------------------------------------------------------------------------------------------
            # Set an absolute exposure time, given in fractions of seconds. 0.0303 is 1/30 second:
            #------------------------------------------------------------------------------------------
            Camera.SetPropertyAbsoluteValue("Exposure","Value",0.0303)
    
            #-----------------------
            # Set Camera gain : auto
            #-----------------------
            Set_Camera_gain(Camera, 0)
    
            #------------------------------------------------------------------------------------------
            # Start the live video stream, but show no own live video window. We will use OpenCV for this.
            #------------------------------------------------------------------------------------------
            Camera.StartLive(0)
    
            return Camera
        else:
            system_log.error("No device selected")
            return False

Gain property setting problem with IC Cameras

Hello,

I am using the python API for the DFK 33UP1300 camera. When I run the "tis-OpenCV.py" demo code, it shows the error related to the "Camera.SetPropertyValue("Gain","Value",10)" line of code. I am not sure if this is a normal issue with the code or the camera hardware. This is the screen shot:
p1
p2

Thanks.

ctypes.ArgumentError: Expected LP_HGRABBER instance instead of LP_HGRABBER

Dear sir,

First, I ran an example 41 without error, however if I close that application and run the program gain, I got a " ctypes.ArgumentError " as below figure:
error

Current solution: restart the kernel every time when running the program.
However, it's quite inconvenient, could you please give me some suggestions to fix this problem?
Thank you so much!

setPropertySwitch for Exposure Auto

Hello,

I'm using tisgrabber.py on Windows with a GigE camera. I'm trying to turn off Auto Exposure temporarily. I have been using calls such as setPropertySwitch('Gain', 'Auto', 0). With Gain and WhiteBalance, I haven't had any difficulty. However, Exposure -- setPropertySwitch('Exposure', 'Auto', 0) -- doesn't work as desired. For example:

import time
import tisgrabber as IC

# Set up camera
Camera = IC.TIS_CAM()
Camera.open('DFM 25GP031-ML 00000000') # insert real serial number...
Camera.SetVideoFormat('RGB32 (640x480)')
Camera.SetFrameRate(8)
Camera.StartLive(0)

Camera.SetPropertySwitch('Gain', 'Auto', 0)
print('Set Auto Exposure Returned: ' + str(Camera.SetPropertySwitch('Exposure', 'Auto', 0)))
Camera.SetPropertySwitch('WhiteBalance', 'Auto', 0)

# Set some values
print('Set Gain Returned: ' + str(Camera.SetPropertyValue('Gain', 'Value', 6)))
print('Set Exposure Returned: ' + str(Camera.SetPropertyValue('Exposure', 'Value', 1234)))

# query them
print('\nImmediately after configuring:')
print('Gain: ' + str(Camera.GetPropertyValue('Gain', 'Value')))
print('Exposure: ' + str(Camera.GetPropertyValue('Exposure', 'Value')))

# wait a bit
time.sleep(0.5)

# query again
print('\nAfter waiting:')
print('Gain: ' + str(Camera.GetPropertyValue('Gain', 'Value')))
print('Exposure: ' + str(Camera.GetPropertyValue('Exposure', 'Value')))

Camera.StopLive()

This code produces the following results on my system:

Set Gain Auto returned: 1
Set Exposure Auto returned: 1
Set WhiteBalance Auto returned: 1
Set Gain Value returned: 1
Set Exposure Value returned: 1

Values immediately after configuring:
Gain: 6
Exposure: 1234

Values after waiting:
Gain: 6
Exposure: 3410 <or some other value not equal to 1234>

I would expect the values for 'Exposure' to remain the same, as I did not change them and 'Auto Exposure' should be turned off and not changing them either. However, the camera behaves as though 'Auto Exposure' was not actually disabled. I cross checked this by examining the Property Page for the device before and after running the program. (I clicked the Update button after each run, and nothing else)
example

As seen in the screenshot, 'Auto Max Exposure' was turned off, but not 'Auto Exposure'. I also note that 'Gain' behaves exactly as desired. Here is a screenshot from the VCD Property Inspector of the properties of 'Exposure' on this device:

inspector

There are two properties by the name 'Auto' under the 'Exposure' section. Perhaps this is the cause of my difficulty, as there may not be a way to distinguish between the two, and the 'Auto Max Exposure' property is taking precedence for arbitrary reasons?

Perhaps my understanding is incorrect and there's a solution I have missed!
Your advice is appreciated -- I'd like to figure out how to programmatically turn off Auto Exposure and instead set Exposure manually.

My apologies for the long post, and thanks for your support.

~Ben

Maximum number of GigE cameras supported on a single computer?

Does the GigE driver have a fundamental limit in the number of simultaneous cameras that are supported? I want to connect 24 cameras through a TRENDnet switch that has a 10GbE uplink to my PC. Each camera is putting out about 370Mbps (24fps 1600x1200 Y800) for an aggregate bandwidth of 8.8Gbps.

I have tested with 2 cameras each saving 12 copies of the frame to disk (to simulate 24 streams) and this works ok (gen 4 NVMe). Bottom line is I have 48 cameras to connect and want to do it with the minimum number of computers possible (hopefully 2)

TIS_GrabberDLL.GetImagePtr() can’t return ImagePtr

Hello.
I've got the problem when running the tis-OpenCV.py. It gave me an error about c and I can't fix it.
OSError: exception: access violation reading 0x0000000000000000
I got this error when trying to get the image, using image=Camera.GetImage()
Thanks a lot if anyone could help.

Camera setting changing after first image capture

While trying to capture the image using python code I am able to get the correct image as per the settings in IC capture software for the first time. But for the second time if I try the same code I am getting some unclear image. If I open and close IC capture software I will be getting the proper image. How to fix this? I also tried the sample code and got the same results.

`

Camera.open("DFK yyyy xxxxx")

Camera.SetContinuousMode(1)

Camera.StartLive(0) 

Camera.SnapImage()

Camera.StopLive() 

Camera.SaveImage(Filename,"JPEG")`

Camera.getImage() returns empty frame

I have a strange error while using your pyhon lib to interface a DMM 42BUC03-ML.

The code seems to work but on some machines the Camera.GetImage() function returns with a all zero array.

I installed the driver, IC Viewer, the thisgrabber dll installer (seperatly, altough it seems included in the Phyton folder as well) .

One pc does work all the time. One pc I had working, then the next morning it would only return black frames during a demo. I tried 5min later and it did work again (with nothing changed...). On another machine I can not get frames no matter what (all Win10 machines).

Is there a way to get some more insight into the thisgrabber dll which the thisgrabber.py accesses? Some debug outputs to analyze or share here?

Open cameras with MODEL NUMBER and/or SERIAL NUMBER

Hi,

Before, we can use MODEL NUMBER and/or SERIAL NUMBER to open cameras like below.

Camera = IC.TIS_CAM()
Camera.open("DFK 33UX287 12345678")
Camera.StartLive(0)
Camera.SnapImage()
im = Camera.GetImage()
im = cv2.flip(im, 0)

I could not find sample which opens camera with MODEL NUMBER and/or SERIAL NUMBER.
Could you please let me know how to do.

thank you in advance !

Explicitly set the gain using the SetPropertyValue value.

I am using tisgrabber.py on a DMK 33UP1300 with Windows.
I am trying to turn off auto gain.
So far I have used calls like Camera.SetPropertyValue('Gain', 'Value', 150).
However, the default value of Gain, 144, is set.
The return code is also -7 and will fail.
Can you tell me why?
For example, it would look like this

import time
import tisgrabber as IC

Set up camera

Camera = IC.TIS_CAM()

Camera.open('DMK 33UP1300 22020377') # insert real serial number...
Camera.SetVideoFormat('Y800 (1280x1024)')
Camera.SetFrameRate(8)
Camera.StartLive(0)

print("Set GainVideoAuto Returned:" , Camera.SetPropertySwitch('Gain', 'Auto', 0))

Set Gain value

print('Set Gain Returned: ' + str(Camera.SetPropertyValue('Gain', 'Value', 150)))

Get Gain value

print('Gain: ' + str(Camera.GetPropertyValue('Gain', 'Value')))

wait a bit

time.sleep(0.5)

query again

print('Gain: ' + str(Camera.GetPropertyValue('Gain', 'Value')))

Camera.StopLive()


Execution result
Set GainVideoAuto Returned: 1
Set Gain Returned: -7
Gain: 144
Gain: 144

OpenCV example code crashes

When I try to run the example code, line 79 in tis-OpenCV.py crashes.

Camera.SetPropertyValue("Gain","Value",10)

The output is:

Traceback (most recent call last): File "D:/rodma/Documents/School/EVD/IC-Imaging-Control-Samples/Python/Open Camera, Grab Image to OpenCV/tis-OpenCV.py", line 79, in <module> Camera.SetPropertyValue("Gain","Value",10) File "D:\rodma\Documents\School\EVD\IC-Imaging-Control-Samples\Python\Open Camera, Grab Image to OpenCV\tisgrabber.py", line 659, in SetPropertyValue error = TIS_GrabberDLL.SetPropertyValue(self._handle, OSError: [WinError -529697949] Windows Error 0xe06d7363

If this is commented out, everything else still works. Is there an issue with my machine? The camera works properly in IC Capture.

MediaStreamSink in IC WPF

Hi Sir,

I am wanting to record my camera output. Initially i tried to use MediaStreamSink as suggested in documentation.

                MediaStreamSink aviSink = new MediaStreamSink();
                // We do not set aviSink.StreamContainer to record an AVI file,
                // as AVI is the default file format.
                // Set DV Video encoder as the codec.
                foreach (AviCompressor codec in AviCompressor.AviCompressors)
                {
                    if (codec.Name == "DV Video Encoder")
                    {
                        aviSink.Codec = codec;
                        break;
                    }
                }

                // Set a target file name.
                aviSink.Filename = "video.avi";
                // Set the sink.
                _ic.Sink = aviSink;
                // Start recording.
                _ic.LiveStart();

Apparently this option is NOT available in Live Mode. How are we supposed to record video while displaying the feed?

Thank you very much for your work on the project. Any help would be greatly appreciated.

Java example property errors

Hi

When trying to run java example with DFK AFU050-L34 I got an error:
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: Failed to query property Gain at ic.PropertyDouble.GetRangePropertyDouble(Native Method) at ic.PropertyDouble.<init>(PropertyDouble.java:11) at ic.Grabber.getProperties(Native Method)

Also it is not possible to change most of the properties (gain, exposure in GUI).

Is it possible that parameters for this camera are integer not double?
By the way, is there source code for ic.jar and JNI dll are available?

Continuous AE

Hello,

I'm working with a GigE camera and the tisgrabber.py library on Windows in Python2.7. I'm trying to configure it such that the Auto Exposure system is continuously running, so when I snap an image, it will already have been auto-exposed. To provide a specific example, here's a little code:

import cv2
import tisgrabber as IC

# Set up camera
Camera = IC.TIS_CAM()
Camera.open('DFM 25GP031-ML 00000000') # insert real serial number...
Camera.SetVideoFormat('RGB32 (640x480)')
Camera.SetFrameRate(8)
Camera.SetPropertySwitch('Exposure', 'Auto', 1)
Camera.SetPropertySwitch('Gain', 'Auto', 1)
Camera.SetPropertySwitch('WhiteBalance', 'Auto', 1)
Camera.SetPropertyValue('Exposure', 'Auto Reference', 128)
Camera.StartLive(0)

# take first image
Camera.SnapImage()
image = Camera.GetImage()
# display it
cv2.imwrite('image1.png', image)
cv2.imshow('Image', image)
cv2.waitKey(0)

# now, scene has changed: AE needs to have readjusted

# take second image
Camera.SnapImage()
image = Camera.GetImage()
# display it
cv2.imwrite('image2.png', image)
cv2.imshow('Image', image)
cv2.waitKey(0)

cv2.destroyWindow('Image')
Camera.StopLive()

I test this code by

  1. pointing the camera at my desk (indoor lighting) and running the program,
  2. viewing the first image and then pointing the camera out the window (bright outdoor lighting) while the program waits (~10s),
  3. pressing a key and viewing the new image.

While the code runs fine, the second image is never exposed correctly. I've attached image1 and image2 for reference.

I'd like the AE to "keep up" even when I'm not actively snapping images. How could I achieve that?

Any help would be much appreciated. Thanks!

image1
image2

Trying to load tisgrabber.dll gives me windows error

Ive tried editing the path- C:\Users\aaron\PycharmProjects\untitled\tisgrabber_x64.dll
Still didnt work. Im i meant to do anything before trying to import. Thanks

WindowsError: [Error 126] The specified module could not be found

`TIS.Imaging.ICImagingControl()` is not released properly and cause memory leaks

Hello,

I reference the issue with this line of code:

ic = TIS.Imaging.ICImagingControl()

When wrapping the referenced file with a for loop, the memory explodes. I've isolated the relevant line (above).
Apparently, ic.LiveStop() (line 82) does not release all resources.

Any suggestions? I don't want to keep ic as some global state.

Best regards!

DisplayImageBuffer(IFrameQueueBuffer buffer) doesn't update ICImagingControl

Hi,

I'm having a bit of an issue displaying saved frames one by one via DisplayImageBuffer, in .NET.

I have set up a FrameQueueSink alongisde a FrameQueueSinkListener. Whenever the listener has a frame queued in output, I save it in a IFrameQueueBuffer[] array to save the last 10 seconds of live imaging, and replay them when I hit a button.

However calling DisplayImageBuffer after calling ic.LiveStop() seems to never update the display (as in the last frame before the call to ic.LiveStop() is frozen).

I have set the ic.LiveDisplay to false before attempting to DisplayImageBuffer.

I understand I might be completely misunderstanding the tools at my disposal, but I have gone through the entire documentation as well as the samples and fall short of understanding my problem.

Thank you for any insight.

Unable to open multiple cameras simultaneously

Greetings,

I am not able to stream from 2 cameras simultaneously with tisgrabber.py

python version: 3.8.12
pywin32-ctypes version: 0.2.0

I modified the sample program 01-Live.py to load two cameras but when I run it, only one camera is streaming.
The modified program is below:
`'''
This sample demonstrates, how to open a camera with the
built in dialog and show a live video stream.
It is changed for import of tisgrabber.py file.
Needed DLLs for 64 bit environment are

  • tisgrabber_x64.dll
  • TIS_UDSHL11_x64.dll
  • tisgrabber.py
    '''
    import ctypes
    import tisgrabber as tis

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

ic.IC_InitLibrary(0)

hGrabber1 = ic.IC_LoadDeviceStateFromFile(None,"camera0.xml".encode("utf-8"))
hGrabber2 = ic.IC_LoadDeviceStateFromFile(None,"camera1.xml".encode("utf-8"))

if( ic.IC_IsDevValid(hGrabber1)):
print("camera1 is valid")
else:
print("camera1 is not valid")

if( ic.IC_IsDevValid(hGrabber2)):
print("camera2 is valid")
else:
print("camera2 is not valid")

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

ic.IC_ReleaseGrabber(hGrabber1)
`

I tried running the sample program 40-qt-stereo.py and got the same result (only 1 camera streaming). The error messages below printed when I run 40-qt-stereo.py. I'm not sure if it's related to the problem I am having.

(py3_8_12) D:\src\repos\IC-Imaging-Control-Samples\Python\tisgrabber\samples>python 40-qt-stereo.py
1.0.0.0
QWindowsContext: OleInitialize() failed: "COM error 0xffffffff80010106 RPC_E_CHANGED_MODE (Unknown error 0x080010106)"
40-qt-stereo.py:266: DeprecationWarning: an integer is required (got type sip.voidptr). Implicit conversion to integers using int is deprecated, and may be removed in a future version of Python.
ic.IC_SetHWnd( LeftCamera, LeftVideo.winId())
40-qt-stereo.py:267: DeprecationWarning: an integer is required (got type sip.voidptr). Implicit conversion to integers using int is deprecated, and may be removed in a future version of Python.
ic.IC_SetHWnd( RightCamera, RightVideo.winId())

How can I stream from multiple cameras simultaneously successfully?
Appreciate any help you can give.
Thank you.

Horizontal black lines on image

I am using a DMK 37BUX287 using TISGrabber.py in python. I am having black horizontal lines show up on every image using SnapImage() that I believe is coming right from the API. Was hoping to track down the issue here.

Here is relevant code:

Camera INIT:

def init_camera(self):
        self.hGrabber = ic.IC_CreateGrabber()
        self.width = 720
        self.height = 100
        ic.IC_OpenVideoCaptureDevice(self.hGrabber, tis.T("DMK 37BUX287"))
        ic.IC_SetVideoFormat(self.hGrabber, tis.T("Y800 ({width}x{height})".format(width=self.width, height=self.height)))
        ic.IC_SetFrameRate(self.hGrabber, ctypes.c_float(5000.0))

Snapping an Image:

    def snap_image(self):
        if ic.IC_SnapImage(self.hGrabber, 1) == tis.IC_SUCCESS:
            # Declare variables of image description
            Width = ctypes.c_long()
            Height = ctypes.c_long()
            BitsPerPixel = ctypes.c_int()
            colorformat = ctypes.c_int()

            # Query the values of image description
            ic.IC_GetImageDescription(self.hGrabber, Width, Height,
                                        BitsPerPixel, colorformat)

            # Calculate the buffer size
            bpp = int(BitsPerPixel.value / 3)
            buffer_size = Width.value * Height.value * bpp

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

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

            # Create the numpy array
            self.cv_img = np.ndarray(buffer=imagedata.contents,
                                     dtype=np.uint8,
                                     shape=(Height.value,
                                            Width.value,
                                            1))
            self.cv_img = np.squeeze(self.cv_img, axis=2)

The image looks like:

image

Another thing to note: I also notice that the return of the "IC_GetImageDescription" function has the bits per pixel coming back as 24, I am shrinking that to 8 (divide by 3)

Any idea where the black lines are coming from?

Possible causes of missing frames?

Hi,

I have been trying to write frames to a video file based on callback functions (more or less like https://github.com/TheImagingSource/IC-Imaging-Control-Samples/blob/master/Python/Open%20Camera%2C%20Grab%20Image%20to%20OpenCV/callback.py ) while reading strobe outputs using an external data acquisition device.

The issue I encounter is that "the number of strobe triggers" and "the number of frames in the video file" often differ from each other (the video files have less frames).

In the implementation, the frame index being passed to the callback function is always referred to, so that the frame i be always followed by the frame i+1. Nevertheless, a 1 h video at 160 FPS have ~10 frames less than what it is supposed to have (or 2-3 frames for a 1 h at 30 FPS).

So I would like to hear your opinion on what could be going on in my situation:

  • Is it possible that frame drops have nevertheless occurred in the course of grabbing? For example, can one in principle detect frame-drop events by checking the frame indices being passed to the callback functions, or must I not rely on these figures for this purpose?
  • Is the callback function possibly dispatched after IC_SuspendLive() or IC_StopLive() are called? If so, is there any way to check how many frames remain to be read from the buffer at the point grabbing stops? (e.g. would it be a sane way to just keep calling IC_GetImagePtr() until a NULL is returned?)

Thanks a lot in advance!
Keisuke

Software trigger (Python)

What is the command to send a software trigger to the camera? There seem to be some clues in the tisgrabber.h but I could not get the Trigger button to work.

The trigger itself exists based on
image
and I also tried using the following command which gave the result to be True.

Camera.PropertyAvailable("Trigger", s("Software Trigger"))

I tried using the following commands with no success:

    Camera.PropertyOnePush("Trigger", "Software Trigger")
    Camera.SetPropertySwitch("Trigger", "Software Trigger", True)
    Camera.SetPropertyValue("Trigger", "Software Trigger", True)

I plan to use hardware triggering, but before doing so would like to use software triggers first.
Thanks, T.

capture with mingw?

Hello
I have an optical inspection application written in C++/QT, using gcc on linux and mingw on windows. Now I need to add support for DFK 33UX183 cameras, as we bought some of them to be used for this task, under windows.
But I can't find any documentation about using mingw (or any other C++ besides the one in Visual Studio) with TheImagingSource cameras. IC-Imaging-Control seems to be only about .NET applications, and for tisgrabber I can only find a chm enumerating all the structures and functions, but no example or explanation about how to do something using this library.
As far as I can tell, this camera is not recognized by windows as a webcam to be used with opencv, as another TheImagingSource camera we bought a few years ago was working.
I only need to grab single frames every now and then, as the processing of one image takes a few seconds.

Pycharm searching file for tisgrabber_x64.dll

Hello, when I run the tisgrabber program in Pycharm I am getting the "[Error 126] The specified module could not be found" error. I have to change the working folder to that folder which contains the "tisgrabber_x64.dll" file. I am wondering if there is a faster way to load the .dll file without changing the working folder? Thanks.

The ground truth of DeviceTimeStamp

Hello TIS team,

I have a question regarding DeviceTimeStamp which I got from FrameMetadata::DeviceTimeStamp.
The current project I'm working on, I need to sync 2 videos which recorded by 2 different camera at same time. In order to make this work, I need to check every frame's timestamp and align it, but I also need to know where the timestamp came from?
Is it from device itself? If so, is it possible that two different devices have different time? How can I set the time for a specific device?
Therefore, I can make sure that the timestamp I got from FrameMetadata can be align directly across different devices.

Hope you have a great day! Thank you.

Best,

W.S.

FrameQueueBufferImpl.Dispose leads to stack overflow.

Hi, I'm trying to use FrameSnapSink introduced in v3.5.

When I dispose result of SnapSingle method, it leads to stack overflow.

Sample code:

using (var buffer = this.Sink.SnapSingle(TimeSpan.FromMilliseconds(timeoutMillisec)))
{
    return buffer.CreateBitmapCopy();
}

And decompiler shows self call in Dispose method.

dispose

Python not responging after clicking the Live window

Hello.

I have a problem. After opening the window using the StartLive method, if the window is made the active one (for example, by clicking on it), Python stops working:
image
Can anyone help me to solve it?

Thanks.

Implementing callback function in python and return data in main loop?

I have been trying to implement the callback function and return the captured image in the main loop, however the examples doesn't show how to do that. I am following this example. Some help will be very appreciated as I am trying to implement the hardware trigger function. Or is there is another way to know if the Frame is ready from the main loop?


import ctypes as C
import tis_utils.tisgrabber as IC
import time as time
import cv2 as cv2
import numpy as np

import sys

def s(strin):
    if sys.version[0] == "2":
        return strin
    if type(strin) == "byte":
        return strin
    return strin.encode("utf-8")

class CallbackUserdata(C.Structure):
    """ Example for user data passed to the callback function. """
    def __init__(self):
        self.width = 0
        self.height = 0
        self.iBitsPerPixel = 0
        self.buffer_size = 0
        self.oldbrightness = 0
    

def Callback(hGrabber, pBuffer, framenumber, pData):
    """ This is an example callback function for image processig  with 
        opencv. The image data in pBuffer is converted into a cv Matrix
        and with cv.mean() the average brightness of the image is
        measuered.

    :param: hGrabber: This is the real pointer to the grabber object.
    :param: pBuffer : Pointer to the first pixel's first byte
    :param: framenumber : Number of the frame since the stream started
    :param: pData : Pointer to additional user data structure
    """
    print("yes")
    if pData.buffer_size > 0:
        image = C.cast(pBuffer, C.POINTER(C.c_ubyte * pData.buffer_size))

        cvMat = np.ndarray(buffer = image.contents,
                        dtype = np.uint8,
                        shape = (pData.height,
                                pData.width,
                                pData.iBitsPerPixel))
        cv2.imshow('image', cvMat)
        cv2.waitKey(1)
        brightness = cv2.mean(cvMat)
        b = int( brightness[0] )
        if b != pData.oldbrightness:
            print( b)
            pData.oldbrightness = b
        print("ok in")
        


# Create the function pointer.
Callbackfunc = IC.TIS_GrabberDLL.FRAMEREADYCALLBACK(Callback)

ImageDescription = CallbackUserdata()    

# Create the camera object.
Camera = IC.TIS_CAM()
Devices = Camera.GetDevices()

for i in range(len( Devices )):
    print( str(i) + " : " + str(Devices[i]))
# Open a camera. 
# Camera.openVideoCaptureDevice("DFx 72BUC02")
Camera.open(Devices[0].decode('utf-8'))
Camera.SetVideoFormat("Y800 (640x480)")
Camera.SetFrameRate(30.0)
# Noe pass the function pointer and our user data to the library.
Camera.SetFrameReadyCallback(Callbackfunc, ImageDescription )
# Handle each incoming frame automatically.
Camera.SetContinuousMode(0)

# Start live video.
Camera.StartLive(0)    

Camera.SetPropertySwitch("Exposure","Auto",0)
Camera.SetPropertyAbsoluteValue("Exposure","Value",1/30)

Camera.SetPropertySwitch("Trigger","Enable",1) # enable hardware trigger!

Camera.SetPropertySwitch("Gain","Auto",0)
Camera.SetPropertyValue("Gain","Value",34)


Imageformat = Camera.GetImageDescription()[:3]
ImageDescription.width = Imageformat[0]
ImageDescription.height= Imageformat[1]
ImageDescription.iBitsPerPixel=Imageformat[2]//8
ImageDescription.buffer_size = ImageDescription.width * ImageDescription.height * ImageDescription.iBitsPerPixel

ExposureTime=[0]

try:
    while ( True ):
        
        #'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        # How to return the image data from the callback function.?
        # or know if frame is ready, so I can call Camera.GetImage() to get the latest frame
        # maybe something like 
        if Camera.FrameReady():
            image = Camera.GetImage()

        #''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        time.sleep(0.1)
        
except KeyboardInterrupt:
    Camera.StopLive()   

IC3D SDK example for Python?

Is there a python example for IC3DSDK?
I am using IC 3D to calibrate a pair of Imaging Source camera. The calibration results are great and I have generated the calibration xml file. Now I want to use these files in python to get XYZ cordinates and disparity maps from left and right images. currently, I am not looking into a live stream solution rather just a offline example where I can load left and right images and pass it the IC3D sdk and return the relevant XYZ coordinates and disparity maps. I see there is a dll file and a ic3d.h file. Any way I could use them to import the functions to python, similar to IC capture sdk?

Any help on this would be much appreciated.
Thank you.

Runtime error with Python example

Hello,

I keep getting a runtime error while running the Python sample code (tis-OpenCV.py) in the line Camera.SetPropertyValue("Gain","Value",10):

Traceback (most recent call last):
File "", line 1, in
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1.1\helpers\pydev_pydev_bundle\pydev_umd.py", line 197, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "C:\Program Files\JetBrains\PyCharm Community Edition 2019.1.1\helpers\pydev_pydev_imps_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "E:/XXX-alpha/code/dynamic/IC-TIS/tis-OpenCV.py", line 79, in
Camera.SetPropertyValue("Gain","Value",10)
File "E:\XXX-alpha\code\dynamic\IC-TIS\tisgrabber.py", line 618, in SetPropertyValue
Value)
OSError: [WinError -529697949] Windows Error 0xe06d7363

The platform is Windows 10, Python 3.6 with DFK 31BU03.H. Do you know how to solve the issue?

Thanks

SnapImage randomly timeout

Hi team,

Thank you for your effort that provide us example, so we can develop based on it.
I have worked with your products over a year. Everything works smoothly. We use your products to create a motion related application for our customers.
However, I create this ticket because there is a thing raising my concern recently. Based on your example, I also used Pythonnet as bridge to utilize your library, so I can get the camera timestamp for further usage. I found out that there is a situation which rarely happen but I have seen few times already.

Using snap sink and set timeout to 5 sec (just like your example); sometimes, the call will continuously timeout every few sec and this won't happen on just one camera, if I have multiple cameras connecting to the same machine, it also happen to other cameras as well.

The other case is cannot connect to camera (open camera), I have checked that no program is using the camera and IC Capture is not running.

Both cases are rarely to see but it happened few times to me; however, once I reboot the computer, then all issues gone. I wonder if you have seen those issues before? Is there any possible case that make those issues happen?

Thank you.

Best,

Takuro

Forgot to provide the device model I'm using right now. It's DFK33GX287.

Zero value

Hi
When I use Tis-openCV-py only a black screen appear.
The camera is working with IC capture software
What is happening.
I use a PC with windows 10 64 bits with python 3.7.6 32 bit
Do you think it is a 32/63. bit problem
Thanks a lot

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.