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
150
Algyan イベント振り返り
linyixian
0
420
.NET nanoFramework programming
linyixian
0
450
Azure Blob Storage on IoT Edge
linyixian
0
550
ALGYAN関西支部2019.pdf
linyixian
0
730
Other Decks in Programming
See All in Programming
C#の現在地 進化の歴史と、AI時代の.NET Everywhere
neuecc
4
2.1k
速く作れる。その次は、速く確かめられる開発へ 〜AIネイティブ開発を支える、Shift Down〜 / Can build fast. Next, moving to development where we can verify fast.
rkaga
5
3.2k
SONY CISC-NEWS NWS-1750 + NWB-225 フレームバッファの NetBSD/news68k ドライバ実装 / OSC2026Hiroshima
tsutsui
0
120
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
150
テストを司るデーモンに会いに行く 〜隔離した仮想マシンでテストを通すまで〜
h1d3mun3
1
430
Everything will be SERVERLESS — 信じて運用した10年の経験値 / Everything Will be Serverless — Lessons Learned from 10 Years of Operational Experience
seike460
PRO
1
110
{ Android | Kotlin } Gradle Plugin in 2026
ryunen344
1
320
What We Talk About When We Talk About XP
m_seki
2
640
Family mrubyの進捗
kishima
1
120
すこし踏み込む CancellationToken
htkym
0
310
AWS DevOps Agentで インシデント対応をAIに任せたい
honmarkhunt
7
3k
App Storeの外へ──日本のiOSサイドローディング入門 for iOSDC Japan 2026
yuukiw00w
0
220
Featured
See All Featured
Speed Design
sergeychernyshev
33
2.1k
Digital Ethics as a Driver of Design Innovation
axbom
PRO
1
420
The Director’s Chair: Orchestrating AI for Truly Effective Learning
tmiket
1
300
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
74
42k
The B2B funnel & how to create a winning content strategy
katarinadahlin
PRO
1
520
How to Think Like a Performance Engineer
csswizardry
28
2.8k
Mind Mapping
helmedeiros
1
360
Building a Scalable Design System with Sketch
lauravandoore
464
34k
The Curse of the Amulet
leimatthew05
3
14k
Context Engineering - Making Every Token Count
addyosmani
9
1.1k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
46
3k
Claude Code のすすめ
schroneko
67
230k
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