[libcamera-devel] qcam display scale bug

Naushir Patuck naush at raspberrypi.com
Tue Jul 7 10:28:06 CEST 2020


Hi Hermann,

On Tue, 7 Jul 2020 at 08:02, <hermann at stamm-wilbrandt.de> wrote:
>
> Hi Laurent,
>
> > I assume you're using the new HQ camera, right ?
> >
> yes, but from looking into the code that should not make a difference.
>
> > I'd like to clarify this first, to make sure I understand the problem
> > correctly. Do you mean that qcam display a captured frame of 800x472
> > pixels in a 800x600 screen region, scaling it in a way that doesn't
> > preserve square pixels ? Do you just start the qcam application without
> > passing it any parameter or resizing the window, or do you perform any
> > specific operation ?
> >
> Yes, I am calling qcam without parameters.
> qcam application requests 800x600 frames (see "size"):
>
> libcamera/src/libcamera/pipeline/raspberrypi/raspberrypi.cpp
>                  case StreamRole::Viewfinder:
>                          fmts =
> data->isp_[Isp::Output0].dev()->formats();
>                          pixelFormat = formats::ARGB8888;
>                          size = { 800, 600 };
>                          bufferCount = 4;
>                          outCount++;
>                          break;
>
> libcamera determines "2028x1520 pbCC" as best fit per log output.
> The 2028x1520 frames captured get scaled into the display frame.
> If the display frame would be 800x600 as requested, all would be fine.
> But display frame being 800x472 compresses captured frame vertically
> by factor 600/472=1.27.

The 2028x1520 frame actually gets cropped in the ISP to correct for
the requested aspect ratio before getting resized to the 800x600
resolution.   So, the flow is actually as follows:

2028x1520 (sensor) -> 2026x1520 (aspect ratio crop) -> 800x600 (isp resize).

The reason for the crop in the middle is that the 800/600 aspect ratio
is exactly 4/3, but 2028/1520 is not.  This is why there will be a
small amount of mismatch.  Having said that, you seem to be seeing a
much bigger variation that does not correspond to the calculations
that take place.


>
> I verified that by picture of micrometer:
> https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=278268&p=1690839#p1690839
> The longest divisions are of length 300µm vertically, but show only
> 221px in display. Horizontally I measured 281px for 300µm.
>

Could you try getting qcam to output 2028x1520 so that no crop/resize
takes place just to confirm your measurements are correct?

Thanks,
Naush

> I just see that the 800x600 is specified in raspberrypi.cpp.
> Can you please start qcam on some non-Raspberry system passing width=800
> and height=600, and then take screenshot and use image processing (I use
> gimp) to measure size of displayed frame?
>
>
> On 2020-07-07 01:30, Laurent Pinchart wrote:
> > Hi Hermann,
> >
> > (CC'ing Naush)
> >
> > On Sun, Jul 05, 2020 at 09:44:15PM +0200, hermann at stamm-wilbrandt.de
> > wrote:
> >> I started working with libcamera on Raspberry Pi.
> >
> > Thank you for your interest in the project :-)
> >
> >> I cannot tell whether this scale bug exists for raspberrypi only, or
> >> in
> >> general.
> >>
> >> qcam app requests a 800x600 window, but displayed window is 800x472
> >> only.
> >> This is not acceptable when using qcam as microscope app:
> >> https://www.raspberrypi.org/forums/viewtopic.php?f=43&t=278268&p=1690839#p1690839
> >
> > I assume you're using the new HQ camera, right ?
> >
> >> The best mode selected by libcamera is 2028x1520 which is 4:3.
> >> So 800x600 (also 4:3) is needed for display.
> >>
> >> It would be helpful to know whether qcam display is also 800x472
> >> instead
> >> of 800x600 when not running on Rasberry Pi.
> >
> > I'd like to clarify this first, to make sure I understand the problem
> > correctly. Do you mean that qcam display a captured frame of 800x472
> > pixels in a 800x600 screen region, scaling it in a way that doesn't
> > preserve square pixels ? Do you just start the qcam application without
> > passing it any parameter or resizing the window, or do you perform any
> > specific operation ?


More information about the libcamera-devel mailing list