question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Using two instances on separate interfaces simultaneously can sometimes fail with "Camera in Configured state trying queueRequest() requiring state Running"

See original GitHub issue

Describe the bug If you initialize two picamera2 objects on different interfaces, then attempt to take pictures with them back-to-back without closing them in-between, they can sometimes fail:

[0:38:03.430892329] [2855] ERROR Camera camera.cpp:533 Camera in Configured state trying queueRequest() requiring state Running

To Reproduce

  1. Spawn two picamera2 objects on separate interfaces
  2. start object one, take a picture, then stop it (but don’t explicitly call close())
  3. attempt to start object 2

– OR –

from picamera2 import Picamera2

def take_pictures(should_close_between=False):
    cam1 = Picamera2(0)
    cam2 = Picamera2(1)

    print('camera 1 seq')
    config1 = cam1.create_still_configuration()
    cam1.configure(config1)
    cam1.start()
    cam1.capture_file("sim_test_c1.jpg")
    cam1.stop()
    
    if should_close_between:
        print('closing camera 1')
        cam1.close()

    print('camera 2 seq')
    config2 = cam2.create_still_configuration()
    cam2.configure(config2)
    cam2.start()
    cam2.capture_file("sim_test_c2.jpg")
    cam2.stop()
    
    if not should_close_between:
        print('closing camera 1')
        cam1.close()
    print('closing camera 2')
    cam2.close()



print("########## taking two photos, this will work")
take_pictures(should_close_between=True)
print("########## taking two photos, this will fail")
take_pictures()

Expected behaviour It just works™ without having to close the object in between

Console Output, Screenshots

❯ python picamera2_sequential_test.py
########## taking two photos, this will work
[0:37:59.038259411] [2845]  INFO Camera camera_manager.cpp:293 libcamera v0.0.0+3866-0c55e522
[0:37:59.069626442] [2846]  WARN RPI raspberrypi.cpp:1258 Mismatch between Unicam and CamHelper for embedded data usage!
[0:37:59.070797109] [2846]  INFO RPI raspberrypi.cpp:1374 Registered camera /base/soc/i2c0mux/i2c@0/imx219@10 to Unicam device /dev/media2 and ISP device /dev/media0
[0:37:59.078736837] [2846]  WARN RPI raspberrypi.cpp:1258 Mismatch between Unicam and CamHelper for embedded data usage!
[0:37:59.079869542] [2846]  INFO RPI raspberrypi.cpp:1374 Registered camera /base/soc/i2c0mux/i2c@1/imx219@10 to Unicam device /dev/media4 and ISP device /dev/media1
camera 1 seq
[0:37:59.085781209] [2845]  INFO Camera camera.cpp:1035 configuring streams: (0) 3280x2464-BGR888
[0:37:59.086328219] [2846]  INFO RPI raspberrypi.cpp:761 Sensor: /base/soc/i2c0mux/i2c@0/imx219@10 - Selected sensor format: 3280x2464-SBGGR10_1X10 - Selected unicam format: 3280x2464-pBAA
closing camera 1
camera 2 seq
[0:38:00.432455763] [2851]  INFO Camera camera.cpp:1035 configuring streams: (0) 3280x2464-BGR888
[0:38:00.432982440] [2846]  INFO RPI raspberrypi.cpp:761 Sensor: /base/soc/i2c0mux/i2c@1/imx219@10 - Selected sensor format: 3280x2464-SBGGR10_1X10 - Selected unicam format: 3280x2464-pBAA
closing camera 2
########## taking two photos, this will fail
camera 1 seq
[0:38:01.833862282] [2853]  INFO Camera camera.cpp:1035 configuring streams: (0) 3280x2464-BGR888
[0:38:01.841378369] [2846]  INFO RPI raspberrypi.cpp:761 Sensor: /base/soc/i2c0mux/i2c@0/imx219@10 - Selected sensor format: 3280x2464-SBGGR10_1X10 - Selected unicam format: 3280x2464-pBAA
camera 2 seq
[0:38:02.607401706] [2855]  INFO Camera camera.cpp:1035 configuring streams: (0) 3280x2464-BGR888
[0:38:02.608323303] [2846]  INFO RPI raspberrypi.cpp:761 Sensor: /base/soc/i2c0mux/i2c@1/imx219@10 - Selected sensor format: 3280x2464-SBGGR10_1X10 - Selected unicam format: 3280x2464-pBAA
[0:38:03.430892329] [2855] ERROR Camera camera.cpp:533 Camera in Configured state trying queueRequest() requiring state Running

Hardware : Compute Module 4, picamera2 0.3.3, bullseye, 2x imx219

Additional context This doesn’t always reproduce, but once it does it will consistently. I cannot figure out what makes that happen, seems very random.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:19

github_iconTop GitHub Comments

1reaction
davidplowmancommented, Oct 4, 2022

Yes, this is in my plans. I’m busy with other stuff at the moment, and also on holiday at some point, so my guess would be that it’s “a few weeks away”.

0reactions
davidplowmancommented, Nov 10, 2022

This should now be available in the 0.3.6 release, so I’ll close this issue. Please let us know of any problems!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Libcamera Dual Camera Setup - Raspberry Pi Forums
If I run the following command, I get the desired result and performance, but it is in two separate windows since I have...
Read more >
asynDriver: Asynchronous Driver Support - Release Notes
Added asynInt64 support for longout, longin, ao, and ai records. This allows these records to be used to communicate with drivers on the...
Read more >
3 Bugs and a Thank You in 5.2.7 - NetWorx Help - SoftPerfect
I can then manually start the two portables and, with all 3 running, monitor 3 different interfaces, and when I click the icon...
Read more >
Broadcom BNX2 RHEL6 Driver - Lenovo Support NP
They include multiple driver change histories for multiple Linux ... to use new WoL and PM kernel APIs - removed power state changes...
Read more >
release-note.md\6.4.0\qt - Qt Project Git Repository Browser
Trying to use an older version will now result in a compile time error. ... 3fc68053db Use qt.qml.states logging category instead of STATECHANGE_DEBUG...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found