Beispiel #1
0
        Rect FromSynesisAntishaker(synesis.AntishakerCrop rct)
        {
            Rect srct = new Rect();

            srct.X      = rct.XOffs;
            srct.Y      = rct.YOffs;
            srct.Width  = rct.CropWidth;
            srct.Height = rct.CropHeight;
            if (srct.Width == 0)
            {
                srct.Width = 10;
            }
            if (srct.Height == 0)
            {
                srct.Height = 10;
            }
            if (srct.X == 0)
            {
                srct.X = 1;
            }
            if (srct.Y == 0)
            {
                srct.Y = 1;
            }
            return(srct);
        }
Beispiel #2
0
 synesis.AntishakerCrop ToSynesisAntishaker(Rect rect)
 {
     synesis.AntishakerCrop crop = new synesis.AntishakerCrop();
     crop.XOffs      = (int)rect.X > 0 ? (int)rect.X : 0;
     crop.YOffs      = (int)rect.Y > 0 ? (int)rect.Y : 0;
     crop.CropWidth  = (int)rect.Width;
     crop.CropHeight = (int)rect.Height;
     return(crop);
 }
        void ScaleAntishakerCropInput(synesis.AntishakerCrop crop)
        {
            //scale from [-1;1] to visible dimensions
            double valueX = (videoDescr.videoSourceResolution.Width / 2) * (crop.XOffs + 1);
            double valueY = videoDescr.videoSourceResolution.Height - (videoDescr.videoSourceResolution.Height / 2) * (crop.YOffs + 1);
            double width  = (videoDescr.videoSourceResolution.Width / 2) * (crop.CropWidth);
            double height = (videoDescr.videoSourceResolution.Height / 2) * (crop.CropHeight);
            //convert ftrom video sourve resolution to encoder resolution
            double scalex = videoDescr.videoInfo.Resolution.Width / (videoDescr.videoSourceResolution.Width == 0 ? 1 : videoDescr.videoSourceResolution.Width);
            double scaley = videoDescr.videoInfo.Resolution.Height / (videoDescr.videoSourceResolution.Height == 0 ? 1 : videoDescr.videoSourceResolution.Height);

            valueX          = valueX * scalex;
            valueY          = valueY * scaley;
            height          = height * scaley;
            width           = width * scalex;
            crop.XOffs      = (float)valueX;
            crop.YOffs      = (float)valueY;
            crop.CropHeight = (float)height;
            crop.CropWidth  = (float)width;
        }
        void ScaleAntishakerCropOutput(synesis.AntishakerCrop crop)
        {
            double valueX = crop.XOffs;
            double valueY = crop.YOffs;
            double width  = crop.CropWidth;
            double height = crop.CropHeight;
            //convert from video sourve resolution to encoder resolution
            double scalex = videoDescr.videoSourceResolution.Width / videoDescr.videoInfo.Resolution.Width;
            double scaley = videoDescr.videoSourceResolution.Height / videoDescr.videoInfo.Resolution.Height;

            valueX = valueX * scalex;
            valueY = valueY * scaley;
            height = height * scaley;
            width  = width * scalex;
            //scale from visible to [-1;1]
            double heightValue = videoDescr.videoSourceResolution.Height - 1;
            double widthValue  = videoDescr.videoSourceResolution.Width - 1;

            crop.XOffs      = (float)(((valueX * 2) / widthValue) - 1);
            crop.YOffs      = (float)((((heightValue - valueY) * 2) / heightValue) - 1);
            crop.CropWidth  = (float)((width * 2) / widthValue);
            crop.CropHeight = (float)((height * 2) / heightValue);
        }
		synesis.AntishakerCrop ToSynesisAntishaker(Rect rect) {
			synesis.AntishakerCrop crop = new synesis.AntishakerCrop();
			crop.XOffs = (int)rect.X > 0 ? (int)rect.X : 0;
			crop.YOffs = (int)rect.Y > 0 ? (int)rect.Y : 0;
			crop.CropWidth = (int)rect.Width;
			crop.CropHeight = (int)rect.Height;
			return crop;
		}