protected override void Generate() { if (frameAvailable) { updateFrameRate(); bool started; camStatus = cam.Acquisition.HasStarted(out started); bool finished; camStatus = cam.Acquisition.IsFinished(out finished); if (cam.IsOpened && started && finished) { int MemId; camStatus = cam.Memory.GetActive(out MemId); int w, h; camStatus = cam.Memory.GetSize(MemId, out w, out h); //copy to FOutput camStatus = cam.Memory.Lock(MemId); IntPtr memPtr; camStatus = cam.Memory.ToIntPtr(out memPtr); camStatus = cam.Memory.CopyImageMem(memPtr, MemId, FOutput.Data); camStatus = cam.Memory.Unlock(MemId); FOutput.Send(); } } }
protected override void Generate() { var frame = this.FGetLatestFrame ? FCamera.GetLatestFrame() : FCamera.GetFrame(); if (frame != null) { if (frame.FrameID() != this.FrameID) { if (FMode == VideoMode.GrayscaleMode) { frame.GetGrayscaleData(FOutput.Data); } else { frame.Rasterize(FOutput.Data); } this.FrameID = frame.FrameID(); FOutput.Send(); lock (this.Objects) { this.Objects.Clear(); for (int i = 0; i < frame.ObjectCount(); i++) { this.Objects.Add(new TrackingObject(frame.Object(i))); } } } frame.Release(); } }
public void Step() { CvInvoke.cvDilate(FOutput.CvMat, FUnmasked.CvMat, IntPtr.Zero, Steps); CvInvoke.cvCopy(FUnmasked.CvMat, FOutput.CvMat, FMask.CvMat); FOutput.Send(); AddNoise(); }
public unsafe void UpdateData() { if (Allocated) { lock (this) { switch (FDataSetType) { case TDataSet.ProjectorInCamera: UpdateProjectorInCamera(); break; case TDataSet.CameraInProjector: UpdateCameraInProjector(); break; case TDataSet.LuminanceInCamera: UpdateLuminanceInCamera(); break; } } FOutput.Send(); } }
public override void Process() { if (!FInput.LockForReading()) { return; } FInput.GetImage(FHsvImage); FInput.ReleaseForReading(); CvInvoke.cvInRangeS(FHsvImage.CvMat, new MCvScalar(Minimum.x * FMult, Minimum.y * FMult, Minimum.z * FMult), new MCvScalar(Maximum.x * FMult, Maximum.y * FMult, Maximum.z * FMult), FBuffer.CvMat); if (PassOriginal) { FOutput.Image.SetImage(FInput.Image); CvInvoke.cvNot(FBuffer.CvMat, FBuffer.CvMat); CvInvoke.cvSet(FOutput.Image.CvMat, new MCvScalar(0.0), FBuffer.CvMat); FOutput.Send(); } else { FOutput.Send(FBuffer); } }
protected override void Generate() { int FrameTargetIndex = (int)((DateTime.Now - FStarted).TotalSeconds * this.FrameRate); bool isEnd = (FrameTargetIndex >= this.FrameCount); if (isEnd) { FrameTargetIndex = this.FrameCount - 1; } bool newFrame = false; while (FrameDecodedIndex < FrameTargetIndex) { FOutput.Image.SetImage(FCapture.QueryFrame()); FrameDecodedIndex++; newFrame = true; } if (newFrame) { this.Position = FCapture.GetCaptureProperty(CAP_PROP.CV_CAP_PROP_POS_MSEC) / 1000.0; FOutput.Send(); } if (isEnd) { //rewind FCapture.SetCaptureProperty(CAP_PROP.CV_CAP_PROP_POS_FRAMES, 0.0); this.FrameDecodedIndex = 0; this.FStarted = DateTime.Now; } }
public override void Process() { //If we want to pull out an image in a specific format //then we must have a local instance of a CVImage initialised to that format //and use //FInput.Image.GetImage(TColorFormat.L8, FInputL8); //in that example, we expect to have a FInputL8 locally which has been intialised //with the correct size and colour format //Whenever you access the pixels directly of FInput //e.g. when using the .CvMat accessor //you must lock it for reading using if (!FInput.LockForReading()) //this { return; } CvInvoke.cvPyrDown(FInput.CvMat, FOutput.CvMat, FILTER_TYPE.CV_GAUSSIAN_5x5); FInput.ReleaseForReading(); //and this after you've finished with FImage if (FInput.ImageAttributes.ColourFormat == TColorFormat.RGB8) { PixelWiseAdd(); } FOutput.Send(); }
public override void Process() { if (Set) { FOutput.Image = FInput.Image; FOutput.Send(); } }
public override void Process() { if (FFlagForSet) { FOutput.Image = FInput.Image; FOutput.Send(); FFlagForSet = false; } }
protected override void Generate() { IImage capbuffer = FCapture.QueryFrame(); if (ImageUtils.IsIntialised(capbuffer)) { FOutput.Image.SetImage(capbuffer); FOutput.Send(); } }
public override void Process() { if (!FInput.LockForReading()) //this { return; } CvInvoke.cvNot(FInput.CvMat, FOutput.CvMat); FInput.ReleaseForReading(); //and this after you've finished with FImage FOutput.Send(); }
public void VideoInputFrameArrived(IDeckLinkVideoInputFrame videoFrame, IDeckLinkAudioInputPacket audioPacket) { IntPtr data; videoFrame.GetBytes(out data); ImageUtils.RawYUV2RGBA(data, FOutput.Data, FOutput.Image.ImageAttributes.PixelsPerFrame); //FOutput.Image.SetPixels(data); FOutput.Send(); System.Runtime.InteropServices.Marshal.ReleaseComObject(videoFrame); }
protected override void Generate() { if (Allocated && FrameRendered != Frame) { Update(); FrameRendered = Frame; Timestamps.Add((ulong)Frame, FOutput.Image.Timestamp); FOutput.Send(); } }
public override void Process() { if (!FInput.LockForReading()) { return; } CvInvoke.cvCmpS(FInput.CvMat, Threshold, FOutput.CvMat, CMP_TYPE.CV_CMP_LT); FInput.ReleaseForReading(); FOutput.Send(); }
public unsafe void CaptureCallback(ManagedImage image) { if (!FOutput.Image.Allocated) { FOutput.Image.Initialise(new Size((int)image.cols, (int)image.rows), Utils.GetFormat(image.pixelFormat)); } FOutput.Image.SetPixels((IntPtr)image.data); FOutput.Send(); }
protected override void Generate() { if (FFormat == TColourFormat.UnInitialised) { return; } FSegment.Lock(); FOutput.Image.SetPixels(FSegment.GetNativePointer()); FOutput.Send(); FSegment.Unlock(); }
public override void Process() { if (!FInput.LockForReading()) { return; } CvInvoke.cvAdaptiveThreshold(FInput.CvMat, FOutput.CvMat, FMaximum, FMethod, FType, (int)FBlockSize, FConstant); FInput.ReleaseForReading(); FOutput.Send(); }
public override void Process() { if (!FInput.LockForReading()) { return; } CvInvoke.cvErode(FInput.CvMat, FOutput.CvMat, IntPtr.Zero, FIterations); FInput.ReleaseForReading(); FOutput.Send(); }
public override void Process() { try { CvInvoke.cvResize(FInput.Image.CvMat, FOutput.Image.CvMat, INTER.CV_INTER_LINEAR); FOutput.Send(); } catch { } }
public override void Process() { try { CvInvoke.cvResize(FInput.Image.CvMat, FOutput.Image.CvMat, INTER.CV_INTER_LINEAR); FOutput.Send(); } catch (Exception e) { ImageUtils.Log(e); } }
public override void Process() { if (!FInput.LockForReading()) { return; } CvInvoke.cvCmpS(FInput.CvMat, Minimum, FImageGT.CvMat, CMP_TYPE.CV_CMP_GE); CvInvoke.cvCmpS(FInput.CvMat, Maximum, FImageLT.CvMat, CMP_TYPE.CV_CMP_LE); FInput.ReleaseForReading(); CvInvoke.cvAnd(FImageGT.CvMat, FImageLT.CvMat, FOutput.CvMat, IntPtr.Zero); FOutput.Send(); }
public override void Process() { FInput.LockForReading(); try { CvInvoke.cvConvertScale(FInput.CvMat, FOutput.CvMat, Scale, Offset); } finally { FInput.ReleaseForReading(); } FOutput.Send(); }
private void LoadImage() { try { FOutput.Image.LoadFile(FFilename); FOutput.Send(); Status = "OK"; } catch { Status = "Image load failed"; } }
public override void Process() { FInput.LockForReading(); try { CvInvoke.cvSobel(FInput.CvMat, FOutput.CvMat, FXOrder, FYOrder, FAperture); } finally { FInput.ReleaseForReading(); } FOutput.Send(); }
private void LoadImage() { try { FOutput.Image.LoadFile(FFilename); FOutput.Send(); Status = "OK"; } catch (Exception e) { Status = e.Message; } }
public override void Process() { if (FInput.Allocated) { if (FBuffer.Allocated) { FOutput.Image.SetImage(FBuffer); FOutput.Send(); } FBuffer.SetImage(FInput.Image); } }
public override void Process() { if (FThresholdEnabled) { if (FInput.ImageAttributes.ColourFormat != TColourFormat.L8) { FInput.Image.GetImage(TColourFormat.L8, FOutput.Image); if (DifferenceMode == TDifferenceMode.AbsoluteDifference) { CvInvoke.cvAbsDiff(FOutput.CvMat, FBuffer.CvMat, FOutput.CvMat); } CvInvoke.cvThreshold(FOutput.CvMat, FOutput.CvMat, 255.0d * Threshold, 255, THRESH.CV_THRESH_BINARY); FInput.Image.GetImage(TColourFormat.L8, FBuffer); } else { if (DifferenceMode == TDifferenceMode.AbsoluteDifference) { if (!FInput.LockForReading()) { return; } CvInvoke.cvAbsDiff(FInput.CvMat, FBuffer.CvMat, FOutput.CvMat); FInput.ReleaseForReading(); } CvInvoke.cvThreshold(FOutput.CvMat, FOutput.CvMat, 255.0d * Threshold, 255, THRESH.CV_THRESH_BINARY); } } else { if (DifferenceMode == TDifferenceMode.AbsoluteDifference) { if (!FInput.LockForReading()) { return; } CvInvoke.cvAbsDiff(FInput.CvMat, FBuffer.CvMat, FOutput.CvMat); FInput.ReleaseForReading(); } FBuffer.SetImage(FInput.Image); } FOutput.Send(); }
public override void Process() { if (!FInput.LockForReading()) { return; } CvInvoke.cvSetImageROI(FInput.CvMat, CropRectangle); CvInvoke.cvCopy(FInput.CvMat, FOutput.CvMat, IntPtr.Zero); CvInvoke.cvResetImageROI(FInput.CvMat); FInput.ReleaseForReading(); FOutput.Send(); }
private void LoadImage(string filename) { try { FOutput.Image.LoadFile(filename); FLoadedImage = filename; FOutput.Send(); Status = "OK"; } catch { Status = "Image load failed"; FLoadedImage = ""; } }
protected override void Generate() { if (FParameterChange) { SetParameters(); } FCamera.getPixels(FOutput.Data, 100); if (FOutput.Image.NativeFormat == TColorFormat.RGBA8) { SetAlphaChannel(); } FOutput.Send(); }