如何在Silverlight中从网络摄像头中截取视频

时间:2013-06-23 05:48:03

标签: c# silverlight video webcam

我注意到,当我在Silverlight中从网络摄像头进行视频捕捉时,视频是“反转的”,这意味着当我向右移动时,我会在向左移动的屏幕上移动。有没有办法翻转视频捕捉?

2 个答案:

答案 0 :(得分:0)

我可以左转,这就是你可以做到的。

private WriteableBitmap flipVideo(WriteableBitmap notFliped)
    {
        WriteableBitmap motionBmp = new WriteableBitmap(notFliped.PixelWidth, notFliped.PixelHeight);
        int leftRight = -1;
        int[] flipedArray = motionBmp.Pixels;
        int[] currentArray = notFliped.Pixels;
        for (int h = 0; h < 480; h++)
        {
            leftRight++;
            for (int w = 0; w < 640; w++)
            {
                flipedArray[h * 640 + w] = currentArray[639 + (h * 640) - w];
            }
        }
        return motionBmp;
    }

请注意640和480是相机分辨率并根据您的值进行调整。我不知道网络摄像头默认支持任何其他分辨率。但是如果640 * 480那么你可以使用这个代码。此外,您需要了解即使一个凸轮框架看起来像这样((3x3)图片)

0,1,2 .......................................... ............................................ 3,4,5 ............................................. ......................................... 6,7,8 ............................................. .........................................

bitmap.Pixels返回[] = {0,1,2,3..8} 所以你需要逐行将值翻转到这个

2,1,0 .......................................... ............................................ 5,4,3 ............................................. ......................................... 8,7,6 ............................................. .........................................

这就是上面的代码所做的.. 干杯......只是忽略了点......

答案 1 :(得分:0)

我通过在Blend中打开项目来翻转一个矩形,选中了我的矩形 - &gt;属性 - &gt;转型 - &gt;由Y翻转。我以前没看过......(悲伤的长号)

相关问题