From: Hans de Goede <j.w.r.degoede@hhs.nl>
To: kilgota@banach.math.auburn.edu
Cc: video4linux-list@redhat.com, sqcam-devel@lists.sourceforge.net
Subject: Re: [sqcam-devel] Advice wanted on producing an in kernel sq905 driver
Date: Thu, 20 Nov 2008 10:38:12 +0100 [thread overview]
Message-ID: <49253004.4010504@hhs.nl> (raw)
In-Reply-To: <alpine.LNX.1.10.0811192005020.2980@banach.math.auburn.edu>
kilgota@banach.math.auburn.edu wrote:
<snip>
>
>> libv4l currently uses linear interpolated demosaicing, the 4 (or 2)
>> surrounding pixels with the missing color components are taken and
>> then straight forward averaged. At the borders only those pixels which
>> are actually present get used ofcourse.
>
> Perhaps you ought at least to use what is in gp_bayer_accrue() as well
> (see libgphoto2/libgphoto2/bayer.c) because it cuts down on the zipper
> effect.
>
Interesting, although I must say the libgphoto code certainly is not written
with speed in mind, but we can fix that. Still doing something like
gp_bayer_accrue() will cause a significant additional CPU load, please keep in
mind that:
1) We often also need to decompress the bayer data first using some form of
Huffman decompression as usb11 bandwidth is not enough for raw bayer
2) Then we have 352x288 (luckily all raw bayer cams seem to be this low) at
30 fps
3) Which we then need to demosaic
4) And do white balance *
5) And normalize *
6) And gamma correct *
7) And flip / rotate the image
8) And the app may want to do stuff with it like display it, which might
involve pixelformat conversion, and / or software scaling
9) And if the app wants to record broadcast, the app often also needs to do
some form of framerate modification to get a steady framerate (webcam
framerate is exposure setting dependend)
10) And the app may do even more such as HG264 compression for video
conferencing
11) And this may all be part of the user just having a chat window open, while
he is mostly using his PC for something else.
*) Not yet implemented
So all in all we need to be carefull with CPU usage here.
>> I'm always open for convincing examples of differences in algorithms,
>> esp. when backed up with a proposed patch and benchmarks showing the
>> additional costs.
>
> The algorithm in libgphoto2/libgphoto2/ahd_bayer.c requires 3X the time
> which is required for the old algorithm in bayer.c
Ugh, and I'm quite sure the algorithm in bayer.c is much much slower then what
is in libv4l, not only because of gp_bayer_accrue(), but because it is not
written very efficient in general IMHO (lots of if's instead of seperate
methods for different cases like borders, different bayer orders).
> . For still photos
> with some rather low quality cameras, it gives much better results. I
> have written a paper about this algorithm, and also some demonstration
> photos from some different cameras, and you can find the paper and the
> demonstration photos at www.auburn.edu/~kilgota. As to whether the speed
> hit of 3X is crucial for a webcam, I am not sure.
Nor am I, but I think we should be careful with not causing too much cpuload,
also think of things like netbooks, which do not come with a very powerful cpu.
<snip>
>>> I clearly have to read the version and either flip the data myself or
>>> inform libv4l that it needs to be flipped. The do as much work in
>>> userspace as possible argument says I should just provide an
>>> indicator that it needs flipping but I don't know how to do that.
>>>
>>
>> Ah interesting, 2 things:
>>
>> 1) Do not do the flipping in the kernel libv4l already has all the
>> necessary
>> code.
>>
>> 2) Currently there is no API for telling libv4l to do the flipping,
>> but I think
>> we should design one. Currently for the few cams which need software
>> flipping (or rather software rotate 180 as that is what libv4l
>> does), are
>> detected by libv4l by doing string comparisons on the
>> v4l2_capability struct
>> card string. We could cheat and let the sq905 driver put something
>> special
>> in there for cams with upside down mounted sensors, but given that
>> this is a
>> re-occuring problem, defining a proper API for this would be good I
>> think.
>
>
> Well, for these particular cameras the problem is twofold. First, the
> image is always upside down (and the way to fix that is with a byte
> reversal of the raw image). Second, it is also true for *some* of them
> that the image has reversed left and right. So what you have to do is
> read the firmware, know which firmware number corresponds to what, and
> then have a standard way to tell the app precisely what it should do.
> Something like a variable called "orientation" and then the appropriate
> one of the bitmap values 00, 01, 10, or 11, or, in ordinary numbers
>
> 0 oriented correctly, no action needed
> 1 reversal of byte string needed (giving 180 degree rotation)
> 2 reverse bytes on lines (i. e. do de-mirroring)
> 3 do both 1 and 2 (notice that 3 = 1|2)
>
Erm, 3 just boils down to only doing vflip, rotate 180 == vflip + hflip,
so rotate180 + hflip == vflip + hflip + hflip == vflip
Regards,
Hans
--
video4linux-list mailing list
Unsubscribe mailto:video4linux-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list
next prev parent reply other threads:[~2008-11-20 9:32 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <mailman.208512.1227000563.24145.sqcam-devel@lists.sourceforge.net>
[not found] ` <Pine.LNX.4.64.0811181216270.2778@banach.math.auburn.edu>
2008-11-19 0:20 ` [sqcam-devel] Advice wanted on producing an in kernel sq905 driver Adam Baker
2008-11-19 7:46 ` Antonio Ospite
2008-11-19 8:42 ` Hans de Goede
[not found] ` <alpine.LNX.1.10.0811192005020.2980@banach.math.auburn.edu>
2008-11-20 9:38 ` Hans de Goede [this message]
[not found] ` <Pine.LNX.4.64.0811201130410.3570@banach.math.auburn.edu>
2008-11-20 19:37 ` Hans de Goede
[not found] ` <Pine.LNX.4.64.0811201657020.3763@banach.math.auburn.edu>
2008-11-21 8:37 ` Hans de Goede
[not found] ` <Pine.LNX.4.64.0811202306360.3930@banach.math.auburn.edu>
2008-11-21 10:54 ` Hans de Goede
[not found] ` <Pine.LNX.4.64.0811211244120.4475@banach.math.auburn.edu>
2008-11-21 21:25 ` Hans de Goede
[not found] ` <Pine.LNX.4.64.0811211929220.4832@banach.math.auburn.edu>
2008-11-23 9:36 ` Report on time needed for completing v4l Bayer interpolation Hans de Goede
[not found] ` <Pine.LNX.4.64.0811231522510.6135@banach.math.auburn.edu>
2008-11-24 8:15 ` Apparent inconsistency in the labels of Bayer tilings Hans de Goede
2008-11-21 21:57 ` [sqcam-devel] Advice wanted on producing an in kernel sq905 driver Adam Baker
2008-11-21 23:39 ` Adam Baker
[not found] ` <Pine.LNX.4.64.0811211658290.4727@banach.math.auburn.edu>
2008-11-22 0:05 ` Adam Baker
[not found] ` <Pine.LNX.4.64.0811211955490.4832@banach.math.auburn.edu>
2008-11-22 21:55 ` The userspace-kernelspace thing. Continuation of sq905 driver discussion Adam Baker
2008-11-24 11:26 ` [sqcam-devel] Advice wanted on producing an in kernel sq905 driver Hans de Goede
[not found] ` <alpine.LNX.1.10.0811191937370.2980@banach.math.auburn.edu>
2008-11-20 7:48 ` Hans de Goede
[not found] ` <492A8E76.3070701@redhat.com>
[not found] ` <Pine.LNX.4.64.0811241446210.6862@banach.math.auburn.edu>
2008-11-25 0:02 ` Adam Baker
[not found] ` <Pine.LNX.4.64.0811241929420.7049@banach.math.auburn.edu>
2008-11-25 20:57 ` Adam Baker
2008-11-25 8:03 ` Hans de Goede
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=49253004.4010504@hhs.nl \
--to=j.w.r.degoede@hhs.nl \
--cc=kilgota@banach.math.auburn.edu \
--cc=sqcam-devel@lists.sourceforge.net \
--cc=video4linux-list@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox