Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Conversation

@tadeubas
Copy link
Contributor

@tadeubas tadeubas commented Jun 6, 2023

[EDITED, see all discussion below for the changes, plz accept this PR first /pull/2 ]

Hi, I've updated the project dependencies PySide and shiboken to support Python 3.7 to 3.11 (before it was like 3.5 to 3.10)

Tested and working on my end, please see if it's ok on yours too!

@pythcoiner
Copy link
Owner

thanks for this first PR!

sys.exit(app.exec_()) should be changed in sys.exit(app.exec()) here

I also notice a little change in behavior => on QLabel.setPixmap(None) here and here, the pixmap is not cleared anymore, I will open a new issue if you don't want to handle that.

@pythcoiner
Copy link
Owner

after a quick check it can be solve by this way:

    def upd_camera_stream(self, frame):
        if frame is None:
            frame = QPixmap(self.ui.video_in.size())
            frame.fill(QColor('#434343'))
            
        self.ui.video_in.setPixmap(frame)

@tadeubas
Copy link
Contributor Author

tadeubas commented Jun 6, 2023

Nice! I will do the changes

while True:
cap = cv2.VideoCapture(index)
if not cap.isOpened():
if not cap.isOpened() and available_cameras:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure about this change, what about if the soft is run on a VM (no camera), in that case, the loop will be endless

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will not, I was getting an error because I had no cameras, this made the error stop and the program execute, later I can plug the camera and the code still works

Copy link
Contributor Author

@tadeubas tadeubas Jun 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code available_cameras.append(str(index)) on line 528 make everything to work just fine without any endless loop...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error before this fix was (with none usbcamera):

seedqreader.py", line 522, in list_available_cameras
    if (index - int(available_cameras[-1])) > 2:
                    ~~~~~~~~~~~~~~~~~^^^^
IndexError: list index out of range

cap = cv2.VideoCapture(index)
if not cap.isOpened():
if not cap.isOpened() and available_cameras:
if (index - int(available_cameras[-1])) > 2:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if no available camera here we got an exception and the program stops, so we need to check it before trying to access the index -1

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recall similar and failed to report it, maybe pyqt window didn't even start. Plugged in usbcam, and solved.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it won't start without a usb camera... but now with this small fix it will start with or without a usb_cam

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if no available camera here we got an exception and the program stops, so we need to check it before trying to access the index -1

I got it but I think is better to check it there (L523)

if available_cameras and (index - int(available_cameras[-1])) > 2:

if not, even if no camera, #0 will be listed

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I add this check (L523) because, under Linux, it seems when 1 camera is plugged, I got 2 listed (only the first one available to get video stream)

@tadeubas
Copy link
Contributor Author

tadeubas commented Jun 6, 2023

I made another change to fix a problem with the terminal hanging even after closing the window because python would continue to run... now closing the window correctly ends the python execution and frees the terminal

@pythcoiner
Copy link
Owner

I made another change to fix a problem with the terminal hanging even after closing the window because python would continue to run... now closing the window correctly ends the python execution and frees the terminal

can you post a different PR for this issue (maybe also for the second one) because they are not really related to switching to Pyside6

@tadeubas
Copy link
Contributor Author

tadeubas commented Jun 6, 2023

Sure no problem, but you started asking for other changes on this PR first 😆

@tadeubas tadeubas changed the title Updated PyQt dependencies PySide and shiboken to support python 3.11 Adding some code checks to avoid exceptions and reworked QMainWindow and the way code executes Jun 6, 2023
@tadeubas tadeubas changed the title Adding some code checks to avoid exceptions and reworked QMainWindow and the way code executes Adding some code checks to avoid exceptions and reworked QMainWindow and the way main code executes Jun 6, 2023
@pythcoiner
Copy link
Owner

Sure no problem, but you started asking for other changes on this PR first

Yes but that changes related to switching from PYside2 to PySide6 😊

@pythcoiner pythcoiner merged commit d4a0cd1 into pythcoiner:main Jun 7, 2023
@pythcoiner
Copy link
Owner

thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants