コード例 #1
0
    IEnumerator CalibrateRoutine()
    {
        if (!Directory.Exists(directory))
        {
            yield break;
        }
        ;

        var files = Directory.GetFiles(directory);

        files = files.Where(e => targetExtensions.Contains(Path.GetExtension(e).ToLower())).ToArray();
        if (files.Length < 1)
        {
            yield break;
        }
        ;

        calibrator.Setup();
        for (var i = 0; i < files.Length; i++)
        {
            using (Mat gray = Imgcodecs.imread(files[i], Imgcodecs.IMREAD_GRAYSCALE))
            {
                if (i == 0)
                {
                    Init(gray);
                }
                calibrator.Calibrate(gray);
                if (draw)
                {
                    Imgproc.cvtColor(gray, rgbMat, Imgproc.COLOR_GRAY2RGB);
                    calibrator.Draw(gray, rgbMat);
                    Utils.matToTexture2D(rgbMat, texture);
                    renderer.material.mainTexture = texture;
                }

                print("progress : " + (i + 1) + " / " + files.Length);
                yield return(new WaitForSeconds(interval));
            }
        }
        if (autoSave)
        {
            calibrator.Save(IOHandler.IntoStreamingAssets(fileName));
        }

        calibrator.Clear();

        print("Complete Calibration");
        yield break;
    }
コード例 #2
0
 private void VideoCaptureController_TextureUpdatedEvent(TextureHolderBase sender, Texture texture)
 {
     if (!this.enabled)
     {
         return;
     }
     if (!this.gameObject.activeInHierarchy)
     {
         return;
     }
     videoCaptureController.RGBMat.copyTo(rgbMat);
     Imgproc.cvtColor(rgbMat, grayMat, Imgproc.COLOR_RGB2GRAY);
     calibrator.Draw(grayMat, rgbMat);
     Core.flip(rgbMat, rgbMat, 0);
     Utils.fastMatToTexture2D(rgbMat, this.texture);
 }