Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
OpenCVを使ってみよう.pdf
Search
linyixain
December 10, 2019
Programming
530
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
OpenCVを使ってみよう.pdf
linyixain
December 10, 2019
More Decks by linyixain
See All by linyixain
AITRIOSとNode-RED
linyixian
0
160
Algyan イベント振り返り
linyixian
0
420
.NET nanoFramework programming
linyixian
0
460
Azure Blob Storage on IoT Edge
linyixian
0
560
ALGYAN関西支部2019.pdf
linyixian
0
740
Other Decks in Programming
See All in Programming
JAWS-UG 東京支部が始める、JAWS-UG支部コラボ / JAWS-UG lunchtime LT Collaboration
y0hgi
0
220
なぜCTOを降りてFDEを選んだのか?〜なぜプロダクト企業がFDEで顧客の現場に踏み込むのか〜
gonta
1
190
パーソナライズPodcastを作った話
repunit11
0
130
HTML-in-Canvasで作る未来のWeb UI表現
clockmaker
3
3.9k
自サークルのIdPからログアウトできるようになるまで
taiseiue
1
130
パスワード再設定メールのURLについて知っておこう
uyuki234
0
110
UnityでSystem.Net.WebSocketsなWebSocketサーバが動かないのでUnity Monoのコードを覗いてみた / about implementing websocket server with unity mono
drumath2237
1
580
モデルのリファクタリングが難しいと思ったら、そもそも複雑だったのはビジネス仕様だった ? / is-the-business-domain-the-real-complexity
hatsu38
0
460
パズルゲームの作り方 / how to make puzzle games
kaityo256
PRO
2
280
UPDATE をやめる — EF Core でマスタをバージョン管理する
panda728
PRO
0
1.2k
最近”作らせてる” ローカルAIアプリの話
akit37
0
440
個人開発者よ、Honoを使え(おじさんver)
tanahiro2010
2
220
Featured
See All Featured
Game over? The fight for quality and originality in the time of robots
wayneb77
1
300
Balancing Empowerment & Direction
lara
6
1.3k
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
330
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
340
First, design no harm
axbom
PRO
2
1.3k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
5
790
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
470
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.6k
Un-Boring Meetings
codingconduct
0
450
Designing Experiences People Love
moore
143
24k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
123
22k
Producing Creativity
orderedlist
PRO
348
41k
Transcript
OpenCVを使ってみよう 2019/12/10 株式会社リンシステムズ 林 宜憲(Yoshinori Hayashi) @linyixian
自己紹介 林 宜憲(はやし よしのり)@linyixian 株式会社リンシステムズ Microsoft MVP for Windows Development
IoTデバイスについてなんかやってます。 AIについてもちょっとだけやってます。
画像認識ってなに? ・今のはやりはカメラに映った映像の内容を理解すること ディープラーニングなどを利用してリアルタイムに映像を解析 できるようになっています。 ・以前からあるのはデジカメの顔検出機能 今日はこの機能をRasPiとカメラを使ってプログラミングします。
人を検出するには 人が写っている画像と写っていない画像を大量(数千枚・・・)に用意して機 械学習を行います。 精度を上げようとすると大量の学習と画像の用意が必要・・・ しかし、先人が学習したモデルがあるので今はそれを利用すれば簡単に検出で きます。
OpenCVとは ・OpenCV(正式名称: Open Source Computer Vision Library)はオープン ソースの画像処理ライブラリ
・画像変換、特徴点抽出、物体認識、機械学習、GUI、カメラビデオ等のコン トロール、ファイル処理など画像に関する様々な機能を持つライブラリ集と なっています。 ・主に対応しているプログラミング言語はC++、Python、JAVAです。その他の 言語でもラッパーライブラリなどがあります。
RaspberryPiにOpenCVをインストール ・RaspberryPiのコンソールを開きます。 ・次に以下のコマンドを実行します。 $ sudo apt update $ sudo
apt upgrade $ sudo apt install libqt4-test libqtgui4 libjasper1 libatlas-base-dev libhdf5-dev $ sudo pip3 install opencv-python==4.1.0.25 $ sudo pip3 install opencv-contrib-python=4.1.0.25 これでインストールは完了です。
インストールの確認 コンソール上でPython3を実行します。 $ python3 >>> import cv2 >>> cv2.__version__
バージョンが表示されればインストールはできています。
Raspiカメラで画像(動画)を表示 import cv2 cap=cv2.VideoCapture(0) while(True): ret,frame=cap.read() cv2.imshow(‘Video’,frame) if cv2.waitKey(1)&0xFF==ord(‘q’): break
cap.release() cv2.destroyAllWindows() video.py
人検出機能を追加 先ほどのコードに人検出機能を追加します。 detect.py import cv2 import time faceCascade=cv2.CascadeClassifier('/usr/local/lib/python3.7/dist-packages/cv2/data/haarcascade_frontalface_default.xml') cap=cv2.VideoCapture(0) while(True):
ret,frame=cap.read() gray=cv2.cvtColor(frame,cv2.COLOR_BGR2GRAY) faces=faceCascade.detectMultiScale(gray,1.1,3,0,(10,10)) for(x,y,w,h) in faces: cv2.rectangle(frame,(x,y),(x+w,y+h),(0,0,255),2) cv2.imshow('Video',frame) if cv2.waitKey(1)&0xFF==ord('q'): break time.sleep(0.1) cap.release() cv2.destroyAllWindows()
参考 インストールがうまくいかない時は次の記事を参考にしてください。 ラズパイ3にOpenCV3/4を簡単に導入 https://qiita.com/mt08/items/e8e8e728cf106ac83218