<form id="j9b99"><th id="j9b99"></th></form>

    南京軟件定制開發

    南京傾心軟件歡迎您訪問本站

    13605185909

    新聞資訊

    NEWS CENTER
    欄目導航

    南京軟件開發之快速搞定攝像頭圖像旋轉

    發布時間:Mar 08, 2022         已有 人瀏覽
    經常會遇到的一個問題,攝像頭顯示出來的圖像是鏡像,與我們真實情況正好相反,
    那么下面的代碼可以幫你快速實現旋轉。

    // 指定圖像的旋轉程度和用于翻轉圖像的軸。
    public void videoSourcePlayer_NewFrame(object sender, ref Bitmap image)
            {
                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);
                }
            }
     
            /// <summary>
            /// 旋轉函數,外部調用觸發
            /// </summary>
            public void Rotate()
            {
                // 計算角度,類變量
                dAngle = dAngle + 90;
                dAngle = dAngle % 360;
                
                // 事件綁定,實時繪制,達到效果,本來就是實時繪制的原理
                videoSourcePlayer.NewFrame -= new VideoSourcePlayer.NewFrameHandler(videoSourcePlayer_NewFrame);
                videoSourcePlayer.NewFrame += new VideoSourcePlayer.NewFrameHandler(videoSourcePlayer_NewFrame);
            }

     
    是不是非常方便且快速呢,歡迎來交流討論。
    Copyright © 2020-2022 南京傾心軟件技術有限公司 版權所有     蘇ICP備2020070309號-1
    QQ在線咨詢
    13605185909
    返回頂部
    √天堂中文官网在线