我认为 的值z应该是 40,因为a[5]有 20 个元素,并且 和 之间的空间a[3]也有 20 个元素。然而,实际值z是2。
谁能解释一下这个概念?
#include <stdio.h>
int main()
{
int a[10][20];
int z = &a[5] - &a[3];
printf("%d\n", &a[3]); // the address information is 6421740
printf("%d\n", &a[5]); // the address information is 6421900
printf("%d\n", z); // z value is 2. why?
}
Run Code Online (Sandbox Code Playgroud) 我想使用 cv2.minAreaRect 来获取最大轮廓,如下图所示。

cnt, hierarchy = cv2.findContours(im_bw, cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
min_rect = cv2.minAreaRect(cnt[0])
box = np.int0(cv2.boxPoints(min_rect))
cv2.drawContours(temp_result, [box], 0, (255, 0, 0), 2)
Run Code Online (Sandbox Code Playgroud)
我参考这篇文章来获取绘图的有序坐标。但是,我得到了以下结果,其中线条不匹配,并且四个点不能与 cv2.minAreaRect 一起使用。

def order_points(pts):
# initialzie a list of coordinates that will be ordered
# such that the first entry in the list is the top-left,
# the second entry is the top-right, the third is the
# bottom-right, and the fourth is the bottom-left
rect …Run Code Online (Sandbox Code Playgroud)