/// <summary>
    /// Copies the given ZEDMat to a given OpenCV mat, creating either or both mats if necessary, then calls an ImageUpdatedEvent with them.
    /// Used in OnZEDGrabbed to call different events, and to make it easy to add more kinds of images/events by just adding more calls to this method.
    /// </summary>
    /// <param name="cam">Unity Camera object that represents the ZED camera. Usually from ZEDManager.GetLeftCamera() or ZEDManager.GetRightCamera().</param>
    /// <param name="zedmat">ZEDMat used to get the ZED image. Passing an empty one is okay - it'll get filled appropriately.</param>
    /// <param name="view">Type of image requested, like LEFT or LEFT_GRAY.</param>
    /// <param name="mattype">Data type and channel of required ZEDMat. See summaries over each enum entry to know which is correct for your image type.</param>
    /// <param name="cvMat">OpenCV mat to copy to. Passing an empty one is okay - it'll get filled appropriately.</param>
    /// <param name="updateevent">Event to call if the method retrieves the image successfully.</param>
    private void DeployGrabbedEvent(Camera cam, ref ZEDMat zedmat, VIEW view, ZEDMat.MAT_TYPE mattype, ref Mat cvMat, ImageUpdatedEvent updateevent,
                                    OpenCVConversion conversionatend = OpenCVConversion.NONE)
    {
        if (zedmat == null)
        {
            zedmat = new ZEDMat((uint)zedCam.ImageWidth, (uint)zedCam.ImageHeight, mattype);
        }

        /*if (cvMat == null)
         * {
         *  cvMat = SLMat2CVMat(zedmat, mattype);
         * }*/

        ERROR_CODE err = zedManager.zedCamera.RetrieveImage(zedmat, view, ZEDMat.MEM.MEM_CPU, zedmat.GetResolution());

        if (err == ERROR_CODE.SUCCESS)
        {
            Mat buffermat = GetOpenCVBufferMat(zedCam.ImageHeight, zedCam.ImageWidth, SLMatType2CVMatType(mattype));

            //copyToMat(zedmat.GetPtr(), cvMat);
            Utils.copyToMat(zedmat.GetPtr(), buffermat);

            ConvertColorSpace(buffermat, ref cvMat, conversionatend);
            //Mat convertedmat = ConvertColorSpace(buffermat, conversionatend);

            //updateevent.Invoke(cam, camMat, cvMat);
            updateevent.Invoke(cam, camMat, cvMat);
        }
    }
 public Task Handle(ImageUpdatedEvent notification, CancellationToken cancellationToken)
 {
     return(Task.CompletedTask);
 }