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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
100
生成系AIで自データを扱うには
planeta
0
230
外観検査の難しさ
planeta
0
540
儲かる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
Technical Debt: Understanding it Rightly, Engaging it Rightly #LaravelLiveJP
shogogg
0
190
LLM Plugin for Node-REDの利用方法と開発について
404background
0
160
jQueryをバージョンアップする前に使いたいjQuery Migrate
matsuo_atsushi
0
190
The Arts and Crafts of Work in the AI Era — Toward Mastery in Software Development
kuranuki
1
720
Oxcを導入して開発体験が向上した話
yug1224
4
290
Stage 3 Decorators でできること / できないこと / TSKaigi 2026
susisu
1
1.5k
Java × distroless で 軽量なコンテナイメージを / Java on Distroless
contour_gara
0
500
権限チェックの一貫性を型で守る TypeScript による多層防御
mnch
4
1.1k
Spec Driven Development | AI Summit Lisbon
danielsogl
PRO
0
150
GitHub Copilot CLIのいいところ
htkym
2
1.3k
開発体験を左右するライブラリの API 設計 - GraphQL スキーマ構築ライブラリから考える #tskaigi
izumin5210
2
1.6k
不変条件と整合性境界—ビジネスが決める設計判断と実現パターン / Invariants and Consistency Boundaries
nrslib
13
3.4k
Featured
See All Featured
4 Signs Your Business is Dying
shpigford
187
22k
Speed Design
sergeychernyshev
33
1.8k
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
190
Utilizing Notion as your number one productivity tool
mfonobong
4
310
How to Ace a Technical Interview
jacobian
281
24k
Navigating Team Friction
lara
192
16k
Leading Effective Engineering Teams in the AI Era
addyosmani
9
2k
Game over? The fight for quality and originality in the time of robots
wayneb77
1
190
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
240
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.2k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.5k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
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)