Make GUI program for webcam feed display and post image-processing display

I’m currently making a defect inspection GUI using QtDesigner and PySide6. my goals is to display a webcam’s capture in a Qlabel name oriCamLabel while on the other side, I also need to display an image processing result of the webcam capture with the following process:

  1. take the original webcam feeds
  2. processed the feeds (Grayscale, roi extract, blob analysis etc) using openCV
  3. display the result by real time in a different Qlabel named ProcessedCamLabel
  4. also displaying the captured image where it produce defects in Qlabel ResultDisplaylabel

But I hardly find the clear instruction tutorial/guide of using PySide6 especially in VSCode to help me achieve my project goals above.

Image of My GUI

I already utilize the QThread class to display the webcam feed (which is a good practice i guess so that my GUI wouldn’t freeze(?)). do not mind the complex camidx things, it’s a matter of adjusting between Qcombobox index and the actual camera index which is not a problem for now.

class ThreadClass(QThread):
    ImageUpdate = Signal(QImage)
    global camIndex

    def run(self):
        camidx = camIndex
        Capture = cv2.VideoCapture(camidx, cv2.CAP_DSHOW)

        if camidx == 0:
            camidx+=1
            Capture = cv2.VideoCapture(camidx,cv2.CAP_DSHOW)

        elif camidx == 1:
            camidx-=1
            Capture = cv2.VideoCapture(camidx,cv2.CAP_DSHOW)
        
        self.ThreadActive = True

        while self.ThreadActive:
            global ret, frame
            ret, frame = Capture.read()
            
            if ret:
                frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
                flipped = cv2.flip(src=frame, flipCode=1)
                ConvertQtFormat = QImage(flipped.data,flipped.shape[1],flipped.shape[0], QImage.Format.Format_RGB888)
                pic = ConvertQtFormat.scaled(640,480)
                self.ImageUpdate.emit(pic)
               
    def stop(self):
        self.ThreadActive = False
        self.quit()

What the actual problem is I would like to ask is, should I have a two different threads, one for the direct webcam display and another one for the image processing? or i can use the same thread with just a tweak in the later function definition? i still don’t understand how to pass the image/frame after capturing to another image processing function and then displaying it in a different display Qlabel widget. here’s my function definition inside mainWindow

class mainWindow(QMainWindow, Ui_MainWindow,ThreadClass):
   def __init__(self):
   .....
        self.StartButton.clicked.connect(self.StartCam)
        self.InspectButton.clicked.connect(self.ImageProcessing)
   .....

   def StartCam(self):
        self.StartButton.setDisabled(True)
        self.StopButton.setDisabled(False)

        self.Worker_CV1 = ThreadClass()
        self.Worker_CV1.ImageUpdate.connect(self.openCV_emit)
        self.Worker_CV1.start()
   .....

   def openCV_emit(self, Image):
        self.OriCamlabel.setPixmap(QPixmap.fromImage(Image))
   .....

   def ImageProcessing(self):
        self.statsLabel.setText("Inspecting")
        *#I don't know the rest to put here*

New contributor

zhilaanabdrsyd is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật