简体   繁体   English

如何在android中拆分相机预览?

[英]How to split camera preview in android?

I want to achieve this kind of feature.我想实现这种功能。

My initial camera preview:我的初始相机预览:

在此处输入图片说明

Now I want to break this camera preview in two parts:现在我想把这个相机预览分成两部分:

在此处输入图片说明

What I have tried:我尝试过的:

  1. Create a surface view to hold preview of camera.[Done]创建一个表面视图来保存相机的预览。[完成]

  2. Shift half of the surface view out off the screen[Done] now half of the surface view shift from out off the screen and only half is visible.将一半的表面视图移出屏幕[完成] 现在一半的表面视图从屏幕移出,只有一半是可见的。

The problem is camera writes it's complete preview only on visible portion of surface view so the preview gets shrink in half of the screen.问题是相机仅在表面视图的可见部分写入完整预览,因此预览会缩小一半的屏幕。

Can anybody help me how can I achieve this?任何人都可以帮助我如何实现这一目标?

Send the camera preview to a SurfaceTexture, then draw two rects with GLES, one with the left part of the preview, one with the right.将相机预览发送到 SurfaceTexture,然后用 GLES 绘制两个矩形,一个是预览的左侧部分,一个是右侧。 Use a single SurfaceView for display.使用单个 SurfaceView 进行显示。

You can find sample code in Grafika's "texture from Camera" Activity, which manipulates the camera output in various ways.您可以在Grafika 的“来自相机纹理”活动中找到示例代码,该活动以各种方式操纵相机输出。 Note in particular the "zoom" feature works by displaying a progressively smaller area of the preview while keeping the output rect the same size.请特别注意“缩放”功能的工作原理是显示预览的逐渐变小区域,同时保持输出矩形的大小相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM