Code Monkey home page Code Monkey logo

Comments (16)

TIS-Tim avatar TIS-Tim commented on August 25, 2024

Can you explain in more detail what "unclear image" means?

from ic-imaging-control-samples.

temp369 avatar temp369 commented on August 25, 2024

Looks like the camera settings changed. I have adjusted the settings in IC capture software for better vision and on running the python script I get a proper image for the first time but for the second time, I a getting an image that looks likes the image settings has changed. If I open and close the software I am getting the proper image.

from ic-imaging-control-samples.

TIS-Tim avatar TIS-Tim commented on August 25, 2024

You should implement proper settings management in your program instead of hoping that the device will keep its state between executions.
The simplest was to do that:

  • Call ShowPropertyDialog. This will display the same dialog that you use in IC Capture to configure device settings
  • Call SaveDeviceStateToFile( ). This Will save the current camera settings into a file
  • On startup, call LoadDeviceStateFromFile( ). This will open the previously opened device and restore all camera settings

from ic-imaging-control-samples.

temp369 avatar temp369 commented on August 25, 2024

I tried without ShowPropertyDialog() and it's doesn't made a difference. When I tried with ShowPropertyDialog I am getting the error "exception: access violation reading 0x0000000000000001" from tisgrabber.py" after giving "ok" in dialog window.

NB = Mine is a dark environment with a display

from ic-imaging-control-samples.

TIS-Stefan avatar TIS-Stefan commented on August 25, 2024

Hello

Please let us know, which camera model you use.
The access violation is unexpected. Where in your code did you use that? I suppose, it is after Camera.open() call, which is, of course, necessary

Stefan

from ic-imaging-control-samples.

temp369 avatar temp369 commented on August 25, 2024

Model No: DFK Z12GP031

I called it after Camera.open().

I tried to save settings without ShowPropertyDialog() and loaded in the next run. It's doesn't made a difference.

from ic-imaging-control-samples.

TIS-Stefan avatar TIS-Stefan commented on August 25, 2024

Hello
Please use the sequence below:

Camera.open("DFK yyyy xxxxx")
Camera.SetContinuousMode(1)
Camera.StartLive(0)
Camera.SnapImage()
Camera.SaveImage(Filename,"JPEG")`
Camera.StopLive()

If the access violation still occurs, please let me know, in which exact line of code it happens.
Thank you in advance!

Stefan

from ic-imaging-control-samples.

erte0011 avatar erte0011 commented on August 25, 2024

Hello,

I have the same access violation issue. The following works fine (no property dialog);

cam.open("DFK yyyy xxxxx") 
cam.SetContinuousMode(1)
cam.StartLive(0)
time.sleep(1.0)
cam.SnapImage()
cam.StopLive()
cam.SaveImage(Filename, "JPEG")

However, adding ShowPropertyDialog() results in the access violation;

cam.open("DFK yyyy xxxxx")
cam.ShowPropertyDialog()
cam.SetContinuousMode(1)
cam.StartLive(0)
time.sleep(1.0)
cam.SnapImage()
cam.StopLive()
cam.SaveImage(Filename, "JPEG")

"...\tisgrabber.py", line 470, in SetContinuousMode
return TIS_GrabberDLL.SetContinuousMode(self._handle, Mode)
OSError: exception: access violation reading 0x0000000000000001

Note, if you instead access the property dialog from ShowDeviceSelectionDialog it works fine;

cam = tisgrabber.TIS_CAM()
cam.open("DFK yyyy xxxxx")
# cam.ShowPropertyDialog()
cam.ShowDeviceSelectionDialog()  # Clicking properties button in this dlg works fine
cam.SetContinuousMode(1)
cam.StartLive(0)
time.sleep(1.0)
cam.SnapImage()
cam.StopLive()
cam.SaveImage(Filename, "JPEG")

I can provide more info if you need it.

Thank you,
-Robert

from ic-imaging-control-samples.

TIS-Stefan avatar TIS-Stefan commented on August 25, 2024

Hello

Can you please add a source code file, so I can try to debug this on next Monday (it is 5:50 pm now, so I wont start this today, Sorry.)

Stefan

from ic-imaging-control-samples.

erte0011 avatar erte0011 commented on August 25, 2024

Sure, please see attached zip containing minimal_example.py
Thank you!

minimal_example.zip

from ic-imaging-control-samples.

erte0011 avatar erte0011 commented on August 25, 2024

Hello, I think I have a fix; looking at tisgrabber.h "IC_ShowPropertyDialog", it appears the return type is int (success, error, etc.), not hgrabber handle. Updating tisgrabber.py as follows makes it work;

Modify Dll interface like this;

ShowPropertyDialog = __tisgrabber.IC_ShowPropertyDialog
# ShowPropertyDialog.restype = GrabberHandlePtr
ShowPropertyDialog.restype = C.c_int
ShowPropertyDialog.argtypes = (GrabberHandlePtr,)

Modify associated method like this;

def ShowPropertyDialog(self):
    # self._handle = TIS_GrabberDLL.ShowPropertyDialog(self._handle)
    return TIS_GrabberDLL.ShowPropertyDialog(self._handle)

I tested and it is working on my setup. I can do a pull request if it makes more sense.

Thanks,
-Robert

from ic-imaging-control-samples.

TIS-Stefan avatar TIS-Stefan commented on August 25, 2024

from ic-imaging-control-samples.

TIS-Stefan avatar TIS-Stefan commented on August 25, 2024

Hello Robert.

You are absolutely correct about the the showPropertydialog call in tisgrabber.py. This is a obvious, stupid copy&paste error. I am very sorry.

However, can you help me regarding what I wrote above about using the ImageFileTypes array?

Thank you in advance!

Stefan

from ic-imaging-control-samples.

erte0011 avatar erte0011 commented on August 25, 2024

As you mention, the 's' method is there for compatibility. In Python 2, strings are already bytes and can be used as-is with ctypes 'c_char_p', whereas in Python 3 strings need to be encoded as a byte string to work, hence the 'strin.encode("utf-8")' line in 's'. So the 's' method is important and used a lot for interfacing with tisgrabber.dll.

In the specific case of the 'ImageFileTypes' dict lookup in 'SaveImage'; as you already said, in Python 3 the key will end up being a byte string after going through the 's' method, and it won't work because the dict is expecting a regular string. In Python 2.7 since the 's' method will not modify the key, then the dict lookup will work. I don't have Python 2.7 installed so I can't test this, but I assume that's why SaveImage was working when this was first implemented/tested. So in summary my opinion is removing the 's' from the 'ImageFileTypes' lookup is the smallest/cleanest solution, with the least impact, that works with both Python 2.7 and 3.x.

I hope this helps answer your question. Also I don't use SaveImage in my specific application, I was just using it as part of the minimal example, so it's not urgent for me at least.

Thanks,
-Robert

from ic-imaging-control-samples.

TIS-Stefan avatar TIS-Stefan commented on August 25, 2024

Hi Robert

thank you for your explanation and the recommendation. I will update the tisgrabber.py as soon as possible.

Stefan

from ic-imaging-control-samples.

temp369 avatar temp369 commented on August 25, 2024

I solved the issue. Later I found that WDR setting is causing the un-stability of the images. When I tried to calibrate the image without WDR, I am getting stable image.

Thank you for the time 👍

from ic-imaging-control-samples.

Related Issues (20)

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.