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

rpicam_still: Add RGB/BGR 48bpp support #599

Merged
merged 2 commits into from
Feb 16, 2024
Merged

rpicam_still: Add RGB/BGR 48bpp support #599

merged 2 commits into from
Feb 16, 2024

Conversation

naushir
Copy link
Collaborator

@naushir naushir commented Nov 17, 2023

Add support for 48-bpp RGB/BGR formats that can be generated by the PiSP. rpicam-still can select this with the "--encoding rgb48" command line option.

@naushir
Copy link
Collaborator Author

naushir commented Nov 22, 2023

Cannot really merge this until we have RGB161616 support in libcamera.

@schoolpost
Copy link
Contributor

Cannot really merge this until we have RGB161616 support in libcamera.

coming soon?

@naushir
Copy link
Collaborator Author

naushir commented Nov 30, 2023

We will try to get it in our next release. It all depends on how and when we can start the driver upstreaming process. You are welcome to try the change out, but note that you will need the latest kernel and build/install libcamera from https://github.com/raspberrypi/libcamera/tree/next.

@schoolpost
Copy link
Contributor

schoolpost commented Nov 30, 2023

We will try to get it in our next release. It all depends on how and when we can start the driver upstreaming process. You are welcome to try the change out, but note that you will need the latest kernel and build/install libcamera from https://github.com/raspberrypi/libcamera/tree/next.

Is this format only supported in the Still stream? or also video?

Does not work in my testing when used like this:

Mode selection for 2028:1520:12:U(24)
    SRGGB10_CSI2P,1332x990/120.048 - Score: 3456.22
    SRGGB12_CSI2P,2028x1080/50.0275 - Score: 1083.84
    SRGGB12_CSI2P,2028x1520/40.0096 - Score: 0
    SRGGB12_CSI2P,4056x3040/10 - Score: 28887
[0:00:51.513902245] [1405]  WARN V4L2 v4l2_pixelformat.cpp:346 Unsupported V4L2 pixel format <INVALID>
[0:00:51.513919760] [1405]  WARN Formats formats.cpp:997 Unsupported pixel format 0x00000000
[0:00:51.513916383] [1405] ERROR RPI pisp.cpp:228 Pixel format <INVALID> unsupported
[0:00:51.513935865] [1405] FATAL default pisp.cpp:229 assertion "0" failed in toPiSPImageFormat()
Backtrace:
/usr/local/lib/aarch64-linux-gnu/libcamera.so.0.1(+0x104e34) [0x7ffef1fc4e34]
/usr/local/lib/aarch64-linux-gnu/libcamera.so.0.1(_ZNK9libcamera14PiSPCameraData16platformValidateEPNS_3RPi22RPiCameraConfigurationE+0x3fc) [0x7ffef1fc8040]
/usr/local/lib/aarch64-linux-gnu/libcamera.so.0.1(_ZN9libcamera3RPi22RPiCameraConfiguration8validateEv+0x358) [0x7ffef1fb0098]
/usr/local/lib/aarch64-linux-gnu/rpicam_app.so.1.4.1(_ZN9RPiCamApp12setupCaptureEv+0x24) [0x7ffef2268434]
/usr/local/lib/aarch64-linux-gnu/rpicam_app.so.1.4.1(_ZN9RPiCamApp14ConfigureVideoEjh+0x354) [0x7ffef226d6f4]
cinepi-raw(+0x25fa8) [0x5555c2b65fa8]
/lib/aarch64-linux-gnu/libc.so.6(+0x27780) [0x7ffef18c7780]
/lib/aarch64-linux-gnu/libc.so.6(__libc_start_main+0x98) [0x7ffef18c7858]
cinepi-raw(+0x27ab0) [0x5555c2b67ab0]
Aborted

Hardcoded the format in the configureVideo Method:

void RPiCamApp::ConfigureVideo(unsigned int flags, uint8_t thumbnailFactor)
{
	LOG(2, "Configuring video...");

	bool have_lores_stream = options_->lores_width && options_->lores_height;
	StreamRoles stream_roles = { StreamRole::VideoRecording };
	int lores_index = 1;
	if (!options_->no_raw)
		stream_roles.push_back(StreamRole::Raw), lores_index++;
	if (have_lores_stream)
		stream_roles.push_back(StreamRole::Viewfinder);
	configuration_ = camera_->generateConfiguration(stream_roles);
	if (!configuration_)
		throw std::runtime_error("failed to generate video configuration");

	// Now we get to override any of the default settings from the options_->
	StreamConfiguration &cfg = configuration_->at(0);
	cfg.pixelFormat = libcamera::formats::BGR161616;
	cfg.bufferCount = 6; // 6 buffers is better than 4

@naushir
Copy link
Collaborator Author

naushir commented Dec 1, 2023

The RGB48 format is supported in all configurations. It's likely you have not updated your kernel, so the driver does not report support for 48-bpp yet, hence your error.

You can either rebuild the kernel yourself, or run sudo rpi-update to get the latest non-stable version to test out.

The existing scripts use Node.js 16 which is deprecated.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
Add support for 48-bpp RGB/BGR formats that can be generated by the
PiSP.  rpicam-still can select this with the "--encoding rgb48" command
line option.

Signed-off-by: Naushir Patuck <naush@raspberrypi.com>
@naushir naushir merged commit 8e5224b into main Feb 16, 2024
10 of 11 checks passed
@naushir naushir deleted the 48bpp branch February 16, 2024 09:03
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.

2 participants