How to use Raspberry Pi 3B+ to display webcam video on ili9341 2.8" display?

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
prayag.shethia
Posts: 1
Joined: Wed Oct 06, 2021 6:37 am

How to use Raspberry Pi 3B+ to display webcam video on ili9341 2.8" display?

Post by prayag.shethia » Wed Oct 06, 2021 6:49 am

Hiya there,
In a current project, I am using a raspberry pi 3b+ connected to a 2.8" cap touch spi ili9341 display. For that, I am wanting to display the video footage from my pycam on the SPI display to be very fast. Currently, I am using the openCV library to capture the video, save it and then capture each frame, resize and reposition it to then be displayed on the display. The video on the display is extremely slow and I struggled extremely to find a library to do this at 60 fps or near that speed. My current code is:
---------------------------------------------------------------
cap = cv2.VideoCapture('test.MP4')
while True:
ret,image = cap.read()

h,w,c = image.shape
image_ratio = w / h
screen_ratio = width / height
if screen_ratio < image_ratio:
scaled_width = w* height // h
scaled_height = height
else:
scaled_width = width
scaled_height = h* width // w
image = cv2.resize(image,dsize=(scaled_width, scaled_height), interpolation=cv2.INTER_CUBIC)
#
# # Crop and center the image
x = scaled_width // 2 - width // 2
y = scaled_height // 2 - height // 2
image = image[0:240,0:320]

# Display image.
image = Image.fromarray(image)
disp.image(image)
---------------------------------------------------------------
Anyone know how to do this or please please can you help me? Thanks in advance!

User avatar
pythoncoder
Posts: 5956
Joined: Fri Jul 18, 2014 8:01 am
Location: UK
Contact:

Re: How to use Raspberry Pi 3B+ to display webcam video on ili9341 2.8" display?

Post by pythoncoder » Wed Oct 06, 2021 7:53 am

This forum is probably not the best place for this query. We deal with queries about MicroPython running on microcontrollers so it's doubtful if anyone here has relevant experience. Try a Raspberry Pi forum.
Peter Hinch
Index to my micropython libraries.

Post Reply