坐标空间树
3DAlignLego.cdb上附加的坐标系
数据类型:CogImage16Range(500*600)
2D/3D | 浮动显示 | 映射点的函数 |
---|---|---|
2D | * | 无 |
2D | *\# | # |
2D | *\#\@ | @ |
2D | *\#\@\Sensor2D | @\Sensor2D |
3D | *\# | # |
3D | *\#\@ | @ |
3D | *\#\@\Sensor3D | @\Sensor3D |
一般情况下,#与@的坐标值相同,Sensor2D与Sensor3D的x、y相同
注意:
坐标系 | 含义 | 是否在坐标空间树中 | 是否能坐标映射 |
---|---|---|---|
* | 显示pixel space,只能在绘图时使用 | 没有 | 没有 |
# | Pixel space | 没有 | 有 |
@ | Root space | 有 | 有 |
示例代码(C#):1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36CogImage16Range InputImage = mToolBlock.Inputs[0].Value as CogImage16Range;
// 坐标空间树
CogCoordinateSpaceTree Tree2D = InputImage.CoordinateSpaceTree;
Cog3DCoordinateSpaceTree Tree3D = InputImage.CoordinateSpaceTree3D;
// 2D坐标空间树的节点
string tree2D_root = Tree2D.RootName; //即@
CogStringCollection tree2D_childs_root = Tree2D.AllChildNames(tree2D_root, CogSpaceTreePathnameConstants.Full, false);
// 3D坐标空间树的节点
string tree3D_root = Tree3D.RootName; //即@
List<string> tree3D_childs_root = Tree3D.AllChildNames(tree3D_root, CogSpaceTreePathnameConstants.Full, false);
Cog3DVect2 point2D;
Cog3DVect3 point3D;
bool pixelUsed;
// 在坐标系空间树中映射坐标:2D点->3D点
point2D = new Cog3DVect2(0, 0);
point3D = new Cog3DVect3();
InputImage.MapPoint3DFrom2D(dst3DspaceName, src2DspaceName, point2D, out pixelUsed, out point3D);
// 在坐标系空间树中映射坐标:3D点->2D点
point2D = new Cog3DVect2();
point3D = new Cog3DVect3(0, 0, 0);
InputImage.MapPoint2DFrom3D(dst2DspaceName, src3DspaceName, point3D, out point2D);
// 验证#是否在坐标空间树中
string res_LookUpName = Tree2D.LookUpName("#", CogSpaceTreePathnameConstants.Full);
CogStringCollection res_FindNames = Tree2D.FindNames("#");
// 获取两个坐标系之间的转换关系
ICog3DTransform trans_3d_tree = Tree3D.GetTransform("Sensor3D", "@"); // ToSpaceName、FromSpaceName
ICog3DTransform trans_3d_img = InputImage.GetTransform3D("Sensor3D", "@");
ICogTransform2D trans_2d_tree = Tree2D.GetTransform("Sensor2D", "@");
ICogTransform2D trans_2d_img = InputImage.GetTransform("Sensor2D", "@");
另:导出点云数据的示例代码(C#):1
2
3
4
5
6string dst3DspaceName = "Sensor3D";
string src2DspaceName = "#";
Cog3DVect2 point2D = new Cog3DVect2(0, 0);
Cog3DVect3 point3D = new Cog3DVect3();
bool pixelUsed;
InputImage.MapPoint3DFrom2D(dst3DspaceName, src2DspaceName, point2D, out pixelUsed, out point3D);
参考
参考内容 | 参考方面 |
---|---|
Cognex VisionPro 9.1的示例作业:3D Align | 主体思路 |