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 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.

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.

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.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)

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)


    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:
        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:

            listyy_ = np.mean(np.array(listy))

        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)):

        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
            outfit = np.polyfit(np.array(nplistyyfit), 2)
            fitout_state = False
            print("more degrees of freedom than data points")
        if(fitout_state == True):
            if(outfit[0] >= 0):
        img.draw_rectangle(blob.rect(),color = (255,0,0))
    if(len(blob_state) == 0):
    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))
          state_str = "UP"
          img.draw_string(0,0,"UP:"+str(int(outfit[0])),scale = 2,color = (255,255,255))

        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))
            state_str = "UP"
            img.draw_string(0,0,"UP:",scale = 2,color = (255,255,255)


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