Kinect Html5 在现有 C# 应用程序中流式传输到 Web
Kinect Html5 Stream to web in existing C# Application
对于我们的大学项目,我们需要从网络中的另一个设备访问 kinect 视频流。最好作为 HTML5 网络服务器。 Microsoft.Samples Web 服务器仅适用于 kinect1,我们需要它用于 kinect 2。另一个有趣的解决方案是来自 intrael 的解决方案,但我们需要在我们自己的应用程序中实现它。
是否有任何我没有找到的解决方案,或者任何人都可以给我们一个工作示例或提示如何进行?
如果有人偶然发现了这个问题,我们现在使用一个简单的 TCP 侦听器来侦听连接来解决这个问题:
TcpListener srv = new TcpListener(IPAddress.Any, 51530);
srv.Start(1);
client = srv.AcceptTcpClient();
然后我们将 Kinect 图片更改为位图,并在每张新图片上将位图发送到连接的设备:
NetworkStream ns = client.GetStream();
Graphics g = Graphics.FromImage(bitmap);
MemoryStream imageStream = new MemoryStream();
using (var ms = new MemoryStream())
{
Bitmap bmp = new Bitmap(bitmap);
bmp.Save(imageStream, ImageFormat.Bmp);
}
// bitmap.Save(imageStream, ImageFormat.Bmp);
Console.WriteLine("Bild wird über Socket geschickt");
//reset the memory stream to start of stream
imageStream.Position = 0;
//copy memory stream to network stream
imageStream.CopyTo(ns);
//make sure copy is completed
imageStream.Flush();
imageStream.Close();
//Makes sure everything is sent before closing it
ns.Flush();
另一边有一个 android 设备获取网络流并将其转换为位图并在图像视图中显示。
如需澄清,请随时提出其他问题。
对于我们的大学项目,我们需要从网络中的另一个设备访问 kinect 视频流。最好作为 HTML5 网络服务器。 Microsoft.Samples Web 服务器仅适用于 kinect1,我们需要它用于 kinect 2。另一个有趣的解决方案是来自 intrael 的解决方案,但我们需要在我们自己的应用程序中实现它。 是否有任何我没有找到的解决方案,或者任何人都可以给我们一个工作示例或提示如何进行?
如果有人偶然发现了这个问题,我们现在使用一个简单的 TCP 侦听器来侦听连接来解决这个问题:
TcpListener srv = new TcpListener(IPAddress.Any, 51530);
srv.Start(1);
client = srv.AcceptTcpClient();
然后我们将 Kinect 图片更改为位图,并在每张新图片上将位图发送到连接的设备:
NetworkStream ns = client.GetStream();
Graphics g = Graphics.FromImage(bitmap);
MemoryStream imageStream = new MemoryStream();
using (var ms = new MemoryStream())
{
Bitmap bmp = new Bitmap(bitmap);
bmp.Save(imageStream, ImageFormat.Bmp);
}
// bitmap.Save(imageStream, ImageFormat.Bmp);
Console.WriteLine("Bild wird über Socket geschickt");
//reset the memory stream to start of stream
imageStream.Position = 0;
//copy memory stream to network stream
imageStream.CopyTo(ns);
//make sure copy is completed
imageStream.Flush();
imageStream.Close();
//Makes sure everything is sent before closing it
ns.Flush();
另一边有一个 android 设备获取网络流并将其转换为位图并在图像视图中显示。
如需澄清,请随时提出其他问题。