Commit 10169dfe authored by Mike Rye's avatar Mike Rye

Added notes and comments about Python 2 and virtual environments.

parent c4dc0bb3
......@@ -8,10 +8,19 @@ The following instructions will allow the user to simply move their head to peer
* [ParaView](https://www.paraview.org/)
* [OpenCV](https://opencv.org/) with Python bindings.
* [PyQt](https://riverbankcomputing.com/software/pyqt/) compatible with the version of Qt used by ParaView.
* [PyQt](https://riverbankcomputing.com/software/pyqt/) compatible with the version of Qt used by ParaView (currently version 5).
You will also need a webcam.
## Python Version
This code has been developed and tested using Python 3. This version may be selected with the CMake option `-DPARAVIEW_PYTHON_VERSION=3` when building ParaView. Official releases after ParaView 5.6.0 should use Python 3 by default. Several distributions already build ParaView 5.6.0 and earlier with Python 3.
The code may work with Python 2 but it has not been tested. At the very least, the shebang in `webcam_server.py` will need to be changed from `#!/usr/bin/env python3` to `#!/usr/bin/env python2` for the wrapper script to work. Some necessary changes are also commented in the code with `# Python 2 note`. Other changes will likely be required as well.
## Virtual Environments
When installing dependencies in a Python virtual environment, it is necessary to add the virtual environment's module directory to the `PYTHONPATH` variable, e.g. `PYTHONPATH=/path/to/virtual_env/lib/pythonX.X/site-packages`. The virtual environment's Python version must match ParaView's Python version and the versions of the installed dependencies must be compatible with both ParaView and this code.
# Quick Start (POSIX)
......
......@@ -14,7 +14,7 @@ SRCDIR=$ROOT/src
# # Set the PYTHONSTARTUP environment variable so the console commands are
# # executed automatically.
export PYTHONSTARTUP=$ROOT/pv_console_cmds.py
# export PYTHONSTARTUP=$ROOT/pv_console_cmds.py
# Set or prepend the Python path depending on whether it's empty.
if [[ -z ${PYTHONPATH:+x} ]]
......@@ -36,7 +36,7 @@ trap "kill $!" EXIT
cat << MSG
Open the Python shell (View -> Python Shell) and run the following command:
exec(open('$PYTHONSTARTUP').read())
exec(open('$ROOT/pv_console_cmds.py').read())
MSG
......
......@@ -3,7 +3,10 @@
# exec(open('path/to/this/file').read())
#
from importlib import reload
try:
from importlib import reload
except ImportError:
reload = None
import adjust_camera
cam = GetActiveCamera()
......@@ -18,13 +21,6 @@ print('''USAGE
ca.stop()
Reload changes in the adjust_camera module:
ca.stop()
reload(adjust_camera)
ca = adjust_camera.CameraAdjuster(cam, Render)
ca.start()
Update camera after changing views:
ca.stop()
......@@ -37,6 +33,14 @@ print('''USAGE
ca.stop()
ca.hands_free = True
ca.start()
''')
if reload is not None:
print(''' Reload changes in the adjust_camera module:
ca.stop()
reload(adjust_camera)
ca = adjust_camera.CameraAdjuster(cam, Render)
ca.start()
''')
......@@ -96,6 +96,10 @@ class ViewTracker:
self.last_face_pos = current_face_pos
if main_face is not None:
self.add_position(*img.shape[:2], *main_face)
# Python 2 note
# Double position expansion generates a syntax error in Python 2.
# Comment the previous line and try the following instead.
# self.add_position(*(img.shape[:2] + main_face))
# Return the averaged position for smooth transitions.
r = np.average(self.positions, axis=0)
......
#!/usr/bin/env python3
import configparser
# Python 2 note
# "ConfigParser" was renamed "configparser" in Python 3. Comment the previous
# line and try the following instead.
# import ConfigParser as configparser
import os
import sys
import time
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment