本文整理汇总了C#中System.Image.ToBitmap方法的典型用法代码示例。如果您正苦于以下问题:C# Image.ToBitmap方法的具体用法?C# Image.ToBitmap怎么用?C# Image.ToBitmap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Image
的用法示例。
在下文中一共展示了Image.ToBitmap方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: render
public void render( Image<Bgr, Byte> img)
{
md.findMarkers(img.Convert<Gray, Byte>());
if (md.isMarker())
{
int id = toolNetwork.recognitionPictograms(md.markers[0].getSymbolImage());
if (id != -1)
{
pos.estimate(md.markers[0]);
piktoViewManager.viewSceneMarker(id, pos.getTransformatinMatrix(), img.ToBitmap());
}
else
{
piktoViewManager.updateDisplayCameraLayer(img.ToBitmap());
}
// piktoViewMan.updateDisplayCameraLayer(img.ToBitmap());
}
else
{
if (!piktoViewManager.videoMode)
piktoViewManager.viewOnlyCameraImage();
piktoViewManager.updateDisplayCameraLayer(img.ToBitmap());
}
displayComponent.displaySetContent();
}
示例2: LearningPathViewModel
public LearningPathViewModel(/*ICommand renderXnaCmd, */DatabaseService db, ICommand returnToMainWindowCmd)
{
ReturnToMainWindowCmd = returnToMainWindowCmd;
MDetector md = new MDetector();
Image<Bgr, Byte> img = new Image<Bgr, Byte>(640, 480, new Bgr(255, 255, 0));
PiktoViewDB piktodb = new PiktoViewDB(db);
pictoViewManager = new PiktoViewManager(piktodb);
ToolArtNetwork toolNetwork = new ToolArtNetwork(piktodb.getImageIdDic());
MarkerPosition3D pos = new MarkerPosition3D(80.0f, 640.0f, 640, 480);
RenderXnaCmd = new BasicCommand(p =>
{
md.findMarkers(img.Convert<Gray, Byte>());
if (md.isMarker())
{
int id = toolNetwork.recognitionPictograms(md.markers[0].getSymbolImage());
if (id != -1)
{
pos.estimate(md.markers[0]);
pictoViewManager.viewSceneMarker(id, pos.getTransformatinMatrix(), img.ToBitmap());
}
}
else
{
pictoViewManager.updateDisplayCameraLayer(img.ToBitmap());
}
displayComponent.displaySetContent();
});
}
示例3: FormGroupMatch
public FormGroupMatch()
{
InitializeComponent();
debugImage = new Image<Bgr, byte>(pictureBox.Size.ToSize());
var detections = getDetections();
drawDetections(detections, Bgr8.Red, 3);
groupMatching = new RectangleGroupMatching(minimumNeighbors: 1, threshold: 0.3);
var clusters = groupMatching.Group(detections);
drawDetections(clusters.Select(x => x.Representative), Bgr8.Green, 1);
pictureBox.Image = debugImage.ToBitmap();
}
示例4: loadCurrentImageAnnotations
private void loadCurrentImageAnnotations()
{
if (capture.Position == capture.Length)
return;
drawingManager.Clear();
frame = capture.ReadAs<Bgr, byte>(); //the order is relevant (position is automatically increased)
this.pictureBox.Image = frame.ToBitmap();
var imageKey = getCurrentImageKey();
if (Database.ContainsKey(imageKey))
drawingManager.AddRange(Database[imageKey]);
this.Text = getCurrentImageKey() + " -> " + new FileInfo(databaseFileName).Name;
this.slider.Value = (int)Math.Max(0, this.capture.Position - 1);
this.slider.Maximum = (int)(capture.Length - 1);
this.lblCurrentFrame.Text = this.slider.Value.ToString();
this.lblTotalFrames.Text = this.slider.Maximum.ToString();
}
示例5: capture_NewFrame
void capture_NewFrame(object sender, EventArgs e)
{
//frame = await capture.ReadAsync(); //faster (does not apply for live streams)
frame = reader.ReadAs<Bgr, byte>();
if (frame == null)
{
Application.Idle -= capture_NewFrame;
return;
}
this.pictureBox.Image = frame.ToBitmap();
GC.Collect();
}
示例6: videoCapture_NewFrame
void videoCapture_NewFrame(object sender, EventArgs e)
{
frame = videoCapture.ReadAs<Bgr, byte>()/*.SmoothGaussian(5)*/; //smoothing <<parallel operation>>
if (frame == null)
return;
if (!isROISelected)
{
Application.Idle += videoCapture_InitFrame;
Application.Idle -= videoCapture_NewFrame;
return;
}
long start = DateTime.Now.Ticks;
Image<Gray, byte> probabilityMap;
Rectangle prevSearchArea;
Box2D foundBox;
processImage(frame, out probabilityMap, out prevSearchArea, out foundBox);
long end = DateTime.Now.Ticks;
long elapsedMs = (end - start) / TimeSpan.TicksPerMillisecond;
frame.Draw("Processed: " + elapsedMs + " ms", font, new PointF(15, 10), new Bgr(0, 255, 0));
frame.Draw(prevSearchArea, new Bgr(0, 0, 255), 3);
frame.Draw(foundBox, new Bgr(0, 255, 0), 5); Console.WriteLine("angle: " + foundBox.Angle);
this.pictureBox.Image = frame.ToBitmap(); //it will be just casted (data is shared) 24bpp color
this.pbProbabilityImage.Image = probabilityMap.ToBitmap(); //it will be just casted (data is shared) 8bpp gray
GC.Collect();
}
示例7: videoCapture_InitFrame
void videoCapture_InitFrame(object sender, EventArgs e)
{
frame = videoCapture.ReadAs<Bgr, byte>();
if (frame == null) return;
if (isROISelected)
{
initTracking(frame);
Application.Idle -= videoCapture_InitFrame;
Application.Idle += videoCapture_NewFrame;
return;
}
else
{
frame.Draw(roi, new Bgr(0, 0, 255), 3);
}
this.pictureBox.Image = frame.ToBitmap(); //it will be just casted (data is shared)
GC.Collect();
}
示例8: videoCapture_NewFrame
void videoCapture_NewFrame(object sender, EventArgs e)
{
frame = videoCapture.ReadAs<Bgr, byte>();
if (frame == null)
return;
var im = frame.Convert<FlowColor, float>();//.SmoothGaussian(5); //smoothing <<parallel operation>>;
long start = DateTime.Now.Ticks;
List<PointF> newPositions;
processImage(prevIm, im, this.oldPositions, out newPositions);
prevIm = im;
oldPositions = newPositions;
long end = DateTime.Now.Ticks;
long elapsedMs = (end - start) / TimeSpan.TicksPerMillisecond;
frame.Draw("Processed: " + elapsedMs + " ms", font, new PointF(15, 10), new Bgr(0, 255, 0));
drawPoints(frame, newPositions);
this.pictureBox.Image = frame.ToBitmap(); //it will be just casted (data is shared) 24bpp color
GC.Collect();
}
示例9: capture_NewFrame
void capture_NewFrame(object sender, EventArgs e)
{
frame = reader.ReadAs<Bgr, byte>();
if (frame == null)
{
Application.Idle -= capture_NewFrame;
return;
}
this.pictureBox.Image = frame.ToBitmap();
bool isFrameWritten = writer.Write(frame);
if (!isFrameWritten)
MessageBox.Show("Frame is not written!", "Frame writing error", MessageBoxButtons.OK, MessageBoxIcon.Error);
GC.Collect();
}
示例10: videoCapture_ProcessFrame
void videoCapture_ProcessFrame(object sender, EventArgs e)
{
frame = videoCapture.ReadAs<Bgr, byte>();
if (frame == null)
return;
long start = DateTime.Now.Ticks;
predict();
update();
long end = DateTime.Now.Ticks;
long elapsedMs = (end - start) / TimeSpan.TicksPerMillisecond;
drawParticles(particleFilter, frame);
frame.Draw("Processed: " + elapsedMs + " ms", font, new PointF(15, 10), new Bgr(0, 255, 0));
this.pictureBox.Image = frame.ToBitmap(); //it will be just casted (data is shared)
GC.Collect();
}
示例11: videoCapture_NewFrame
void videoCapture_NewFrame(object sender, EventArgs e)
{
frame = videoCapture.ReadAs<Bgr, byte>();
if (frame == null)
return;
if (!isROISelected)
{
Application.Idle += videoCapture_InitFrame;
Application.Idle -= videoCapture_NewFrame;
return;
}
long start = DateTime.Now.Ticks;
Rectangle prevSearchArea = searchArea; //processImage overwrites searchArea
bool isPredicted = nonVisibleCount > 0;
Image<Gray, byte> probabilityMap;
Box2D foundBox;
trackOneStep(frame, out probabilityMap, out foundBox);
long end = DateTime.Now.Ticks;
long elapsedMs = (end - start) / TimeSpan.TicksPerMillisecond;
frame.Draw("Processed: " + elapsedMs + " ms", font, new PointF(15, 10), new Bgr(0, 255, 0));
frame.Draw(prevSearchArea, new Bgr(0, 0, 255), 3);
frame.Draw(foundBox, new Bgr(0, 255, 0), 5); Console.WriteLine("angle: " + foundBox.Angle);
this.pictureBox.Image = frame.ToBitmap(); //it will be just casted (data is shared) 24bpp color
this.pbProbabilityImage.Image = probabilityMap.ToBitmap(); //it will be just casted (data is shared) 8bpp gray
GC.Collect();
//Thread.Sleep(100);
}
示例12: timer_Tick
private void timer_Tick(object sender, EventArgs e)
{
const int BORDER_OFFSET = 20;
scale += 10 * dScale; if (scale > 300) dScale = -1; if (scale < 100) dScale = 1;
angle += 5 * dAngle; if (angle > 360) dAngle = -1; if (dAngle < 0) dAngle = 1;
var transformation = Transforms2D.Combine
(
Transforms2D.Rotation((float)Angle.ToRadians(angle)),
Transforms2D.Scale(scale, scale)
);
IEnumerable<PointF> pts = modelPts.Transform(transformation);
var box = pts.BoundingRect(); //maybe apply it to bounding box instead of points (expensive)
pts = pts.Transform(Transforms2D.Translation(-box.X + BORDER_OFFSET, -box.Y + BORDER_OFFSET));
var image = new Image<Bgr, byte>(scale + BORDER_OFFSET * 2, scale + BORDER_OFFSET * 2);
drawContour(pts.ToList(), image);
pictureBox.Image = image.ToBitmap();
}
示例13: videoCapture_NewFrame
void videoCapture_NewFrame(object sender, EventArgs e)
{
frame = videoCapture.ReadAs<Bgr, byte>();
if (frame == null)
return;
long preprocessTime, matchTime;
var bestRepresentatives = findObjects(frame, out preprocessTime, out matchTime);
/************************************ drawing ****************************************/
foreach (var m in bestRepresentatives)
{
frame.Draw(m.BoundingRect, new Bgr(0, 0, 255), 1);
if (m.Template is ImageTemplateWithMask)
{
var mask = ((ImageTemplateWithMask)m.Template).BinaryMask;
if (mask == null) continue; //just draw bounding boxes
var area = new Rectangle(m.X, m.Y, mask.Width, mask.Height);
if (area.X < 0 || area.Y < 0 || area.Right >= frame.Width || area.Bottom >= frame.Height) continue; //must be fully inside
using (var someImage = new Image<Bgr, byte>(mask.Width, mask.Height, Bgr8.Red))
{
someImage.CopyTo(frame.GetSubRect(area), mask);
}
}
else
{
frame.Draw(m, Bgr8.Blue, 3, true, Bgr8.Red);
}
Console.WriteLine("Best template: " + m.Template.ClassLabel + " score: " + m.Score);
}
frame.Draw(String.Format("Matching {0} templates in: {1} ms", templPyrs.Count, matchTime),
font, new PointF(5, 10), new Bgr(0, 255, 0));
/************************************ drawing ****************************************/
this.pictureBox.Image = frame.ToBitmap(); //it will be just casted (data is shared) 24bpp color
//frame.Save(String.Format("C:/probaImages/imgMarked_{0}.jpg", i)); b.Save(String.Format("C:/probaImages/img_{0}.jpg", i)); i++;
GC.Collect();
}