Comments (12)
You use the outdated Python implementation. It is no longer maintained. Therefore, you can no find a sample. Please look at https://github.com/TheImagingSource/IC-Imaging-Control-Samples/tree/master/Python/tisgrabber for the current version. Look at https://github.com/TheImagingSource/IC-Imaging-Control-Samples/blob/master/Python/tisgrabber/samples/02-open-manually.py in particular:
ic.IC_InitLibrary(0)
hGrabber = ic.IC_CreateGrabber()
ic.IC_OpenVideoCaptureDevice(hGrabber, tis.T("DFK Z30GP031"))
Stefan
from ic-imaging-control-samples.
from ic-imaging-control-samples.
Yes.
That is possible. Use the function "IC_OpenDevByUniqueName"
ic.IC_OpenDevByUniqueName(hGrabber[0],"DFK 33UX287 12345678")
ic.IC_OpenDevByUniqueName(hGrabber[1],"DFK 33UX287 12345679")
See the tisgrabber.chm for a documentation of the DLL:
Stefan
from ic-imaging-control-samples.
from ic-imaging-control-samples.
Hi,
I'm trting, but this is pain.
All I want to do is to get images of 4ms exposure in every 15ms and
feed them to OpenCV process.
My code works with outdated dlls.
Why do you eliminate simple and useful command like
img = Camera.GetImage() ??
thanks
from ic-imaging-control-samples.
Why do you eliminate simple and useful command like
Because it was no longer maintainable. When changing something in the tisgrabber.dll, I needed to make two additionally changes in the Python wrapper. That is was too much work overload. The biggest advantage is, that I do not need to declare every function exported by the tisgrabber.dll in particular. It can be used directly.
How to grab an image and convert it to an OpenCV cvMat is shown at https://github.com/TheImagingSource/IC-Imaging-Control-Samples/blob/master/Python/tisgrabber/samples/11-image-processing.py. From this, you can write a simple function for image grabbing:
def snapimage(hGrabber):
image = None
if ic.IC_SnapImage(hGrabber, 2000) == 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(hGrabber, Width, Height,
BitsPerPixel, colorformat)
# Calculate the buffer size
bpp = int(BitsPerPixel.value / 8.0)
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))
return image
You can enumerate and handle your four cameras as follows:
ic.IC_InitLibrary(0)
devicecount = ic.IC_GetDeviceCount()
grabbers = []
for i in range(0, devicecount):
print("Device {}".format(tis.D(ic.IC_GetDevice(i))))
uniquename = tis.D(ic.IC_GetUniqueNamefromList(i))
print("Unique Name : {}".format(uniquename))
# Uncomment this section, if you want to open all
# video capture devices and show their live streams.
g = ic.IC_CreateGrabber()
ic.IC_OpenDevByUniqueName(g, tis.T(uniquename))
grabbers.append(g)
Now you have a list containing objects for all connected cameras. Next step is configuration:
for grabber in grabbers:
if(ic.IC_IsDevValid(grabber)):
exposureauto = ctypes.c_long()
#Gain
ic.IC_SetPropertySwitch(grabber, tis.T("Gain"), tis.T("Auto"), 0)
ic.IC_SetPropertyAbsoluteValue(grabber, tis.T("Gain"), tis.T("Value"),
ctypes.c_float(0.0))
#Exposure
ic.IC_SetPropertySwitch(grabber, tis.T("Exposure"), tis.T("Auto"), 0)
ic.IC_SetPropertyAbsoluteValue(grabber, tis.T("Exposure"), tis.T("Value"),
ctypes.c_float(0.004))
ic.IC_SetVideoFormat(grabber, tis.T("RGB32 (720x540)" ))
ic.IC_SetFrameRate(grabber, ctypes.c_float(30.0))
# pass 0 instead of 1, if no video window should be visible
ic.IC_StartLive(grabber, 1)
Snapping the images would be
mat0 = snapimage(grabbers[0])
mat1 = snapimage(grabbers[1])
mat2 = snapimage(grabbers[2])
mat3 = snapimage(grabbers[3])
I am not sure, whether this last one could be done in a loop too, because I am not that Python expert.
At the end of your program you have
for grabber in grabbers:
if(ic.IC_IsDevValid(grabber)):
ic.IC_StopLive(grabber)
ic.IC_ReleaseGrabber(grabber)
I hope, this reduces your pain a little bit. And I am very sorry to cause so much pain to you.
Stefan
from ic-imaging-control-samples.
Hi,
They say no pain, no gain. Now I would say more pain, more gain.
I've read through tisgrabber.py, tisgrabber.h and TISGrabberGlobalDefs.h
again and realized that scripts are about the same.
Pain is because of my poor knowledge.
Based on your suggestion, my modified code works almost as expected.
2 more questions come up.
-
How to set "Brightness" value in code ?
-
What is the best way to get images with very short exposure in interval which is much longer than exposure time ?
thank you !
yuji
from ic-imaging-control-samples.
Hello Yuji
Thank you very much for your comment!
Setting Brightness:
ic.IC_SetPropertyRangeValue(grabber, tis.T("Brightness"), tis.T("Value"),ctypes.c_int(123))
What is the best way to get images with very short exposure in interval which is much longer than exposure time ?
If the exposure time is shorter than 1/fps, you do not really need to bother about this.
- If you want to get each image automatically:
Use a callback. FrameReadyCallback. It is called every time, an image is received.
The FrameReadyCallback is called by the Grabber object. Each grabber object has its own thread, therefore, the FrameReadyCallbacks are running in own threads, so they are called in parallel for each of your four cameras.
Make sure, the image processing does not last long, that 1/framerate seconds.
The callback is explained at https://github.com/TheImagingSource/IC-Imaging-Control-Samples/blob/master/Python/tisgrabber/documentation-source/images.rst#frameready-callback
A complete sample for callbacks with many cameras is available at https://github.com/TheImagingSource/IC-Imaging-Control-Samples/blob/master/Python/tisgrabber/samples/41-qt-triggering.py As you can see, the callback function is define only once. All grabber objects use the same function in their thread. (That works!) (Triggering is not necessary, that can be disabled in that sample)
- If you want image on demand only, then you can use the usual snapimage code.
Stefan
from ic-imaging-control-samples.
Hi Stefan
It says "AttributeError: function 'IC_SetPropertyRangeValue' not found"
Did I make something wrong ?
Also I could not find 'IC_SetPropertyRangeValue' in "tisgrabber.py" nor "tisgrabber.h".
If you want image on demand only, then you can use the usual snapimage code.
In above case, snapped image is newest. Yes or No ?
Thank you.
from ic-imaging-control-samples.
My fault. The function is IC_SetPropertyValue():
from ic-imaging-control-samples.
Hi Stefan,
Now it works !
This will be on site next month.
In case of another issue, I will contact you.
I really appreciate your continuing cooperations !
Arigatou Gozaimasita !
yuji
from ic-imaging-control-samples.
Hello Yuji-san
Thank you very much. (I am sorry, my Japanese is totally insufficient)
Stefan
from ic-imaging-control-samples.
Related Issues (20)
- Framesnapsink/Framequesink HOT 3
- Noise Reduction HOT 18
- Taking images after external trigger for a fixed time HOT 13
- How to operate multiple cameras at the same time get image through python HOT 2
- Knowing when callback fails HOT 8
- Detailed trigger mode setting HOT 2
- Capture AVI program is not working HOT 12
- Activate/deactivate external trigger using python script HOT 4
- Exception: A set operation on a VCDProperty object failed HOT 10
- IC_StartLive fail HOT 3
- Cannot get Map Strings for Strobe Mode in python HOT 18
- Get crashed on create MediaStreamSink object in C# in .net core 7 HOT 2
- Web browser stream HOT 5
- Getting the exposure time HOT 3
- IC Imaging source upgrade to 3.5 from 3.4 HOT 1
- Ic imaging control 3.5 HOT 3
- tisfrabber LoadDeviceStateFromFile() and SnapImage HOT 1
- Python (tisgrabber): interaction with camera livestream IC_StartLive HOT 5
- Wondering if it's possible to make the video window scrollable in python HOT 1
- Exposure Mode to Trigger Width with Device Trigger enabled using 3.4 SDK HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ic-imaging-control-samples.