void InitialiseBack()
 {
     lock (FBackLock)
     {
         FBackBuffer.Initialise(FImageAttributes);
     }
 }
Exemplo n.º 2
0
		/// <summary>
		/// Copy CVImage into target CVImage 
		/// </summary>
		/// <param name="target"></param>
		public void GetImage(CVImage target)
		{
            if (target.NativeFormat == TColorFormat.UnInitialised)
            {
                target.Initialise(this.ImageAttributes);
            }

            GetImage(target.ImageAttributes.ColourFormat, target);
		}
Exemplo n.º 3
0
        public override void Allocate()
        {
            FSize = FInput.ImageAttributes.Size;
            FOutput.Image.Initialise(FSize, TColorFormat.RGB32F);

            FCurrent.Initialise(FSize, TColorFormat.L8);
            FPrevious.Initialise(FSize, TColorFormat.L8);
            FVelocityX.Initialise(FSize, TColorFormat.L32F);
            FVelocityY.Initialise(FSize, TColorFormat.L32F);
        }
Exemplo n.º 4
0
        public override void Allocate()
        {
            TColorFormat AsGrayscale = TypeUtils.ToGrayscale(FInput.ImageAttributes.ColourFormat);

            FNeedsConversion = (AsGrayscale != FInput.ImageAttributes.ColourFormat);

            if (FNeedsConversion)
            {
                FGrayscale.Initialise(FInput.ImageAttributes.Size, AsGrayscale);
            }

            FOutput.Image.Initialise(FGrayscale.ImageAttributes);
        }
Exemplo n.º 5
0
 public override void Allocate()
 {
     FGrayscale.Initialise(FInput.ImageAttributes.Size, TColorFormat.L8);
 }
Exemplo n.º 6
0
 void UpdateAttributes(CVImageAttributes attributes)
 {
     FImage.Initialise(attributes);
 }
Exemplo n.º 7
0
 public override void Allocate()
 {
     FOutput.Image.Initialise(FInput.ImageAttributes);
     FLastFrame.Initialise(FInput.ImageAttributes);
 }
 public override void Allocate()
 {
     FOutput.Image.Initialise(FInput.ImageAttributes.Size, TColorFormat.L8);
     FBackground.Initialise(FInput.ImageAttributes.Size, TColorFormat.L8);
 }
Exemplo n.º 9
0
 public override void Allocate()
 {
     FBuffer.Initialise(FInput.ImageAttributes);
 }
		void FContext_Update(object sender, EventArgs e)
		{
			FContext.Update -= OnUpdate;

			var colorWidth = FContext.FSensor.ColorStream.FrameWidth;
			var colorHeight = FContext.FSensor.ColorStream.FrameHeight;
			var depthWidth = FContext.FSensor.DepthStream.FrameWidth;
			var depthHeight = FContext.FSensor.DepthStream.FrameHeight;

			//find board positions in world coordinates

			//get mapped color image
			CVImage Image = new CVImage();
			//it's mapped so it's in depth coords
			Image.Initialise(new System.Drawing.Size(depthWidth, depthHeight), TColorFormat.RGBA8);
			lock (FContext.ColorLock)
			{
				Image.SetPixels(FContext.ColorData);
			}

			//create grayscale
			CVImage Luminance = new CVImage();
			Luminance.Initialise(Image.Size, TColorFormat.L8);
			Image.GetImage(TColorFormat.L8, Luminance);

			//find corners in rgb
			var pointsInRGB = CameraCalibration.FindChessboardCorners(Luminance.GetImage() as Image<Gray, byte>, new Size(FInBoardX[0], FInBoardY[0]), CALIB_CB_TYPE.ADAPTIVE_THRESH);

			//destroy images
			Image.Dispose();
			Luminance.Dispose();

			//find corners in world
			lock (FContext.DepthLock)
			{
				FContext.FWorldLock.AcquireReaderLock(500);
				try
				{
					var world = FContext.WorldData;
					lock (FDepthCorners)
					{
						FDepthCorners.Clear();
						lock (FWorldCorners)
						{
							FWorldCorners.Clear();
							foreach (var rgbCorner in pointsInRGB)
							{
								int index = (int)rgbCorner.X + (int)rgbCorner.Y * depthWidth;

								FDepthCorners.Add(new Vector3D(
										rgbCorner.X,
										rgbCorner.Y,
										(double) FContext.DepthData[index] / 1000.0
									));
								FWorldCorners.Add(new Vector3D(
										world[index * 4],
										world[index * 4 + 1],
										world[index * 4 + 2]
									));
							}
						}
					}
					FCornersDirty = true;
				}
				catch
				{

				}
				finally
				{
					FContext.FWorldLock.ReleaseReaderLock();
				}
			}
		}
Exemplo n.º 11
0
		public static void CopyImageConverted(CVImage source, CVImage target)
		{
            if (target.Size != source.Size)
            {
                target.Initialise(source.Size, target.NativeFormat);
            }

			COLOR_CONVERSION route = ConvertRoute(source.NativeFormat, target.NativeFormat);

			if (route == COLOR_CONVERSION.CV_COLORCVT_MAX)
			{
				CvInvoke.cvConvert(source.CvMat, target.CvMat);
			} else {
				try
				{
					CvInvoke.cvCvtColor(source.CvMat, target.CvMat, route);
				}
				catch
				{
					//CV likes to throw here sometimes, but the next frame it's fine
				}
			}

		}
 public override void Allocate()
 {
     FImageGT.Initialise(FInput.Image.ImageAttributes.Size, TColorFormat.L8);
     FImageLT.Initialise(FInput.Image.ImageAttributes.Size, TColorFormat.L8);
     FOutput.Image.Initialise(FInput.Image.ImageAttributes.Size, TColorFormat.L8);
 }