Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix opencv_mertems_merge example #15

Closed
wants to merge 4 commits into from

Conversation

tvoverbeek
Copy link
Contributor

It seems picam2.configure has to be called before each picam2.start.
Without this the exposure short already aborts.

Add possibility to position the upper left hand corner of the preview window.
Also update drm preview example
It seems picam2.configure has to be called before each picam2.start.
Without this the exposure short already aborts.
@davidplowman
Copy link
Collaborator

Hi, thanks for looking at this. I'm a bit bothered by it because reconfiguring really shouldn't be necessary, and it causes an entire teardown of the camera session, re-allocation of all the buffers and so on. Is this change fixing some warnings (but the code works anyway, which is the case for me) or that something is genuinely failing? Thanks!

@tvoverbeek
Copy link
Contributor Author

tvoverbeek commented Feb 24, 2022

Here is the output I get from the original version:

pi@picam2-32:~/picamera2/examples $ ./opencv_mertens_merge.py 
[0:09:04.461375283] [2513]  INFO IPAManager ipa_manager.cpp:138 libcamera is not installed. Adding '/home/pi/libcamera/build/src/ipa' to the IPA search path
[0:09:04.484381908] [2513]  INFO Camera camera_manager.cpp:293 libcamera v0.0.0+3421-16d99c30
[0:09:04.490602839] [2518] ERROR CameraSensor camera_sensor.cpp:551 'ov5647 10-0036': Camera sensor does not support test pattern modes.
[0:09:04.501323433] [2518]  INFO IPAProxy ipa_proxy.cpp:130 libcamera is not installed. Loading IPA configuration from '/home/pi/libcamera/src/ipa/raspberrypi/data'
[0:09:04.517356370] [2518]  INFO RPI raspberrypi.cpp:1331 Registered camera /base/soc/i2c0mux/i2c@1/ov5647@36 to Unicam device /dev/media3 and ISP device /dev/media0
Camera manager: <libcamera._libcamera.CameraManager object at 0xab6dc5c0>
Made <picamera2.Picamera2 object at 0xb65e2178>
Opened camera: <libcamera.Camera '/base/soc/i2c0mux/i2c@1/ov5647@36'>
Requesting configuration: {'use_case': 'preview', 'transform': <libcamera.Transform 'identity'>, 'colour_space': <libcamera.ColorSpace 'JPEG'>, 'buffer_count': 4, 'main': {'format': 'XBGR8888', 'size': (640, 480), 'stride': 2560, 'framesize': 1228800}, 'lores': None, 'raw': None, 'controls': {'NoiseReductionMode': 3}}
[0:09:04.519773728] [2513]  INFO Camera camera.cpp:1028 configuring streams: (0) 640x480-XBGR8888
[0:09:04.521774052] [2518]  INFO RPI raspberrypi.cpp:747 Sensor: /base/soc/i2c0mux/i2c@1/ov5647@36 - Selected sensor format: 640x480-SGBRG10_1X10 - Selected unicam format: 640x480-pGAA
Configuration successful!
Final configuration: {'use_case': 'preview', 'transform': <libcamera.Transform 'identity'>, 'colour_space': <libcamera.ColorSpace 'JPEG'>, 'buffer_count': 4, 'main': {'format': 'XBGR8888', 'size': (640, 480), 'stride': 2560, 'framesize': 1228800}, 'lores': None, 'raw': None, 'controls': {'NoiseReductionMode': 3}}
Streams: {'main': <libcamera._libcamera.Stream object at 0xaa7434e0>, 'lores': None, 'raw': None}
Allocated 4 buffers for stream 0
[0:09:04.536535199] [2522]  INFO IPARPI raspberrypi.cpp:626 Request ctrl: NoiseReductionMode = 3
Camera started
Camera stopped
Requesting configuration: {'use_case': 'preview', 'transform': <libcamera.Transform 'identity'>, 'colour_space': <libcamera.ColorSpace 'JPEG'>, 'buffer_count': 4, 'main': {'format': 'RGB888', 'size': (1024, 768), 'stride': 3072, 'framesize': 2359296}, 'lores': None, 'raw': None, 'controls': {'NoiseReductionMode': 3}}
[0:09:05.660909462] [2521]  INFO Camera camera.cpp:1028 configuring streams: (0) 1024x768-RGB888
[0:09:05.662707454] [2518]  INFO RPI raspberrypi.cpp:747 Sensor: /base/soc/i2c0mux/i2c@1/ov5647@36 - Selected sensor format: 1296x972-SGBRG10_1X10 - Selected unicam format: 1296x972-pGAA
Configuration successful!
Final configuration: {'use_case': 'preview', 'transform': <libcamera.Transform 'identity'>, 'colour_space': <libcamera.ColorSpace 'JPEG'>, 'buffer_count': 4, 'main': {'format': 'RGB888', 'size': (1024, 768), 'stride': 3072, 'framesize': 2359296}, 'lores': None, 'raw': None, 'controls': {'NoiseReductionMode': 3}}
Streams: {'main': <libcamera._libcamera.Stream object at 0xaa7434e0>, 'lores': None, 'raw': None}
Allocated 4 buffers for stream 0
[0:09:05.701106957] [2526]  INFO IPARPI raspberrypi.cpp:626 Request ctrl: AnalogueGain = 4.001368
[0:09:05.701249957] [2526]  INFO IPARPI raspberrypi.cpp:626 Request ctrl: ExposureTime = 43437
[0:09:05.701314642] [2526]  INFO IPARPI raspberrypi.cpp:626 Request ctrl: NoiseReductionMode = 3
Camera started
Camera stopped
[0:09:05.999901025] [2527]  INFO IPARPI raspberrypi.cpp:626 Request ctrl: AnalogueGain = 4.001368
[0:09:06.000099079] [2527]  INFO IPARPI raspberrypi.cpp:626 Request ctrl: ExposureTime = 14479
[0:09:06.000156709] [2527]  INFO IPARPI raspberrypi.cpp:626 Request ctrl: NoiseReductionMode = 3
Camera started
[0:09:06.072722143] [2518] ERROR RPISTREAM rpi_stream.cpp:242 Failed to queue buffer for ISP Output0
[0:09:06.072798884] [2518] ERROR RPISTREAM rpi_stream.cpp:242 Failed to queue buffer for ISP Output0
[0:09:06.072854717] [2518] ERROR RPISTREAM rpi_stream.cpp:242 Failed to queue buffer for ISP Output0
^CTraceback (most recent call last):
  File "/home/pi/picamera2/examples/./opencv_mertens_merge.py", line 33, in <module>
    picam2.stop()
  File "/home/pi/picamera2/picamera2.py", line 404, in stop
    self.wait()
  File "/home/pi/picamera2/picamera2.py", line 490, in wait
    self.event.wait()
  File "/usr/lib/python3.9/threading.py", line 574, in wait
    signaled = self._cond.wait(timeout)
  File "/usr/lib/python3.9/threading.py", line 312, in wait
    waiter.acquire()
