[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Camera module change proposal



On Mon, May 18, 2009 at 5:34 PM, René Dudfield <renesd@xxxxxxxxx> wrote:
>
>
> We can't decide on a final API at this point.  Better to wait until we find
> out what each one can do.  Marking it final before getting into the
> implementation won't work.
>
> It's definitely time to discuss the API, just not marking it final until we
> need to.
>
> The camera module is going to be marked experimental, and we can change it
> post 1.9 - like we agreed.  It's way to late in the 1.9 release process to
> change anything drastically in 1.9 now.
>

Alright, we can hold off until later.

>   - yuv is important for Movie, and Overlay (two other important use cases).

The YUV being output from the camera module is packed YUV, not the
YUYV, YUV422, etc used for video or the Overlay module.  It is really
only useful for computer vision purposes.  The get_raw() function in
the camera module can however output data useful for Movie or Overlay.

> Having a colorspace conversion function in another module is fine (not for
> 1.9 though).  However requiring it to be separate means the implementer can
> not output YUV etc in the fast path.
>
> If it is in the camera module, then if the implementor does not want to they
> can get out RGB, then convert it to YUV.  They also have the option to try
> and get YUV out using a fast path.
>
> eg. this psedo code Camera class shows, how by keeping the details in the
> Camera class it's possible to get yuv in the fast path if implemented, and
> if not use the conversion function from RGB.
>
> class Camera(object):
>     def get_yuv(self)
>         if self.can_get_yuv:
>             return self._yuv()
>         else:
>             rgb = self.get_rgb()
>             return pygame.color.convert_rbg_to_yuv(rgb)
>

This is basically how we are doing it now.

The shorter path we are using now is initializing the camera with the
pixelformat closest to the desired output.  Eg:  If you want YUV,
it'll try to initialize with YUYV, or RGB565 for RGB.  Once it's
initialized, you would have to close and reopen it to switch between
YUV and RGB to get a short path.

Nirav