gphoto / gphoto2

The gphoto2 commandline tool for accessing and controlling digital cameras.
GNU General Public License v2.0
718 stars 116 forks source link

Capture preview on Raspberry Pi with Raspbian produces PBM instead of JPEG despite libjpeg-dev being installed and found #614

Closed mvmn closed 11 months ago

mvmn commented 12 months ago

Describe the bug

gphoto2 --capture-preview produces PBM instead of JPEG LibJPEG-dev is installed and detected

Name the camera Canon PowerShot SX530 HS

libgphoto2 and gphoto2 version

gphoto2 2.5.28.1

Copyright (c) 2000-2021 Marcus Meissner and others

gphoto2 comes with NO WARRANTY, to the extent permitted by law. You may
redistribute copies of gphoto2 under the terms of the GNU General Public
License. For more information about these matters, see the files named COPYING.

This version of gphoto2 is using the following software versions and options:
gphoto2         2.5.28.1       gcc, popt(m), exif, no cdk, no aa, jpeg, readline
libgphoto2      2.5.31         standard camlibs (SKIPPING docupen lumix), gcc, no ltdl, EXIF
libgphoto2_port 0.12.2         iolibs: disk ptpip serial usb1 usbdiskdirect usbscsi, gcc, no ltdl, EXIF, USB, serial without locking

Raspberry Pi 4 Linux raspberrypi 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr 3 17:24:16 BST 2023 aarch64 GNU/Linux

To Reproduce gphoto2 --capture-preview

Note: on macOS with same camera and these versions of (lib)gphoto2 I get a proper JPEG:

gphoto2 2.5.28

Copyright (c) 2000-2021 Marcus Meissner and others

gphoto2 comes with NO WARRANTY, to the extent permitted by law. You may
redistribute copies of gphoto2 under the terms of the GNU General Public
License. For more information about these matters, see the files named COPYING.

This version of gphoto2 is using the following software versions and options:
gphoto2         2.5.28         clang, popt(m), exif, no cdk, no aa, jpeg, readline
libgphoto2      2.5.31         standard camlibs, clang, no ltdl, EXIF
libgphoto2_port 0.12.2         iolibs: disk ptpip serial usb1, clang, no ltdl, EXIF, USB, serial without locking

Intel MacBook Pro Darwin MVMnMBP2020.local 23.1.0 Darwin Kernel Version 23.1.0: Mon Oct 9 21:27:27 PDT 2023; root:xnu-10002.41.9~6/RELEASE_X86_64 x86_64

I'm attaching debut outputs for capture preview from both machines debug_pi.txt debug_macos.txt

msmeissn commented 12 months ago

(chdk in use, there the ptp2 camlib in libgphoto2 uses libjpeg to encode the preview image)

Have you also built libgphoto2 with libjpeg-dev installed?

it seems the pi variant was not, but the macos variant was.

mvmn commented 12 months ago

Yes, I have - it's reflected in the attached logs as far as I understand.

msmeissn commented 12 months ago

can you run ldd /usr/local/lib/libgphoto2/2.5.31/ptp2.so in the pi and look for libjpeg?

should show a line like
libjpeg.so.8 => /lib64/glibc-hwcaps/x86-64-v3/libjpeg.so.8.2.2 (0x00007f779edd1000)

mvmn commented 12 months ago
    linux-vdso.so.1 (0x0000007fb66b2000)
    libgphoto2.so.6 => /usr/local/lib/libgphoto2.so.6 (0x0000007fb64b4000)
    libgphoto2_port.so.12 => /usr/local/lib/libgphoto2_port.so.12 (0x0000007fb6498000)
    libpthread.so.0 => /lib/aarch64-linux-gnu/libpthread.so.0 (0x0000007fb6467000)
    libm.so.6 => /lib/aarch64-linux-gnu/libm.so.6 (0x0000007fb63bc000)
    libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000007fb6247000)
    libltdl.so.7 => /lib/aarch64-linux-gnu/libltdl.so.7 (0x0000007fb622d000)
    libexif.so.12 => /lib/aarch64-linux-gnu/libexif.so.12 (0x0000007fb61d4000)
    /lib/ld-linux-aarch64.so.1 (0x0000007fb6682000)
    libdl.so.2 => /lib/aarch64-linux-gnu/libdl.so.2 (0x0000007fb61c0000)

