File tree Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Original file line number Diff line number Diff line change 32
32
33
33
from __future__ import print_function
34
34
35
+ import six
35
36
import numpy as np
36
- try :
37
- import cv2
38
- except ImportError :
39
- cv2 = None
37
+ # FIXME(minqiyang): this is an ugly fix for the numpy bug reported here
38
+ # https://github.com/numpy/numpy/issues/12497
39
+ if six .PY3 :
40
+ import subprocess
41
+ import sys
42
+ import_cv2_proc = subprocess .Popen (
43
+ [sys .executable , "-c" , "import cv2" ],
44
+ stdout = subprocess .PIPE ,
45
+ stderr = subprocess .PIPE )
46
+ out , err = import_cv2_proc .communicate ()
47
+ retcode = import_cv2_proc .poll ()
48
+ if retcode != 0 :
49
+ cv2 = None
50
+ else :
51
+ import cv2
52
+ else :
53
+ try :
54
+ import cv2
55
+ except ImportError :
56
+ cv2 = None
40
57
import os
41
58
import tarfile
42
59
import six .moves .cPickle as pickle
You can’t perform that action at this time.
0 commit comments