現在の状況・解決したいこと
現在,以下のソースコードで動かした結果,画像のような砂嵐がでるような結果になってしまいます.
実行ごとに,砂嵐の状況は違います.
これをどうにかして解決できないでしょうか?ご助言お願いいたします.
C#
1using System.Collections; 2using System.Collections.Generic; 3using UnityEngine; 4using OpenCVForUnity.CoreModule; 5using OpenCVForUnity.UnityUtils; 6using OpenCVForUnity.ImgprocModule; 7 8using static OpenCVForUnity.CoreModule.Core; 9using static OpenCVForUnity.CoreModule.CvType; 10 11public class OpenCV_Test: MonoBehaviour 12{ 13 // Start is called before the first frame update 14 void Start() 15 { 16 int scleen_size_X = 500; 17 int scleen_size_Y = 500; 18 19 Mat img_origin = new Mat(scleen_size_X, scleen_size_Y, CV_8UC3); 20 21 Point[] p_origin = new Point[4]; 22 p_origin[0] = new Point((scleen_size_X / 2) - 100, (scleen_size_Y / 2) - 100); 23 p_origin[1] = new Point((scleen_size_X / 2) - 100, (scleen_size_Y / 2) + 100); 24 p_origin[2] = new Point((scleen_size_X / 2) + 100, (scleen_size_Y / 2) + 100); 25 p_origin[3] = new Point((scleen_size_X / 2) + 100, (scleen_size_Y / 2) - 100); 26 27 Imgproc.fillConvexPoly(img_origin, new MatOfPoint(p_origin), new Scalar(255, 255, 255)); 28 29 30 Texture2D texture = new Texture2D(img_origin.cols(), img_origin.rows(), TextureFormat.ARGB32, false); 31 Utils.matToTexture2D(img_origin, texture); 32 33 this.gameObject.GetComponent<Renderer>().material.mainTexture = texture; 34 } 35}
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/05/29 03:27