AR0234 C OpenCV image capture on Buster: which documentation?

Hi, I’m trying to get an AR0234 camera working under a Buster environment and I’m stuck. The reason I need Buster specifically is that all of our existing software (including OpenCV) is built under Kernel Version: 5.10.17-v7l+. I’m using the buster image listed on the site, the full armhf one from raspios_full_armhf-2021-05-28.

After spending basically a full day searching online and changing things around, I finally managed to take pictures with libcamera-still, so the camera is being detected fine. Now I want to capture images from a C-language OpenCV program, and I haven’t tried that part yet.

Which documentation should I be looking at to capture images in a C OpenCV program on Buster? Any pointer would help.

Welcome. Let me be straight with you: the Buster kernel you need (5.10.17-v7l+) is quite old, and the AR0234 isn’t maintained on that Buster version anymore, so we’re limited in what we can support there. Buster is just too old for this camera on our side.

The thing is, your application stack should be portable — the same software (OpenCV included) can be migrated over to Bullseye, where the camera IS maintained. For reference, the OpenCV version running on our reference Pi here is 4.5.1.

So rather than fighting Buster, my recommendation is to port your software to Bullseye. There are no special commands for this, it’s really just moving the stack over. In the meantime, can you confirm whether the OpenCV code you have depends on anything Buster-only? That will tell us how painful the move is.

OK, while I think about moving to Bullseye, I tried building the libcamera C++ demo to get a feel for the capture code. I’m using main.c / main.cpp from libcamera-cpp-demo/main.cpp at main · edward-ardu/libcamera-cpp-demo · GitHub and following the commands at GitHub - edward-ardu/libcamera-cpp-demo: libcamera c++ demo · GitHub . I can’t generate an executable file — the build just errors out. OpenCV 4.5.1 is NOT installed on my system.

Attempt 1 — I ran the 6-line sequence exactly as given:

sudo apt install -y libopencv-dev
sudo apt install -y cmake
mkdir build
cd build
cmake …
make -j4

Result: error, no executable produced.

Attempt 2 — I installed libopencv-dev/cmake, downloaded libcamera-cpp-demo-main.zip, extracted it into the pi directory, then ran this inside the libcamera-cpp-demo-main directory:

mkdir build
cd build
cmake …
make -j4

Result: same error, still no executable.

So what operation details am I missing in between? Do I need to install OpenCV 4.5.1 first, and then run sudo apt install -y libopencv-dev and sudo apt install -y cmake? Do those two install commands need to be run in the directory where OpenCV is installed, or some specific directory, or does any directory work? Should libcamera-cpp-demo-main.zip be extracted into OpenCV’s samples/cpp directory or somewhere else? If you can send a screenshot of your file directory so I can replicate it exactly, that would really help. And just to confirm — mkdir build / cd build / cmake … / make -j4 are for compiling libcamera-cpp-demo-main, right?

Good that you’re trying the demo, that main.cpp is the right starting point for a libcamera C++ capture. A few clarifications first:

  • The apt installs can be run from any directory. They do NOT need to be inside the OpenCV install directory.
  • The zip doesn’t need to go into samples/cpp. Anywhere works — you just cd into the extracted libcamera-cpp-demo-main folder and create the build dir there.
  • Yes, mkdir build / cd build / cmake … / make -j4 is what compiles libcamera-cpp-demo-main.

The problem is we can’t tell what’s actually failing without the output. “Error, no executable” could be a dozen different things — missing libcamera dev headers, missing pkg-config entry, a cmake version issue, etc.

Can you paste the full text of what cmake … prints and what make -j4 prints, especially the first error line? Also please run these and paste the results:

dpkg -l | grep libcamera
pkg-config --modversion opencv4

And let me know whether libcamera-dev / libcamera-apps are installed. Once we see the log we can actually narrow it down.

Reposting this since I’m still stuck and want to make sure nothing got lost — same problem as before.

Experimenting with main.c / main.cpp from libcamera-cpp-demo/main.cpp at main · edward-ardu/libcamera-cpp-demo · GitHub and I cannot generate an executable file, the build fails. I followed the command sequence from GitHub - edward-ardu/libcamera-cpp-demo: libcamera c++ demo · GitHub . Note that OpenCV 4.5.1 is NOT installed.

Attempt 1 — ran the 6 commands in sequence without installing OpenCV 4.5.1:

sudo apt install -y libopencv-dev
sudo apt install -y cmake
mkdir build
cd build
cmake …
make -j4

→ error (出错), no executable.

Attempt 2 — downloaded libcamera-cpp-demo-main.zip, extracted to the pi directory, then ran the same inside libcamera-cpp-demo-main:

mkdir build
cd build
cmake …
make -j4

→ error, no executable produced.

Same questions as before: what operation details need attention in the middle? Should OpenCV 4.5.1 be installed first, then run sudo apt install -y libopencv-dev and sudo apt install -y cmake? Should those two install commands be run in the directory where OpenCV is installed, or another specific directory, or any directory? Should libcamera-cpp-demo-main.zip be extracted into OpenCV’s samples/cpp directory or another directory? A screenshot of the file directory would help me replicate it exactly. And confirm: are mkdir build / cd build / cmake … / make -j4 for compiling libcamera-cpp-demo-main?

Thanks for the repost. To summarize where we’ve landed:

  1. The AR0234 isn’t maintained on the Buster kernel you need, so there’s no supported path to run the camera on that setup. The workaround is to port your software stack over to Bullseye, where the camera is maintained — our reference Pi there runs OpenCV 4.5.1. The apt install commands and the demo build steps are the same on Bullseye, so your migration shouldn’t need any special changes.

  2. On the libcamera-cpp-demo build: we still can’t pinpoint the failure, because we don’t have the actual error text yet. “No executable” isn’t enough to go on — the first line of the cmake or make output is what we need. Please paste:

  • the full cmake … output
  • the full make -j4 output (first error line especially)
  • the output of: dpkg -l | grep libcamera
  • the output of: pkg-config --modversion opencv4

Once we have that, we can see whether it’s a missing libcamera-dev package, a missing pkg-config entry, or something else in the CMakeLists. Until then, the Bullseye migration is the recommended route for actually getting the camera working.