public Image SmartScaleCrop(Image sourceImage, SmartScaleCropArguments args) { string fingerprint = ImageOptimizationHelper.GetImageFingerprint(sourceImage); var entry = OptimizationManager.GetImageOptimizationLogEntrys().Where(e => e.Fingerprint == fingerprint).FirstOrDefault(); int focalPointX = 0; int focalPointY = 0; int focalPointWidth = 0; int focalPointHeight = 0; int focalPointAnchor = 0; if (entry != null) { var sfImage = LibManager.GetImage(entry.ImageId); focalPointX = sfImage.GetValue <int>("FocalPointX"); focalPointY = sfImage.GetValue <int>("FocalPointY"); focalPointWidth = sfImage.GetValue <int>("FocalPointWidth"); focalPointHeight = sfImage.GetValue <int>("FocalPointHeight"); focalPointAnchor = sfImage.GetValue <int>("FocalPointAnchor"); if (focalPointX != 0 && focalPointY != 0) { return(Process(sourceImage, focalPointX, focalPointY, focalPointWidth, focalPointHeight, focalPointAnchor, args)); } } return(base.Crop(sourceImage, args)); }
public override void Setup() { webCamTextureToMatHelper = gameObject.GetComponent <WebCamTextureToMatHelper> (); imageOptimizationHelper = gameObject.GetComponent <ImageOptimizationHelper> (); webCamTextureToMatHelper.Initialize(); didUpdateResultMat = false; }
// Use this for initialization void Start() { fpsMonitor = GetComponent <FpsMonitor>(); imageOptimizationHelper = gameObject.GetComponent <ImageOptimizationHelper>(); webCamTextureToMatHelper = gameObject.GetComponent <MLCameraPreviewToMatHelper>(); classes_filepath = Utils.getFilePath("dnn/" + classes); config_filepath = Utils.getFilePath("dnn/" + config); model_filepath = Utils.getFilePath("dnn/" + model); Run(); }
public override void Setup() { imageOptimizationHelper = gameObject.GetComponent <ImageOptimizationHelper>(); #if UNITY_WEBGL getFilePath_Coroutine = GetFilePath(); StartCoroutine(getFilePath_Coroutine); #else videoFilePath = OpenCVForUnity.UnityUtils.Utils.getFilePath(videoFileName); Run(); #endif didUpdateResultMat = false; }
/// <summary> /// Check for all required variables to be initialized. /// </summary> void Start() { if (_screenRenderer == null) { Debug.LogError("Error: RawVideoCaptureVisualizer._screenRenderer is not set, disabling script."); enabled = false; return; } //if (_recordingIndicator == null) //{ // Debug.LogError("Error: RawVideoCaptureVisualizer._recordingIndicator is not set, disabling script."); // enabled = false; // return; //} _screenRenderer.enabled = true; imageOptimizationHelper = gameObject.GetComponent <ImageOptimizationHelper>(); haarcascade_frontalface_alt_xml_filepath = OpenCVForUnity.UnityUtils.Utils.getFilePath("haarcascade_frontalface_alt.xml"); dlibShapePredictorFilePath = DlibFaceLandmarkDetector.UnityUtils.Utils.getFilePath(dlibShapePredictorFileName); if (string.IsNullOrEmpty(dlibShapePredictorFilePath)) { Debug.LogError("shape predictor file does not exist. Please copy from “DlibFaceLandmarkDetector/StreamingAssets/” to “Assets/StreamingAssets/” folder. "); } cascade = new CascadeClassifier(haarcascade_frontalface_alt_xml_filepath); #if !UNITY_WSA_10_0 if (cascade.empty()) { Debug.LogError("cascade file is not loaded. Please copy from “OpenCVForUnity/StreamingAssets/” to “Assets/StreamingAssets/” folder. "); } #endif if (string.IsNullOrEmpty(dlibShapePredictorFilePath)) { Debug.LogError("shape predictor file does not exist. Please copy from “DlibFaceLandmarkDetector/StreamingAssets/” to “Assets/StreamingAssets/” folder. "); } faceLandmarkDetector = new FaceLandmarkDetector(dlibShapePredictorFilePath); detectionResult = new List <UnityEngine.Rect>(); }
// Use this for initialization void Start() { fpsMonitor = GetComponent <FpsMonitor>(); imageOptimizationHelper = gameObject.GetComponent <ImageOptimizationHelper>(); webCamTextureToMatHelper = gameObject.GetComponent <MLCameraPreviewToMatHelper>(); webCamTextureToMatHelper.Initialize(); cascade = new CascadeClassifier(); //cascade.load (Utils.getFilePath ("lbpcascade_frontalface.xml")); cascade.load(Utils.getFilePath("haarcascade_frontalface_alt.xml")); if (cascade.empty()) { Debug.LogError("cascade file is not loaded. Please copy from “OpenCVForUnity/StreamingAssets/” to “Assets/StreamingAssets/” folder. "); } }