sr99622 / libonvif

Onvif library with GUI implementation and built in YOLOX
GNU Lesser General Public License v2.1
154 stars 39 forks source link

onvif-util (v.2.1.1) can't find camera, but onvif-gui (v1.4.4) can?! #93

Open rbelew opened 2 months ago

rbelew commented 2 months ago

hi, a new libonvif user and already a fan, thanks for your work.

TL;DR: Ubuntu 24.04 apt only knew about onvif-gui v1.4.4, and so i started with that. onvif-gui could use it to discover the camera, but onvif-util -a could not. if i give onvif-util full user/pw/IPnumber parameters it just hangs. prior to posting this issue, i tried to install libonvif v2.1.1 and while it seems to install correctly, the pip package cannot load: "`GLIBCXX_3.4.32' not found". Trying to use pip to install onvif-gui fails with bad dependency: "onvif-gui 2.1.1 depends on PyQt6-Qt6==6.6.1"

[versions: Ubuntu 24.04, python 3.12.4]

even that summary is too long! Basically i'm running into issues installing the new 2.1.1 versions. i happen to have been using an earlier release v1.4.4 because that's what the ubuntu repo knew about, and this onvif-gui can discover the camera, while the v1.4.4 onvif-util could not.

Here is python3 -m pip install onvif-gui issue:

ERROR: Cannot install onvif-gui==2.0.1, onvif-gui==2.0.9, onvif-gui==2.1.0 and onvif-gui==2.1.1 because these package versions have conflicting dependencies.

    The conflict is caused by:
    onvif-gui 2.1.1 depends on PyQt6-Qt6==6.6.1; platform_system != "Darwin"
    onvif-gui 2.1.0 depends on PyQt6-Qt6==6.6.1; platform_system != "Darwin"
    ...

I figured maybe I'd have different luck with onvif-util which wouldn't have a Qt6 issues...? following the install instructions for linux onvif-util here

work just fine:

    [ 66%] Built target libonvif
    [100%] Built target onvif-util
    Install the project...
    -- Install configuration: ""
    -- Installing: /usr/local/lib/libonvif.so.1
    -- Installing: /usr/local/lib/libonvif.so
    -- Installing: /usr/local/bin/onvif-util
    -- Set non-toolchain portion of runtime path of "/usr/local/bin/onvif-util" to ""
    -- Installing: /usr/local/include/aarch64-linux-gnu/onvif.h
    -- Installing: /usr/local/include/aarch64-linux-gnu/onvif_data.h
    -- Installing: /usr/local/include/aarch64-linux-gnu/session.h
    -- Installing: /usr/local/share/man/man1/onvif-util.1
    (zm) rik@eye5:~/git/libonvif/build$ sudo ldconfig

and running onvif-util -a runs just fine BUT STILL DOESN'T FIND THE CAMERA!:

Looking for cameras on the network...
Found 0 cameras

