TheImagingSource / IC-Imaging-Control-Samples

Windows Sample in C#, C++, Python, LabVIEW and Java
92 stars 52 forks source link

DFK37BUX287:WDR function through tisgrabber.py #58

Closed SwHaraday closed 1 year ago

SwHaraday commented 1 year ago

Hi I'm using DFK37BUX287 through tisgrabber.py on Windows10 + Python3.7.

Is it possible to use WDR function with code below ?

ic.IC_SetPropertySwitch(hGrabber, tis.T("ToneMapping"), tis.T("Enable"), 1)
ic.IC_SetPropertySwitch(hGrabber, tis.T("ToneMapping"), tis.T("Auto"), 0)
ic.IC_SetPropertyAbsoluteValue(hGrabber, tis.T("ToneMapping"), tis.T("Intensity"), ctypes.c_float(0.5))
ic.IC_SetPropertyAbsoluteValue(hGrabber, tis.T("ToneMapping"), tis.T("GlobalBrightnessFactor"), ctypes.c_float(0.0))
TIS-Stefan commented 1 year ago

Yes, I think so. I use Python 3.8.10.

I suppose, you encountered an issue, right? Which one?

Stefan

SwHaraday commented 1 year ago

Hi Stefan

Wie geht's ?

Thank you for quick response. They did not work with "ToneMapping" and "GlobalBrightnessFactor". Then found that "Tone Mapping" and "Global Brightness Factor" work. I've read several issue which you mention to disable Tone Mapping (WDR). Does it make any harm on acquisition in case of (FPS=70 Exposure=0.004sec) ?

Our next target products have shiny surface and are under dark environment. As I told you before, images from 4 direction are needed to feed to object detection. I'm trying to achieve image as bright as possible playing with camera setting, because we experienced that lighting without harmful reflection is quite difficult. It is fine if only "Gain" work fine to achieve acceptable (bright enough and no noise) quality. If not, I suppose I have to use WDR. Am I right ?

TIS-Stefan commented 1 year ago

Hello

I am sorry, but I do not have all correct property names in mind, thus, my help was bad. (I could have looked on my own.) You should also set the "Intensity" of Tone Mapping.

I've read several issue which you mention to disable Tone Mapping (WDR). Does it make any harm on acquisition in case of (FPS=70 Exposure=0.004sec) ?

No, it should not, except you have a very weak computer and run into trouble. Tone Mapping is done by software in the driver. The Tone Mapping values to be used depend highly on the light and dynamic situation. If you have a very low dynamic, which means, without Tone Mapping there is nothing very dark and very bright in the image, then Tone Mapping does not make too much sense. In this situation Gamma is more helpful. But it is mainly try and error.

Our next target products have shiny surface and are under dark environment. As I told you before, images from 4 direction are needed to feed to object detection. I'm trying to achieve image as bright as possible playing with camera setting, because we experienced that lighting without harmful reflection is quite difficult. It is fine if only "Gain" work fine to achieve acceptable (bright enough and no noise) quality. If not, I suppose I have to use WDR. Am I right ?

Reflection is always hard. In case you have plastic material to examine, you may try a polarisation filter. You should use the RGB64 video format and Tone Mapping, so you can take a little advantage of 10bits per channel color depth. Are the objects moving? If not, you should consider using HDR. Take four images with different exposure times and merge them: https://docs.opencv.org/3.4/d2/df0/tutorial_py_hdr.html. That could reduce the size of the reflections. You may try the sample: 42-HDR.zip

If the objects are moving, it becomes more complicated and you can play around with camera properties only.

Stefan

SwHaraday commented 1 year ago

Hi Stefan

Thanks for many suggestions. Don't worry about property names.

PC for next project has enough power with USB3 expansion (ZVA-IOI PCIe USB3.0 Quad Channel 4 Port).

Actual image taken at site contains the object and ceiling light.

20221025y01_01

I'm little confused. Is WDR(Tone Mapping) not equal to HDR ? The object is moving at ca. 100mm/sec. I understand HDR is not suitable for moving object, but how about Tone Mapping ?

Anyway, tomorrow I'm planning to visit our factory and play with camera properties.

Yuji

TIS-Stefan commented 1 year ago

Tone Mapping maps the the brirghtnesses so they fit into the whole range of possible values. If you have e.g a brigthness range of 0-1024 you use tone mapping to map this to an 8bit range of 0-256. You use only one image as source. For HDR you take some images with different exposure times and merge them in a smart way, so you get all parts of the image nicely exposed into one image. As shown on the OpenCV link I gave. But: HDR is not option for you, because your object moves.

In you image you have a spot. I suggest to make the light more indirect light and also may use two light sources for the left and right side. I am not sure, whether you can avoid the spot.

Stefan

SwHaraday commented 1 year ago

Hi Stefan

Thank you for detailed explanation. I believe I understood.

Yesterday I played with Gamma, Gain and WDR. Now it is quite sure that quality images can be achieved.

20221215y01_奥下2

During try, I noticed that camera sometimes returned All-White images, when program restarted. Problem solved by unplugging and plugging in the USB. Can you guess what is going on ? I'm not sure about repeatable condition. So I leave this issue open.

added: It happens quite randomly about roughly once in every 5 - 10 times of restart. And unplugging is not necessarily needed for returning normal...

Yuji

TIS-Stefan commented 1 year ago

Hello Yuji

White images are not to be expected, in case all automatics are turned off. However, that is my first guess.

Stefan

SwHaraday commented 11 months ago

Hi Stefan,

Now this system is working nicely. Unfortunately device lost callbacks doesn't work, so I take the way to pick 40x40 pixels from center of each cam image and compare them to previous ones. And judge device lost by count. This process is finished less than 1msec.

Thank you for your kind contribution. Excuse me for the late notification.

Yuji

TIS-Stefan commented 11 months ago

Hello Yuji

If Device Lost is not fired, then there is no device lost at all. Maybe it is only, that your computer interrupts the image data strem transfer, so you do not get complete images anymore .