Skip to content
Kazunari Kudo edited this page Dec 10, 2018 · 39 revisions

Harvester raises ClosedException but I don't know why

I'm just creating ImageAcquirer objects passing a factory method a Harvester object:

class Foo:
    def create_image_acquirer(harvester: Harvester, index: int):
        return harvester.create_image_acquirer(id_=index)

However, Harvester unexpectedly raises ClosedException. Why?

Exception ignored in: <function ImageAcquirer.__del__ at 0x0000019F2A2E8C80>
Traceback (most recent call last):
  File "C:\Python37\lib\site-packages\harvesters\core.py", line 1383, in __del__
    self.destroy()
  File "C:\Python37\lib\site-packages\harvesters\core.py", line 1968, in destroy
    self._parent._destroy_image_acquirer(self)
  File "C:\Python37\lib\site-packages\harvesters\core.py", line 2489, in _destroy_image_acquirer
    id_ = ia._device.id_
  File "C:\Python37\lib\site-packages\genicam2\gentl.py", line 3238, in _get_id_
    return _gentl.Device__get_id_(self)
_gentl.ClosedException: GenTL exception: Tried to call a function but the library has been closed. Call GCInitLib first. (ID: -10002)

Answer

A possible short answer is you don't hold the Harvester object while the created ImageAcquirer objects.

Nothing wrong with creating ImageAcquirer objects calling a factory method but if the Foo object reaches out to its life although the ImageAcquirer objects will keep existing, the C++ objects of each Python ImageAcquirer object will be automatically destructed by design.

Having that destruction, the ImageAcquirer objects turn dangling and any operation on the objects lose meaning because it's C++ object has gone.

Again, please keep holding the Harvester object as long as you keep holding ImageAcquirer objects.

I want to upgrade Harvester to an arbitrary version

How can I upgrade Harvester to an arbitrary version using pip?

Answer

You can upgrade/downgrade Harvester just typing as follows; if you want to upgrade to 0.2.0 then:

$ pip install harvesters==0.2.0

I want to identify the dependency of the installed Python packages

It's not always but sometimes I need to check the dependenies of the Python packages that I installed using pip. Is there any way to easily make it?

Answer

Maybe pipdeptree could help you. You can install pipdeptree typing the following command:

$ pip install pipdeptree

After installed that, type the following command:

$ pipdeptree

It will dispay the dependency tree.

I pointed out a CTI file but Harvester says the image doesn't exist (Part 2)

Following the "Getting started" page, I copied a CTI file to my location and actually pointed out the location where my target CTI files are located as follows:

h = Harvester()
h.add_cti_file('my_target.cti')
h.update_device_info_list()
_gentl.LoadLibraryException: GenTL exception: Failed to load CTI file; The specified module could not be found. (ID: -10001)

Answer

A CTI file is a shared library actually. So PLEASE DO NOT USE THE COPIED CTI FILE!! PLEASE!! Library manufacturers provide you CTI files in appropriate locations because the libraries may need to retrieve relevant libraries to link. If you use the copied one, it may be located in an incorrect location where the library can't load other relevant libraries.

I pointed out a CTI file but Harvester says the image doesn't exist (Part 1)

Following the "Getting started" page, I actually pointed out the location where my target CTI files are located as follows:

h = Harvester()
h.add_cti_file('c:\path\to\my_target.cti')
h.update_device_info_list()
_gentl.LoadLibraryException: GenTL exception: Failed to load CTI file; The specified module could not be found. (ID: -10001)

Answer

If you want to describe a file path using the Windows style directory separator, you will have to use \\ instead of \. I mean you had to code as follows:

h = Harvester()
h.add_cti_file('c:\\path\\to\\my_target.cti')

Or, the UNIX style is also a way to go:

h.add_cti_file('c:/path/to/my_target.cti')

I actually loaded a .cti file but Harvester returns me an error

Following the "Getting started" page, I actually pointed out the location where my target CTI files are located as follows:

h = Harvester()
h.add_cti_file('/path/to/my_target.cti')
h.update_device_info_list()

However, Harvester raises the following exception.

_gentl.LoadLibraryException: GenTL exception: Failed to load CTI file; /home/server/Desktop/ctifiles/GxGVTL.cti: invalid ELF header (ID: -10001)

Answer

Are you sure the CTI file was generated for your target operating system? In general, CTI files are system dependent and usually don't work on other operating systems; so the Windows version works only on Windows and the others as well. Actually, CTI files are shared objects or DLLs that renamed the file extension to cti. Please make sure if the CTI file is generated for your target operatingsystem.

Images in .rst files are not displayed on my web browser

Any image in .rst files is not correctly displayed on my web browser while I'm trying it at my office. However, they are actually displayed if I browse them on my private laptop. What is the difference?

Answer

Perhaps your company's Proxy server could be blocking you to access the resources in GitHub domain. In this case, you should browse the .rst file locally.

First, you should clone out repository:

Then install a restructured text file browser called restview:

$ pip install restview

Finally, open the README.rst in your working copy from it:

$ restview README.rst

restview will open your default web browser and show the contents of the .rst file. In the displayed contents the images in the .rst file should be correctly displayed.

Clone this wiki locally