我刚从源代码构建了opencv,但似乎没有python绑定。
(ocv) me@vm:~$ python
Python 3.5.2 (default, Sep 14 2017, 22:51:06)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'cv2'
>>> exit()
(ocv) me@vm:~$ sudo ldconfig -p | grep libopencv
libopencv_videostab.so.3.0 (libc6,x86-64) => /usr/local/lib/libopencv_videostab.so.3.0
libopencv_videostab.so (libc6,x86-64) => /usr/local/lib/libopencv_videostab.so
libopencv_videoio.so.3.0 (libc6,x86-64) => /usr/local/lib/libopencv_videoio.so.3.0
libopencv_videoio.so (libc6,x86-64) => /usr/local/lib/libopencv_videoio.so
libopencv_video.so.3.0 (libc6,x86-64) => /usr/local/lib/libopencv_video.so.3.0
libopencv_video.so (libc6,x86-64) => /usr/local/lib/libopencv_video.so
libopencv_superres.so.3.0 (libc6,x86-64) => /usr/local/lib/libopencv_superres.so.3.0
libopencv_superres.so (libc6,x86-64) => /usr/local/lib/libopencv_superres.so
libopencv_stitching.so.3.0 (libc6,x86-64) => /usr/local/lib/libopencv_stitching.so.3.0
libopencv_stitching.so (libc6,x86-64) => /usr/local/lib/libopencv_stitching.so
libopencv_shape.so.3.0 (libc6,x86-64) => /usr/local/lib/libopencv_shape.so.3.0
libopencv_shape.so (libc6,x86-64) => /usr/local/lib/libopencv_shape.so
libopencv_photo.so.3.0 (libc6,x86-64) => /usr/local/lib/libopencv_photo.so.3.0
libopencv_photo.so (libc6,x86-64) => /usr/local/lib/libopencv_photo.so
libopencv_objdetect.so.3.0 (libc6,x86-64) => /usr/local/lib/libopencv_objdetect.so.3.0
libopencv_objdetect.so (libc6,x86-64) => /usr/local/lib/libopencv_objdetect.so
libopencv_ml.so.3.0 (libc6,x86-64) => /usr/local/lib/libopencv_ml.so.3.0
libopencv_ml.so (libc6,x86-64) => /usr/local/lib/libopencv_ml.so
libopencv_imgproc.so.3.0 (libc6,x86-64) => /usr/local/lib/libopencv_imgproc.so.3.0
libopencv_imgproc.so (libc6,x86-64) => /usr/local/lib/libopencv_imgproc.so
libopencv_imgcodecs.so.3.0 (libc6,x86-64) => /usr/local/lib/libopencv_imgcodecs.so.3.0
libopencv_imgcodecs.so (libc6,x86-64) => /usr/local/lib/libopencv_imgcodecs.so
libopencv_highgui.so.3.0 (libc6,x86-64) => /usr/local/lib/libopencv_highgui.so.3.0
libopencv_highgui.so (libc6,x86-64) => /usr/local/lib/libopencv_highgui.so
libopencv_flann.so.3.0 (libc6,x86-64) => /usr/local/lib/libopencv_flann.so.3.0
libopencv_flann.so (libc6,x86-64) => /usr/local/lib/libopencv_flann.so
libopencv_features2d.so.3.0 (libc6,x86-64) => /usr/local/lib/libopencv_features2d.so.3.0
libopencv_features2d.so (libc6,x86-64) => /usr/local/lib/libopencv_features2d.so
libopencv_core.so.3.0 (libc6,x86-64) => /usr/local/lib/libopencv_core.so.3.0
libopencv_core.so (libc6,x86-64) => /usr/local/lib/libopencv_core.so
libopencv_calib3d.so.3.0 (libc6,x86-64) => /usr/local/lib/libopencv_calib3d.so.3.0
libopencv_calib3d.so (libc6,x86-64) => /usr/local/lib/libopencv_calib3d.so
(ocv) me@vm:~/opencv-in-python$ uname -a
Linux vm 4.10.0-38-generic #42~16.04.1-Ubuntu SMP Tue Oct 10 16:32:20 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
然后,这是我从源码构建的方式,主要遵循the website的指示:
pushd /tmp
wget https://github.com/opencv/opencv/archive/3.1.0.zip
unzip 3.1.0.zip
mkdir opencv-3.1.0
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local ..
make -j $(nproc)
popd
答案 0 :(得分:2)
我忘了包含df = (df.set_index('Day')
.reindex(pd.date_range(df['Day'].min(), df['Day'].max()), fill_value=0)
.reset_index())
print (df)
index Movie Rating
0 2017-01-01 GreatGatsby 5
1 2017-01-02 TopGun 5
2 2017-01-03 Deadpool 1
3 2017-01-04 0 0
4 2017-01-05 0 0
5 2017-01-06 0 0
6 2017-01-07 0 0
7 2017-01-08 0 0
8 2017-01-09 0 0
9 2017-01-10 PlanetOfApes 2
项目,并确保它与opencv项目在同一版本中。我也忘了对共享对象文件进行符号链接。
opencv_contrib
之后,我的导入工作:
cd ~/.virtualenvs/cv/lib/python3.5/site-packages
ln -s /usr/local/lib/python3.5/site-packages/cv2.cpython-35m-x86_64-linux-gnu.so cv2.so