Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Speaker Deck
PRO
Sign in
Sign up for free
Pythonによる工業用カメラ画像取得事例
OHNO
August 08, 2020
Programming
0
720
Pythonによる工業用カメラ画像取得事例
OHNO
August 08, 2020
Tweet
Share
More Decks by OHNO
See All by OHNO
外観検査の難しさ
planeta
0
200
儲かるPython
planeta
0
170
画像処理ライブラリOpenCVの使い方0910
planeta
0
860
画像処理ライブラリOpenCVの使い方
planeta
0
530
SONYのNNC
planeta
0
310
機械学習による動作認識
planeta
0
510
画像類似度計算
planeta
0
1.1k
Tensorflow/Keras(Python)で作ったモデルをC++で使う
planeta
0
1.3k
Other Decks in Programming
See All in Programming
Jetpack Compose 完全に理解した
mkeeda
1
420
Kyvernoを利用したKubernetesのポリシー制御
kisokazu
0
170
ITエンジニア特化型Q&Aサイトteratailを 言語、DB、クラウドなど フルリプレイスした話
leveragestech
0
370
ちょうぜつ改め21世紀ふつうのソフトウェア設計
tanakahisateru
7
5.7k
Hono v3 - Do Everything, Run Anywhere, But Small, And Faster
yusukebe
4
120
ipa-medit: Memory search and patch tool for IPA without Jailbreaking/ipa-medit-bh2022-europe
tkmru
0
120
eBPF와 함께 이해하는 Cilium 네트워킹
hadaney
3
830
Felteで作る簡単フォームバリデーション
kubotak
1
130
Ruby Pattern Matching
bkuhlmann
0
600
Zynq MP SoC で楽しむエッジコンピューティング ~RTLプログラミングのススメ~
ryuz88
0
160
Swift Concurrency in GoodNotes
inamiy
4
1.3k
「自律型開発組織」を目指すCTOの、試行錯誤の記録
ar_tama
1
200
Featured
See All Featured
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
182
15k
Infographics Made Easy
chrislema
235
17k
YesSQL, Process and Tooling at Scale
rocio
159
12k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
226
16k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
10
1.3k
Reflections from 52 weeks, 52 projects
jeffersonlam
338
18k
Rails Girls Zürich Keynote
gr2m
87
12k
Navigating Team Friction
lara
176
12k
From Idea to $5000 a Month in 5 Months
shpigford
374
44k
Pencils Down: Stop Designing & Start Developing
hursman
114
10k
The Straight Up "How To Draw Better" Workshop
denniskardys
225
130k
Building Adaptive Systems
keathley
27
1.3k
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)