Skip to content

Commit

Permalink
fixed video backend for windows. Interface changed and thus errors oc…
Browse files Browse the repository at this point in the history
…curred with the old windows backend.
  • Loading branch information
MichaelBarz committed Jul 21, 2015
1 parent 8f33850 commit cafff14
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 22 deletions.
19 changes: 14 additions & 5 deletions deploy_capture/bundle.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand All @@ -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')],
Expand Down
2 changes: 1 addition & 1 deletion pupil_src/shared_modules/video_capture/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
34 changes: 18 additions & 16 deletions pupil_src/shared_modules/video_capture/win_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -133,15 +135,15 @@ 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")
self.timebase = 0
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
Expand All @@ -162,29 +164,29 @@ 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()
self.readSetting.symbolicLink = self.deviceSettings.symbolicLink
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)
Expand Down

0 comments on commit cafff14

Please sign in to comment.