本文整理汇总了C#中System.Matrix.SetRandNormal方法的典型用法代码示例。如果您正苦于以下问题:C# Matrix.SetRandNormal方法的具体用法?C# Matrix.SetRandNormal怎么用?C# Matrix.SetRandNormal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Matrix
的用法示例。
在下文中一共展示了Matrix.SetRandNormal方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestArithmatic
public void TestArithmatic()
{
Matrix<byte> m = new Matrix<byte>(10, 8);
m.SetRandNormal(new MCvScalar(), new MCvScalar(30));
Matrix<byte> mMultiplied = m.Mul(2.0);
for (int i = 0; i < m.Rows; i++)
for (int j = 0; j < m.Cols; j++)
Assert.AreEqual(m[i, j] * 2, mMultiplied[i, j]);
}
示例2: TestQuaternions1
public void TestQuaternions1()
{
Quaternions q = new Quaternions();
double epsilon = 1.0e-10;
Matrix<double> point = new Matrix<double>(3, 1);
point.SetRandNormal(new MCvScalar(), new MCvScalar(20));
using (Matrix<double> pt1 = new Matrix<double>(3, 1))
using (Matrix<double> pt2 = new Matrix<double>(3, 1))
using (Matrix<double> pt3 = new Matrix<double>(3, 1))
{
double x1 = 1.0, y1 = 0.2, z1 = 0.1;
double x2 = 0.0, y2 = 0.0, z2 = 0.0;
q.SetEuler(x1, y1, z1);
q.GetEuler(ref x2, ref y2, ref z2);
EmguAssert.IsTrue(
Math.Abs(x2 - x1) < epsilon &&
Math.Abs(y2 - y1) < epsilon &&
Math.Abs(z2 - z1) < epsilon);
q.RotatePoints(point, pt1);
Matrix<double> rMat = new Matrix<double>(3, 3);
q.GetRotationMatrix(rMat);
CvInvoke.Gemm(rMat, point, 1.0, null, 0.0, pt2, Emgu.CV.CvEnum.GemmType.Default);
CvInvoke.AbsDiff(pt1, pt2, pt3);
EmguAssert.IsTrue(
pt3[0, 0] < epsilon &&
pt3[1, 0] < epsilon &&
pt3[2, 0] < epsilon);
}
double rotationAngle = 0.2;
q.SetEuler(rotationAngle, 0.0, 0.0);
EmguAssert.IsTrue(Math.Abs(q.RotationAngle - rotationAngle) < epsilon);
q.SetEuler(0.0, rotationAngle, 0.0);
EmguAssert.IsTrue(Math.Abs(q.RotationAngle - rotationAngle) < epsilon);
q.SetEuler(0.0, 0.0, rotationAngle);
EmguAssert.IsTrue(Math.Abs(q.RotationAngle - rotationAngle) < epsilon);
q = q * q;
EmguAssert.IsTrue(Math.Abs(q.RotationAngle / 2.0 - rotationAngle) < epsilon);
q.SetEuler(0.2, 0.1, 0.05);
double t = q.RotationAngle;
q = q * q;
EmguAssert.IsTrue(Math.Abs(q.RotationAngle / 2.0 - t) < epsilon);
}
示例3: GoToNextState
public void GoToNextState()
{
Matrix<float> processNoise = new Matrix<float>(2, 1);
processNoise.SetRandNormal(new MCvScalar(), new MCvScalar(processNoise[0, 0]));
state = transitionMatrix * state + processNoise;
}
示例4: GetMeasurement
public Matrix<float> GetMeasurement()
{
Matrix<float> measurementNoise = new Matrix<float>(2, 1);
measurementNoise.SetRandNormal(new MCvScalar(), new MCvScalar(Math.Sqrt(measurementNoise[0, 0])));
return measurementMatrix * state + measurementNoise;
}
示例5: TestEigenVV
public void TestEigenVV()
{
int size = 3;
Matrix<float> tmp = new Matrix<float>(size, size);
tmp.SetRandNormal(new MCvScalar(0), new MCvScalar(1));
Matrix<float> symMat = new Matrix<float>(tmp.Size);
CvInvoke.MulTransposed(tmp, symMat, false, null, 1.0, CvEnum.DepthType.Cv32S);
Matrix<float> clone = symMat.Clone();
Matrix<float> evects = new Matrix<float>(symMat.Size);
Matrix<float> evals = new Matrix<float>(symMat.Rows, 1);
CvInvoke.Eigen(symMat, evals, evects);
}
示例6: TestRuntimeSerialize1
public void TestRuntimeSerialize1()
{
Matrix<Byte> mat = new Matrix<Byte>(100, 80, 2);
mat.SetRandNormal(new MCvScalar(100, 100, 100), new MCvScalar(50, 50, 50));
System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
formatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
Byte[] bytes;
using (MemoryStream ms = new MemoryStream())
{
formatter.Serialize(ms, mat);
bytes = ms.GetBuffer();
}
using (MemoryStream ms2 = new MemoryStream(bytes))
{
Matrix<Byte> mat2 = (Matrix<Byte>) formatter.Deserialize(ms2);
EmguAssert.IsTrue(mat.Equals(mat2));
}
}
示例7: TestEigenVV
public void TestEigenVV()
{
int size = 3;
Matrix<float> tmp = new Matrix<float>(size, size);
tmp.SetRandNormal(new MCvScalar(0), new MCvScalar(1));
Matrix<float> symMat = new Matrix<float>(tmp.Size);
CvInvoke.cvMulTransposed(tmp, symMat, 1, IntPtr.Zero, 1.0);
Matrix<float> clone = symMat.Clone();
Matrix<float> evects = new Matrix<float>(symMat.Size);
Matrix<float> evals = new Matrix<float>(symMat.Rows, 1);
CvInvoke.cvEigenVV(symMat, evects, evals, 1.0e-15, 0, 0);
}
示例8: TestBinaryStorage
public void TestBinaryStorage()
{
//generate some randome points
PointF[] pts = new PointF[120];
GCHandle handle = GCHandle.Alloc(pts, GCHandleType.Pinned);
using (Matrix<float> ptsMat = new Matrix<float>(pts.Length, 2, handle.AddrOfPinnedObject(), Marshal.SizeOf(typeof(float)) * 2))
{
ptsMat.SetRandNormal(new MCvScalar(), new MCvScalar(100));
}
handle.Free();
String fileName = Path.Combine(Path.GetTempPath(), "tmp.dat");
Stopwatch watch = Stopwatch.StartNew();
BinaryFileStorage<PointF> stor = new BinaryFileStorage<PointF>(fileName, pts);
//BinaryFileStorage<PointF> stor = new BinaryFileStorage<PointF>("abc.data", pts);
watch.Stop();
EmguAssert.WriteLine(String.Format("Time for writing {0} points: {1} milliseconds", pts.Length, watch.ElapsedMilliseconds));
int estimatedSize = stor.EstimateSize();
//EmguAssert.IsTrue(pts.Length == estimatedSize);
watch.Reset();
watch.Start();
PointF[] pts2 = stor.ToArray();
watch.Stop();
EmguAssert.WriteLine(String.Format("Time for reading {0} points: {1} milliseconds", pts.Length, watch.ElapsedMilliseconds));
if (File.Exists(fileName))
File.Delete(fileName);
//EmguAssert.IsTrue(pts.Length == pts2.Length);
//Check for equality
for (int i = 0; i < pts.Length; i++)
{
//EmguAssert.IsTrue(pts[i] == pts2[i]);
}
}
示例9: TestVectorOfMat
public void TestVectorOfMat()
{
Matrix<double> m1 = new Matrix<double>(3, 3);
m1.SetRandNormal(new MCvScalar(0.0), new MCvScalar(1.0));
Matrix<int> m2 = new Matrix<int>(4, 4);
m2.SetRandNormal(new MCvScalar(2), new MCvScalar(2));
VectorOfMat vec = new VectorOfMat(m1.Mat, m2.Mat);
Mat tmp1 = vec[0];
Mat tmp2 = vec[1];
Matrix<double> n1 = new Matrix<double>(tmp1.Size);
Matrix<int> n2 = new Matrix<int>(tmp2.Size);
tmp1.CopyTo(n1, null);
tmp2.CopyTo(n2, null);
EmguAssert.IsTrue(m1.Equals(n1));
EmguAssert.IsTrue(m2.Equals(n2));
}
示例10: GoToNextState
public void GoToNextState()
{
Matrix<float> processNoise = new Matrix<float>(2, 1);
processNoise.SetRandNormal(new MCvScalar(), new MCvScalar(Math.Sqrt(ProcessNoise[0, 0])));
_state = TransitionMatrix * _state + processNoise;
}
示例11: GoToNextState
public void GoToNextState()
{
var processNoise = new Matrix<float>(4, 1);
processNoise.SetRandNormal(new MCvScalar(), new MCvScalar(processNoise[0, 0]));
State = TransitionMatrix * State + processNoise;
}