KeyboardInterrupt
Freeing resources for <picamera2.Picamera2 object at 0xb65e2178>
Camera stopped
Close camera: <libcamera.Camera '/base/soc/i2c0mux/i2c@1/ov5647@36'>

pi@picam2-32:~/picamera2/examples $ 

It is hanging in the 'short' capture
I had to stop it with ctrl-C. No output files.
With the added configures it works.
Additional info : I am also running realvnc server. Do not know if that matters.

@davidplowman
Copy link
Collaborator

I'll try it over vnc but I don't think that should make a difference. From what you've said previously I take it this is a 2GB Pi 4B, and a v1 camera, so I'll try to match that as well. But in any case, I don't think the change here is the correct fix, could you perhaps file a bug instead? Thanks!

@davidplowman
Copy link
Collaborator

Just tried this with the v1 sensor and indeed that seems to be the problem. Almost certainly a sensor/driver issue, so we'll have to look into that.

@tvoverbeek
Copy link
Contributor Author

Yes it is a 2G Pi4B and a V1 camera.
WIll open an issue instead.

@tvoverbeek
Copy link
Contributor Author

tvoverbeek commented Feb 24, 2022

Tried also with the HQ camera on Pi 4B 2G with 32-bit OS.
opencv_mertens_merge.py runs till the end and the output files are created.
But both the short and long exposures still show the error message:
ERROR RPISTREAM rpi_stream.cpp:242 Failed to queue buffer for ISP Output0.
Full output below:

