本文整理汇总了C#中Emgu.CV.Mat.Clone方法的典型用法代码示例。如果您正苦于以下问题:C# Mat.Clone方法的具体用法?C# Mat.Clone怎么用?C# Mat.Clone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Emgu.CV.Mat
的用法示例。
在下文中一共展示了Mat.Clone方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnImageReceived
protected override void OnImageReceived(Mat image)
{
if (DetectionMode == DetectionModes.AllFrames)
{
DetectFaces(image);
}
else if (DetectionMode == DetectionModes.Periodic || DetectionMode == DetectionModes.Manual)
{
// Do it asynchronously, don't interrupt the stream of frames, the detection result will be drawn to next frame
if (detectNextFrame && !detectingInProgress)
{
detectNextFrame = false;
// If we don't clone the imeage, the drawing operation will modify it and face cannot be detected on that image
Mat imgCopy = image.Clone();
Task.Factory.StartNew(() => DetectFaces(imgCopy));
}
}
else if (DetectionMode == DetectionModes.Disabled)
{
lastDetectedFaces.Clear();
}
if (DrawDetection)
{
foreach (FaceFeatures f in lastDetectedFaces)
f.DrawToImage(image, DrawProbableAreas);
}
//CvInvoke.PutText(image, "Detection took " + detectionTime + " ms", new Point(10, 30), FontFace.HersheyComplex, 1.0, new Bgr(Color.Black).MCvScalar, 1, LineType.AntiAlias);
OnImageAvailable(image);
}
示例2: button2_Click
private void button2_Click(object sender, EventArgs e)
{
pic1Copy = pic1.Clone();
pic2Copy = pic2.Clone();
Transformation.transformation(DNA1, DNA2, ref edgeMatch, ref centroid1, ref centroid2, ref angle);
angle = angle * 180 / Math.PI;
angle = -angle;
Console.WriteLine(centroid1.ToString());
Console.WriteLine(centroid2.ToString());
Console.WriteLine(angle);
mask1 = pic1Copy.Clone();
mask2 = pic2Copy.Clone();
ReturnColorImg result = Transformation.transformColor(pic1, mask1, pic2, mask2, joined, joined_mask, centroid1, centroid2, -angle + 180, p1Tweak, p2Tweak,blackOrWhite);
joined = result.img;
//pictureBox3.Image = result.img./*Resize(pictureBox1.Width, pictureBox1.Height, INTER.CV_INTER_LINEAR).*/ToBitmap();
confidence = edgeMatch.confidence;
overlap = result.overlap;
ConfidenceView.Text = confidence.ToString();
OverlapView.Text = overlap.ToString();
//AddMatchHistory();
if (result.success)
{
DisplayImage dip = new DisplayImage(result.img, p1Tweak, p2Tweak, (int)overlap);
dip.Show();
}
else
{
MessageBox.Show("You cannot tweak further in that direction");
}
}
示例3: transformColor
//Transform images according to transform matrix
// From Line 130-239
public static ReturnColorImg transformColor(Mat img1, Mat mask1, Mat img2, Mat mask2,
Mat dst, Mat dst_mask,
Point centroid1, Point centroid2, double angle, Point tweak1, Point tweak2, bool mode = true)
{
Mat E = img2.Clone();
Mat E_mask = mask2.Clone();//Don't ruin original images
double intersections = 0;
double x = centroid2.X;
double y = centroid2.Y;
double _x, _y, _y2;
double y2;
LineSegment2D centerLine = new LineSegment2D(new Point((int)x, (int)y), new Point(img2.Width - (int)x, img2.Height - (int)y));
//Rectangle r=new Rectangle((int)x,(int)y,2*(img2.Width-(int)x),2*(img2.Height-(int)y));
Mat ri = new Mat(2 * (img2.Width - (int)x), 2 * (img2.Height - (int)y),DepthType.Cv8U, 3);
ri.SetTo(new MCvScalar(255, 255, 255));
Point oldc = new Point((int)x, (int)y);
bool success = false; // if the tweaking is not successful, return false
// inverse y axis
// y2 = -y;
// rotation of centeroid
x -= img2.Width / 2;
y -= img2.Height / 2;//shift origin to (w/2,h/2)
_x = x * Math.Cos(angle / (180 / Math.PI)) - y * Math.Sin(angle / (180 / Math.PI));//rotate by theta
_y = x * Math.Sin(angle / (180 / Math.PI)) + y * Math.Cos(angle / (180 / Math.PI));
_x += img2.Width / 2;
_y += img2.Height / 2;//back to origin
//_x = x+img2.Width/2;
//_y = y+img2.Height/2;
// inverse y axis
//_y = -_y2;
centroid2.X = (int)_x;
centroid2.Y = (int)_y;
Point shift = new Point();
shift.X = centroid1.X - centroid2.X;
shift.Y = centroid1.Y - centroid2.Y;
MatImage m1 = new MatImage(E);
m1.Rotate(angle, new Bgr(255, 255, 255));
E = m1.Out();
MatImage m2 = new MatImage(E_mask);
m1.Rotate(angle, new Bgr(255, 255, 255));
E_mask = m2.Out();
//Find optimal size of canvas to hold both images and appropriate transformations
Point t1, t2;//transformation 1 and 2
t1 = new Point();
t2 = new Point();
int optimal_h = 0, optimal_w = 0;//of canvas(IplImage* dst)
switch (quadrant(shift))
{
case 1:
t1.X = 0;
t1.Y = 0;
t2 = shift;
optimal_h = Math.Max(img1.Height, img2.Height + shift.Y);
optimal_w = Math.Max(img1.Width, img2.Width + shift.X);
break;
case 2:
t1.X = -shift.X;
t1.Y = 0;
t2.X = 0;
t2.Y = shift.Y;
optimal_h = Math.Max(img1.Height, img2.Height + shift.Y);
optimal_w = Math.Max(img2.Width, img1.Width - shift.X);
break;
case 3:
t1.X = -shift.X;
t1.Y = -shift.Y;
t2.X = 0;
t2.Y = 0;
optimal_h = Math.Max(img1.Height - shift.Y, img2.Height);
optimal_w = Math.Max(img1.Width - shift.X, img2.Width);
break;
case 4:
t1.X = 0;
t1.Y = -shift.Y;
t2.X = shift.X;
t2.Y = 0;
optimal_h = Math.Max(img1.Height - shift.Y, img2.Height);
optimal_w = Math.Max(img2.Width + shift.X, img1.Width);
break;
}
// add tweak factor
t1.X += tweak1.X;
t1.Y += tweak1.Y;
t2.X += tweak2.X;
t2.Y += tweak2.Y;
//optimal_h = 1000;
//.........这里部分代码省略.........