zivid / zivid-python-samples

Python code samples for Zivid
https://zivid.com
BSD 3-Clause "New" or "Revised" License
37 stars 14 forks source link

Improve error message if file loading fails when app is not running #137

Closed SamDM closed 7 months ago

SamDM commented 2 years ago

When executing the code:

import zivid
# zivid.Application()  # uncomment to make the code work
frame = zivid.Frame(zdf_path)

The result is:

    def __init__(self, file_name):
        """Create a frame by loading data from a file.

        Args:
            file_name: A pathlib.Path instance or a string specifying a Zivid Data File (ZDF)

        Raises:
            TypeError: Unsupported type provided for file name
        """
        if isinstance(file_name, (str, Path)):
>           self.__impl = _zivid.Frame(str(file_name))
E           RuntimeError: Failed to load .zdf file. To load this file you may need to update to a newer version of Zivid SDK.

The error message is misleading, the true problems seems to be that the application is not initialized. Running zivid.Application() before loading the file solves the issue.

It took me an hour to figure out this was the problem, installing and re-installing zivid libraries in new envs and such.

In the meantime, I hope this issue may help a future dev encountering this may find this page by googling, and identify the issue faster. 😃

SatjaSivcev commented 2 years ago

I am sorry for the inconvenience and the time you spent on this Sam. Zivid::Application must be kept alive while operating the Zivid Camera. This is essentially the Zivid driver. I suggest going through the Capture Tutorial that we host on our Knowledge Base to get familiar with the process: https://support.zivid.com/latest/academy/camera/capture-tutorial.html