-
Notifications
You must be signed in to change notification settings - Fork 5
Adding some code checks to avoid exceptions and reworked QMainWindow and the way main code executes #1
Conversation
|
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) |
|
Nice! I will do the changes |
| while True: | ||
| cap = cv2.VideoCapture(index) | ||
| if not cap.isOpened(): | ||
| if not cap.isOpened() and available_cameras: |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)
|
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 |
|
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 😊 |
|
thanks! |
[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!