gphoto / libgphoto2

The libgphoto2 camera access and control library.
GNU Lesser General Public License v2.1
1.06k stars 326 forks source link

Is it possible to use this library with arduino? #956

Open uguraltinsoy opened 9 months ago

uguraltinsoy commented 9 months ago

I want to control my camera with Arduino, I want to connect via usb and I want to do things like video start stop etc. through Arduino and I want to read data such as iso, shutter speed, video recording on cameras that support it, is this possible?

My camera Sony A7RII

msmeissn commented 9 months ago

I am not familiar with Arduino level support. Also google search did not bring up references so far.

uguraltinsoy commented 9 months ago

I just want to get the information of the camera. Does it record video or not? It started recording and it didn't start, it's enough if I can read this data

ndim commented 9 months ago

The answer will certainly depend on what kind of Arduino are you thinking of.

There are a number of very different boards on offer from Arduino, starting from a 512B SRAM + 16KB Flash Arduino Nano. libgphoto2 (plus libusb) will certainly not fit into that small amount of memory at all.

Going by https://en.wikipedia.org/wiki/List_of_Arduino_boards_and_compatible_systems#Official, the biggest MCUs in the Arduino portfolio are an ESP32 with 16MB Flash/512KB SRAM running whatever and an Atheros AR9331 with 16MB Flash, 64 MB DDR2 DRAM running Linux.

Using libgphoto2 without an underlying operating system (as is typical for Arduinos) would also require you to write an operating system compatibility layer.

The 16MB Flash of the Arduino Yún rev2 might be possible with some effort. Whether it is worth the effort to try to cram linux + libgphoto2 + libusb into that small a space... no idea. How/whether the Yún rev2 allows you to program the Linux processor, and how/whether the Linux processor is connected to a (host?) USB port, I could not find out quickly.

So I am also not certain if is possible to run libgphoto2 on any Arduino product in general, and for you personally (I do not know you and your level of technical expertise).

If I were to look for a small computer to run libgphoto2 on, I would be looking at something running BSD or Linux, with at least several dozen MB of RAM. More Raspberry Pi territory than Arduino territory. As always though, more (computing) power requires more (electrical) power.

Going smaller and more bare metal (without an operating system) might be possible with libgphoto2, but will certainly require a lot of low level USB and C and build system knowledge. For such hardware, it might be easier to build on some existing USB layer and implement a PTP layer on top of, maybe using libgphoto2 code more or less as documentation. That will certainly be a lot of work, even if you really know your way around embedded stuff. Using the Arduino software stack for such a thing might or might not be possible.

uguraltinsoy commented 9 months ago

Unfortunately I don't know much about embedded systems but thank you for your explanatory article I will think of another way

SongZihui-sudo commented 4 months ago

I cross-compiled libgphoto2 with the arm-rockchip830-linux-uclibcgnueabihf toolchain and ported it to a Luckfox Pico Mini B (the chip is RV1103, a very small board that can run linux).