本文整理汇总了C#中Picture.AddRef方法的典型用法代码示例。如果您正苦于以下问题:C# Picture.AddRef方法的具体用法?C# Picture.AddRef怎么用?C# Picture.AddRef使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Picture
的用法示例。
在下文中一共展示了Picture.AddRef方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BufferCB
public int BufferCB(double sampleTime, IntPtr buffer, int len)
{
using (var rgba = new Picture<Rgba, byte>(Width, Height))
using (var gray = new Picture<Gray, byte>(Width, Height))
{
if ((len / 3) == (Width * Height))
{
using (var bgr = new Image<Bgr, byte>(Width, Height, Width * 3, buffer))
{
bgr._Flip(FLIP.VERTICAL);
CvInvoke.cvCvtColor(bgr.Ptr, rgba.Emgu.Ptr, COLOR_CONVERSION.CV_BGR2RGBA);
CvInvoke.cvCvtColor(bgr.Ptr, gray.Emgu.Ptr, COLOR_CONVERSION.CV_BGR2GRAY);
}
}
else
{
gray.Errorize();
rgba.Errorize();
}
OnNext(gray.AddRef(), rgba.AddRef());
}
return 0;
}
示例2: OnNext
protected void OnNext(Picture<Gray, byte> gray, Picture<Rgba, byte> rgba)
{
UpdateTexture2D(gray.AddRef(), rgba.AddRef());
using (gray)
{
GrayReq.Enqueue(null);
TaskCompletionSource<Picture<Gray, byte>> req = null;
while (GrayReq.TryDequeue(out req) && req != null)
req.SetResult(gray.AddRef());
}
using (rgba)
{
RgbaReq.Enqueue(null);
TaskCompletionSource<Picture<Rgba, byte>> ceq = null;
while (RgbaReq.TryDequeue(out ceq) && ceq != null)
ceq.SetResult(rgba.AddRef());
}
}
示例3: Update
private void Update(object sender, EventArgs e)
{
if (Scene == null)
return;
// Todo
// ...
// using (var rgba = new Picture<Rgba, byte>(Width, Height))
// using (var gray = new Picture<Gray, byte>(Width, Height))
// {
Program.EnsureRendering();
Program.Renderer.RenderInto(Scene, Rgba);
Gray.Dispose();
Gray = new Picture<Gray, byte>(Width, Height);
Gray.Emgu.ConvertFrom(Rgba.Emgu);
if (UndistortMapX != null && UndistortMapY != null)
Gray.Remap(UndistortMapX, UndistortMapY);
OnNext(Gray.AddRef(), Rgba.AddRef());
}
示例4: BufferCB
public int BufferCB(double sampleTime, IntPtr buffer, int len)
{
using (var bgra = new Picture(Width, Height))
{
if (len <= pic.Bytes.Length)
{
using (var bgr = new Picture(Width, Height))
{
Marshal.Copy(buffer, bgr.Bytes, 0, len);
bgra.AddRef();
bgra.Bgra.ConvertFrom(bgr.Bgr);
Enqueue(bgra.AddRef());
}
}
else
{
bgra.Bgra.SetValue(Microsoft.Xna.Framework.Color.Fuchsia.ToBgra());
Enqueue(bgra.AddRef());
}
}
return 0;
}
示例5: Runner
private void Runner()
{
Exposure = TimeSpan.FromSeconds(0.9 / FPS);
WhiteBalance = Color.White;
Gain = 0;
CLEyeSetCameraParameter(Handle, Param.CLEYE_AUTO_EXPOSURE_0_1, 0);
CLEyeSetCameraParameter(Handle, Param.CLEYE_AUTO_GAIN_0_1, 0);
CLEyeSetCameraParameter(Handle, Param.CLEYE_AUTO_WHITEBALANCE_0_1, 0);
if (Global.No)
{
CLEyeSetCameraParameter(Handle, Param.CLEYE_AUTO_WHITEBALANCE_0_1, 1);
CLEyeSetCameraParameter(Handle, Param.CLEYE_AUTO_GAIN_0_1, 1);
CLEyeSetCameraParameter(Handle, Param.CLEYE_AUTO_EXPOSURE_0_1, 1);
}
CLEyeCameraStart(Handle);
while (Running)
{
using (var rgba = new Picture<Rgba, byte>(this.Width, this.Height))
using (var gray = new Picture<Gray, byte>(this.Width, this.Height))
using (var bayer = new Picture<Gray, byte>(this.Width, this.Height))
using (var bgr = new Picture<Bgr, byte>(this.Width, this.Height))
{
var waitTimeOutMs = 2000;
var ok = NumChannels == 1
? CLEyeCameraGetFrame(Handle, bayer.Ptr, waitTimeOutMs)
: false;
if (!ok)
bayer.Errorize();
CvInvoke.cvCvtColor(bayer.Emgu.Ptr, bgr.Emgu.Ptr, COLOR_CONVERSION.CV_BayerGB2BGR_VNG);
CvInvoke.cvCvtColor(bgr.Emgu.Ptr, rgba.Emgu.Ptr, COLOR_CONVERSION.CV_BGR2RGBA);
CvInvoke.cvCvtColor(bgr.Emgu.Ptr, gray.Emgu.Ptr, COLOR_CONVERSION.CV_BGR2GRAY);
OnNext(gray.AddRef(), rgba.AddRef());
}
}
if (Handle != IntPtr.Zero)
{
CLEyeCameraStop(Handle);
CLEyeDestroyCamera(Handle);
Handle = IntPtr.Zero;
}
}