【发布时间】:2018-02-02 08:04:58
【问题描述】:
首先,感谢您抽出宝贵时间。我试图了解下面显示的特定代码试图将它们转换为 python 的目的。第一行是将内存分配给我知道python没有的指针(aPointContour)。第二行是在 iContourLenght 中获取随机数。第三行将值 (2*aPointContour[iRandomPoint1].x + aPointContour[iRandomPoint1].y) 分配给第 0 行第 0 列的矩阵 (pMatA)。
我的问题:
1) "aPointContour[iRandomPoint1].x" 试图做什么?
2) .x .y 的用途?
我的想法:
1) 访问指针“aPointContour”内位于“iRandomPoint1”的内存。需要放入矩阵“pMatA”的值为“2*iRandomPoint1”,根据下面的代码访问内存不应该给我们“iRandomPoint1”的值吗?
2) .x 和 .y 是 Cvpoint 的一部分还是一般用作指针“aPointContour”的成员?如果它是一个成员,它将仅用于参考目的还是具有实际数学意义?
我很抱歉发了这么长的帖子,真的希望有人能帮助我。谢谢你任何好心的先生或女士! :)
// C++
CvPoint *aPointContour = (CvPoint *) malloc(sizeof(CvPoint) * iContourLength);
iRandomPoint1 = (int)((double)rand() / ((double)RAND_MAX + 1) * iContourLength);
cvmSet(pMatA, 0, 0,2* aPointContour[iRandomPoint1].x + aPointContour[iRandomPoint1].y)
【问题讨论】:
标签: c++ pointers malloc member-function-pointers