-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented video file removal (#22)
- Loading branch information
1 parent
bd757e6
commit bcf2f23
Showing
6 changed files
with
118 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# Author: Dylan Turner | ||
# Description: File-to-file version of Cam class | ||
|
||
from cv2 import VideoCapture, VideoWriter, VideoWriter_fourcc, namedWindow, destroyAllWindows | ||
from cvzone.SelfiSegmentationModule import SelfiSegmentation | ||
from bgrm.cam import Cam | ||
|
||
WIN_TITLE = 'Conversion' | ||
|
||
class VidFile(Cam): | ||
def __init__(self, settings): | ||
self._settings = settings | ||
|
||
# Set up file input | ||
self._vid_feed = VideoCapture(settings.input_file) | ||
_success, base_frame = self._vid_feed.read() | ||
height, width, self.channels = base_frame.shape | ||
self._settings.screen_width = width | ||
self._settings.screen_height = height | ||
settings.screen_width = width | ||
settings.screen_height = height | ||
|
||
if not settings.disable_win: | ||
namedWindow(WIN_TITLE) | ||
|
||
# Set up removal | ||
self._segmentor = SelfiSegmentation() | ||
|
||
if settings.bg_img != '': | ||
self._bg_img = self._create_correctly_sized_bg() | ||
else: | ||
self._bg_img = None | ||
|
||
# Set up file output | ||
self._out_feed = VideoWriter( | ||
settings.output_file, VideoWriter_fourcc('M', 'J', 'P', 'G'), | ||
settings.fps, (width, height) | ||
) | ||
|
||
def __exit__(self, exc_type, exc_value, traceback): | ||
self._vid_feed.release() | ||
self._out_feed.release() | ||
destroyAllWindows() | ||
|
||
def write(self, frame): | ||
self._out_feed.write(frame) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "bgrm" | ||
version = "8" | ||
version = "9" | ||
description = "Remove backgrounds from video feeds in your web cam applications." | ||
authors = [ "Dylan Turner <[email protected]>" ] | ||
license = "GPL-3.0-only" | ||
|