[英]How flip video capture from webcam in Silverlight
I noticed that when I am doing video capture from webcam in Silverlight video is "reversed" meaning when I am moving right then me on a screen moving left. 我注意到,当我在Silverlight中从网络摄像头进行视频捕获时,视频是“反转”的,这意味着当我向右移动时,我在屏幕上向左移动。 Is there any way to flip video capture?
有没有办法翻转视频捕获?
I could flip left right and this is how you can do it. 我可以左右翻转,这就是您的方法。
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;
}
note that 640 and 480 are the camera resolutions and adjust them to your values. 请注意,640和480是相机分辨率,然后将其调整为您的值。 I don't know if webcam default support any other resolution.
我不知道摄像头默认是否支持其他分辨率。 But If 640*480 then you can use this code as it is.
但是,如果是640 * 480,则可以按原样使用此代码。 Also you need to understand that even if the one cam frame looks like this in pixels ((3x3) picture)
您还需要了解,即使一个凸轮帧看起来像这样(像素((3x3)))
0,1,2...................................................................................... 3,4,5...................................................................................... 6,7,8...................................................................................... 0,1,2 ................................................... ................................................... 3,4,5 .... ................................................... ................................ 6,7,8 ............ ................................................... .......................
bitmap.Pixels return []={0,1,2,3..8} so you need to flip the values row by row into this bitmap.Pixels返回[] = {0,1,2,3..8},因此您需要将值逐行翻转到
2,1,0...................................................................................... 5,4,3...................................................................................... 8,7,6...................................................................................... 2,1,0 ................................................... ......................................... 5,4,3 .... ................................................... ................................ 8,7,6 ............ ................................................... .......................
this is what the above code does.. cheers..and just ignore the dots... 这就是上面的代码所做的..干杯..而忽略了点...
我通过在Blend中打开项目来翻转矩形,选择矩形->属性->变换->按Y翻转。以前我怎么没看到它……(悲伤的长号)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.