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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
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
170
Algyan イベント振り返り
linyixian
0
430
.NET nanoFramework programming
linyixian
0
470
Azure Blob Storage on IoT Edge
linyixian
0
580
ALGYAN関西支部2019.pdf
linyixian
0
750
Other Decks in Programming
See All in Programming
Vue.jsで作る空間解析アプリとCapacitorプラグインのData Bridge
hal_spidernight
1
170
Performance Optimization With LLMs
xleitix
0
250
自作Discord音声botをLambda MicroVMsに移行した話 / Migrating My Discord Voice Bot to Lambda MicroVMs
akihisaikeda
1
300
[JA] Domain Modeling with Vanilla Rails: 「操作」から再考するRailsの設計論
yasaichi
4
1.8k
PumaからFalconに移行したRailsアプリケーションでの実践
falcon8823
0
360
Kawaiicon: Kubernetes, it's no longer cool, but let's secure it anyway!
barnbarn
0
120
AIが生成したコードは読むべきか?抽象化設計とコードの品質保証 / abstraction-design-and-quality
minodriven
16
8.8k
FactoryBotをやめればRSpecは速くなるのか?
yuta_onishi_97
0
1.6k
Modernizing iOS Apps
seyfoyun
0
150
Zero-Tap Sign-In対応、結局何をすればいいの?
mitohato14
0
1.8k
ActionController meets Protocol Buffers
sorah
1
790
Spec-driven Development with AI
simas
PRO
0
2.3k
Featured
See All Featured
Raft: Consensus for Rubyists
vanstee
143
7.9k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
470
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.2k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2.8k
How to Grow Your eCommerce with AI & Automation
katarinadahlin
PRO
2
350
Optimising Largest Contentful Paint
csswizardry
37
4k
Money Talks: Using Revenue to Get Sh*t Done
nikkihalliwell
0
550
A Soul's Torment
seathinner
8
3.9k
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.7k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
970
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