[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: Issue with QCamera in PyQt6
From:       RedHuli <redhuli.comments () gmail ! com>
Date:       2021-11-12 3:54:12
Message-ID: CACDNW2UR4x2JMwEYQOeFVqNATWC_fojh5FFHb5e7v40xs+OL2A () mail ! gmail ! com
[Download RAW message or body]

Hi Phil,

Thanks so much for taking a moment to look at this.

I realized that the problem I was having was with the zsh shell on macOS. I
reverted back to the bash shell, ran the short script and had no
issues with the code.

Thanks,
Joshua Willman

On Tue, Nov 9, 2021 at 6:28 AM Phil Thompson <phil@riverbankcomputing.com>
wrote:

> On 08/11/2021 08:14, RedHuli wrote:
> > Hello,
> >
> > I was wondering if someone could help me with my issue. I want to
> > update my
> > code from PyQt5 to PyQt6. I need to use QCamera, but every time I do I
> > get
> > the following error:
> >
> > zsh: segmentation fault
> > /Library/Frameworks/Python.framework/Versions/3.9/bin/python3
> > test_camera.py
> >
> >
> > No matter what I do, I still get an error. I've played around with
> > QMediaPlayer and QVideoWidget. I am not sure which new classes to use
> > in
> > PyQt6 to get the camera to play. Below is the minimum code (I believe)
> > should get the camera working:
> >
> >
> > # Import necessary modules
> > import sys
> > from PyQt6.QtWidgets import QApplication
> > from PyQt6.QtMultimedia import (QCamera, QMediaCaptureSession,
> > QMediaDevices
> > )
> > from PyQt6.QtMultimediaWidgets import QVideoWidget
> >
> > app = QApplication(sys.argv)
> >
> > video_widget = QVideoWidget()
> > video_widget.resize(640, 480)
> > video_widget.show()
> >
> > camera = QCamera(QMediaDevices.defaultVideoInput())
> > camera.start()
> >
> > mediaCaptureSession = QMediaCaptureSession()
> > mediaCaptureSession.setCamera(camera)
> > mediaCaptureSession.setVideoOutput(video_widget)
> >
> > sys.exit(app.exec())
> >
> >
> > Thanks for your help!
> >
> >
> > Joshua Willman
>
> It worked fine for me on macOS.
>
> Phil
>

[Attachment #3 (text/html)]

<div dir="ltr">Hi Phil,<div><br></div><div>Thanks so much for taking a moment to look \
at this.  </div><div><br></div><div>I realized that the problem I was having was with \
the zsh shell on macOS. I reverted back to the bash shell, ran the short script and \
had no issues  with the code.  </div><div><br></div><div>Thanks,</div><div>Joshua \
Willman</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On \
Tue, Nov 9, 2021 at 6:28 AM Phil Thompson &lt;<a \
href="mailto:phil@riverbankcomputing.com">phil@riverbankcomputing.com</a>&gt; \
wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px \
0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">On \
08/11/2021 08:14, RedHuli wrote:<br> &gt; Hello,<br>
&gt; <br>
&gt; I was wondering if someone could help me with my issue. I want to <br>
&gt; update my<br>
&gt; code from PyQt5 to PyQt6. I need to use QCamera, but every time I do I <br>
&gt; get<br>
&gt; the following error:<br>
&gt; <br>
&gt; zsh: segmentation fault<br>
&gt; /Library/Frameworks/Python.framework/Versions/3.9/bin/python3<br>
&gt; test_camera.py<br>
&gt; <br>
&gt; <br>
&gt; No matter what I do, I still get an error. I&#39;ve played around with<br>
&gt; QMediaPlayer and QVideoWidget. I am not sure which new classes to use <br>
&gt; in<br>
&gt; PyQt6 to get the camera to play. Below is the minimum code (I believe)<br>
&gt; should get the camera working:<br>
&gt; <br>
&gt; <br>
&gt; # Import necessary modules<br>
&gt; import sys<br>
&gt; from PyQt6.QtWidgets import QApplication<br>
&gt; from PyQt6.QtMultimedia import (QCamera, QMediaCaptureSession, <br>
&gt; QMediaDevices<br>
&gt; )<br>
&gt; from PyQt6.QtMultimediaWidgets import QVideoWidget<br>
&gt; <br>
&gt; app = QApplication(sys.argv)<br>
&gt; <br>
&gt; video_widget = QVideoWidget()<br>
&gt; video_widget.resize(640, 480)<br>
&gt; video_widget.show()<br>
&gt; <br>
&gt; camera = QCamera(QMediaDevices.defaultVideoInput())<br>
&gt; camera.start()<br>
&gt; <br>
&gt; mediaCaptureSession = QMediaCaptureSession()<br>
&gt; mediaCaptureSession.setCamera(camera)<br>
&gt; mediaCaptureSession.setVideoOutput(video_widget)<br>
&gt; <br>
&gt; sys.exit(app.exec())<br>
&gt; <br>
&gt; <br>
&gt; Thanks for your help!<br>
&gt; <br>
&gt; <br>
&gt; Joshua Willman<br>
<br>
It worked fine for me on macOS.<br>
<br>
Phil<br>
</blockquote></div>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic