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.

#!/usr/bin/python3

# Configure a raw stream and capture an image from it.
import time

from picamera2 import Picamera2, Preview

picam2 = Picamera2()
picam2.start_preview(Preview.QTGL)

preview_config = picam2.create_preview_configuration(raw={"size": picam2.sensor_resolution})
print(preview_config)
picam2.configure(preview_config)

picam2.start()
time.sleep(2)

raw = picam2.capture_array("raw")
print(raw.shape)
print(picam2.stream_configuration("raw"))

ERROR

[72:40:04.172678509] [7765]  INFO RPI raspberrypi.cpp:1374 Registered camera /base/soc/i2c0mux/i2c@1/imx477@1a to Unicam device /dev/media0 and ISP device /dev/media2
{'use_case': 'preview', 'transform': <libcamera.Transform 'identity'>, 'colour_space': <libcamera.ColorSpace 'sYCC'>, 'buffer_count': 4, 'main': {'format': 'XBGR8888', 'size': (640, 480)}, 'lores': None, 'raw': {'format': 'SBGGR12_CSI2P', 'size': (4056, 3040)}, 'controls': {'NoiseReductionMode': <NoiseReductionModeEnum.Minimal: 3>, 'FrameDurationLimits': (100, 83333)}, 'display': 'main', 'encode': 'main'}
[72:40:05.956939345] [7764]  INFO Camera camera.cpp:1035 configuring streams: (0) 640x480-XBGR8888 (1) 4056x3040-SBGGR12_CSI2P
[72:40:05.957404833] [7765]  INFO RPI raspberrypi.cpp:761 Sensor: /base/soc/i2c0mux/i2c@1/imx477@1a - Selected sensor format: 4056x3040-SBGGR12_1X12 - Selected unicam format: 4056x3040-pBCC
qt.qpa.xcb: QXcbConnection: XCB error: 148 (Unknown), sequence: 192, resource id: 0, major code: 140 (Unknown), minor code: 20
(3040, 6112)
{'format': 'SBGGR12_CSI2P', 'size': (4056, 3040), 'stride': 6112, 'framesize': 18580480}

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
chrisrukcommented, Sep 12, 2022

capture_dng.py will save you a DNG file, which is a raw image format that can be loaded into image editing software ( https://en.wikipedia.org/wiki/Digital_Negative )

1reaction
chrisrukcommented, Sep 12, 2022

Hi, I’m not quite sure what you’re trying to do, the following line captures a raw image and stores the result in a numpy array:

raw = picam2.capture_array("raw")

Note that this data won’t have been demosaiced.

If you want to save a raw image to a file that can be loaded in an image editor capture_dng.py or capture_dng_and_jpeg.py might be more handy for you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Streamlit error code streamlit requires raw py - Stack Overflow
Try 'streamlit run --help' for help. Error: Streamlit requires raw Python (.py) files, but the provided file has no extension. For more ...
Read more >
rawpy - PyPI
RAW image processing for Python, a wrapper for libraw. ... On Linux, if you get the error "ImportError: libraw.so: cannot open shared object...
Read more >
Error: Streamlit requires raw Python (.py) files
every time I try to run streamlit this error shows up and I don't know how to fix it. can somebody help?
Read more >
How To Use Python Raw String | DigitalOcean
You can create a raw string in Python by prefixing a string literal with r or R . Python raw string treats the...
Read more >
re — Regular expression operations — Python 3.11.1 ...
The solution is to use Python's raw string notation for regular expression patterns; backslashes are not handled in any special way in a...
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