Skip to content

Commit

Permalink
Dev artefacts of CV2
Browse files Browse the repository at this point in the history
- OBS Virtual Camera support
- Update type stubs
  • Loading branch information
Avasam committed Jun 5, 2023
1 parent 410d9f3 commit ec4bff1
Show file tree
Hide file tree
Showing 10 changed files with 11,838 additions and 5,273 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ This program can be used to automatically start, split, and reset your preferred
About 10-15x slower than BitBlt based on original window size and can mess up some applications' rendering pipelines.
- **Video Capture Device**
Uses a Video Capture Device, like a webcam, virtual cam, or capture card.
If you want to use this with OBS' Virtual Camera, use the [Virtualcam plugin](/~https://github.com/Avasam/obs-virtual-cam/releases) instead.

#### Capture Device

Expand Down Expand Up @@ -218,7 +217,6 @@ The AutoSplit LiveSplit Component will directly connect AutoSplit with LiveSplit

- For many games, it will be difficult to find a split image for the last split of the run.
- The window of the capture region cannot be minimized.
- OBS' integrated Virtual Camera does not work and makes AutoSplit crash. So it's been disabled. Use the [Virtualcam plugin](/~https://github.com/Avasam/obs-virtual-cam/releases) instead.

## Resources

Expand Down
Binary file not shown.
3 changes: 2 additions & 1 deletion scripts/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ certifi
ImageHash>=4.3.1 # Contains type information + setup as package not module
git+/~https://github.com/boppreh/keyboard.git#egg=keyboard # Fix install on macos and linux-ci /~https://github.com/boppreh/keyboard/pull/568
numpy>=1.23.2 # Python 3.11 wheels
opencv-python-headless>=4.6 # Breaking changes importing cv2.cv2
# opencv-python-headless>=4.6 # Breaking changes importing cv2.cv2
./res/opencv_python_headless-4.7.0+be945d8-cp37-abi3-win_amd64.whl # New typing + OBS Camera fixes
packaging
Pillow>=9.2 # gnome-screeshot checks
psutil
Expand Down
6 changes: 2 additions & 4 deletions src/capture_method/VideoCaptureDeviceCaptureMethod.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
if TYPE_CHECKING:
from AutoSplit import AutoSplit

OBS_CAMERA_BLANK_PIXEL = [127, 129, 128]
OBS_VIRTUALCAM_PLUGIN_BLANK_PIXEL = [127, 129, 128]


def is_blank(image: cv2.Mat):
# Running np.all on the entire array or looping manually through the
# entire array is extremely slow when we can't stop early.
# Instead we check for a few key pixels, in this case, corners
return np.all(image[::image.shape[0] - 1, ::image.shape[1] - 1] == OBS_CAMERA_BLANK_PIXEL)
return np.all(image[::image.shape[0] - 1, ::image.shape[1] - 1] == OBS_VIRTUALCAM_PLUGIN_BLANK_PIXEL)


class VideoCaptureDeviceCaptureMethod(CaptureMethodBase):
Expand All @@ -30,8 +30,6 @@ class VideoCaptureDeviceCaptureMethod(CaptureMethodBase):
description = (
"\nUses a Video Capture Device, like a webcam, virtual cam, or capture card. "
+ "\nYou can select one below. "
+ "\nIf you want to use this with OBS' Virtual Camera, use the Virtualcam plugin instead "
+ "\n/~https://github.com/Avasam/obs-virtual-cam/releases"
)

capture_device: cv2.VideoCapture
Expand Down
3 changes: 0 additions & 3 deletions src/capture_method/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,6 @@ async def get_camera_info(index: int, device_name: str):
*[
get_camera_info(index, name) for index, name
in enumerate(named_video_inputs)
# Will crash when trying to resize, and does not work to begin with
# TODO: Should be fixed in next release of OpenCV (4.8)
if name != "OBS Virtual Camera"
],
)

Expand Down
Loading

0 comments on commit ec4bff1

Please sign in to comment.