Breakthrough / DVR-Scan

:vhs: Tool for extracting scenes with motion from videos (e.g. security camera or DVR footage). Written in Python, uses OpenCV.
http://www.dvr-scan.com/
Other
362 stars 47 forks source link

how do you install this program? #139

Closed claudiuskerth closed 8 months ago

claudiuskerth commented 11 months ago

Hi,

despite many hours of trying I just can't seem to get a working installation of dvr-scan on MacOS 10.14.6 nor on Raspbian GNU/Linux 11.

  1. On the raspberry pi 4 I used:

pip install --upgrade dvr-scan[opencv]

which ended with

Successfully installed dvr-scan-1.5.1 opencv-python-4.6.0.66 platformdirs-3.10.0 scenedetect-0.6.2 screeninfo-0.8.1 tqdm-4.66.1

Calling dvr-scan then returns the following error trace:

Traceback (most recent call last): File "/home/claudius/.local/bin/dvr-scan", line 5, in from dvr_scan.main import main File "/home/claudius/.local/lib/python3.9/site-packages/dvr_scan/init.py", line 41, in import dvr_scan.opencvloader as File "/home/claudius/.local/lib/python3.9/site-packages/dvr_scan/opencvloader.py", line 34, in import cv2 as File "/home/claudius/.local/lib/python3.9/site-packages/cv2/init.py", line 181, in bootstrap() File "/home/claudius/.local/lib/python3.9/site-packages/cv2/init.py", line 153, in bootstrap native_module = importlib.import_module("cv2") File "/usr/lib/python3.9/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) ImportError: libcblas.so.3: cannot open shared object file: No such file or directory

  1. On the Mac I first tried pip install --upgrade dvr-scan[opencv] but opencv wouldn't install because it wants its own numpy package, which it seem to try compiling from source, which failed. I tried pip install --prefer-binary opencv-python instead which succeeded with

Successfully installed numpy-1.25.2 opencv-python-4.7.0.68

Then I tried pip install dvr-scan[opencv] (i.e. without --upgrade). This seemed to be successful at first:

Successfully installed Click-8.1.6 Cython-3.0.0 dvr-scan-1.5.1 platformdirs-3.10.0 pyobjc-core-9.2 pyobjc-framework-Cocoa-9.2 scenedetect-0.6.2 screeninfo-0.8.1 tqdm-4.66.1

but calling dvr-scan returned this error message:

Traceback (most recent call last): File "/Library/Frameworks/Python.framework/Versions/3.9/bin/dvr-scan", line 5, in from dvr_scan.main import main File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/dvr_scan/init.py", line 41, in import dvr_scan.opencvloader as File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/dvr_scan/opencvloader.py", line 34, in import cv2 as File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/cv2/init.py", line 181, in bootstrap() File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/cv2/init.py", line 153, in bootstrap native_module = importlib.import_module("cv2") File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) ImportError: dlopen(/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/cv2/cv2.abi3.so, 2): Symbol not found: ___darwin_check_fd_set_overflow Referenced from: /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/cv2/.dylibs/libX11.6.dylib (which was built for Mac OS X 11.0) Expected in: /usr/lib/libSystem.B.dylib in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages/cv2/.dylibs/libX11.6.dylib

Building dvr-scan from source and installing via pip results in the same error after calling dvr-scan.

pip list returns:

Package Version build 0.10.0 click 8.1.6 Cython 3.0.0 dvr-scan 1.5.1 numpy 1.25.2 opencv-python 4.7.0.68 packaging 23.1 pip 23.2.1 platformdirs 3.10.0 pyobjc-core 9.2 pyobjc-framework-Cocoa 9.2 pyproject_hooks 1.0.0 scenedetect 0.6.2 screeninfo 0.8.1 setuptools 58.1.0 tomli 2.0.1 tqdm 4.66.1

It seems that the opencv-python package ist the culprit, but I have no ideas on how to fix this.

Any help greatly apreaciated!

claudius

Breakthrough commented 11 months ago

Can you run the following command and provide the output if possible? This should at least verify your opencv-python package is working as intended:

python -c "import cv2; print(cv2.__version__)"

Regarding the RPi, it seems you might be missing some system dependencies - try installing those and see if that helps.

You can also use the opencv-python-headless and opencv-contrib-python-headless packages if you don't have a window manager. As a last resort, you can also compile the OpenCV Python module yourself, and pick and choose the specific dependencies. That might be your best option for an embedded application.

Regarding Mac, I'm working on getting some builders running on Github soon, so hopefully I can track down the issues on that end of things. I did something recently for another project without any issues, however unlike that project, DVR-Scan also uses opencv-contrib-python which carries several additional dependencies. Also note that this package has to be kept in sync with the version of opencv-python you are using. I did not see it in the list above.

Hopefully this helps you get on track, keep me posted and I'll do my best to help out.

Edit: The opencv-python module page covers deprecated OSX versions at the bottom: https://pypi.org/project/opencv-python/

It says OpenCV 4.7 and above require OSX 11. You may want to try installing an older version on OSX if you can't update to 11.

claudiuskerth commented 11 months ago

Hi Brandon,

thank you so much for your quick response and sorry, I think the issue is entirely with the opencv-python package.

On my RPi, I have installed the system dependencies mentioned in the forum thread, in particular libatlas-base-dev. Now trying to import opencv in python (with opencv-python 4.8.0.76 installed) throws this error message:

Traceback (most recent call last): File "", line 1, in File "/home/claudius/.local/lib/python3.9/site-packages/cv2/init.py", line 181, in bootstrap() File "/home/claudius/.local/lib/python3.9/site-packages/cv2/init.py", line 153, in bootstrap native_module = importlib.import_module("cv2") File "/usr/lib/python3.9/importlib/init.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) ImportError: /home/claudius/.local/lib/python3.9/site-packages/cv2/cv2.abi3.so: undefined symbol: __atomic_store_8

claudius

claudiuskerth commented 10 months ago

Hi Brandon,

an my Mac (10.14.6), I was now successful after installing an older version of the opencv-python package:

pip install opencv-contrib-python-headless==4.4.0.46

DVR-scan is currently scanning... I'm excited :-)

claudius

claudiuskerth commented 10 months ago

Hi,

an my Raspi 4 I was now successfull as well with the older version of opencv-contrib-python-headerless and an upgrade of numpy from version 1.19.3 to 1.25.2.

On my Mac I could also install the GUI version of opencv-contrib-python, so that I can select roi's with the mouse. Nice, so far :-)

Now let's see whether dvr-scan can actually detect all bats emerging from tree roosts...

Thanks again for your help, Brandon!

claudius

Breakthrough commented 10 months ago

Hi @claudiuskerth, just wanted to follow up - is everything working as expected now? Thanks!

Breakthrough commented 8 months ago

Have tried to make the error messaging here more clear in v1.6, thanks for the report.