Display image on brain

The documentation makes this seem straightforward (Python Brain Screen Guide for VEX IQ (2nd-gen) | Vex.com — VEXcode Documentation), but I’m at a loss for what I’m doing wrong. How do you get the brain to display an image? I’ve tried Python and C++, and many different images: bmp and png.

brain.screen.draw_image_from_file("vex_logo.png", 0, 0)

I’ve confirmed that the file is found on the sdcard using:
brain.sdcard.exists("vex_logo.png")

What am I missing?

The image is too large. IQ has limited memory, images are limited to 80x50 (could be 80x64, I forget exactly)

3 Likes

Thanks for your reply.

I tried resizing the file to 80x50px but same result. I also tried making simple drawings that were 20x20px.

No matter what, when I run the code from VSCode, the terminal reports “False”.

# Library imports
from vex import *

# Brain should be defined by default
brain=Brain()

filename = "vex_logo_small.png"
print("WELCOME")
if (brain.sdcard.is_inserted()):
    print("sdcard is inserted")
if brain.sdcard.exists(filename):
    print("file exists")

brain.screen.draw_image_from_file(filename, 0, 0)


vex_logo_small

1 Like

Ok I made another 20x20px image and the bmp version of it does work but the png does not. The run timer at the top left of the brain just locks at 0:00 when the png is loaded.

That file is 4,698 bytes, whereas another bmp I made is 6162 bytes and does not work. Maybe 5kB is the limit?

Kind of a bummer. I thought you’d be able to fill the screen, especially with a simple B&W image.

1 Like

There is a file size limit, but it should be much more than 5k. I’ll look up what it is later in the week when I get a chance.

1 Like

and now you mention it, IQ may not support png at all. V5 and EXP do, but IIRC there was not enough memory for decompression buffers used by zlib on IQ.

1 Like

It might not work (made for V5) but this could help.

1 Like

i have tried it from last year, and every method didn’t help.
but, you can resize the image to vex iq brain screen size (maybe 107x50 or sth so, i don’t remember it), then let opencv read your image and return a list of color of each pixel, then let your iq code read through the list and display it (although it may slow, about 3-4 second to load in python, faster in c++)
another method is just use the math to draw your picture (if it simple or you are a pro). i have draw vietnam flag onto my vex iq brain and use it in competition

1 Like

@56860A Thanks for sharing this. Very interesting approach, but I couldn’t get it to work. I’m assuming it has to do with the IQ brain having a smaller resolution than 480x240.

arm-none-eabi-ld: build/cpp.elf section `.rodata' will not fit in region `SRAM_1_2_3'
arm-none-eabi-ld: region `SRAM_1_2_3' overflowed by 36768 bytes
vex/mkrules.mk:17: recipe for target 'build/cpp.elf' failed
make: *** [build/cpp.elf] Error 1

@pham_tuyen It sounds like your solution is similar to the one above, but custom for the IQ brain. Maybe I’ll give this a try, but I was hoping for a one-liner that my middle school students could understand and have some fun with.

Not enough memory to build the code, you were short by about 36k.

I got around to looking up the limitations for image display on IQ2.
Max image size is 80x64 or some combination that multiplies to 5120 or less.
max file size is 6k bytes.
only .bmp images supported, I would suggest 8 bit RLE encoded for minimum file size.

3 Likes