如何计算每个轮廓中的白色像素

发布于 2025-01-26 08:52:13 字数 524 浏览 2 评论 0原文

我有一种算法来计算视频中的人数。这是一个概念:

背景减法>阈值> Canny> FindContour>总结每个轮廓中的白色像素,然后将它们变为数组列表。

所以,我希望输出变为eskexpLearRay = [总和右框中的像素的数量,总和左框中的像素的数量]

完成此操作

line=[]

for area in cv2.contourArea(cnt):

    count=np.sum(box == 255)
    line.append(count)

我想我可以使用此代码来 当然,代码是错误,说只能在Interger中迭代而不是浮动。除此之外,我还不确定我的代码。

I have an algorithm to count the number of people in video. Here is the concept:

background subtraction > Thresholding > canny > findcontour > sum the white pixel in each contour and make them to array list.

enter image description here

So, I want the output becomes examplearray = [sum the number of pixel in right box, sum the number of pixel in left box]

I think I can do it with this code

line=[]

for area in cv2.contourArea(cnt):

    count=np.sum(box == 255)
    line.append(count)

but I'am not sure, the code is error saying can only iterate in interger not float. Other than that, I'am not sure about my code yet.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文