tomekziel
Posts: 2
Joined: Sun Dec 29, 2013 2:13 am

Raspistill preview with 16:9 ratio on PAL composite display

Sun Dec 29, 2013 2:19 am

Hi!

Software: raspbian, hardware: Pi model B 512 with camera board

Display: rear view car display, PAL composite input, 480x272 resolution, 16:9 aspect ratio

Goal: I'd like to shot still images with raspistill then show it on the screen - with valid 16:9 ratio at both stages (camera preview and final image). I know PAL is 4:3 only, I'd like to push anamorphic signal from Pi and let display scale it to target width/height proportions.

What I'm able to do: if I switch display to 4:3 mode, use raspistill to shot and fbi to show works as expected, but display has black bars on left and right edge.

Problem: If I switch display to widened 16:9 mode, I'm unable to convince raspistill to do 16:9 fullscreen image preview (which would be too tall on assumed 4:3 display but OK on widened display).

When I use sdtv_aspect=3 mode switch in config.txt, nothing changes in raspistill preview no matter what options I use. It has either 16:9 image preview with black bars on top and bottom (therefore deformed on widened display) or fullscreen 4:3 preview (also deformed on widened display) but not both (expected fullscreen preview of 16:9 image).

With sdtv_aspect=3 the fbi image viewer adds extra black bars to displayed 4:3 image which effectively cancels widening done in display (expected effect). Raspistill ignores sdtv_aspect.

I have tried to disable overscan or define 480x272 framebuffer, without luck.

Thanks!
Tomasz

(also asked on http://raspberrypi.stackexchange.com/qu ... l-169-disp)

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 19076
Joined: Sat Jul 30, 2011 7:41 pm

Re: Raspistill preview with 16:9 ratio on PAL composite disp

Sun Dec 29, 2013 9:14 am

You can use the preview windows size specifier and the region of interest command line options to set image aspect.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Please direct all questions to the forum, I do not do support via PM.

tomekziel
Posts: 2
Joined: Sun Dec 29, 2013 2:13 am

Re: Raspistill preview with 16:9 ratio on PAL composite disp

Sun Dec 29, 2013 9:26 pm

Thanks! I was not aware of the -roi switch.

For the record: with PAL screen widened from 4:3 to 16:9, following line results with valid-ratio preview of half screen width & full screen height picture, which is then shown on the screen. Proportions are valid thanks to using 75% of sensor height.

Code: Select all

sudo raspistill -vf -w 1296 -h 1944 -o out.jpg -fp -p 0,0,720,576 -v -vf -roi '0,0.125,0.99,0.75' && sudo fbi -T 1 out.jpg
Interesting catch: when ROI width is 1 (like -roi '0,0.125,1,0.75'), height change is ignored. When ROI width is slightly decreased (-roi '0,0.125,0.99,0.75'), all parameters are honored. This issue was observed with codebase from November 2013.

jamesh
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 19076
Joined: Sat Jul 30, 2011 7:41 pm

Re: Raspistill preview with 16:9 ratio on PAL composite disp

Mon Dec 30, 2013 9:12 am

Yes, we have a bug report that ROI seems a little odd in some circumstances. Can you add your observations to the report here..

https://github.com/raspberrypi/userland/issues/86

Thanks.
Principal Software Engineer at Raspberry Pi (Trading) Ltd.
Please direct all questions to the forum, I do not do support via PM.

karlkiste
Posts: 184
Joined: Tue Jan 22, 2013 8:50 am
Location: berlin, germany

Re: Raspistill preview with 16:9 ratio on PAL composite disp

Wed Jun 22, 2016 10:37 am

tomekziel wrote:Thanks! I was not aware of the -roi switch.

Code: Select all

sudo raspistill -vf -w 1296 -h 1944 -o out.jpg -fp -p 0,0,720,576 -v -vf -roi '0,0.125,0.99,0.75' && sudo fbi -T 1 out.jpg
Good to have a forum archive :-) I wasn't aware of the -roi switch to release the aspect ratio lock.

But now I'm trying to do the same using video. There is no -vf switch on raspivid, and requesting a bigger picture just to crop it might break the framerate... Is there a way to distort the raspivid preview?

Edit: I can get the correct preview aspect like
raspivid -w 1440 -h 1080 -roi "0,0,1,0.75"
but naturally this does not produce the desired recording.

Greets,
Kiste

karlkiste
Posts: 184
Joined: Tue Jan 22, 2013 8:50 am
Location: berlin, germany

Re: Raspistill preview with 16:9 ratio on PAL composite disp

Wed Jun 22, 2016 11:17 am

Hmpf... The mentioned line does fix a bit of a preview problem, but not for all cases. I'd like to also save full-sensor jpegs, for which I'd need a pillarboxed preview. This seems not to be possible with current raspistill.

