仅在经过一定数量的帧后才增加值

发布于 2025-01-20 03:08:59 字数 631 浏览 2 评论 0原文

我最近写了一个程序,该程序使我正在绘制数字信号。这很简单:

def plotdigital(Af):
    arraysbinary = []
    blinkcheck = False
    for i in Af:
        if i >  -15 and blinkcheck == False:
            arraysbinary.append(1)
            blinkcheck = True
        else:
            arraysbinary.append(0)
    return arraysbinary

AF是我正在处理的信号,我是当前的元素。因此,每当我达到-15的值时,我都会将1附加到阵列比率。该信号是一种眼球跟踪器,有时会将一个眨眼算作两个单独的眨眼,就像彼此非常近的两个单独的眨眼:1 1 1 1 0 0 0 0 1 1 1 1 1 1 我的目标是一旦我检测到i,就不允许该程序检测另一个I> 15在检测到第一个帧后,大约20帧,从而确保每个眨眼都被视为一个,而不是两个单独的闪烁。我已经开始使用一个布尔值进行解决方案,一旦检测到I> 15,它应该切换到True,但是我似乎无法完成该程序的关闭,因此在接下来的20帧中它切换到False(I +20)。欢迎任何建议!

I recently wrote a program that makes a signal I'm plotting digital. It's pretty straight forward:

def plotdigital(Af):
    arraysbinary = []
    blinkcheck = False
    for i in Af:
        if i >  -15 and blinkcheck == False:
            arraysbinary.append(1)
            blinkcheck = True
        else:
            arraysbinary.append(0)
    return arraysbinary

Af is the signal I'm working on and i is the current element. So whenever i reaches the value of -15 I append 1 to the arraysbinary. The signal is an eye-tracker and it sometimes counts one blink as two separate ones very close to each other like so: 1 1 1 0 0 0 1 1 1 1
My goal is once I detect an i to not allow the program to detect another i> 15 for about 20 frames after it's detected the first one, thus ensuring that each blink is counted as one and not as two separate ones. I've started working on a solution with a boolean that is supposed to switch to True once an i>15 has been detected, but I can't seem to finish the program off so it switches to False for the next 20 frames (i+20). Any suggestions are welcome!

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

波浪屿的海角声 2025-01-27 03:08:59

您应该将索引值放入最小连续帧阈值的 if 条件中。见下文:

frame_threshold = 2
def plotdigital(Af):
    arraysbinary = []
    last_blink_checkpoint = 0
    for (index, value) in enumerate(Af):
        if value > 5 and last_blink_checkpoint + frame_threshold < index:
            arraysbinary.append(1)
            last_blink_checkpoint = index
        else:
            arraysbinary.append(0)
    return arraysbinary

test = [1,2,23,4,4,5,6,6,7,8,6,9,453,0,45,4,8,5,4,3,4,34,63,46,34]

print(plotdigital(test))

注意:我使用了与您不同的比较值,请根据您的用例进行更改。

You should put the index value in if condition for your min consecutive frame threshold. See below:

frame_threshold = 2
def plotdigital(Af):
    arraysbinary = []
    last_blink_checkpoint = 0
    for (index, value) in enumerate(Af):
        if value > 5 and last_blink_checkpoint + frame_threshold < index:
            arraysbinary.append(1)
            last_blink_checkpoint = index
        else:
            arraysbinary.append(0)
    return arraysbinary

test = [1,2,23,4,4,5,6,6,7,8,6,9,453,0,45,4,8,5,4,3,4,34,63,46,34]

print(plotdigital(test))

Note: I have used a different comparison value than yours, please change it as per your use case.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文