From cafff1463a91678290c9ace437cc0e2e2dc4af0c Mon Sep 17 00:00:00 2001 From: MichaelBarz Date: Tue, 21 Jul 2015 15:14:53 +0200 Subject: [PATCH] fixed video backend for windows. Interface changed and thus errors occurred with the old windows backend. --- deploy_capture/bundle.spec | 19 ++++++++--- .../shared_modules/video_capture/__init__.py | 2 +- .../shared_modules/video_capture/win_video.py | 34 ++++++++++--------- 3 files changed, 33 insertions(+), 22 deletions(-) diff --git a/deploy_capture/bundle.spec b/deploy_capture/bundle.spec index ee1462a3e5..a5194a8be6 100644 --- a/deploy_capture/bundle.spec +++ b/deploy_capture/bundle.spec @@ -81,21 +81,30 @@ elif platform.system() == 'Windows': system_path = os.path.join(os.environ['windir'], 'system32') + print "Using Environment:" python_path = None package_path = None for path in sys.path: + print " -- " + path if path.endswith("scripts"): python_path = os.path.abspath(os.path.join(path, os.path.pardir)) elif path.endswith("site-packages"): + lib_dir = os.path.abspath(os.path.join(path, os.path.pardir)) + python_path = os.path.abspath(os.path.join(lib_dir, os.path.pardir)) package_path = path - + if (python_path and package_path): + print "PYTHON PATH @ " + python_path + print "PACKAGE PATH @ " + package_path + else: + print "could not find python_path or package_path. EXIT." + quit() scipy_imports = ['scipy.integrate'] - #scipy_imports += ['scipy.integrate._ode', 'scipy.integrate.quadrature', 'scipy.integrate.odepack', 'scipy.integrate._odepack', 'scipy.integrate.quadpack', 'scipy.integrate._quadpack'] - #scipy_imports += ['scipy.integrate.vode', 'scipy.integrate.lsoda', 'scipy.integrate._dop', 'scipy.special._ufuncs_cxx'] + scipy_imports += ['scipy.integrate._ode', 'scipy.integrate.quadrature', 'scipy.integrate.odepack', 'scipy.integrate._odepack', 'scipy.integrate.quadpack', 'scipy.integrate._quadpack'] + scipy_imports += ['scipy.integrate.vode', 'scipy.integrate.lsoda', 'scipy.integrate._dop', 'scipy.special._ufuncs', 'scipy.special._ufuncs_cxx'] a = Analysis(['../pupil_src/capture/main.py'], pathex=['../pupil_src/shared_modules/'], - hiddenimports=['pyglui.cygl.shader']+scipy_imports, + hiddenimports=['pyglui.cygl.shader']+scipy_imports+av_hidden_imports, hookspath=None, runtime_hooks=None, excludes=['pyx_compiler','matplotlib']) @@ -120,7 +129,7 @@ elif platform.system() == 'Windows': [('glfw3.dll', '../pupil_src/shared_modules/external/glfw3.dll','BINARY')], [('glfw3.lib', '../pupil_src/shared_modules/external/glfw3.lib','BINARY')], [('glfw3dll.lib', '../pupil_src/shared_modules/external/glfw3dll.lib','BINARY')], - [('opencv_ffmpeg248_64.dll', os.path.join(python_path, 'opencv_ffmpeg248_64.dll'),'BINARY')], + [('opencv_ffmpeg2411.dll', os.path.join(python_path, 'opencv_ffmpeg2411.dll'),'BINARY')], [('_videoInput.lib', os.path.join(python_path, '_videoInput.lib'),'BINARY')], [('msvcp110.dll', os.path.join(system_path, 'msvcp110.dll'),'BINARY')], [('msvcr110.dll', os.path.join(system_path, 'msvcr110.dll'),'BINARY')], diff --git a/pupil_src/shared_modules/video_capture/__init__.py b/pupil_src/shared_modules/video_capture/__init__.py index a022b201f1..c4b8954db4 100644 --- a/pupil_src/shared_modules/video_capture/__init__.py +++ b/pupil_src/shared_modules/video_capture/__init__.py @@ -72,7 +72,7 @@ def autoCreateCapture(src,timestamps=None,timebase = None): return FakeCapture(timebase=timebase) - cap = Camera_Capture(matching_devices[preferred_idx]['uid'],timebase) + cap = Camera_Capture(matching_devices[preferred_idx]['uid'],timebase=timebase) logger.info("Camera selected: %s with id: %s" %(matching_devices[preferred_idx]['name'],matching_devices[preferred_idx]['uid'])) return cap diff --git a/pupil_src/shared_modules/video_capture/win_video.py b/pupil_src/shared_modules/video_capture/win_video.py index e228de6033..35eaf49a84 100644 --- a/pupil_src/shared_modules/video_capture/win_video.py +++ b/pupil_src/shared_modules/video_capture/win_video.py @@ -113,18 +113,20 @@ def __init__(self, uid, size=(640,480), fps=None, timebase=None): def _init(self, uid, size=(640,480), fps=None, timebase=None): devices = vi.DeviceList() - for cam in _getVideoInputInstance().getListOfDevices(devices): - if cam.symbolicName == uid: + _getVideoInputInstance().getListOfDevices(devices) + for device in devices: + if device.symbolicName == uid: break - if cam.symbolicName != uid: + if device.symbolicName != uid: raise CameraCaptureError("uid for camera not found.") if not len(size) == 2: msg = ERR_INIT_FAIL + "Parameter 'size' must have length 2." logger.error(msg) raise CameraCaptureError(msg) + # setting up device - self.device = cam.device + self.device = device self.deviceSettings = vi.DeviceSettings() self.deviceSettings.symbolicLink = self.device.symbolicName self.deviceSettings.indexStream = 0 @@ -133,7 +135,7 @@ def _init(self, uid, size=(640,480), fps=None, timebase=None): self.captureSettings.readMode = vi.ReadMode.SYNC self.captureSettings.videoFormat = vi.CaptureVideoFormat.RGB32 self.stream = self.device.listStream[self.deviceSettings.indexStream] - + # collecting additional information if timebase == None: logger.debug("Capture will run with default system timebase") @@ -141,7 +143,7 @@ def _init(self, uid, size=(640,480), fps=None, timebase=None): else: logger.debug("Capture will run with app wide adjustable timebase") self.timebase = timebase - + self.width = size[0] self.height = size[1] self.preferred_fps = fps @@ -162,7 +164,7 @@ def _init(self, uid, size=(640,480), fps=None, timebase=None): sleep(1) else: break - + # creating frame buffer and initializing capture settings frame = np.empty((self.actual_height * self.actual_width * 4), dtype=np.uint8) self.readSetting = vi.ReadSetting() @@ -170,21 +172,21 @@ def _init(self, uid, size=(640,480), fps=None, timebase=None): self.readSetting.setNumpyArray(frame) frame.shape = (self.actual_height, self.actual_width, -1) self._frame = frame - + logger.debug("Successfully set up device: %s @ %dx%dpx %dfps (mediatype %d)" %(self.name, self.actual_height, self.actual_width, self.frame_rate, self.deviceSettings.indexMediaType)) self._is_initialized = True self._failed_inits = 0 def re_init(self, uid, size=(640,480), fps=None): if self.sidebar is None: - msg = "Sidebar menu was not defined. This happens if the camera could not be initialized correctly for the first time." - logger.error(msg) - raise CameraCaptureError(msg) - self.deinit_gui() - self._close_device() - self._init(uid, size, fps) - self.init_gui(self.sidebar) - self.menu.collapsed = False + self._close_device() + self._init(uid, size, fps) + else: + self.deinit_gui() + self._close_device() + self._init(uid, size, fps) + self.init_gui(self.sidebar) + self.menu.collapsed = False def get_frame(self): res = self.context.readPixels(self.readSetting)