Question: Hi ! When I run this code, it just shows the gui and a frozen display where it should've continuously show the display from the
Hi
When I run this code, it just shows the gui and a frozen display where it should've continuously show the display from the rasapberry pi camera lens. Currently learning Yolov object detection in realtime use of picamera module is a must in the latest python update in raspberry pi Please show me how I can continuously run the camera of the raspberry pi so that it can detect object in realtime. This code is running in raspberry pi bit Bullseye system and I am using raspberry pi camera v Thank you so much to the person that will help me solve this camera problem
The code run in Thonny:
import tkinter as tk
from tkinter import Label, Frame
import torch
from picamera import Picamera
import numpy as np
from PIL import Image, ImageTk
model torch.hub.loadultralyticsyolov 'custom', path'yolovbestptforcereloadTrue
model.conf
app tkTk
app.geometryx
app.titleGUI
label Labelapp text'detectionTest', fontArial
labelpackside'top', pady
vidframe Frameheight width
vidframe.pack
vid Labelvidframe
vid.pack
camera Picamera
cameraconfig camera.createpreviewconfigurationmainsize:
camera.configurecameraconfig
camera.start
def detect:
while True:
request camera.capturerequest
frame request.makearraymain
results modelframe
outputimage npsqueezeresultsrender
displayimage Image.fromarrayoutputimage
imgtk ImageTk.PhotoImageimagedisplayimage
vid.imgtk imgtk
vid.configureimageimgtk
vid.after detect
break
detect
app.mainloop
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
