RuntimeError:Frame capture has timed out

I run a program in half an hour after this error, and the error is not an accident, I met in different openmv, and time after running for half an hour to an hour, probably the most part is in the running for half an hour later, I there are about 150 lines of code, at first, I think is long running the cause of memory fragmentation,My firmware version is 4.2.1, OpenMV4 H7, RAM 2Mbyte


I tried the firmware version 4.1.4 today and this error occurred again after running it for 20 minutes。
RuntimeErroe:Frame capture has timed out

This is the mem message output before the crash

And I ran ir_beacon_grayscale_tracking.py without error with runing 2 hours

Frame capture timeout is generated by the camera frame grabber process not getting a frame after 3000ms. It’s not a memory error. If it was a memory error you’d get that. This happens because something related to the camera sensor crashed.

1 Like

What is the reason, I have this problem on different openmv, is it related to the grayscale image? When I replaced the grayscale image in the code with a binary image, this problem did not seem to pop up, and now the error is generally popped up It takes 30 minutes to run, so I’m pretty sure my changes are correct and it’s hard to find where the problem is.

Snipaste_2022-02-20_22-05-31
Now I changed the code a little bit, but the problem popped up at 21 minutes

Please post a minimal, self-contained example script that shows the issues.

import uio ,os
import sensor, image, time, math, pyb
from pyb import LED,Pin
from ulab import numpy as np

sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 200)
sensor.set_auto_gain(False) # must be turned off for color tracking
sensor.set_auto_whitebal(False) # must be turned off for color tracking
p_out = Pin('P7', Pin.OUT_PP)

STATE_STR0 = "DOWN"
STATE_STR1 = "UP"
mythreshold = 215

time_temp = -1
def Timelog():
    global time_temp
    if time_temp != int(pyb.millis()/1000/60):
        time_temp = int(pyb.millis()/1000/60)
        print (time_temp)

while(True):

    img = sensor.snapshot()
    statiss = []
    blob_state = []
    blob_width =[]
    fitout_state = True
    state_str = STATE_STR0

    for blob in img.find_blobs([(mythreshold,255)], pixels_threshold=120, area_threshold=150, merge=False):
        blob_width_ = blob.w()
        blob_w_h = blob.w()/blob.h()
        if  blob_w_h > 6 or blob_w_h < 0.5:
            continue
        listyy = []
        for i in range(blob.w()):
            listy = []
            for j in range(blob.h()):
                listy_number_ = img.get_pixel(blob.x()  + i ,blob.y() + j)
                if listy_number_ >= mythreshold:
                    listy.append(blob.h()-j)

            listyy_ = np.mean(np.array(listy))
            listyy.append(listyy_*300)

        nplistyy = np.array(listyy)
        nplistyydiff = np.diff(nplistyy)/100
        deletekk = []

        for k in range(nplistyydiff.size()):
            if(nplistyydiff[k] > 0.5*np.std(nplistyydiff) or nplistyydiff[k]<-0.5*np.std(nplistyydiff)):
                deletekk.append(k)
                deletekk.sort()

        for p in reversed(deletekk):
            del listyy[p]

        lenyy_o = len(listyy) -1
        lenyy_d = int(lenyy_o*0.09)
        for pp in range(lenyy_d):
            del listyy[lenyy_o - pp]

        for pp in range(lenyy_d):
            del listyy[0]

        nplistyyfit = np.array(listyy)
        fitout_state = True
        try:
            outfit = np.polyfit(np.array(nplistyyfit), 2)
        except:
            fitout_state = False
            print("more degrees of freedom than data points")
        if(fitout_state == True):
            if(outfit[0] >= 0):
                blob_state.append(1)
            else:
                blob_state.append(0)
            blob_width.append(blob_width_)
        img.draw_rectangle(blob.rect(),color = (255,0,0))
    if(len(blob_state) == 0):
        pass
    elif(len(blob_state) == 1):
      if blob_state[0] == 0:
          state_str = "DOWN"
          img.draw_string(0,0,"DOWN:"+str(int(outfit[0])),scale = 2,color = (255,255,255))
      else:
          state_str = "UP"
          img.draw_string(0,0,"UP:"+str(int(outfit[0])),scale = 2,color = (255,255,255))

    else:
        temp_ = np.array(blob_width,dtype = np.uint8)
        index_width = np.argsort(temp_,axis=0)
        blob_state2 = blob_state[index_width[-1]]
        img.draw_string(0,0,"UP:",scale = 2,color = (255,255,255))
        if blob_state2 == 0:
            state_str = "DOWN"
            img.draw_string(0,0,"DOWN:",scale = 2,color = (255,255,255))
        else:
            state_str = "UP"
            img.draw_string(0,0,"UP:",scale = 2,color = (255,255,255)

    Timelog()

Finding a script short enough to show problems can be difficult.There was an error in my code after about 30 minutes of running.During the process, you need to make sure that the program is in FindBlob, so make sure that the camera field of view is as large as possible, so that it is more likely to jump out of this error. I am using the USB power of the PC
thanks