接受数据

RemoteCamera.cs

using UnityEngine;public class RemoteCamera : MonoBehaviour {public static byte[] currentFrame;private Texture2D viewTexture;public static int CameraID;// Use this for initializationvoid Start () {currentFrame = new byte[640 * 480 * 4];viewTexture = new Texture2D(640, 480);}// Update is called once per framevoid Update (){viewTexture.LoadImage(currentFrame);viewTexture.Apply();GetComponent<Renderer>().material.mainTexture = viewTexture;}}

LocalCustomMessagesManager.cs

/// <summary>/// Called when a remote user sends a message./// </summary>/// <param name="msg"></param>private void UpdateMessage(NetworkInMessage msg){// Parse the messagelong userID = msg.ReadInt64();//接受videoint videoLen =  msg.ReadInt32();if (videoLen > 1) {msg.ReadArray (RemoteCamera.currentFrame, (uint)videoLen);}//接受场景位置Scene.transform.localPosition = LocalCustomMessages.ReadVector3(msg);Scene.transform.localRotation = LocalCustomMessages.ReadQuaternion(msg);//接收头部位置remotehead.transform.localPosition = LocalCustomMessages.ReadVector3(msg);remotehead.transform.localRotation = LocalCustomMessages.ReadQuaternion(msg);//接收眼动位置remotegaze.transform.localPosition = LocalCustomMessages.ReadVector3(msg);remotegaze.transform.localRotation = LocalCustomMessages.ReadQuaternion(msg);}

发送数据

LocalCamera.cs

using UnityEngine;
using System;public class LocalCamera : MonoBehaviour
{public static Texture2D viewTexture;private WebCamTexture viewTextureCamera;static public int CameraID;// Use this for initializationvoid Start (){WebCamDevice[] devices = WebCamTexture.devices;viewTextureCamera = new WebCamTexture(devices[0].name, 1280, 720, 30);viewTextureCamera.Play();viewTexture = new Texture2D(viewTextureCamera.width, viewTextureCamera.height);}// Update is called once per framevoid Update (){viewTexture.SetPixels(viewTextureCamera.GetPixels());viewTexture.Apply();GetComponent<Renderer>().material.mainTexture = viewTexture;}}

LocalCustomMessages.cs

 public void SendMessage(){// If we are connected to a session, broadcast our head infoif (serverConnection != null && serverConnection.IsConnected()){// Create an outgoing network message to contain all the info we want to sendNetworkOutMessage msg = CreateMessage((byte)TestMessageID.StringMessageID);//send videobyte[] currentLocalVideo = LocalCamera.viewTexture.EncodeToJPG();msg.Write(currentLocalVideo.Length);msg.WriteArray(currentLocalVideo, (uint)currentLocalVideo.Length);//发送场景位置AppendVector3(msg, Scene.transform.localPosition);AppendQuaternion(msg, Scene.transform.localRotation);//发送头部位置AppendVector3(msg, headPos.transform.localPosition);AppendQuaternion(msg, headPos.transform.localRotation);//发送眼动位置AppendVector3(msg, GazePos.transform.localPosition);AppendQuaternion(msg, GazePos.transform.localRotation);}}

HoloToolkit视频共享接受发送脚本相关推荐

  1. powershell共享服务器写文件,Windows PowerShell:共享您的脚本 - 轻松实现

    Windows PowerShell:共享您的脚本 - 轻松实现 08/17/2016 本文内容 Don Jones Windows PowerShell v1 的一项限制是它不能轻松实现脚本共享.当 ...

  2. 第四组视频:在bash脚本中使用脚本选项

    马哥教育(http://www.magedu.com)在bash脚本中使用脚本选项.本视频是我们上课过程的实际记录.下载地址:    http://down.51cto.com/data/414002 ...

  3. Silverlight+WCF 实战-网络象棋最终篇之对战视频-下篇[客户端发送与服务端中转](六)...

    本篇继上一篇:Silverlight+WCF 实战-网络象棋最终篇之对战视频-上篇[客户端开启视频/注册编号/接收视频](五)  一:对战视频 简单原理 略,内容见上篇. 二:对战视频 步骤解析: 略 ...

  4. 使用计算机的方法视频,怎么直接把电脑的视频共享给电视?巧用当贝市场,四种方法供你选...

    怎么直接把电脑的视频共享给电视?巧用当贝市场,四种方法供你选 2021年03月22日 21:13作者:网络编辑:王动 分享 近日,有用户问到如何直接把电脑的视频共享给电视?今天,小编就给大家带来了全网 ...

  5. 写脚本的作用是什么?做自媒体,什么样的视频一定要写脚本?

    写脚本的作用是什么?做自媒体,什么样的视频一定要写脚本? 今天这期内容就来跟大家聊一聊什么样的视频是需要写脚本的,一个成功的视频作品是需要有一个好故事的. 如果你的故事中有很多对白和故事,那么你最好是 ...

  6. Yeslab现任明教教主CCNP Security第四天第一部分视频共享

    Yeslab现任明教教主CCNP Security第四天第一部分视频共享 这是讲CCNP Security第四个周六讲的课程录像,本周一共录制了4个录像,时长超过5小时,本周仅仅共享第一部分.本周对8 ...

  7. GB28181/RTSP/Onvif/HikSDK/Ehome协议视频共享平台EasyCVR人脸识别系统助力打造智慧安检系统

    一.项目需求 随着经济及交通的发展,海关和陆路边境口岸之间每天都有大量的人和货物在此周转,随之而来的安检工作也越来越重要,检查藏匿的违禁品和危险品一直是相关安全部门的重要工作.一套人行.物检等全方位的 ...

  8. python视频批量抽帧脚本更新

    原来的脚本代码:https://blog.csdn.net/JZJZ73/article/details/108851403 因项目工程需要,对原来的python视频批量抽帧脚本进行了更新,更新特点如 ...

  9. 超过100mb的视频怎么微信发送?如何将超过25mb视频发送微信?

    随着制作视频的小伙伴越来越多,大家都想把视频传到一些平台或发送给自己的朋友,有时候我们会遇到视频过大发不了的问题,今天我给大家介绍一个简单的解决视频过大发送不了的方法: 搜索一下: ~~~~~~~~~ ...

  10. qq视频转码失败怎么办_微信视频大于25M发送失败怎么办?学会这3招教你秒传视频...

    微信在我们的生活和工作中可谓是占有重要地位呀,接收和传送文件是常有的事.不知道大家有没有发现当我们发送视频时,超过25M的就不能发送出去了!今天教给大家三招,大于25M的视频很快就可以发送出去啦! 一 ...

最新文章

  1. 开发者被要求向破解者道歉,竟揪出“阿里云假员工”,网友:这人有前科
  2. html调用百度地图语音播报,实现百度地图导航演示的语音播放功能
  3. volley框架使用
  4. python写错了怎么更改-Python中修改字符串的四种方法
  5. Histogram of Oriented Gridients(HOG) 方向梯度直方图
  6. Chapter7-7_Deep Learning for Coreference Resolution
  7. Android studio修改包
  8. Envoy 源码分析--network L4 filter manager
  9. PIC温控器c语言程序,PIC CCS C语言程序范例.doc
  10. Coder Essential之编程语言学习知识点纲要
  11. SQL 2005 Beta2 和VS 2005 Beta1安装的问题
  12. python实例 优化目标函数_python scipy optimize.minimize用法及代码示例
  13. isv支付宝小程序三方模板开发快速指南
  14. 【文本识别】CRNN
  15. video.js在react中实现视频播放(video.js)
  16. excel转word_Office批量打印精灵教程--Word、PDF、Excel、PPT批量打印及批量转PDF
  17. 十五个免费Windows桌面系统工具(附下载)
  18. docx文档文字怎么加边框,WORD文档给文字加的边框,如何调大小
  19. 机器学习 简答题 速记
  20. 【建模算法】Python调用Gurobi求解TSP问题

热门文章

  1. WIN10右键菜单没有新建项了,怎么办?
  2. jmail mysql_教你怎么使用Jmail发送匿名的邮件(不要身份认证)
  3. presto读取oracle,Presto数据接入方式
  4. mysql索引使用b_mysql索引的数据结构,为什么用b+树
  5. string类的函数
  6. 【Linux】sed命令用法详解
  7. javascript获取TreeView控件选中节点的Text和Value
  8. [转] 常用Loss函数
  9. 智慧酒店:锐捷网络打造的完美酒店
  10. zabbix客户端部署