首页 > 编程语言 > 详细

Unity调用摄像头拍照

时间:2019-11-12 11:33:40      阅读:154      评论:0      收藏:0      [点我收藏+]

//开启摄像头

public RawImage rawImage;

private WebCamTexture cameraTexture;

 

protected IEnumerator Camera(){

    yield return Application.RequestUserAuthorization(UserAuthorization.WebCam);

    Application.HasUserAuthorization(UserAuthorization.WebCam);

    WebCamDevice[] devices = WebCamTexture.devices; 

    string cameraName = devices[0].name;

    cameraTexture = new WebCamTexture (cameraName ,1920,1080,30);

    cameraTexture .Play();

    rawImage.texture = cameraTexture ;

}

 

//拍照

private void Photo(){

    string path = string.Format("{0}/{1}.png",Application.streamingAssetsPath,DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss_ffff"));

    ScreenCapture.CaptureScreenshot(path);

}

 

Unity调用摄像头拍照

原文:https://www.cnblogs.com/zhizun1314/p/11839992.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!