SlideShare a Scribd company logo
1 of 9
Download to read offline
cascade分波器を作ってopenCVで使ってみ
たけどうまくいかないいったり、いかな
かったりする件について
H.Oishi
2023/10/7
1
Cascade分波器についての理解
*このサイトを参考しました。(ジコログさん)
https://self-
development.info/opencv%E3%81%A7%E7%89%A9%E4%BD%93%E6%A4%9C
%E5%87%BA%E3%80%90%E3%82%AB%E3%82%B9%E3%82%B1%E3%83%B
C%E3%83%89%E5%88%86%E9%A1%9E%E5%99%A8%E3%82%92%E8%87%
AA%E4%BD%9C%E3%81%99%E3%82%8B%E3%80%91/
きっかけは、仕事で動画のコマからとある画像を抽出して画像解
析をしたいと思ったのがきっかけです。
結局、とある画像の抽出は、特徴線を円や矩形で抽出すること
でできたのですが、その時トライアルしたOpenCVを利用したオ
ブジェクト検出で自作のcascade分波器で画像認識ができなかっ
たので、お知恵をお借りできないかと考えてエントリーしました。
もし、自作された方いらっしゃたら情報交換させていただけると
幸いです。
2
てまりのユニバーサルデザイン
ユニバーサル社会で役立つデザインや技術の研究
「いろんな意味で、分類器自作は難しい!」と結論づけられていて、やっぱり難しいのかな。。
Cascade分波器の作成手順①
• OpenCV公式サイトより、3系をダウンロード。
https://opencv.org/releases/
3
展開したフォルダ内から、以下3ファイルを別フォルダに移動。
*opencv_createsamples.exe
*opencv_traincascade.exe
*opencv_world3412.dll
Cascade分波器の作成手順②
• 正解画像の準備
1枚の正解画像から、1000枚の正解画像を作成。
「opencv_createsamples.exe」使用。
“opencv_createsamples.exe -img ./ok_pict/monster_v1.png -vec ./monster_v1.vec -
num 1000 -bgcolor 255 -maxidev 40 -maxxangle 0.8 -maxyangle 0.8 -maxzangle 0.5
–show”
4
「monster_v1.vec」ファイルに正解画像の特徴データを保存
Cascade分波器の作成手順③
• 不正解画像の準備
機械学習のサイトより入手。ジコログさんのHPに貼ってあった
鳥の画像ファイル倉庫は死んでいるようなので、別で探して準備。
CaltechDATA
100枚を選択して、
NGリスト化。
5
get_file_list.py ng_bird_list
Cascadeclassfier_monster_lessディレクトリ作成
「opencv_traincascade.exe」使用。
“opencv_traincascade.exe -data ./cascadeclassfier_monster_less/ -vec
./monster_v1.vec -bg ./ng_bird_list_less.txt -numPos 900 -numNeg 100”
*作成した正解画像1000枚から900枚を使用。仮に100枚使用不可であっても無視できる。
Cascade分波器の作成手順④
• Cascade分波器の作成
6
Cascadeclassfier_monster_less
ディレクトリ内に、「cascade.xml」作成
されていることを確認。
Cascade分波器の作成手順⑤
• Cascade分波器の動作検証
7
Imput_img
Output_img
残念ながら何も認識していない。
*ちなみに、
ジコログさんのページでは
↓のように認識されていた。
print出力
他やってみたことリスト
8
No ok画像
(モンスター)
ng画像
(鳥)
作成された.xml
ファイルのサイズ
結果
Ref 1,000枚 100枚 5kB 画像認識されず
1 1,000枚 1,000枚 4kB 画像認識されず
2 10,000枚 10,000枚 10kB 画像認識されず
3 1,000枚 100枚 5kB(Refと同じ) 画像認識されず
No ok画像
(顔画像)
ng画像
(鳥)
作成された.xml
ファイルのサイズ
結果
4 1,000枚 100枚 5kB 顔認識された!
5 1,000枚 100枚 5kB(No.4と同じ) 顔認識されず
学習画像
入力画像 出力画像
入力画像 出力画像
No.3
No.4 入力画像 出力画像
No.5
文字背景をちょっと追加
まとめ
• お手製cascade分波器では、サイズの違いなどで認識がうまくいか
ないことが多い。コメント通りにはいかない。やはり難しい。
• 顔、目、笑顔を識別するcascade分波器は、githubの
opencv/data/haarcascadesに.xml(extensible markup
language)形式で格納されている。
9

More Related Content

Featured

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by HubspotMarius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

cascadecascade分波器を作ってopenCVで使ってみた.pdf