1
0

More than 3 years have passed since last update.

サーマルカメラ(サーモ AI デバイス TiD) Python 高速化編

Last updated at Posted at 2021-01-10

MH ソフトウェア&サービスでの画像処理として、OpenCV使用しています。
Raspberry Piでの最高速な処理方法を検討すべく、OpenCVとnumpyの処理速度の比較をしています。


  1. 紹介編
  2. センサ編
  3. センサケース編
  4. Raspberry Pi編
  5. Python編
    5.1 Form編
    5.2 オムロン 非接触温度センサ D6T-44L-06編
    5.3 Pololu 測距センサ VL53L0X編
    5.4 BOSCH 温湿度・気圧センサ BME280
    5.5 シャットダウン・再起動スイッチ編
    5.6 OpenCV編
    5.7 高速化編

ベンチマーク結果

各処理を50万回処理させて、どちらが速いか調査し、速い方を採用してTiD サーモ AI デバイス TiDの処理の高速化を図りました。

import cv2
import numpy as np

# ファイル名は適宜決定してください
file_name = "test.jpg"

img = None
org = cv2.imread(file_name)

for i in range(500000):
    # Resize: OpenCV is fast.
    #img = cv2.resize(org, (300,300), cv2.INTER_CUBIC)
    #img = cv2.resize(org, dsize=(300,300))
    #img = org.repeat(2, axis=0).repeat(2, axis=1)

    # Frip: OpenCV is fast.
    #img = cv2.flip(org, 1)
    #img = np.fliplr(org)

    # BGR to RGB: Numpy is fast.
    #img = org
    #img = cv2.cvtColor(org, cv2.COLOR_BGR2RGB)
    #img = org[:, :, ::-1]

    # Grayslace: OpenCV is fast.
    #img = cv2.cvtColor(org, cv2.COLOR_BGR2GRAY)
    #img = 0.299 * org[:, :, 0] + 0.587 * org[:, :, 1] + 0.114 * org[:, :, 2]

    # Rotate: OpenCV is fast.
    #img = np.rot90(org)
    #img = cv2.rotate(org, cv2.ROTATE_90_CLOCKWISE) #2.99[sec]

YouTube: サーマルカメラ(サーモ AI デバイス TiD) Python編
web: サーモ AI デバイス TiD Python 高速化編 (URLが変更されました)

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0