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. 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. I don't know if webcam default support any other resolution. But If 640*480 then you can use this code as it is. Also you need to understand that even if the one cam frame looks like this in pixels ((3x3) picture)
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
2,1,0...................................................................................... 5,4,3...................................................................................... 8,7,6......................................................................................
this is what the above code does.. cheers..and just ignore the dots...
我通过在Blend中打开项目来翻转一个矩形,选择了我的矩形 - >属性 - >转换 - > Y翻转。我之前没有看到它...(悲伤的长号)
链接地址: http://www.djcxy.com/p/14234.html上一篇: 使用双摄像头在平板电脑上捕获图像