1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

python3.5.2にopenCVを導入するメモ

Last updated at Posted at 2017-11-13

openCVのインストール

PythonでopenCVを導入するメモ

環境

  • Windows7
  • anaconda
  • Python3.5.2
  • GitBash(MING64)

openCVインストール

ここ」から「opencv_python-3.3.1+contrib-cp35-cp35m-win_amd64.whl」をダウンロード

下記のコマンドでインストール
pip install opencv_python-3.3.1+contrib-cp35-cp35m-win_amd64.whl

参考:「OpenCV 3(core + contrib)をWindows & Python 3の環境にインストール&OpenCV 2とOpenCV 3の違い&簡単な動作チェック

サンプルコード実行

画像を半分のサイズに変更するサンプルコード

resize.py
import cv2
import numpy as np

def half_size(im):
        height = im.shape[0]
        width = im.shape[1]
        
        cv2.imshow("full_size",im)
        cv2.waitKey(0)
        cv2.destroyAllWindows()  
        
        half_size = cv2.resize(im,(int(width/2),int(height/2)))

        cv2.imshow("half_size",half_size)
        cv2.waitKey(0)
        cv2.destroyAllWindows()  

if __name__ == '__main__':
    im = cv2.imread("image.jpg")
    if not (im.all() == None):
        half_size(im)
    else:
        print('Not exist')
        

condaさんを使うと簡単にインストールできますね。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?