<div dir="ltr">Hello, <div><br></div><div>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:</div><div><br></div><div><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures">zsh: segmentation fault<span class="gmail-Apple-converted-space">  </span>/Library/Frameworks/Python.framework/Versions/3.9/bin/python3 test_camera.py</span></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="font-variant-ligatures:no-common-ligatures"><br></span></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;font-size:small">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:</span><br></p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;font-size:small"><br></span></p><div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:Menlo,Monaco,"Courier New",monospace;font-size:12px;line-height:18px;white-space:pre"><div><span style="color:rgb(106,153,85)"># Import necessary modules</span></div><div><span style="color:rgb(197,134,192)">import</span> <span style="color:rgb(78,201,176)">sys</span> </div><div><span style="color:rgb(197,134,192)">from</span> <span style="color:rgb(78,201,176)">PyQt6</span>.<span style="color:rgb(78,201,176)">QtWidgets</span> <span style="color:rgb(197,134,192)">import</span> <span style="color:rgb(78,201,176)">QApplication</span></div><div><span style="color:rgb(197,134,192)">from</span> <span style="color:rgb(78,201,176)">PyQt6</span>.<span style="color:rgb(78,201,176)">QtMultimedia</span> <span style="color:rgb(197,134,192)">import</span> (<span style="color:rgb(78,201,176)">QCamera</span>, <span style="color:rgb(78,201,176)">QMediaCaptureSession</span>, <span style="color:rgb(78,201,176)">QMediaDevices</span>)</div><div><span style="color:rgb(197,134,192)">from</span> <span style="color:rgb(78,201,176)">PyQt6</span>.<span style="color:rgb(78,201,176)">QtMultimediaWidgets</span> <span style="color:rgb(197,134,192)">import</span> <span style="color:rgb(78,201,176)">QVideoWidget</span></div><br><div><span style="color:rgb(156,220,254)">app</span> = <span style="color:rgb(78,201,176)">QApplication</span>(<span style="color:rgb(78,201,176)">sys</span>.<span style="color:rgb(156,220,254)">argv</span>)</div><br><div><span style="color:rgb(156,220,254)">video_widget</span> = <span style="color:rgb(78,201,176)">QVideoWidget</span>()</div><div><span style="color:rgb(156,220,254)">video_widget</span>.<span style="color:rgb(220,220,170)">resize</span>(<span style="color:rgb(181,206,168)">640</span>, <span style="color:rgb(181,206,168)">480</span>)</div><div><span style="color:rgb(156,220,254)">video_widget</span>.<span style="color:rgb(220,220,170)">show</span>()</div><br><div><span style="color:rgb(156,220,254)">camera</span> = <span style="color:rgb(78,201,176)">QCamera</span>(<span style="color:rgb(78,201,176)">QMediaDevices</span>.<span style="color:rgb(220,220,170)">defaultVideoInput</span>())</div><div><span style="color:rgb(156,220,254)">camera</span>.<span style="color:rgb(220,220,170)">start</span>()</div><br><div><span style="color:rgb(156,220,254)">mediaCaptureSession</span> = <span style="color:rgb(78,201,176)">QMediaCaptureSession</span>()</div><div><span style="color:rgb(156,220,254)">mediaCaptureSession</span>.<span style="color:rgb(220,220,170)">setCamera</span>(<span style="color:rgb(156,220,254)">camera</span>)</div><div><span style="color:rgb(156,220,254)">mediaCaptureSession</span>.<span style="color:rgb(220,220,170)">setVideoOutput</span>(<span style="color:rgb(156,220,254)">video_widget</span>)</div><br><div><span style="color:rgb(78,201,176)">sys</span>.<span style="color:rgb(220,220,170)">exit</span>(<span style="color:rgb(156,220,254)">app</span>.<span style="color:rgb(220,220,170)">exec</span>())</div></div><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;font-size:small"><br></span></p><p style="margin:0px;font-stretch:normal;line-height:normal">Thanks for your help!</p><p style="margin:0px;font-stretch:normal;line-height:normal"><br></p><p style="margin:0px;font-stretch:normal;line-height:normal">Joshua Willman</p><p style="margin:0px;font-stretch:normal;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,0,0)"><span style="color:rgb(34,34,34);font-family:Arial,Helvetica,sans-serif;font-size:small"><br></span></p></div></div>