0

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

4

2 回答 2

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...... ..................................................... .....................

这就是上面的代码所做的......干杯......并且忽略这些点......

于 2013-06-25T14:58:01.860 回答
0

我通过在 Blend 中打开项目翻转了一个矩形,选择了我的矩形 -> 属性 -> 转换 -> 按 Y 翻转。我以前怎么没看到它......(悲伤的长号)

于 2013-06-26T02:58:16.643 回答