Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use opencv by default instead of pygame #44

Merged
merged 1 commit into from
Feb 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions bitcoin_qr_tools/gui/video_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,15 +355,19 @@ def get_cv2camera(self, index: int) -> CV2Camera | None:

return None

def _get_camera(self, camera_name: str | int, index: int) -> TypeSomeCamera | None:
# default is opencv, since pygame doesnt work on mac
return self.get_cv2camera(index) or self.get_pygame_camera(camera_name, index)

def get_valid_cameras(self) -> List[Tuple[int, str, TypeSomeCamera]]:
valid_cameras: List[Tuple[int, str, TypeSomeCamera]] = []
for index, camera_name in enumerate(pygame.camera.list_cameras()):
temp_camera = self.get_pygame_camera(camera_name, index) or self.get_cv2camera(index)
temp_camera = self._get_camera(camera_name, index)
if temp_camera:
valid_cameras.append((index, camera_name, temp_camera))

if not valid_cameras:
temp_camera = self.get_pygame_camera(0, 0) or self.get_cv2camera(0)
temp_camera = self._get_camera(0, 0)
if temp_camera:
valid_cameras.append((0, str(0), temp_camera))

Expand Down Expand Up @@ -520,8 +524,8 @@ def update_frame(self):
if self.current_camera:
try:
surface = self.current_camera.get_image()
except:
# logger.debug("Could not get image")
except Exception as e:
logger.debug(str(e))
return
else:
return
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ line-length = 110

[tool.poetry]
name = "bitcoin-qr-tools"
version = "1.0.4"
version = "1.0.5"
authors = ["andreasgriffin <[email protected]>"]
license = "GPL-3.0"
readme = "README.md"
Expand Down