Skip to content

Commit

Permalink
Merge pull request #44 from andreasgriffin/mac_camera
Browse files Browse the repository at this point in the history
Use opencv by default instead of pygame
  • Loading branch information
andreasgriffin authored Feb 16, 2025
2 parents c963540 + 978dc3c commit ff89699
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
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

0 comments on commit ff89699

Please sign in to comment.