当前位置:网站首页>Exam23 named windows and simplified paths, grayscale conversion

Exam23 named windows and simplified paths, grayscale conversion

2022-06-13 02:29:00 An unforgettable squirrel

Function as follows :

src = new Mat(@"..\..\Images\ocv02.jpg", ImreadModes.Grayscale)

// Add @ No need to use double / Said path , That is, the following string does not change meaning

var window = new Window("window", image: src)

// Be careful window This function is not in cv Under the namespace , Belong to OpenCvSharp Next function , The second parameter can be written directly src

Color image to grayscale image

Cv2.CvtColor(srcCopy, srcCopy, ColorConversionCodes.BGRA2GRAY);

Debugging found , Original resolution 700*377*3=DataEnd-Data ,CV_8U3 Consistent with the theory

After the transformation 700*377=DataEnd-Data, The debug environment is displayed as CV_8U1

routine 2 The complete code is as follows

static void Main(string[] args)
        {
            readImage1();
            readImage2();
        }

        private static void readImage2()
        {
           // Add @  No need to use double / Said path , That is, the following string does not change meaning 
            using (var src = new Mat(@"..\..\Images\ocv02.jpg", ImreadModes.Unchanged))
            {
                // Be careful window This function is not in cv Under the namespace ,OpenCvSharp Next function 
                using (var window = new Window("window", image: src))
                {
                    // Error closing window manually 
                    Cv2.WaitKey();
                }
            }
        }

        private static void readImage1()
        {
            using (var src = new Mat(@"..\..\Images\ocv02.jpg", ImreadModes.Grayscale))
            {
                using (var window = new Window("window", image: src))
                {
                    Cv2.WaitKey();
                }
            }
        }

原网站

版权声明
本文为[An unforgettable squirrel]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202280542541760.html