From 209d5fe0955a360614507418f4bee71deb2ae435 Mon Sep 17 00:00:00 2001
From: Abhishek Kadian <abhishekkadiyan@gmail.com>
Date: Thu, 5 Sep 2019 11:39:08 -0700
Subject: [PATCH] update cv2 import to work with pyrobot

---
 examples/shortest_path_follower_example.py | 8 +++++++-
 habitat/tasks/nav/nav_task.py              | 8 +++++++-
 habitat/utils/visualizations/maps.py       | 8 +++++++-
 habitat/utils/visualizations/utils.py      | 8 +++++++-
 4 files changed, 28 insertions(+), 4 deletions(-)

diff --git a/examples/shortest_path_follower_example.py b/examples/shortest_path_follower_example.py
index b70c69db9..d62d7a643 100644
--- a/examples/shortest_path_follower_example.py
+++ b/examples/shortest_path_follower_example.py
@@ -7,7 +7,13 @@
 import os
 import shutil
 
-import cv2
+# TODO(akadian): remove the below pyrobot hack
+import sys
+ros_path = '/opt/ros/kinetic/lib/python2.7/dist-packages'
+if ros_path in sys.path:
+    sys.path.remove(ros_path)
+    import cv2
+sys.path.append(ros_path)
 import numpy as np
 
 import habitat
diff --git a/habitat/tasks/nav/nav_task.py b/habitat/tasks/nav/nav_task.py
index 3aac5d9aa..0c67b8c7a 100644
--- a/habitat/tasks/nav/nav_task.py
+++ b/habitat/tasks/nav/nav_task.py
@@ -7,7 +7,13 @@
 from typing import Any, List, Optional, Type
 
 import attr
-import cv2
+# TODO(akadian): remove the below pyrobot hack
+import sys
+ros_path = '/opt/ros/kinetic/lib/python2.7/dist-packages'
+if ros_path in sys.path:
+    sys.path.remove(ros_path)
+    import cv2
+sys.path.append(ros_path)
 import numpy as np
 from gym import spaces
 
diff --git a/habitat/utils/visualizations/maps.py b/habitat/utils/visualizations/maps.py
index 1028bf380..a46f4e695 100644
--- a/habitat/utils/visualizations/maps.py
+++ b/habitat/utils/visualizations/maps.py
@@ -7,7 +7,13 @@
 import os
 from typing import List, Optional, Tuple
 
-import cv2
+# TODO(akadian): remove the below pyrobot hack
+import sys
+ros_path = '/opt/ros/kinetic/lib/python2.7/dist-packages'
+if ros_path in sys.path:
+    sys.path.remove(ros_path)
+    import cv2
+sys.path.append(ros_path)
 import imageio
 import numpy as np
 import scipy.ndimage
diff --git a/habitat/utils/visualizations/utils.py b/habitat/utils/visualizations/utils.py
index 48ffc02ba..687558a1f 100644
--- a/habitat/utils/visualizations/utils.py
+++ b/habitat/utils/visualizations/utils.py
@@ -7,7 +7,13 @@
 import os
 from typing import Dict, List, Optional, Tuple
 
-import cv2
+# TODO(akadian): remove the below pyrobot hack
+import sys
+ros_path = '/opt/ros/kinetic/lib/python2.7/dist-packages'
+if ros_path in sys.path:
+    sys.path.remove(ros_path)
+    import cv2
+sys.path.append(ros_path)
 import imageio
 import numpy as np
 import tqdm
-- 
GitLab