PetteriAimonen / focus-stack

Fast and easy focus stacking
MIT License
249 stars 37 forks source link

make builddeb: opencv version issue 3.2 vs 4.2 (debian bullseye) #10

Open mviereck opened 3 years ago

mviereck commented 3 years ago

On debian bullseye I can successfully build a deb package with make builddeb. But installing the package gives a dependency issue:

$ sudo env LANG=C apt install ./focus-stack_1.1-4-g72a3527_amd64.deb 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
You might want to run 'apt --fix-broken install' to correct these.
The following packages have unmet dependencies:
 focus-stack : Depends: libopencv-core3.2 but it is not installable
               Depends: libopencv-video3.2 but it is not installable
               Depends: libopencv-imgcodecs3.2 but it is not installable
               Depends: libopencv-photo3.2 but it is not installable
               Depends: libopencv-imgproc3.2 but it is not installable
E: Unmet dependencies. Try 'apt --fix-broken install' with no packages (or specify a solution).

debian bullseye provides the same packages with number 4.2 instead of 3.2. I've changed the according line debian/control before build to:

Depends: libopencv-core4.2, libopencv-video4.2, libopencv-imgcodecs4.2, libopencv-photo4.2, libopencv-imgproc4.2, ${shlibs:Depends}, ${misc:Depends}, libgcc1, libstdc++6

But the issue persists, the changes are not regarded. Same error message as before.

Installing the package with dpkg -i works, focus-stack itself works, too, but apt complains about broken packages if I want to install anything else.

PetteriAimonen commented 3 years ago

To make the changes included in .deb you need to commit them (locally) first.

As for a real fix, I'm not sure how debian packaging is supposed to be done, I think there may be some syntax for "any version >= 3.2"? Normally that would be simple but because opencv packages have version number in package name it may be more complex.

mviereck commented 3 years ago

because opencv packages have version number in package name it may be more complex.

In debian packages it is possible to declare an OR dependency with |. E.g. libopencv-core3.2|libopencv-core4.2 would be satisfied with one of these packages. If the first one is not available, the second one is installed. If the second one is already present, the first one won't be installed.

I've checked libopencv-imgproc versions:

So the current declaration is wrong for buster, too, because there is no libopencv-imgproc3.2 (>=4.2.0+dfsg).

I've extracted the deb package and changed the dependency line accordingly so it can install on buster and bullseye as well:

Depends: libc6 (>= 2.14), libgcc-s1 (>= 3.0), libopencv-core3.2 (>= 3.2.0+dfsg) | libopencv-core4.2 (>= 4.2.0+dfsg), libopencv-imgcodecs3.2 (>= 3.2.0+dfsg) | libopencv-imgcodecs4.2 (>= 4.2.0+dfsg), libopencv-imgproc3.2 (>= 3.2.0+dfsg) | libopencv-imgproc4.2 (>= 4.2.0+dfsg), libopencv-video3.2 (>= 3.2.0+dfsg) | libopencv-video4.2 (>= 4.2.0+dfsg), libstdc++6 (>= 6), libgcc1

This installs successfully on bullseye, and probably on buster, too.

Side note: I have an AMD GPU and get opencv error messages. So I cannot check if all this works as intended.

DRM_IOCTL_I915_GEM_APERTURE failed: No such file or directory
Assuming 131072kB available aperture size.
May lead to reduced performance or incorrect rendering.
get chip id failed: -1 [22]
param: 4, val: 0
DRM_IOCTL_I915_GEM_APERTURE failed: No such file or directory
Assuming 131072kB available aperture size.
May lead to reduced performance or incorrect rendering.
get chip id failed: -1 [22]
param: 4, val: 0
beignet-opencl-icd: no supported GPU found, this is probably the wrong opencl-icd package for this hardware
(If you have multiple ICDs installed and OpenCL works, you can ignore this message)

The aligned result looks fine nonetheless.

PetteriAimonen commented 3 years ago

Is it necessary to have the version specifiers, or would this work as well?

 Depends: libopencv-core3.2 | libopencv-core4.2, libopencv-imgcodecs3.2 | libopencv-imgcodecs4.2, ...

I'm not sure what you mean about "the current declaration is wrong for buster", because AFAIK the current declaration has no version specifiers for any of the packages.

Regarding the OpenCL warnings, it just means you do not have the OpenCL drivers for your gpu installed. apt-get install mesa-opencl-icd might fix that, but beware, at least some old amdgpu kernel drivers were quite crash-prone when using mesa-opencl. Alternatively uninstalling beignet-opencl-icd should get rid of the warnings, as that package is the Intel driver. OpenCL is not necessary for usage, it just speeds up a small amount.

mviereck commented 3 years ago

Is it necessary to have the version specifiers, or would this work as well? Depends: libopencv-core3.2 | libopencv-core4.2, libopencv-imgcodecs3.2 | libopencv-imgcodecs4.2, ...

That should work as well.

I'm not sure what you mean about "the current declaration is wrong for buster", because AFAIK the current declaration has no version specifiers for any of the packages.

I found libopencv-imgproc3.2 (>=4.2.0+dfsg) (and others) in the generated deb file, extracted with dpkg-deb -R ./focus-stack_1.1-4-g72a3527_amd64.deb tmp. I am not sure when or how the minimal versions are declared. Maybe this is done somehow in the make debbuild process?

Regarding the OpenCL warnings, it just means you do not have the OpenCL drivers for your gpu installed. apt-get install mesa-opencl-icd might fix that, but beware, at least some old amdgpu kernel drivers were quite crash-prone when using mesa-opencl.

Thank you, I'll try out! Edit: I got severe issues after installing mesa-opencl-icd and removed it meanwhile. While running focus-stack the monitor began to shut off and turn on repeatly and focus-stack stucked. The flickering issue remained after killing focus-stack. Driver is radeon on debian bullseye:

[    14.677] (II) Module radeon: vendor="X.Org Foundation"
[    14.677]    compiled for 1.20.4, module version = 19.1.0
[    14.677]    Module class: X.Org Video Driver
[    14.678]    ABI class: X.Org Video Driver, version 24.0
mviereck commented 3 years ago

Just want to note that compiling on debian buster and using opencl 4.2 succeeds now after installing mesa-opencl-icd. Aligning is about 25% faster than before, so I assume opencl is used indeed.

AFAIK the current declaration has no version specifiers for any of the packages.

I am not sure when or how the minimal versions are declared. Maybe this is done somehow in the make debbuild process?

Maybe this is somehow automatically done because I've compiled with the 4.2 -dev packages.