Doesn't seem to include libjpeg. Is there any special configuration for the compilation to make sure it includes libjpeg? I was compiling using gphoto2-updater

msmeissn commented 11 months ago

no idea, libgphoto2 uses the same check as the gphoto2 build and that seemed to have caught libjpeg. can you try again capture the output of the gphoto2-updater script and attach it here?

mvmn commented 11 months ago

Sure gp2upd_log.txt

msmeissn commented 11 months ago

it seems to have built current GIT 2.5.31.1, but the gphoto2 --versiuon still shows 2.5.31, so it still seems to pick up the system flavor.

perhaps try:

/usr/local/lib to /etc/ld.so.conf

mvmn commented 11 months ago

Unfortunately, that didn't work

Also it seems that /usr/local/lib should've already been included, because the /etc/ld.so.conf contains this:

include /etc/ld.so.conf.d/*.conf

And in /etc/ld.so.conf.d/ I have a libc.conf with has this content

# libc default configuration
/usr/local/lib
msmeissn commented 11 months ago

usually /usr/local would take precedence. looking at your traces, can you check

ls -l /usr/local/lib/libgphoto2.so*

perhaps soemthing is missed there

mvmn commented 11 months ago
❯ ls -l /usr/local/lib/libgphoto2.so*

lrwxrwxrwx 1 root root     19 Nov 11 01:13 /usr/local/lib/libgphoto2.so -> libgphoto2.so.6.3.0
lrwxrwxrwx 1 root root     19 Nov 11 01:13 /usr/local/lib/libgphoto2.so.6 -> libgphoto2.so.6.3.0
-rwxr-xr-x 1 root root 598960 Nov 11 01:13 /usr/local/lib/libgphoto2.so.6.3.0
msmeissn commented 11 months ago

ldd which gphoto2 please too ... not sure where it loads libgphoto2.so.6 from

mvmn commented 11 months ago

I'm very confused about the paths aswell which gphoto2 gives me /usr/local/bin/gphoto2 ldd $(which gphoto2) (I presume this is what you meant) gives me this:

    linux-vdso.so.1 (0x0000007f9399b000)
    libgphoto2.so.6 => /usr/local/lib/libgphoto2.so.6 (0x0000007f9388f000)
    libgphoto2_port.so.12 => /usr/local/lib/libgphoto2_port.so.12 (0x0000007f93873000)
    libpthread.so.0 => /lib/aarch64-linux-gnu/libpthread.so.0 (0x0000007f93842000)
    libexif.so.12 => /lib/aarch64-linux-gnu/libexif.so.12 (0x0000007f937e9000)
    libreadline.so.8 => /lib/aarch64-linux-gnu/libreadline.so.8 (0x0000007f93780000)
    libpopt.so.0 => /lib/aarch64-linux-gnu/libpopt.so.0 (0x0000007f93763000)
    libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000007f935ee000)
    libltdl.so.7 => /lib/aarch64-linux-gnu/libltdl.so.7 (0x0000007f935d4000)
    libm.so.6 => /lib/aarch64-linux-gnu/libm.so.6 (0x0000007f93529000)
    /lib/ld-linux-aarch64.so.1 (0x0000007f9396b000)
    libtinfo.so.6 => /lib/aarch64-linux-gnu/libtinfo.so.6 (0x0000007f934eb000)
    libdl.so.2 => /lib/aarch64-linux-gnu/libdl.so.2 (0x0000007f934d7000)
msmeissn commented 11 months ago

i currently dont understand why gphoto2-updater.sh logfile reports 2.5.31.1 libgphoto2 being built and installed to /usr/local/lib, and gphoto2 --version reporting it as 2.5.31 :/

mvmn commented 11 months ago
❯ sudo find / -iname "libgphoto*"
find: ‘/run/user/1000/gvfs’: Permission denied
/var/cache/apt/archives/libgphoto2-l10n_2.5.27-1_all.deb
/var/cache/apt/archives/libgphoto2-6_2.5.27-1_arm64.deb
/var/cache/apt/archives/libgphoto2-port12_2.5.27-1_arm64.deb
/usr/local/share/libgphoto2
/usr/local/share/doc/libgphoto2
/usr/local/share/doc/libgphoto2_port
/usr/local/share/man/man3/libgphoto2.3
/usr/local/share/man/man3/libgphoto2_port.3
/usr/local/share/libgphoto2_port
/usr/local/share/locale/zh_TW/LC_MESSAGES/libgphoto2_port-12.mo
/usr/local/share/locale/da/LC_MESSAGES/libgphoto2-6.mo
/usr/local/share/locale/da/LC_MESSAGES/libgphoto2_port-12.mo
/usr/local/share/locale/pl/LC_MESSAGES/libgphoto2-6.mo
/usr/local/share/locale/pl/LC_MESSAGES/libgphoto2_port-12.mo
/usr/local/share/locale/ru/LC_MESSAGES/libgphoto2-6.mo
/usr/local/share/locale/ru/LC_MESSAGES/libgphoto2_port-12.mo
/usr/local/share/locale/sv/LC_MESSAGES/libgphoto2-6.mo
/usr/local/share/locale/sv/LC_MESSAGES/libgphoto2_port-12.mo
/usr/local/share/locale/pt_BR/LC_MESSAGES/libgphoto2_port-12.mo
/usr/local/share/locale/nl/LC_MESSAGES/libgphoto2-6.mo
/usr/local/share/locale/nl/LC_MESSAGES/libgphoto2_port-12.mo
/usr/local/share/locale/de/LC_MESSAGES/libgphoto2-6.mo
/usr/local/share/locale/de/LC_MESSAGES/libgphoto2_port-12.mo
/usr/local/share/locale/sk/LC_MESSAGES/libgphoto2_port-12.mo
/usr/local/share/locale/zh_CN/LC_MESSAGES/libgphoto2-6.mo
/usr/local/share/locale/zh_CN/LC_MESSAGES/libgphoto2_port-12.mo
/usr/local/share/locale/cs/LC_MESSAGES/libgphoto2-6.mo
/usr/local/share/locale/cs/LC_MESSAGES/libgphoto2_port-12.mo
/usr/local/share/locale/ja/LC_MESSAGES/libgphoto2-6.mo
/usr/local/share/locale/ja/LC_MESSAGES/libgphoto2_port-12.mo
/usr/local/share/locale/vi/LC_MESSAGES/libgphoto2-6.mo
/usr/local/share/locale/vi/LC_MESSAGES/libgphoto2_port-12.mo
/usr/local/share/locale/es/LC_MESSAGES/libgphoto2-6.mo
/usr/local/share/locale/es/LC_MESSAGES/libgphoto2_port-12.mo
/usr/local/share/locale/eu/LC_MESSAGES/libgphoto2-6.mo
/usr/local/share/locale/eu/LC_MESSAGES/libgphoto2_port-12.mo
/usr/local/share/locale/fur/LC_MESSAGES/libgphoto2_port-12.mo
/usr/local/share/locale/sr/LC_MESSAGES/libgphoto2_port-12.mo
/usr/local/share/locale/it/LC_MESSAGES/libgphoto2-6.mo
/usr/local/share/locale/it/LC_MESSAGES/libgphoto2_port-12.mo
/usr/local/share/locale/uk/LC_MESSAGES/libgphoto2-6.mo
/usr/local/share/locale/uk/LC_MESSAGES/libgphoto2_port-12.mo
/usr/local/share/locale/fr/LC_MESSAGES/libgphoto2-6.mo
/usr/local/share/locale/fr/LC_MESSAGES/libgphoto2_port-12.mo
/usr/local/share/locale/fi/LC_MESSAGES/libgphoto2_port-12.mo
/usr/local/share/locale/hu/LC_MESSAGES/libgphoto2-6.mo
/usr/local/share/locale/ro/LC_MESSAGES/libgphoto2_port-12.mo
/usr/local/share/locale/ka/LC_MESSAGES/libgphoto2_port-12.mo
/usr/local/lib/libgphoto2_port.so.12.1.0
/usr/local/lib/libgphoto2
/usr/local/lib/libgphoto2.so
/usr/local/lib/libgphoto2.so.6
/usr/local/lib/libgphoto2_port.so.12
/usr/local/lib/libgphoto2.so.6.3.0
/usr/local/lib/libgphoto2_port.la
/usr/local/lib/libgphoto2_port.so.12.2.0
/usr/local/lib/libgphoto2_port
/usr/local/lib/libgphoto2_port.so
/usr/local/lib/libgphoto2.la
/usr/local/lib/pkgconfig/libgphoto2_port.pc
/usr/local/lib/pkgconfig/libgphoto2.pc
❯ sudo find / -iname "gphoto2"
find: ‘/run/user/1000/gvfs’: Permission denied
/usr/share/bash-completion/completions/gphoto2
/usr/local/share/doc/gphoto2
/usr/local/include/gphoto2
/usr/local/bin/gphoto2

Is this helpful?

msmeissn commented 11 months ago

can you perhaps remove the /usr/local/lib stuff and reinstal with gphoto2-updater just to make sure it gets written

mvmn commented 11 months ago

Ok, so I did sudo find / -iname "*gphoto*" -exec rm -rf {} \; to make sure I remove EVERYTHING. Then reboot and re-run GPhoto2-Updater.

It could not build the trunk. Perhaps something is broken there now.

libusb1/libusb1.c: In function ‘has_external_fd’:
libusb1/libusb1.c:134:28: error: ‘LIBUSB_OPTION_NO_DEVICE_DISCOVERY’ undeclared (first use in this function)
  134 |     libusb_set_option(NULL,LIBUSB_OPTION_NO_DEVICE_DISCOVERY,NULL);
      |                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
libusb1/libusb1.c:134:28: note: each undeclared identifier is reported only once for each function it appears in
make[2]: *** [Makefile:1081: libusb1/usb1_la-libusb1.lo] Error 1
make[2]: Leaving directory '/home/pi/Downloads/gphoto2-temp-folder/libgphoto2/libgphoto2_port'
make[1]: *** [Makefile:1226: install-recursive] Error 1
make[1]: Leaving directory '/home/pi/Downloads/gphoto2-temp-folder/libgphoto2/libgphoto2_port'
make: *** [Makefile:768: install-recursive] Error 1

So instead I had to choose whatever latest stable release option it had - which is libgphoto 2.5.30; gphoto 2.5.28.

I did sudo find / -iname "*gphoto*" -exec rm -rf {} \; again and re-built with those.

Now I have this version:

gphoto2 2.5.28

Copyright (c) 2000-2021 Marcus Meissner and others

gphoto2 comes with NO WARRANTY, to the extent permitted by law. You may
redistribute copies of gphoto2 under the terms of the GNU General Public
License. For more information about these matters, see the files named COPYING.

This version of gphoto2 is using the following software versions and options:
gphoto2         2.5.28         gcc, popt(m), exif, no cdk, no aa, jpeg, readline
libgphoto2      2.5.30         standard camlibs (SKIPPING docupen lumix), gcc, no ltdl, EXIF
libgphoto2_port 0.12.1         iolibs: disk ptpip serial usb1 usbdiskdirect usbscsi, gcc, no ltdl, EXIF, USB, serial without locking

And now ldd /usr/local/lib/libgphoto2/2.5.30/ptp2.so shows libjpeg in the list

❯ ldd /usr/local/lib/libgphoto2/2.5.30/ptp2.so

    linux-vdso.so.1 (0x0000007f9010a000)
    libgphoto2.so.6 => /usr/local/lib/libgphoto2.so.6 (0x0000007f8ff10000)
    libgphoto2_port.so.12 => /usr/local/lib/libgphoto2_port.so.12 (0x0000007f8fef4000)
    libjpeg.so.62 => /lib/aarch64-linux-gnu/libjpeg.so.62 (0x0000007f8fea4000)
    libm.so.6 => /lib/aarch64-linux-gnu/libm.so.6 (0x0000007f8fdf9000)
    libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000007f8fc84000)
    libltdl.so.7 => /lib/aarch64-linux-gnu/libltdl.so.7 (0x0000007f8fc6a000)
    libexif.so.12 => /lib/aarch64-linux-gnu/libexif.so.12 (0x0000007f8fc11000)
    libpthread.so.0 => /lib/aarch64-linux-gnu/libpthread.so.0 (0x0000007f8fbe0000)
    /lib/ld-linux-aarch64.so.1 (0x0000007f900da000)
    libdl.so.2 => /lib/aarch64-linux-gnu/libdl.so.2 (0x0000007f8fbcc000)
msmeissn commented 11 months ago

which libusb 1 version do you have on the raspberry? Need to check how to detect that correctly in configure script

msmeissn commented 11 months ago

i added a configure check for i, hope it will build now

mvmn commented 11 months ago

which libusb 1 version do you have on the raspberry?

Not sure how to properly check for this - I did a search and it found a bunch of files with 1.0 in the name, e.g.

/usr/share/doc/libusb-1.0-doc
/usr/share/doc/libusb-1.0-doc/api-1.0/libusb_packetoverflow.html
/usr/share/doc/libusb-1.0-doc/api-1.0/libusb_contexts.html
/usr/share/doc/libusb-1.0-doc/api-1.0/libusb.png
/usr/share/doc/libusb-1.0-doc/api-1.0/libusb_hotplug.html
/usr/share/doc/libusb-1.0-doc/api-1.0/libusb_8h_source.html
/usr/share/doc/libusb-1.0-doc/api-1.0/libusb_api.html
/usr/share/doc/libusb-1.0-doc/api-1.0/libusb_mtasync.html
/usr/share/doc/libusb-1.0-doc/api-1.0/libusb_io.html
/usr/share/doc/libusb-1.0-doc/api-1.0/libusb_caveats.html
/usr/share/doc/libusb-1.0-0-dev
/usr/share/doc/libusbmuxd6
/usr/share/doc/libusb-1.0-0
/usr/share/doc-base/libusb-1.0-doc
/usr/include/libusb-1.0
/usr/include/libusb-1.0/libusb.h
/usr/lib/aarch64-linux-gnu/libusbmuxd.so.6.0.0
/usr/lib/aarch64-linux-gnu/libusb-1.0.so
/usr/lib/aarch64-linux-gnu/libusbmuxd-2.0.so.6.0.0
/usr/lib/aarch64-linux-gnu/libusb-1.0.so.0
/usr/lib/aarch64-linux-gnu/libusbmuxd-2.0.so.6
/usr/lib/aarch64-linux-gnu/libusbmuxd.so.6
/usr/lib/aarch64-linux-gnu/libusb-1.0.a
/usr/lib/aarch64-linux-gnu/libusb-1.0.so.0.3.0
/usr/lib/aarch64-linux-gnu/pkgconfig/libusb-1.0.pc

So I presume it's 1.0

i added a configure check for i, hope it will build now

I've done sudo find / -iname "*gphoto*" -exec rm -rf {} \; again and built from scratch with GPhoto2-Updater via Install last development version option.

This time it did success, and mow I got these version:

This version of gphoto2 is using the following software versions and options:
gphoto2         2.5.28.1       gcc, popt(m), exif, no cdk, no aa, jpeg, readline
libgphoto2      2.5.31.1       standard camlibs (SKIPPING docupen lumix), gcc, no ltdl, EXIF
libgphoto2_port 0.12.2         iolibs: disk ptpip serial usb1 usbdiskdirect usbscsi, gcc, no ltdl, EXIF, USB, serial without locking

And ptp2.so has libjpeg

❯ ldd /usr/local/lib/libgphoto2/2.5.31.1/ptp2.so

    linux-vdso.so.1 (0x0000007f92efc000)
    libgphoto2.so.6 => /usr/local/lib/libgphoto2.so.6 (0x0000007f92cfc000)
    libgphoto2_port.so.12 => /usr/local/lib/libgphoto2_port.so.12 (0x0000007f92ce0000)
    libjpeg.so.62 => /lib/aarch64-linux-gnu/libjpeg.so.62 (0x0000007f92c90000)
    libm.so.6 => /lib/aarch64-linux-gnu/libm.so.6 (0x0000007f92be5000)
    libc.so.6 => /lib/aarch64-linux-gnu/libc.so.6 (0x0000007f92a70000)
    libltdl.so.7 => /lib/aarch64-linux-gnu/libltdl.so.7 (0x0000007f92a56000)
    libexif.so.12 => /lib/aarch64-linux-gnu/libexif.so.12 (0x0000007f929fd000)
    libpthread.so.0 => /lib/aarch64-linux-gnu/libpthread.so.0 (0x0000007f929cc000)
    /lib/ld-linux-aarch64.so.1 (0x0000007f92ecc000)
    libdl.so.2 => /lib/aarch64-linux-gnu/libdl.so.2 (0x0000007f929b8000)
msmeissn commented 11 months ago

very good, thanks for the feedback :)

mvmn commented 11 months ago

No problem

And many thanks for all the support!