小编Cre*_*eek的帖子

减去地址引用是如何工作的?

我认为 的值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)

c arrays pointer-arithmetic memory-address

3
推荐指数
1
解决办法
88
查看次数

即使图像有破损区域,如何使用 cv2.minAreaRect 获得最大轮廓?

这是原始图像。 在此输入图像描述

我想使用 cv2.minAreaRect 来获取最大轮廓,如下图所示。 在此输入图像描述

尝试 1 - 失败

在此输入图像描述

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)

尝试 2 - 失败

我参考这篇文章来获取绘图的有序坐标。但是,我得到了以下结果,其中线条不匹配,并且四个点不能与 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)

opencv image-processing

0
推荐指数
1
解决办法
423
查看次数