running onvif-util -u USER -p PW IPNumber still hangs. Trying to import the libonvif package into python also fails:

    Python 3.12.4 | packaged by Anaconda, Inc. | (main, Jun 18 2024, 15:03:55) [GCC 11.2.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import libonvif
    Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
    File ".../envs/zm/lib/python3.12/site-packages/libonvif/__init__.py", line 19, in <module>
    sys.modules[name] = importlib.util.module_from_spec(spec)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    ImportError: .../envs/zm/bin/../lib/libstdc++.so.6: version `GLIBCXX_3.4.32' not found (required by .../envs/zm/lib/python3.12/site-packages/libonvif/libonvif.cpython-312-aarch64-linux-gnu.so)

It appears the libonvif.cpython-312-aarch64-linux-gnu.so library is not built or where it should be?

Sorry to dump these messy issues in a pile, but that's how life deals them out some times! Thanks for any help. - Rik

sr99622 commented 2 months ago

Thank you so much for taking the time to put this summary together, it contains a lot of useful information. There are a number of issues at play here that can influence the performance of the applications. There is some history as well that could use some explaining.

As to the history, v1.4.4 version is a fundamentally different program than the 2.x versions. The 1.4.4 versions are what reside in the Ubuntu apt repository and are C++ entirely. The v2.x are based on python for the GUI program, although the current version of onvif-util is still C++ based. For starters, I would recommend removing the libonvif apt packages if you still have those on the machine.

Another issue that comes into play is the difference between the discovery options of the two programs. Onvif GUI has the ability to search through all of the network interfaces on the host computer, whereas onvif-util will only use the primary network interface. If your host has more than one interface, this could be an explanation as to why the gui can find the cameras, but the util cannot. I will update the util program to include this feature, it is an omission that should be addressed.

Looking at the outputs, it appears that the host computer is an ARM based architecture. This has not been tested for Ubuntu, which may or may not be an issue. The GUI has been tested on MAC OS, which is also an ARM architecture, so it should theoretically work. Additionally, it looks like the installation was done with an Anaconda version of python, which is less well tested than using a virtualenv python environment. Although this should not be a problem, it does introduce some uncertainty.

My suggestion would be to create a fresh python virtual environment and try to build Onvif GUI from source. At the very least, this will produce the compiler output messages which can be further analyzed for error messages.

sudo apt install git cmake g++ python3-pip virtualenv libxml2-dev libavdevice-dev libsdl2-dev '^libxcb.*-dev' libxkbcommon-x11-dev
virtualenv myenv
source myenv/bin/activate
git clone --recursive https://github.com/sr99622/libonvif
cd libonvif
assets/scripts/compile

The output of the last command line is a summary of the installation process. If there are no errors, the program should be working properly. One potential pitfall could be the operation of PyQt6 running on ARM. I am looking for a good ARM linux machine currently, and hope to be testing one soon.

Once again, thank you for your inquiry, I hope this has been useful. Please let me know if you experience further issues.

Stephen

rbelew commented 2 months ago

hi Stephen, ok i've done as you suggested. and the build ran for a bit before failing:

Successfully built avio Installing collected packages: avio Successfully installed avio-3.2.0 Processing /home/rik/libonvif/onvif-gui Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... done Requirement already satisfied: libonvif==3.2.0 in /home/rik/zmve/lib/python3.12/site-packages (from onvif-gui==2.1.1) (3.2.0) Requirement already satisfied: avio==3.2.0 in /home/rik/zmve/lib/python3.12/site-packages (from onvif-gui==2.1.1) (3.2.0) Collecting numpy (from onvif-gui==2.1.1) Using cached numpy-2.0.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.metadata (62 kB) Collecting loguru (from onvif-gui==2.1.1) Using cached loguru-0.7.2-py3-none-any.whl.metadata (23 kB) Collecting opencv-python (from onvif-gui==2.1.1) Using cached opencv_python-4.10.0.84-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.metadata (20 kB) INFO: pip is looking at multiple versions of onvif-gui to determine which version is compatible with other requirements. This could take a while.

ERROR: Ignored the following versions that require a different python version: 1.21.2 Requires-Python >=3.7,<3.11; 1.21.3 Requires-Python >=3.7,<3.11; 1.21.4 Requires-Python >=3.7,<3.11; 1.21.5 Requires-Python >=3.7,<3.11; 1.21.6 Requires-Python >=3.7,<3.11 ERROR: Could not find a version that satisfies the requirement PyQt6-Qt6==6.6.1; platform_system != "Darwin" (from onvif-gui) (from versions: none) ERROR: No matching distribution found for PyQt6-Qt6==6.6.1; platform_system != "Darwin"

Is there a way to tweak your build to just get onvif-util, avoiding the Qt6 issues?

sr99622 commented 2 months ago

Thank you for trying, sorry for the confusion. You can install the onvif-util with the following commands. It looks like you have already tried this approach. You will probably still experience the inability to find the cameras on a second network interface as the onvif-util does not yet have the mulitple network discovery function.

git clone --recursive https://github.com/sr99622/libonvif
cd libonvif
mkdir build
cd build
cmake -DWITHOUT_PYTHON=ON ..
make
sudo make install
sudo ldconfig

If you wanted to try something else, you could edit the pyproject.toml file in the onvif-gui directory to remove the version requirement on PyQt6. The requirement for that version is not a major issue, and you will most likely be able to get the thing running with whatever version exists for your platform. It's a pretty easy edit, so it might be worth a shot.

The file you are looking for is libonvif/onvif-gui/pyproject.toml and what you want to do is to remove the ==6.6.1 qualifiers on the PyQt6 components of the dependencies section so that it looks like this:

  dependencies = [
    'libonvif==3.2.0', 'avio==3.2.0', 'numpy', 'loguru', 'opencv-python', 
    'PyQt6-Qt6; platform_system != "Darwin"', 
    'pyqt6; platform_system != "Darwin"',
    'PyQt6-Qt6; platform_system == "Darwin"', 
    'pyqt6; platform_system == "Darwin"'
  ]

That will let the installer choose whatever PyQt6 version it has available, which has a very good chance of working, then just run

  assets/scripts/compile

from the libonvif directory.

Anyway, thank you so much for the feedback, I hope this helps

rbelew commented 2 months ago

still trying, but no love:(

modifying libonvif/onvif-gui/pyproject.toml to remove the ==6.6.1 qualifiers caused it to fail on the python < 3.11 requirement, THEN complain about not matching ANY PyQT6-Qt6:

ERROR: Ignored the following versions that require a different python version: 1.21.2 Requires-Python >=3.7,<3.11; 1.21.3 Requires-Python >=3.7,<3.11; 1.21.4 Requires-Python >=3.7,<3.11; 1.21.5 Requires-Python >=3.7,<3.11; 1.21.6 Requires-Python >=3.7,<3.11 ERROR: Could not find a version that satisfies the requirement PyQt6-Qt6; platform_system != "Darwin" (from onvif-gui) (from versions: none) ERROR: No matching distribution found for PyQt6-Qt6; platform_system != "Darwin"

and so i used conda to produce a venv with python 3.10 (because it doesn't seem virtualenv can maintain a separate python versioned environment?), started from scratch from the git clone and tried to rebuild, again updated the libonvif/onvif-gui/pyproject.toml file to drop its version dependency, but still:

ERROR: Could not find a version that satisfies the requirement PyQt6-Qt6; platform_system != "Darwin" (from onvif-gui) (from versions: none) ERROR: No matching distribution found for PyQt6-Qt6; platform_system != "Darwin"

sr99622 commented 1 month ago

Wow, that's a tough one. It looks like PyQt6 is not well supported for your configuration. I just wanted to double check that you are running Ubuntu on ARM architecture?

I updated the onvif-util to broadcast discovery on all network interfaces, and it can now access cameras on external networks as well. If you git pull the repository, the utility should compile as before

cd libonvif
git pull
mkdir build
cd build
cmake -DWITHOUT_PYTHON=ON ..
make
sudo make install
sudo ldconfig

Thank you so much for your efforts, I will be looking at solutions to the PyQt6 issue, but it may take some time.

Best Regards,

Stephen