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

Check for unsupported pixel format #218

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

doug-holtsinger
Copy link

If an unsupported pixel format is handed to libcamera, then it hits an assertion error in pisp.cpp instead of returning
a proper return code. The problem was originally seen here:
opencv/opencv#21653 (comment)
I can reproduce the same issue with the latest main branch of libcamera and opencv 4.x

naushir and others added 18 commits November 4, 2024 15:31
Add a new subpoject wrap file for the libpisp library located at
https://github.com/raspberrypi/libpisp

The libpisp library is used to configure the Raspberry Pi 5 Frontend
and Backend ISP components.

Signed-off-by: Naushir Patuck <[email protected]>
Reviewed-by: David Plowman <[email protected]>
Add the Raspberry Pi 5 ISP (PiSP) pipeline handler to libcamera. To
include this pipeline handler in the build, set the following meson
option:

meson configure -Dpipelines=rpi/pisp

Signed-off-by: Naushir Patuck <[email protected]>
Reviewed-by: David Plowman <[email protected]>
Add the Raspberry Pi 5 ISP (PiSP) IPA to libcamera. To include this IPA
in the build, set the following meson option:

meson configure -Dipas=rpi/pisp

Signed-off-by: Naushir Patuck <[email protected]>
Reviewed-by: David Plowman <[email protected]>
Use an r-value reference in set() and setLocked(), allowing more
efficient metadata handling with std::forward and std::move if needed.

Signed-off-by: Naushir Patuck <[email protected]>
These function erases a key/value pair from the metadata object.

Signed-off-by: Naushir Patuck <[email protected]>
This property (cfeDataBufferStrided) indicates if the CSI-2 hardware
writes to the embedded/metadata buffer directly, or if it treats the
buffer like an image buffer and strides the metadata lines.

Unicam write this buffer strided, while the PiSP Frontend writes to it
directly. This information will be relevant to data parsers in the
helpers where the data is structured in lines.

Signed-off-by: Naushir Patuck <[email protected]>
Add the follwing RPi vendor controls to handle Convolutional Neural
Network processing:

CnnOutputTensor
CnnOutputTensorInfo
CnnEnableInputTensor
CnnInputTensor
CnnInputTensorInfo
CnnKpiInfo

These controls will be used to support the new Raspberry Pi AI Camera,
using an IMX500 sensor with on-board neural network processing.

Signed-off-by: Naushir Patuck <[email protected]>
Add code to handle the new CNN vendor controls in the Raspberry Pi IPA.

The value of CnnInputTensorInfo is cached as it is the only stateful
input control.

All other controls are output controls, and the values are copied into
directly from the rpiMetadata object if present. The camera helpers
populate the rpiMetadata object if the sensor supports on-board CNN
processing, such as the IMX500.

Signed-off-by: Naushir Patuck <[email protected]>
Add a CamHelper::setHwConfig() helper used by the IPA to set the
hardware configuartion in use by the pipeline. This will be needed by
the IMX500 camera helper in a future commit to determine if the
metadata buffer is strided.

Signed-off-by: Naushir Patuck <[email protected]>
Add a Sony IMX500 camera helper to the IPA. This also includes support
for the on-chip CNN hardware accelerator and parsing of the neural
network data stream returned in the metadata buffer.

Add tuning files for both VC4 and PiSP platforms.

Signed-off-by: Naushir Patuck <[email protected]>
The IMX708 sensor driver advertises its module variants (narrow/wide angle lens,
IR block/pass) by modifying the media entity name string. So add duplicate
entries for each variant.

Signed-off-by: Nick Hollinghurst <[email protected]>
Signed-off-by: Naushir Patuck <[email protected]>
Reviewed-by: Naushir Patuck <[email protected]>
Reviewed-by: David Plowman <[email protected]>
Look for the RAW mandatory stream flag in the pipeline handler config
file. If this flag is set, it guarantees that the application will
provide buffers for Unicam Image, so override the minUnicamBuffers and
minTotalUnicamBuffers config parameters in the following way:

- If startup drop frames are required, allocate at least 1 internal buffer.
- If no startup drop frames are required, do not allocate any internal buffers.

Look for the Output 0 mandatory stream flag in in the pipeline handler
config file. If this flag is set, it guarantees that the application
will provide buffers for the ISP, do not allocate any internal buffers
for the device.

Add a new rpi_apps.yaml pipeline handler config file that enables both
these flags.  To use the file, set the following env variable for a
custom build:

export LIBCAMERA_RPI_CONFIG_FILE=/usr/local/share/libcamera/pipeline/rpi/vc4/rpi_apps.yaml

or for a packaged install:

export LIBCAMERA_RPI_CONFIG_FILE=/usr/share/libcamera/pipeline/rpi/vc4/rpi_apps.yaml

Signed-off-by: Naushir Patuck <[email protected]>
… buffers

V4L2 only allows upto VIDEO_MAX_FRAME frames to be queued at a time, so
if we reach this limit, store the framebuffers in a pending queue, and
try to enqueue once a buffer has been dequeued.

Signed-off-by: Naushir Patuck <[email protected]>
If grey world AWB is setup in the tuning file, the CT curve will either
be missing or invalid. Disable biasing the statistics for the search in
such cases.

Fixes: ea8fd63 ("ipa: rpi: awb: Add a bias to the AWB search")
Signed-off-by: Naushir Patuck <[email protected]>
Reviewed-by: David Plowman <[email protected]>
Reviewed-by: Kieran Bingham <[email protected]>
Signed-off-by: Douglas Holtsinger <[email protected]>
@naushir
Copy link
Collaborator

naushir commented Dec 9, 2024

@doug-holtsinger, thank you for this fix. However, I'm a bit surprised this is needed. Do you happen to know exactly what format is originally requested to cause the failure?

@naushir
Copy link
Collaborator

naushir commented Dec 9, 2024

Also, can you post the output of dmesg when the error occurs to see if the kernel driver is complaining about anything?

@doug-holtsinger
Copy link
Author

Also, can you post the output of dmesg when the error occurs to see if the kernel driver is complaining about anything?

Here is the dmesg:
https://pastebin.com/KwRPPe28

There is a warning at line 384 but I can still use my RPi v3 camera just fine with libcamera using the YUYV format.

The failing requested format was libcamera::formats::MJPEG which is evidently not supported by my camera.

Output from 'cam -c1 -I' that lists supported Pixelformat and resolutions for my camera:
https://pastebin.com/jg3KGGSX

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.

5 participants