# Getting IDE to display the most recent image

**URL:** <https://forums.openmv.io/t/getting-ide-to-display-the-most-recent-image/11306>\
**Category:** OpenMV Boards\
**Created:** [August 4, 2025, 9:01pm UTC](https://forums.openmv.io/t/getting-ide-to-display-the-most-recent-image/11306 "2025-08-04T21:01:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![CobraMike](https://avatars.discourse-cdn.com/v4/letter/c/ad7895/32.png) [@CobraMike](https://forums.openmv.io/u/CobraMike)\
**Post date:** [August 4, 2025, 9:01pm UTC](https://forums.openmv.io/t/getting-ide-to-display-the-most-recent-image/11306/1 "2025-08-04T21:01:17Z")

</div>

I am trying to troubleshoot my code, but I am having issues due to the IDE not displaying the most recent snapshot image, which I am adding lines to with draw\_line. I am getting an image displayed but I think it is likely the next to last image and not the one that I am trying to trouble shoot. Below is an abbreviated version of my code, and I need to have the most recent img snapshot with the added draw\_lines at the time of the sys.exit.

```auto
import sys
from pyb import UART

# UART 3, and baudrate - this is the communication channel
uart = UART(3, 115200, timeout_char=200)

sensor.reset() # Reset and initialize the sensor.
sensor.set_pixformat(sensor.GRAYSCALE) # Set pixel format to RGB565 (or GRAYSCALE)
sensor.set_framesize(sensor.SVGA) # Set frame size to SVGA (800x600)
sensor.set_auto_exposure(False, exposure_us=1000)
sensor.skip_frames(time=500) # Wait for settings take effect.
clock = time.clock() # Create a clock object to track the FPS.

rec_code = 0 #this will contain the sheet count received
send_code = 0 #this will contain the outgoing positioning pixel
code_ready = 0 #ready indicator
test = 1 #set to 1 to run continuously for testing, 0 for regular operation

def get_data(rec_code,code_ready):
	#code removed

def send_data(send_code,code_ready):
	#code removed

def main(rec_code,pic_cnt):
	#code removed
    print(sheet_width)
    print(gaps)
    print(sheets)
    print("xxx")
    map_var = 0
    img.to_rgb565() #change image to colro so colored lines can be added
    for q_pos,q in enumerate(sheets):
        if q_pos == rec_code-1:
            map_var = q
            img.draw_line((300,q,500,q), color=(50, 0, 205)) #add purple line for sheet being sent back
        else:
            img.draw_line((300,q,500,q), color=(255, 0, 0)) #add red lines at other sheets
    if map_var > 440:
        sensor.flush()
        sys.exit()

while True:

    if uart.any(): #"listen" for go signal, then call get_data
        rec_code,code_ready = get_data(rec_code,code_ready)

    if test: #set test to 1 to allow to run without incoming go signal
        rec_code = 16
        code_ready = 1

    if code_ready != 0: #good go signal received
        send_code = main(rec_code) # call main function to find sheets (does all the work)
        rec_code,code_ready = send_data(send_code,code_ready)

```

Thanks,

Mike

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [August 4, 2025, 9:14pm UTC](https://forums.openmv.io/t/getting-ide-to-display-the-most-recent-image/11306/2 "2025-08-04T21:14:08Z")

</div>

Hi, flush() is async… so, when you call sys.exit() the script will end before the flushed image is pulled by the IDE.

Add a 1-2 second delay before sys.exit() to allow the IDE time to pull the frame.