Greets,
Kiste

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4946
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Raspistill preview with 16:9 ratio on PAL composite disp

Wed Jun 22, 2016 11:35 am

Going anamorphic is contrary to the setup of almost all the GPU components.
Yes roi allows you to force a non-square crop from the sensor, but that is not the intent. Likewise video_render normally has the intent of preserving the aspect ratio on the basis that the output image is 1:1.

If it is just for display, then you need to amend the config of video_render, and that is not something that raspistill can do as it stands.

If you look in the code then it configures a MMAL_DISPLAYREGION_T to say where the preview needs to be. There are numerous fields in there with descriptions of what they do. I think you want "param.noaspect = MMAL_TRUE", and also "param.set |= MMAL_DISPLAY_SET_NOASPECT" to tell it to ignore the source frame aspect ratio and just stretch it to fill your display rectangle that can be specified with the "-win" option.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

karlkiste
Posts: 184
Joined: Tue Jan 22, 2013 8:50 am
Location: berlin, germany

Re: Raspistill preview with 16:9 ratio on PAL composite disp

Wed Jun 22, 2016 11:56 am

Thank you for the quick reply!

I read it like anamorphic preview can be done (with reasonable effort) for raspivid, but not for raspistill. Probably I'll set the display to pillarboxed 4:3 for now, maybe I'll try to fiddle with sources one day...

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4946
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Raspistill preview with 16:9 ratio on PAL composite disp

Wed Jun 22, 2016 12:40 pm

karlkiste wrote:Thank you for the quick reply!

I read it like anamorphic preview can be done (with reasonable effort) for raspivid, but not for raspistill. Probably I'll set the display to pillarboxed 4:3 for now, maybe I'll try to fiddle with sources one day...
Pi is all about learning, not having things served to you on a plate.
RaspiPreview.c is used for both raspivid and raspistill. It's a 2 line change if you want to force the setting rathe than make it an option.

Code: Select all

git clone https://github.com/raspberrypi/userland.git
cd userland
./buildme
should get you the sources on your Pi and build them. Test your version works.

Choose an editor and go into host_applications/linux/apps/raspicam/RaspiPreview.c and add

Code: Select all

param.set |= MMAL_DISPLAY_SET_NOASPECT;
param.noaspect= MMAL_TRUE;
around line 116.
"./buildme" again, and the renderer will ignore the aspect ratio. Pat yourself on the back that you've just done a bit of real programming.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

karlkiste
Posts: 184
Joined: Tue Jan 22, 2013 8:50 am
Location: berlin, germany

Re: Raspistill preview with 16:9 ratio on PAL composite disp

Wed Jun 22, 2016 1:16 pm

You're too kind!

In fact I'm no real newbie to programming (having started on a ZX81), but I'm quite uncomfortable with everything that starts with "C". First half of your excellent advice is done already. Eventually I might dig me through so to have it imagemagick-like, that an appended "!" to the window definition will switch to anamorphic mode.

Thanks again!

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4946
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Raspistill preview with 16:9 ratio on PAL composite disp

Wed Jun 22, 2016 1:36 pm

karlkiste wrote:In fact I'm no real newbie to programming (having started on a ZX81),
Ah the 16kB wobble-pack!
karlkiste wrote:but I'm quite uncomfortable with everything that starts with "C".
Well Cobol is pretty scary, but in demand ;)
karlkiste wrote:Eventually I might dig me through so to have it imagemagick-like, that an appended "!" to the window definition will switch to anamorphic mode.
Any mods to the raspicam apps have to maintain backward compatibility. It's normally easier to add it as a new parameter rather than trying to overload.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

karlkiste
Posts: 184
Joined: Tue Jan 22, 2013 8:50 am
Location: berlin, germany

Re: Raspistill preview with 16:9 ratio on PAL composite disp

Thu Jun 23, 2016 6:32 am

First of all: hardcoding your two lines works, my problem is therefore solved.

Moving on to the learning (or practise) part:
6by9 wrote:
karlkiste wrote:In fact I'm no real newbie to programming (having started on a ZX81),
Ah the 16kB wobble-pack!
Mine has the 16kB extension built-in :-)
6by9 wrote:Any mods to the raspicam apps have to maintain backward compatibility. It's normally easier to add it as a new parameter rather than trying to overload.
Well, the appended "!" to the window definition would break the compatibility in cases where someone relied on the fact, that an appended "!" is ignored up to now. If I'm adding a parameter, say "-fpa --freepreviewaspect" it would break the compatibility in cases where someone used that letter combination to prevent a program from starting. I agree that the latter is more unlikely than the first, but the unlikeliness of the first would suffice my feeling of compatibility. And I had preferred not to blow up the help pages with options hardly anyone ever uses...

Return to “Camera board”

Who is online

Users browsing this forum: No registered users and 12 guests