Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Pythonによる工業用カメラ画像取得事例
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
OHNO
August 08, 2020
Programming
1.5k
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Pythonによる工業用カメラ画像取得事例
OHNO
August 08, 2020
More Decks by OHNO
See All by OHNO
自社データを生成AIに活用
planeta
0
120
生成系AIで自データを扱うには
planeta
0
230
外観検査の難しさ
planeta
0
550
儲かるPython
planeta
0
250
画像処理ライブラリOpenCVの使い方0910
planeta
0
1.5k
画像処理ライブラリOpenCVの使い方
planeta
0
1.1k
SONYのNNC
planeta
0
630
機械学習による動作認識
planeta
0
780
画像類似度計算
planeta
0
2.1k
Other Decks in Programming
See All in Programming
Oxlintはいいぞ(続)
yug1224
1
490
自動化したのに回らない テスト運用の壁―AI時代の品質責任と生産性
mfunaki
0
540
AI駆動開発にグラフDBを重ねてみた
satoshi256kbyte
1
400
ドリフトを絶対に許さない(?)CDK運用 / CDK Ops with Zero Tolerance for Drifts (?)
akihisaikeda
1
250
Webエンジニアなのにブラウザの仕組みがわからないので、Pythonで自作してみた
tatsuki12
4
1.1k
My Marp Sample
sinoue0108
0
130
AIに既存システムを理解させる技術 ~レガシーを見捨てないハーネスエンジニアリング入門~
ochtum
0
170
生成AIで帳票OCRが「簡単に」作れる時代になった?
kon_shou
0
1.2k
Introducing Stack Pull Request in GitHub
kkamegawa
0
110
夏だ!祭りだ!祭りとはドメインモデリングでは?
ryugen04
0
450
異なる設計思想のフレームワークを経験して得た学び
amekuhideki
2
850
[PyCon KR 2026] More Variants, More Diversity for AI Accelerators
achimnol
0
120
Featured
See All Featured
How to Build an AI Search Optimization Roadmap - Criteria and Steps to Take #SEOIRL
aleyda
1
2.2k
Documentation Writing (for coders)
carmenintech
77
5.5k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
12
1.8k
Google's AI Overviews - The New Search
badams
0
1.6k
Building Applications with DynamoDB
mza
96
7.2k
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
260
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
520
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.1k
Why Our Code Smells
bkeepers
PRO
340
58k
A Tale of Four Properties
chriscoyier
163
24k
Mobile First: as difficult as doing things right
swwweet
225
10k
Transcript
Pythonによる工業用カメラ 画像取得事例 TensorFlow User Group Niigata #3 大野 宏
画像分類をするためには ・製造業で画像分類や傷を検査するためには、多くの高 解像度の画像が必要 ・PythonではUSBカメラの画像の取得は容易であるが、高 解像度の工業用カメラは・・・ ・メーカが提供するライブラリは、C、C#、C++ ・画像取り込みはC、画像分類はPython → 同じ言語で画像取り込みから分類まで出来るとよい 露光時間、フレームレート等を制御可能
Basler 社のカメラ https://www.baslerweb.com/jp/products/software/basler-pylon- camera-software-suite/pylon-open-source-projects/
Pythonライブラリ https://github.com/basler/pypylon
PythonによるUSBカメラ画像取得 ・画像処理ライブラリOpenCVを使ったプログラム import cv2 capture = cv2.VideoCapture(1) while(True): ret, frame
= capture.read() cv2.imshow('title',frame) if cv2.waitKey(1) & 0xFF == ord('q'): break
Pythonプログラム1/3 from pypylon import pylon from pypylon import genicam import
sys import cv2 import numpy as np width = 2044 height = 1536 img1 = np.zeros((height, width, 1), np.uint8) countOfImagesToGrab = 10 exitCode = 0 try: camera =pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice()) camera.Open() print("Using device ", camera.GetDeviceInfo().GetModelName()) new_width = camera.Width.GetValue() - camera.Width.GetInc()
Pythonプログラム2/3 if new_width >= camera.Width.GetMin(): camera.Width.SetValue(new_width) camera.MaxNumBuffer = 5 while
True: camera.StartGrabbingMax(1) while camera.IsGrabbing(): grabResult = camera.RetrieveResult(5000, pylon.TimeoutHandling_ThrowException) if grabResult.GrabSucceeded(): img = grabResult.Array cv2.imshow("img",img) key=cv2.waitKey(1) else: print("Error: ", grabResult.ErrorCode, grabResult.ErrorDescription) if key=='q’: break grabResult.Release()
Pythonプログラム3/3 camera.Close() except genicam.GenericException as e: # Error handling. print("An
exception occurred.") print(e.GetDescription()) exitCode = 1 sys.exit(exitCode)