关于preivew和take picture的协调

 Hello Xie,
What you asked was about taking picture with camera device, and I
should say that there could be few different ways depending on H/W
features or S/W concepts.

Actually I've been facing similar issue and tried to figure out the
better way in taking camera snapshots. You can find my RFC at
following archive :
http://www.spinics.net/lists/linux-media/msg05013.html

I have no idea about what kind of camera module you are using, I mean
how big resolution, how many colorspaces it supports kind of things.

To go easier  we can sort it out with H/W features like whether the
camera module supports JPEG capture or not. (in that case, you can
take a look at my earlier RFC that I mentioned above about capturing
JPEG). So, if your H/W is supporting JPEG capture, you have to stop
previewing and change your camera module into JPEG capture mode, and
sync data with your camera interface and copy to user space.

But, if your camera module is not supporting that cool JPEG capturing
feature, you have to think about and establish your baseline about the
resolutions. Let me take an example of taking picture without a JPEG
capturing features.

CASE 1: Preview resolution and expecting captured image's resolution
doesn't differ
It means that you are running preview image with 640*480 (or
whatever..I'm just assuming) and take snapshot also with 640*480.
In this case you don't even need to stop previewing. just take the
image frame. you want and encode with you S/W encoder or just leave it
with RAW format and save as a file.

CASE 2: Preview resolution and expecting captured image resolution are
different.
This is totally more complicated than CASE 1. Apparently, you should
stop previewing before taking snapshot. Because your camera interface
H/W should be reset to sync the upcoming image frame. with other
resolution. Of course you can do that without reset in some H/W but
the  received image in the switching resolution moment can be ugly
with noise or distorted image.
So, If you are taking picture bigger than preview Image, you should
better stop previewing with VIDIOC_STREAMOFF and try VIDIOC_S_FMT with
new resolution and start capturing with VIDIOC_STREAMON.
I'm not sure about this kind of order is recommended in V4L2
specification, but it comes from my experience.

I hope it is the answer you expected.
Cheers,

Nate



On Mon, May 25, 2009 at 10:31 AM, xie <yili.xie@gmail.com> wrote:
> Dear all ~
>     I have to implement the hal in Android with v4l2. Now i use one
> thread to preview , i just use V4L2 capture interface to implement the
> preview. Now i have one confusion :
>     I think i can implement the taking picture just copy the preview
> frame. , and  am i right ? I want to use another thread to take picture ,
> when I am taking picture ,whether I have to stop the previewing ?
>     Thanks a lot ~!~
>





camera device : video0
YUV thread : thread A
JPEG thread : thread B

=> therad A, thread B open video0 at the same time
=> enum_framesizes
=> thread A gets discrete YUV frame. sizes in resolution and thread B
gets byte sized JPEG size
=> thread A S_FMT preview size  with YUV

<snip>

=> thread A STREAMON
=> preview working
=> JPEG capture start issued
=> thread A STREAMOFF
=> thread B S_FMT JPEG size with JPEG

<snip>

=> thread B STREAMON => copy JPEG data
=> thread B STREAMOFF
=> thread A STREAMON
=> preview working

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值