Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 6814

Camera board • Camera MMAL graph on baremetal with resizer

$
0
0
I have progress in my baremetal project with imx219 camera on raspberry pi 3b+.
I have vchiq and threading implemented.
I have this graph working well

"ril.camera".video_out ---> "encoder(h264)"--->compressed video written to sd card

I have and SPI display and want to draw resized video to display.
For that I have added splitter and resizer components.
My goal is to setup this:

Code:

"ril.camera".video_out(1280x1024)  ---> "ril.video_splitter" -----> "encoder(h264)"       ----> compressed video written to SD card                                                           -----> "ril.resize(320x240)"----> SPI display
Before trying out the full graph above, I first have implemented and tested same thing but without resizer - second splitter output was just checked for existence but ignored. It worked fine.

Now I add "ril.resize" component and start to have problems
When I create new mmal component "ril.resize" I check what is created by default:

Code:

resizer.IN:handle:1 type:3,encoding:"RGBA",variant:00000000,160x16            resizer.IN: minbuf: 1x10240, recommended:1x10240, current:1x10240                   resizer.OUT:handle:2 type:3,encoding:"RGBA",variant:00000000,160x16           resizer.OUT: minbuf: 1x10240, recommended:1x10240, current:1x10240
But then I immediately want to change input and output port of resizer to reflect this:
resizer.input: encoding:OPAQUE,variant:I420, width 1280x1024,framerate:0
resizer.output: encoding: RGB24, variant:0, width 320x240,framerate:0

But this fails already on the input step, here is what I see in logs:

Code:

MESS:00:00:19.352017:0: mmal: mmal_ril_set_port_settings: ril.resize:in:0: failed to set port definition (4) buffers 1/1/10240MESS:00:00:19.363024:0: mmalsrv: mmal_server_do_port_info_set: ril.resize:in:0(RGBA): failed (handle 1, status 3)
Update:
If I only change smaller portion of parameters in mmal port format, then I am able to set resizer input to required settings, see code below,
but for the resizer output port this still does not work.

Code:

  resizer = component_create("ril.resize");                                                                                                         CHECK_ERR_PTR(resizer, "Failed to create component 'ril.resize'");              if (!resizer->inputs || !resizer->outputs) {                                      MMAL_ERR("err: resizer has 0 outputs or inputs");                               return ERR_GENERIC;                                                           }                                                                                                                                                               err = mmal_component_enable(resizer);                                                                                                                                                                                                 resizer->input[0].format.encoding = MMAL_ENCODING_OPAQUE;                       resizer->input[0].format.encoding_variant = MMAL_ENCODING_I420;                 resizer->input[0].format.es->video.width = in_width;                            resizer->input[0].format.es->video.height = in_height;                          resizer->input[0].format.es->video.crop.width = in_width;                       resizer->input[0].format.es->video.crop.height = in_height;                     err = mmal_port_set_format(&resizer->input[0]);                                 CHECK_ERR("Failed to set format for resizer.IN port");                          printf("-------INPUT DONE\r\n");      /* This below does not work */  resizer->output[0].format.encoding = MMAL_ENCODING_RGB24;                       resizer->output[0].format.encoding_variant = 0;                                 resizer->output[0].format.es->video.width = out_width;                          resizer->output[0].format.es->video.height = out_height;                        resizer->output[0].format.es->video.crop.width = out_width;                     resizer->output[0].format.es->video.crop.height = out_height;                   err = mmal_port_set_format(&resizer->output[0]);                                CHECK_ERR("Failed to set format for resizer.OUT port");                         printf("-------OUTPUT DONE\r\n"); 

Code:

MESS:00:00:19.531716:0: mmal: mmal_ril_set_port_settings: ril.resize:out:0: failed to set port definition (4) buffers 1/1/10240                         MESS:00:00:19.542809:0: mmalsrv: mmal_server_do_port_info_set: ril.resize:out:0(RGB3): failed (handle 2, status 3)  
Also, I am confused.
I have found this thread with relevant topic.
viewtopic.php?p=1384321&hilit=ril.resizer#p1384321,
I tried to check if my start_x.elf have "vc.ril.resize" or "vc.ril.isp", but both calls to create component failed. Still I understood the limitation of resizer implementation done by vector instructions in the VideoCore (ril.resizer). So what is ril.resize and how it is different?

Also, please advise, maybe I should go for a different graph for my purpose:
My main goal is achieved - writing video to SD card.
I want something to be shown on display as a preview.
I have read in RaspiVid.c sources - preview and video port should have same resolution - I can not order them different sizes.
But theoretically I could go without splitter, by attaching resizer to camera preview port.
What are pros/cons/alternatives?

Statistics: Posted by valc — Mon May 20, 2024 8:02 pm — Replies 0 — Views 35



Viewing all articles
Browse latest Browse all 6814

Trending Articles