pi@picam2-32:~/picamera2/examples $ ./opencv_mertens_merge.py 
[0:05:59.319607539] [2020]  INFO IPAManager ipa_manager.cpp:138 libcamera is not installed. Adding '/home/pi/libcamera/build/src/ipa' to the IPA search path
[0:05:59.320402345] [2020]  INFO Camera camera_manager.cpp:293 libcamera v0.0.0+3421-16d99c30
[0:05:59.323113613] [2021]  WARN CameraSensorProperties camera_sensor_properties.cpp:141 No static properties available for 'imx477'
[0:05:59.323156353] [2021]  WARN CameraSensorProperties camera_sensor_properties.cpp:143 Please consider updating the camera sensor properties database
[0:05:59.323185797] [2021] ERROR CameraSensor camera_sensor.cpp:551 'imx477 10-001a': Camera sensor does not support test pattern modes.
[0:05:59.329753451] [2021]  INFO IPAProxy ipa_proxy.cpp:130 libcamera is not installed. Loading IPA configuration from '/home/pi/libcamera/src/ipa/raspberrypi/data'
[0:05:59.340934555] [2021]  INFO RPI raspberrypi.cpp:1331 Registered camera /base/soc/i2c0mux/i2c@1/imx477@1a to Unicam device /dev/media2 and ISP device /dev/media0
Camera manager: <libcamera._libcamera.CameraManager object at 0xb662dca0>
Made <picamera2.Picamera2 object at 0xb662e178>
Opened camera: <libcamera.Camera '/base/soc/i2c0mux/i2c@1/imx477@1a'>
Requesting configuration: {'use_case': 'preview', 'transform': <libcamera.Transform 'identity'>, 'colour_space': <libcamera.ColorSpace 'JPEG'>, 'buffer_count': 4, 'main': {'format': 'XBGR8888', 'size': (640, 480), 'stride': 2560, 'framesize': 1228800}, 'lores': None, 'raw': None, 'controls': {'NoiseReductionMode': 3}}
[0:05:59.343024311] [2020]  INFO Camera camera.cpp:1028 configuring streams: (0) 640x480-XBGR8888
[0:05:59.343363900] [2021]  INFO RPI raspberrypi.cpp:747 Sensor: /base/soc/i2c0mux/i2c@1/imx477@1a - Selected sensor format: 2028x1520-SBGGR12_1X12 - Selected unicam format: 2028x1520-pBCC
Configuration successful!
Final configuration: {'use_case': 'preview', 'transform': <libcamera.Transform 'identity'>, 'colour_space': <libcamera.ColorSpace 'JPEG'>, 'buffer_count': 4, 'main': {'format': 'XBGR8888', 'size': (640, 480), 'stride': 2560, 'framesize': 1228800}, 'lores': None, 'raw': None, 'controls': {'NoiseReductionMode': 3}}
Streams: {'main': <libcamera._libcamera.Stream object at 0xaa78e580>, 'lores': None, 'raw': None}
Allocated 4 buffers for stream 0
[0:05:59.363202951] [2025]  INFO IPARPI raspberrypi.cpp:626 Request ctrl: NoiseReductionMode = 3
Camera started
Camera stopped
Requesting configuration: {'use_case': 'preview', 'transform': <libcamera.Transform 'identity'>, 'colour_space': <libcamera.ColorSpace 'JPEG'>, 'buffer_count': 4, 'main': {'format': 'RGB888', 'size': (1024, 768), 'stride': 3072, 'framesize': 2359296}, 'lores': None, 'raw': None, 'controls': {'NoiseReductionMode': 3}}
[0:06:00.906205225] [2024]  INFO Camera camera.cpp:1028 configuring streams: (0) 1024x768-RGB888
[0:06:00.906887458] [2021]  INFO RPI raspberrypi.cpp:747 Sensor: /base/soc/i2c0mux/i2c@1/imx477@1a - Selected sensor format: 2028x1520-SBGGR12_1X12 - Selected unicam format: 2028x1520-pBCC
Configuration successful!
Final configuration: {'use_case': 'preview', 'transform': <libcamera.Transform 'identity'>, 'colour_space': <libcamera.ColorSpace 'JPEG'>, 'buffer_count': 4, 'main': {'format': 'RGB888', 'size': (1024, 768), 'stride': 3072, 'framesize': 2359296}, 'lores': None, 'raw': None, 'controls': {'NoiseReductionMode': 3}}
Streams: {'main': <libcamera._libcamera.Stream object at 0xaa78e580>, 'lores': None, 'raw': None}
Allocated 4 buffers for stream 0
[0:06:00.969099585] [2032]  INFO IPARPI raspberrypi.cpp:626 Request ctrl: AnalogueGain = 1.950456
[0:06:00.969341805] [2032]  INFO IPARPI raspberrypi.cpp:626 Request ctrl: ExposureTime = 9994
[0:06:00.969491581] [2032]  INFO IPARPI raspberrypi.cpp:626 Request ctrl: NoiseReductionMode = 3
Camera started
Camera stopped
[0:06:01.794905332] [2033]  INFO IPARPI raspberrypi.cpp:626 Request ctrl: AnalogueGain = 1.950456
[0:06:01.795064274] [2033]  INFO IPARPI raspberrypi.cpp:626 Request ctrl: ExposureTime = 3331
[0:06:01.795139681] [2033]  INFO IPARPI raspberrypi.cpp:626 Request ctrl: NoiseReductionMode = 3
Camera started
[0:06:02.494100637] [2021] ERROR RPISTREAM rpi_stream.cpp:242 Failed to queue buffer for ISP Output0
[0:06:02.494304227] [2021] ERROR RPISTREAM rpi_stream.cpp:242 Failed to queue buffer for ISP Output0
Camera stopped
[0:06:02.611302250] [2038]  INFO IPARPI raspberrypi.cpp:626 Request ctrl: AnalogueGain = 1.950456
[0:06:02.611422878] [2038]  INFO IPARPI raspberrypi.cpp:626 Request ctrl: ExposureTime = 29982
[0:06:02.611476396] [2038]  INFO IPARPI raspberrypi.cpp:626 Request ctrl: NoiseReductionMode = 3
Camera started
[0:06:03.298466639] [2021] ERROR RPISTREAM rpi_stream.cpp:242 Failed to queue buffer for ISP Output0
[0:06:03.298608526] [2021] ERROR RPISTREAM rpi_stream.cpp:242 Failed to queue buffer for ISP Output0
Camera stopped
Freeing resources for <picamera2.Picamera2 object at 0xb662e178>
Close camera: <libcamera.Camera '/base/soc/i2c0mux/i2c@1/imx477@1a'>
pi@picam2-32:~/picamera2/examples $ 

@tvoverbeek
Copy link
Contributor Author

Closed transferred to issue #18

@tvoverbeek tvoverbeek closed this Feb 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants