当前位置: 首页>>代码示例>>C#>>正文


C# Mat.size方法代码示例

本文整理汇总了C#中Mat.size方法的典型用法代码示例。如果您正苦于以下问题:C# Mat.size方法的具体用法?C# Mat.size怎么用?C# Mat.size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mat的用法示例。


在下文中一共展示了Mat.size方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Start

				// Use this for initialization
				void Start ()
				{


						Texture2D imgTexture = Resources.Load ("lena") as Texture2D;
			
						Mat img1Mat = new Mat (imgTexture.height, imgTexture.width, CvType.CV_8UC3);
						Utils.texture2DToMat (imgTexture, img1Mat);
						Debug.Log ("img1Mat dst ToString " + img1Mat.ToString ());

						Mat img2Mat = new Mat (imgTexture.height, imgTexture.width, CvType.CV_8UC3);
						Utils.texture2DToMat (imgTexture, img2Mat);
						Debug.Log ("img2Mat dst ToString " + img2Mat.ToString ());



						float angle = UnityEngine.Random.Range (0, 360), scale = 1.0f;

						Point center = new Point (img2Mat.cols () * 0.5f, img2Mat.rows () * 0.5f);

						Mat affine_matrix = Imgproc.getRotationMatrix2D (center, angle, scale);

						Imgproc.warpAffine (img1Mat, img2Mat, affine_matrix, img2Mat.size ());


						FeatureDetector detector = FeatureDetector.create (FeatureDetector.ORB);
						DescriptorExtractor extractor = DescriptorExtractor.create (DescriptorExtractor.ORB);

						MatOfKeyPoint keypoints1 = new MatOfKeyPoint ();
						Mat descriptors1 = new Mat ();

						detector.detect (img1Mat, keypoints1);
						extractor.compute (img1Mat, keypoints1, descriptors1);

						MatOfKeyPoint keypoints2 = new MatOfKeyPoint ();
						Mat descriptors2 = new Mat ();
		
						detector.detect (img2Mat, keypoints2);
						extractor.compute (img2Mat, keypoints2, descriptors2);


						DescriptorMatcher matcher = DescriptorMatcher.create (DescriptorMatcher.BRUTEFORCE_HAMMINGLUT);
						MatOfDMatch matches = new MatOfDMatch ();

						matcher.match (descriptors1, descriptors2, matches);


						Mat resultImg = new Mat ();

						Features2d.drawMatches (img1Mat, keypoints1, img2Mat, keypoints2, matches, resultImg);



						Texture2D texture = new Texture2D (resultImg.cols (), resultImg.rows (), TextureFormat.RGBA32, false);
		
						Utils.matToTexture2D (resultImg, texture);

						gameObject.GetComponent<Renderer> ().material.mainTexture = texture;

				}
开发者ID:lsewata,项目名称:OpenCVForUnity,代码行数:61,代码来源:Feature2DSample.cs

示例2: Start

        // Use this for initialization
        void Start()
        {
            Texture2D imageTexture = Resources.Load ("lena") as Texture2D;

            Mat image = new Mat (imageTexture.height, imageTexture.width, CvType.CV_8UC3);

            Utils.texture2DToMat (imageTexture, image);
            Debug.Log ("image.ToString() " + image.ToString ());

            Texture2D maskTexture = Resources.Load ("lena_grabcut_mask") as Texture2D;

            Mat mask = new Mat (imageTexture.height, imageTexture.width, CvType.CV_8UC1);

            Utils.texture2DToMat (maskTexture, mask);
            Debug.Log ("mask.ToString() " + mask.ToString ());

            OpenCVForUnity.Rect rectangle = new OpenCVForUnity.Rect (10, 10, image.cols () - 20, image.rows () - 20);

            Mat bgdModel = new Mat (); // extracted features for background
            Mat fgdModel = new Mat (); // extracted features for foreground

            convertToGrabCutValues (mask); // from grayscale values to grabcut values

            int iterCount = 5;
            //          Imgproc.grabCut (image, mask, rectangle, bgdModel, fgdModel, iterCount, Imgproc.GC_INIT_WITH_RECT);
            Imgproc.grabCut (image, mask, rectangle, bgdModel, fgdModel, iterCount, Imgproc.GC_INIT_WITH_MASK);

            convertToGrayScaleValues (mask); // back to grayscale values
            Imgproc.threshold (mask, mask, 128, 255, Imgproc.THRESH_TOZERO);

            Mat foreground = new Mat (image.size (), CvType.CV_8UC3, new Scalar (0, 0, 0));
            image.copyTo (foreground, mask);

            Texture2D texture = new Texture2D (image.cols (), image.rows (), TextureFormat.RGBA32, false);

            Utils.matToTexture2D (foreground, texture);

            gameObject.GetComponent<Renderer> ().material.mainTexture = texture;
        }
开发者ID:EnoxSoftware,项目名称:OpenCVForUnity,代码行数:40,代码来源:GrabCutSample.cs

示例3: detectInRegion

				private void detectInRegion (Mat img, Rect r, List<Rect> detectedObjectsInRegions)
				{
						Rect r0 = new Rect (new Point (), img.size ());
						Rect r1 = new Rect (r.x, r.y, r.width, r.height);
						Inflate (r1, (int)((r1.width * innerParameters.coeffTrackingWindowSize) - r1.width) / 2,
            (int)((r1.height * innerParameters.coeffTrackingWindowSize) - r1.height) / 2);
						r1 = Intersect (r0, r1);

						if ((r1.width <= 0) || (r1.height <= 0)) {
								Debug.Log ("DetectionBasedTracker::detectInRegion: Empty intersection");
								return;
						}


						int d = Math.Min (r.width, r.height);
						d = (int)Math.Round (d * innerParameters.coeffObjectSizeToTrack);


						MatOfRect tmpobjects = new MatOfRect ();

						Mat img1 = new Mat (img, r1);//subimage for rectangle -- without data copying

						regionCascade.detectMultiScale (img1, tmpobjects, parameters.scaleFactor, parameters.minNeighbors, 0 | Objdetect.CASCADE_DO_CANNY_PRUNING | Objdetect.CASCADE_SCALE_IMAGE | Objdetect.CASCADE_FIND_BIGGEST_OBJECT, new Size (d, d), new Size ());


						Rect[] tmpobjectsArray = tmpobjects.toArray ();
						int len = tmpobjectsArray.Length;
						for (int i = 0; i < len; i++) {
								Rect tmp = tmpobjectsArray [i];
								Rect curres = new Rect (new Point (tmp.x + r1.x, tmp.y + r1.y), tmp.size ());
								detectedObjectsInRegions.Add (curres);
						}
				}
开发者ID:prlosana,项目名称:OpenCVForUnity,代码行数:33,代码来源:WebCamTextureAsyncDetectFaceSample.cs


注:本文中的Mat.size方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。