WebEnh

.net7 mvc jquery bootstrap json 学习中 第一次学PHP,正在研究中。自学进行时... ... 我的博客 https://enhweb.github.io/ 不错的皮肤:darkgreentrip,iMetro_HD
  首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

C# Afroge摄像头翻转90

Posted on 2023-01-30 09:42  WebEnh  阅读(155)  评论(0)    收藏  举报
1.dll和命名空间就不在此列举了,如下只是将转换方法介绍:
第一个函数:
        public void Rotate90()
        {
            // 计算角度,类变量
            //dAngle = dAngle + 90;
            //dAngle = dAngle % 360;
 
            // 事件绑定,实时绘制,达到效果,本来就是实时绘制的原理
            videoSourcePlayer1.NewFrame -= new VideoSourcePlayer.NewFrameHandler(videoSourcePlayer_NewFrame);
            videoSourcePlayer1.NewFrame += new VideoSourcePlayer.NewFrameHandler(videoSourcePlayer_NewFrame);
        }
 
第二个函数:
        public void videoSourcePlayer_NewFrame(object sender, ref Bitmap image)
        {
            int dAngle = 90;
            if (image != null)
            {
                RotateFlipType pType = RotateFlipType.RotateNoneFlipNone;
                if (dAngle == 0)
                {
                    pType = RotateFlipType.RotateNoneFlipNone;
                }
                else if (dAngle == 90)
                {
                    pType = RotateFlipType.Rotate90FlipNone;
                }
                else if (dAngle == 180)
                {
                    pType = RotateFlipType.Rotate180FlipNone;
                }
                else if (dAngle == 270)
                {
                    pType = RotateFlipType.Rotate270FlipNone;
                }
 
                // 实时按角度绘制
                image.RotateFlip(pType);
            }
        }
直接在要调节摄像头的地方调用Rotate90();方法就可以了。