本文整理汇总了C#中Mat.convertTo方法的典型用法代码示例。如果您正苦于以下问题:C# Mat.convertTo方法的具体用法?C# Mat.convertTo怎么用?C# Mat.convertTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mat
的用法示例。
在下文中一共展示了Mat.convertTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: convert_image
Mat convert_image (Mat im)
{
Mat I = null;
if (im.channels () == 1) {
if (im.type () != CvType.CV_32F) {
I = new Mat ();
im.convertTo (I, CvType.CV_32F);
} else {
I = im;
}
} else {
if (im.channels () == 3) {
Mat img = new Mat ();
Imgproc.cvtColor (im, img, Imgproc.COLOR_RGBA2GRAY);
if (img.type () != CvType.CV_32F) {
I = new Mat ();
img.convertTo (I, CvType.CV_32F);
} else {
I = img;
}
} else {
Debug.Log ("Unsupported image type!");
}
}
Core.add (I, new Scalar (1.0), I);
Core.log (I, I);
return I;
}
示例2: estimatePosition
/// <summary>
/// Estimates the position.
/// </summary>
/// <param name="detectedMarkers">Detected markers.</param>
void estimatePosition (List<Marker> detectedMarkers)
{
for (int i=0; i<detectedMarkers.Count; i++) {
Marker m = detectedMarkers [i];
Mat Rvec = new Mat ();
Mat Tvec = new Mat ();
Mat raux = new Mat ();
Mat taux = new Mat ();
Calib3d.solvePnP (m_markerCorners3d, new MatOfPoint2f (m.points.toArray ()), camMatrix, distCoeff, raux, taux);
raux.convertTo (Rvec, CvType.CV_32F);
taux.convertTo (Tvec, CvType.CV_32F);
Mat rotMat = new Mat (3, 3, CvType.CV_64FC1);
Calib3d.Rodrigues (Rvec, rotMat);
m.transformation.SetRow (0, new Vector4 ((float)rotMat.get (0, 0) [0], (float)rotMat.get (0, 1) [0], (float)rotMat.get (0, 2) [0], (float)Tvec.get (0, 0) [0]));
m.transformation.SetRow (1, new Vector4 ((float)rotMat.get (1, 0) [0], (float)rotMat.get (1, 1) [0], (float)rotMat.get (1, 2) [0], (float)Tvec.get (1, 0) [0]));
m.transformation.SetRow (2, new Vector4 ((float)rotMat.get (2, 0) [0], (float)rotMat.get (2, 1) [0], (float)rotMat.get (2, 2) [0], (float)Tvec.get (2, 0) [0]));
m.transformation.SetRow (3, new Vector4 (0, 0, 0, 1));
// Debug.Log ("m.transformation " + m.transformation.ToString ());
Rvec.Dispose ();
Tvec.Dispose ();
raux.Dispose ();
taux.Dispose ();
rotMat.Dispose ();
}
}