Vuforia SDK中如何获取每一帧图片byte数组数据

10 篇文章 0 订阅
3 篇文章 0 订阅

Vuforia SDK中如何获取每一帧图片数据(byte[])


1、最近在Unity3d使用Vuforia进行AR开发,做Android开发的时候,在Android中对相机中的每一帧进行处理的时候,可以使用Camera的回调函数,public void onPreviewFrame(byte[] data, Camera camera)来实现获取每一帧图像的数据,以byte数组的方式进行图形图像的处理,现在在Unity3d中,使用Vuforia的SDK进行开发,第一件事就是想到如何获取每一帧的数据,然后进行处理,在对Vuforia有个简单的了解后,查阅了一些资料,得到了Vuforia中每一帧数据的接口,现在分享给大家。废话不说了,上代码:
public class getByte : MonoBehaviour {

	private Texture2D text;
	private byte[] buff = null;		//得到每一帧数据的byte数组
	private float width;			//每一帧图像的宽度
	private float height;			//每一帧图像的高度

	// Use this for initialization
	void Start () {
	}
	
	// Update is called once per frame
	void Update () {
		if(Vuforia.VuforiaRenderer.Instance != null){
		if(Vuforia.VuforiaRenderer.Instance.VideoBackgroundTexture != null){
			text = (Texture2D)Vuforia.VuforiaRenderer.Instance.VideoBackgroundTexture;
			buff = text.GetRawTextureData();
				width = text.width;
				height = text.height;
				Debug.Log("---length :" + buff.Length + " w :"+ width +" h :"+height);
		}
		}
	}
}

2、这样就得到了每一帧图像的数据,控制台输出如下:


3、以上就是Vuforia的SDK中打开相机后得到每一帧数据的方法,希望对大家有帮助。
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值