Arducam 108MP Motorized Focus camera crashes when saving high-res image in demo

Hi everyone, hoping someone can point me in the right direction. I’ve got an Arducam 108MP Motorized Focus USB 3.0 Camera Module and I’m trying to capture and save a high-res image, but the demo script crashes every time I press ‘a’ to save to a file.

Environment:

I cloned the demo with:

git clone -b Arducam108MPDemo https://github.com/ArduCAM/ArducamUVCPythonDemo.git

Then ran:

python arducam_demo.py -W 1280 -H 720 --ccm --tuning-file arducam_108mp.json -F

The crash:

ValueError: cannot reshape array of size 1843200 into shape (9000, 12000)

It happens on line 112 of arducam_demo.py, right after I press ‘a’ to save to file.

One thing that confuses me: the Wiki doesn’t seem to distinguish between the Evaluation Kit and the Motorized Focus camera, and when I search git I only see the Arducam108MPDemo branch. Any ideas?

Welcome! Looking at your command and the error, the issue is that the demo code isn’t using the right buffer size for the Motorized Focus module. The Arducam108MPDemo branch has a value set for the Evaluation Kit, but the Motorized Focus module needs a different setting.

Specifically, open arducam_demo.py in the Arducam108MPDemo branch and go to line 109:

Change the value 2 to 5 there, save it, and run the demo again. Then try saving the high-res image and see if that reshape error goes away.

Also worth noting: make sure you’re following the Motorized Focus demo path and not the Evaluation Kit one, since the two products aren’t the same.

Thanks for the reply. Unfortunately I had already changed 2 to 5 at line 109 before posting, and the crash still happens. The link you gave points to a spot that looks a bit different from what’s in the Wiki, and I can’t find any other demo option in git besides the Arducam108MPDemo branch.

So far I’ve:

  • Made the 2 → 5 change at line 109
  • Tried it on two different machines (Windows and Ubuntu 20.04)
  • Googled for similar reshape errors

Same ValueError on line 112 every time after pressing ‘a’. Is there maybe a different branch or a separate demo for the Motorized Focus module that I’m missing?

Just to make sure I understand: you changed the value from 2 to 5 in arducam_demo.py, and after that the same crash still occurs?

I know the Wiki isn’t great at separating the Evaluation Kit from the Motorized Focus module, and git only showing the Arducam108MPDemo branch doesn’t help. If you’ve definitely got the Motorized Focus module and you’re on that branch, the 2 → 5 change should be the right first step, but since it’s still failing we need to dig a bit deeper.

Could you confirm exactly which line you modified and that the change actually saved? The original crash was ValueError: cannot reshape array of size 1843200 into shape (9000, 12000) on line 112, after pressing ‘a’ to save. If that error is still identical, we might be looking at the wrong code path rather than a bad edit.

Confirmed — I changed 2 to 5 in arducam_demo.py and the problem still happens. Same error on line 112 after pressing ‘a’ to save. The file definitely saved with the change, and I’ve re-run it multiple times on both machines.

Got it, thanks for confirming. To summarize where we are: the 2 → 5 modification at line 109 of the Arducam108MPDemo branch has been applied, but the ValueError: cannot reshape array of size 1843200 into shape (9000, 12000) still occurs on line 112 when saving the high-res image. That suggests the current Arducam108MPDemo branch isn’t correctly handling the Motorized Focus module’s buffer/reshape path, or there’s a demo variant for the Evaluation Kit vs the Motorized Focus module that isn’t clearly separated in the repo/Wiki.

At this point I’d treat this as unresolved, and we’ll need to keep investigating the correct code path for the Motorized Focus module. If anyone else has hit this with the Motorized Focus 108MP, please chime in.