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)
Re: Raspistill preview with 16:9 ratio on PAL composite disp
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 Ltd.
Working in the Applications Team.
Working in the Applications Team.
Re: Raspistill preview with 16:9 ratio on PAL composite disp
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.
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.
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
Re: Raspistill preview with 16:9 ratio on PAL composite disp
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.
https://github.com/raspberrypi/userland/issues/86
Thanks.
Principal Software Engineer at Raspberry Pi Ltd.
Working in the Applications Team.
Working in the Applications Team.
Re: Raspistill preview with 16:9 ratio on PAL composite disp
Good to have a forum archivetomekziel 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

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
Re: Raspistill preview with 16:9 ratio on PAL composite disp
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
Greets,
Kiste
-
- Raspberry Pi Engineer & Forum Moderator
- Posts: 12998
- 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
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.
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.
I'm not interested in doing contracts for bespoke functionality - please don't ask.
I'm not interested in doing contracts for bespoke functionality - please don't ask.
Re: Raspistill preview with 16:9 ratio on PAL composite disp
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...
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...
-
- Raspberry Pi Engineer & Forum Moderator
- Posts: 12998
- 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
Pi is all about learning, not having things served to you on a plate.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...
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
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;
"./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.
I'm not interested in doing contracts for bespoke functionality - please don't ask.
I'm not interested in doing contracts for bespoke functionality - please don't ask.
Re: Raspistill preview with 16:9 ratio on PAL composite disp
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!
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!
-
- Raspberry Pi Engineer & Forum Moderator
- Posts: 12998
- 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
Ah the 16kB wobble-pack!karlkiste wrote:In fact I'm no real newbie to programming (having started on a ZX81),
Well Cobol is pretty scary, but in demandkarlkiste wrote:but I'm quite uncomfortable with everything that starts with "C".

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.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.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.
I'm not interested in doing contracts for bespoke functionality - please don't ask.
Re: Raspistill preview with 16:9 ratio on PAL composite disp
First of all: hardcoding your two lines works, my problem is therefore solved.
Moving on to the learning (or practise) part:
Moving on to the learning (or practise) part:
Mine has the 16kB extension built-in6by9 wrote:Ah the 16kB wobble-pack!karlkiste wrote:In fact I'm no real newbie to programming (having started on a ZX81),

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...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.