<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[OpenCV and PyQt5 window position]]></title><description><![CDATA[<p dir="auto">Hey all, I'm trying to position my camera feed window in the same window of my application, specifically inside the camera frame widget. Currently the camera feed opens in a separate window.</p>
<p dir="auto">My question is how would I go about positioning the camera feed in the same window?<br />
Do your best to ignore some of the variable names as i've scraped some things out from current project.</p>
<pre><code># -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'camera.ui'
#
# Created by: PyQt5 UI code generator 5.13.0
#
# WARNING! All changes made in this file will be lost!

import cv2
from PyQt5 import QtCore, QtGui, QtWidgets


class Capture():
    def __init__(self):
        self.capturing = False
        self.c = cv2.VideoCapture(0) #where camera feed is pulled from

    def startCapture(self):
        print ("pressed start")
        self.capturing = True
        cap = self.c
        while(self.capturing):
            ret, frame = cap.read()
            cv2.imshow("Capture", frame)
            cv2.waitKey(5)
        cv2.destroyAllWindows()
        
    def endCapture(self):
        print ("pressed End")
        self.capturing = False

class Ui_Camera(object):
    def setupUi(self, Camera):
        self.capture = Capture()
        Camera.setObjectName("Camera")
        Camera.resize(1099, 623)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(Camera.sizePolicy().hasHeightForWidth())
        Camera.setSizePolicy(sizePolicy)
        self.centralwidget = QtWidgets.QWidget(Camera)
        self.centralwidget.setObjectName("centralwidget")
        self.ControlBox = QtWidgets.QGroupBox(self.centralwidget)
        self.ControlBox.setGeometry(QtCore.QRect(590, 20, 491, 571))
        self.ControlBox.setTitle("")
        self.ControlBox.setObjectName("ControlBox")
        self.groupBox_4 = QtWidgets.QGroupBox(self.ControlBox)
        self.groupBox_4.setGeometry(QtCore.QRect(10, 20, 231, 251))
        self.groupBox_4.setAlignment(QtCore.Qt.AlignCenter)
        self.groupBox_4.setObjectName("groupBox_4")
        self.zoom_out = QtWidgets.QPushButton(self.groupBox_4)
        self.zoom_out.setGeometry(QtCore.QRect(20, 70, 75, 23))
        self.zoom_out.setObjectName("zoom_out")
        self.zoom_out.clicked.connect(self.capture.endCapture)
        self.Camera_start = QtWidgets.QPushButton(self.groupBox_4)
        self.Camera_start.setGeometry(QtCore.QRect(20, 20, 75, 23))
        self.Camera_start.setObjectName("Camera_start")
        self.Camera_start.clicked.connect(self.capture.startCapture)
        
        self.groupBox_6 = QtWidgets.QGroupBox(self.centralwidget)
        self.groupBox_6.setGeometry(QtCore.QRect(10, 20, 571, 571))
        self.groupBox_6.setAlignment(QtCore.Qt.AlignCenter)
        self.groupBox_6.setObjectName("groupBox_6")
        self.cameraFrame = QtWidgets.QFrame(self.groupBox_6)
        self.cameraFrame.setGeometry(QtCore.QRect(10, 30, 551, 521))
        self.cameraFrame.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.cameraFrame.setFrameShadow(QtWidgets.QFrame.Raised)
        self.cameraFrame.setObjectName("cameraFrame")
        Camera.setCentralWidget(self.centralwidget)
        self.statusbar = QtWidgets.QStatusBar(Camera)
        self.statusbar.setObjectName("statusbar")
        Camera.setStatusBar(self.statusbar)

        self.retranslateUi(Camera)
        QtCore.QMetaObject.connectSlotsByName(Camera)

    def retranslateUi(self, Camera):
        _translate = QtCore.QCoreApplication.translate
        Camera.setWindowTitle(_translate("Camera", "Camera"))
        self.groupBox_4.setTitle(_translate("Camera", "Camera"))
        self.zoom_out.setText(_translate("Camera", "Stop"))
        self.Camera_start.setText(_translate("Camera", "Start"))
        self.groupBox_6.setTitle(_translate("Camera", "Camera Feed"))


if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    Camera = QtWidgets.QMainWindow()
    ui = Ui_Camera()
    ui.setupUi(Camera)
    Camera.show()
    sys.exit(app.exec_())


</code></pre>
]]></description><link>https://forum.qt.io/topic/106113/opencv-and-pyqt5-window-position</link><generator>RSS for Node</generator><lastBuildDate>Wed, 12 Aug 2026 23:30:10 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/106113.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 21 Aug 2019 20:01:49 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to OpenCV and PyQt5 window position on Wed, 21 Aug 2019 23:23:52 GMT]]></title><description><![CDATA[<p dir="auto">Great! honestly not a fan of the Designer more so because I have not quite taken the time to fully understand it, basically what i'm trying to accomplish is just a user interface that displays an openCV stream while also having buttons on the side within the same window. My end goal is to also have this scale-able to full screen but that can come later.</p>
<p dir="auto">I didn't make it clear that there is only one camera, back to my main post I just need the camera stream to stay within the camera feed frame when I start it. but as of right now it creates a separate window with the camera feed.</p>
<p dir="auto">Heres an example of how it looks when start the camera feed:</p>
<p dir="auto"><a href="https://imgur.com/a/wbFmLVn" target="_blank" rel="noopener noreferrer nofollow ugc">https://imgur.com/a/wbFmLVn</a></p>
<p dir="auto">As for the "camera" tab on the right with the butons its there for controls to the camera feed</p>
]]></description><link>https://forum.qt.io/post/547256</link><guid isPermaLink="true">https://forum.qt.io/post/547256</guid><dc:creator><![CDATA[Jwhit64]]></dc:creator><pubDate>Wed, 21 Aug 2019 23:23:52 GMT</pubDate></item></channel></rss>