Skip to content

Commit d47b161

Browse files
Revert "Fix MJPEG streams not connecting."
This reverts commit ecef0e8.
1 parent ecef0e8 commit d47b161

14 files changed

+48
-1122
lines changed

BabbleApp/babbleapp.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ exe = EXE(pyz,
2323
[],
2424
exclude_binaries=True,
2525
name='Babble_App',
26-
debug=True,
26+
debug=False,
2727
bootloader_ignore_signals=False,
2828
strip=False,
2929
upx=True,

BabbleApp/camera.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
from enum import Enum
1111
import serial.tools.list_ports
1212
from lang_manager import LocaleStringManager as lang
13+
1314
from colorama import Fore
1415
from config import BabbleConfig, BabbleSettingsConfig
15-
from utils.misc_utils import get_camera_index_by_name, list_camera_names, is_nt
16+
from utils.misc_utils import get_camera_index_by_name, list_camera_names
1617

1718
from vivefacialtracker.vivetracker import ViveTracker
1819
from vivefacialtracker.camera_controller import FTCameraController
@@ -94,7 +95,6 @@ def run(self):
9495
self.config.capture_source is not None
9596
and self.config.capture_source != ""
9697
):
97-
self.current_capture_source = self.config.capture_source
9898
isSerial = any(x in str(self.config.capture_source) for x in PORTS)
9999

100100
if isSerial:
@@ -103,7 +103,7 @@ def run(self):
103103
self.cv2_camera = None
104104
if self.vft_camera is not None:
105105
self.vft_camera.close()
106-
self.device_is_vft = False
106+
self.device_is_vft = False;
107107
if (
108108
self.serial_connection is None
109109
or self.camera_status == CameraState.DISCONNECTED
@@ -116,7 +116,7 @@ def run(self):
116116
if self.cv2_camera is not None:
117117
self.cv2_camera.release()
118118
self.cv2_camera = None
119-
self.device_is_vft = True
119+
self.device_is_vft = True;
120120

121121
if self.vft_camera is None:
122122
print(self.error_message.format(self.config.capture_source))
@@ -141,18 +141,18 @@ def run(self):
141141
self.cv2_camera is None
142142
or not self.cv2_camera.isOpened()
143143
or self.camera_status == CameraState.DISCONNECTED
144-
#or get_camera_index_by_name(self.config.capture_source) != self.current_capture_source
145-
or self.config.capture_source != self.current_capture_source
144+
or get_camera_index_by_name(self.config.capture_source) != self.current_capture_source
146145
):
147146
if self.vft_camera is not None:
148147
self.vft_camera.close()
149-
self.device_is_vft = False
148+
self.device_is_vft = False;
150149

151150
print(self.error_message.format(self.config.capture_source))
152151
# This requires a wait, otherwise we can error and possible screw up the camera
153152
# firmware. Fickle things.
154153
if self.cancellation_event.wait(WAIT_TIME):
155154
return
155+
156156
if self.config.capture_source not in self.camera_list:
157157
self.current_capture_source = self.config.capture_source
158158
else:
@@ -163,8 +163,9 @@ def run(self):
163163
self.current_capture_source, cv2.CAP_FFMPEG
164164
)
165165
else:
166-
self.cv2_camera = cv2.VideoCapture()
167-
self.cv2_camera.open(self.current_capture_source)
166+
self.cv2_camera = cv2.VideoCapture(
167+
self.current_capture_source
168+
)
168169

169170
if not self.settings.gui_cam_resolution_x == 0:
170171
self.cv2_camera.set(
@@ -180,6 +181,7 @@ def run(self):
180181
self.cv2_camera.set(
181182
cv2.CAP_PROP_FPS, self.settings.gui_cam_framerate
182183
)
184+
183185
should_push = False
184186
else:
185187
# We don't have a capture source to try yet, wait for one to show up in the GUI.
@@ -213,14 +215,15 @@ def get_camera_picture(self, should_push):
213215
return
214216
self.frame_number = self.frame_number + 1
215217
elif self.cv2_camera is not None and self.cv2_camera.isOpened():
216-
ret, image = self.cv2_camera.read() # MJPEG Stream reconnects are currently limited by the hard coded 30 second timeout time on VideoCapture.read(). We can get around this by recompiling OpenCV or using a custom MJPEG stream imp.
218+
ret, image = self.cv2_camera.read()
217219
if not ret:
218220
self.cv2_camera.set(cv2.CAP_PROP_POS_FRAMES, 0)
219221
raise RuntimeError(lang._instance.get_string("error.frame"))
220222
self.frame_number = self.cv2_camera.get(cv2.CAP_PROP_POS_FRAMES) + 1
221223
else:
222224
# Switching from a Vive Facial Tracker to a CV2 camera
223225
return
226+
224227
self.FRAME_SIZE = image.shape
225228
# Calculate FPS
226229
current_frame_time = time.time() # Should be using "time.perf_counter()", not worth ~3x cycles?

BabbleApp/mjpeg_client.py

Lines changed: 0 additions & 33 deletions
This file was deleted.

BabbleApp/mjpeg_test.py

Lines changed: 0 additions & 77 deletions
This file was deleted.

BabbleApp/mjpeg_videocapture.py

Lines changed: 0 additions & 115 deletions
This file was deleted.

0 commit comments

Comments
 (0)