aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Wang2024-04-23 21:12:39 -0400
committerAnthony Wang2024-04-23 21:12:39 -0400
commit74b6ae8ddc7506a57b6ba197b67b629f869794a8 (patch)
treee491ab85674b36c44383f6ad71a26d51c7e328eb
parent6d315e7a8e476ef9e20691f8c991614bcab7205a (diff)
Purge PyQt
-rw-r--r--decoder.py1
-rw-r--r--encoder.py79
-rw-r--r--requirements.txt13
3 files changed, 24 insertions, 69 deletions
diff --git a/decoder.py b/decoder.py
index 2229bd8..dbe9751 100644
--- a/decoder.py
+++ b/decoder.py
@@ -2,7 +2,6 @@ import argparse
import sys
import traceback
import cv2
-import matplotlib.pyplot as plt
import numpy as np
from creedsolo import RSCodec
from raptorq import Decoder
diff --git a/encoder.py b/encoder.py
index 3b67cf0..15ee859 100644
--- a/encoder.py
+++ b/encoder.py
@@ -1,12 +1,7 @@
import argparse
-import sys
import cv2
import numpy as np
from creedsolo import RSCodec
-from PyQt6.QtWidgets import QApplication, QWidget, QLabel, QVBoxLayout
-from PyQt6.QtGui import QPixmap
-from PyQt6.QtCore import QTimer
-from PIL import Image, ImageQt
from raptorq import Encoder
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
@@ -78,55 +73,29 @@ def get_frame():
).astype(np.uint8)
-class EncoderWidget(QWidget):
- def __init__(self):
- super().__init__()
- self.timer = QTimer(self)
- self.timer.timeout.connect(self.update)
- self.timer.start(1000 // args.fps)
- self.label = QLabel(self)
- layout = QVBoxLayout(self)
- layout.addWidget(self.label)
- layout.setContentsMargins(0, 0, 0, 0)
- self.setLayout(layout)
- self.showFullScreen()
-
- def update(self):
- img = Image.fromarray(get_frame())
- qt_img = ImageQt.ImageQt(img)
- pixmap = QPixmap.fromImage(qt_img).scaled(self.size())
- self.label.setPixmap(pixmap)
-
-
-if args.output:
- if args.mix:
- cap = cv2.VideoCapture(args.input)
- height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
- width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
- hscale = height // args.height
- wscale = width // args.width
- out = cv2.VideoWriter(args.output, cv2.VideoWriter_fourcc(*"RGBA"), args.fps, (width, height))
- while cap.isOpened():
- ret, frame = cap.read()
- if not ret:
- break
- frame = frame.astype(np.float64) / 255
- frame[: hscale * cheight, : wscale * cwidth] = 1
- frame[: hscale * cheight, wscale * (args.width - cwidth) :] = 1
- frame[hscale * (args.height - cheight) :, : wscale * cwidth] = 1
- frame[hscale * (args.height - cheight) :, wscale * (args.width - cwidth) :] = 1
- out.write(
- cv2.cvtColor(
- (frame * np.repeat(np.repeat(get_frame(), hscale, 0), wscale, 1)).astype(np.uint8),
- cv2.COLOR_RGB2BGR,
- )
+if args.mix:
+ cap = cv2.VideoCapture(args.input)
+ height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
+ width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
+ hscale = height // args.height
+ wscale = width // args.width
+ out = cv2.VideoWriter(args.output, cv2.VideoWriter_fourcc(*"FFV1"), args.fps, (width, height))
+ while cap.isOpened():
+ ret, frame = cap.read()
+ if not ret:
+ break
+ frame = frame.astype(np.float64) / 255
+ frame[: hscale * cheight, : wscale * cwidth] = 1
+ frame[: hscale * cheight, wscale * (args.width - cwidth) :] = 1
+ frame[hscale * (args.height - cheight) :, : wscale * cwidth] = 1
+ frame[hscale * (args.height - cheight) :, wscale * (args.width - cwidth) :] = 1
+ out.write(
+ cv2.cvtColor(
+ (frame * np.repeat(np.repeat(get_frame(), hscale, 0), wscale, 1)).astype(np.uint8),
+ cv2.COLOR_RGB2BGR,
)
- else:
- out = cv2.VideoWriter(args.output, cv2.VideoWriter_fourcc(*"RGBA"), args.fps, (args.width, args.height))
- for _ in packets:
- out.write(cv2.cvtColor(get_frame(), cv2.COLOR_RGB2BGR))
+ )
else:
- input("Seizure warning!")
- app = QApplication([])
- widget = EncoderWidget()
- sys.exit(app.exec())
+ out = cv2.VideoWriter(args.output, cv2.VideoWriter_fourcc(*"FFV1"), args.fps, (args.width, args.height))
+ for _ in packets:
+ out.write(cv2.cvtColor(get_frame(), cv2.COLOR_RGB2BGR))
diff --git a/requirements.txt b/requirements.txt
index 9dc3725..6a26da4 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,18 +1,5 @@
-contourpy==1.2.1
-cycler==0.12.1
Cython==3.0.10
-fonttools==4.51.0
-kiwisolver==1.4.5
-matplotlib==3.8.4
numpy==1.26.4
opencv-python==4.9.0.80
-packaging==24.0
-pillow==10.3.0
-pyparsing==3.1.2
-PyQt6==6.6.1
-PyQt6-Qt6==6.6.3
-PyQt6-sip==13.6.0
-python-dateutil==2.9.0.post0
raptorq==2.0.0
reedsolo==1.7.0
-six==1.16.0