8
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Matlabとカメラを接続 Kinectでリアルタイム画像を取得!

Last updated at Posted at 2019-10-04

matlabを使って様々な画像処理ができる。matlabのImage Processing Toolbox を使うことでカメラやLiDARつなげることができるが、公式のドキュメンテーションは現在英語版しかないので、今回はどのようなカメラとつなげてどのようなことができるのかをまとめていきたいと思う。
その後、matlabとの接続方法に関してはkinect for windows v2 に焦点を当てて紹介する。
(参考記事:https://jp.mathworks.com/help/imaq/image-data-acquisition.html?s_tid=CRUX_lftnav)

つなげられるカメラ

  • GigE Vision
    産業用カメラ
    GigE Visionは、高速イーサーネット規格のギガビットイーサーネットに対応することにより、パラレル出力に比べてより細いケーブルでダイレクトにPCへの接続ができます。また、フレームグラバボードが不要で最大100mまでの長距離伝送ができます。また画像処理に最適な非圧縮データを最大1Gbps で高速転送することで、高精細/高フレームレートの伝送に対応します。
    (引用元:https://www.hitachi-kokusai.co.jp/products/tv/camera/index-gigevision.html)

  • LiDAR Sensors
    LiDAR(Light Detection And Ranging の略)
    光を使ったリモートセンシング技術を利用することで、物体検知をしたりオブジェクトまでの距離を計測し、オブジェクトまでの距離や方向を測定する。

  • Matrox
    さまざまな業界向けの画像取り込み・分析・保存をPCベースの画像処理ソフトと画像処理/入力ボードで実健している。また、画像処理ボードと入力装置であるカメラが一体化している。

  • Kinect for Windows (v2)
    マイクロソフトから発売されたセンサーデバイス。
    RGBカメラ、深度センサ、マイクアレイから成り、カラー画像や距離データ、赤外線画像が得られるだけでなく、体の情報(骨格,関節など)や音声データを得ることができる。

Image Data Acquisition の使い方(kinect for windows v2)

準備

windows 8 以上の環境が必要
Image Acquisition Toolbox Support Package for Kinect For Windows Sensor(アドオン エクスプローラーから入手する必要アリ)

参考:https://jp.mathworks.com/help/imaq/installing-the-kinect-for-windows-sensor-support-package.html

使い方(基本)

1.起動方法(kinectの準備)
(1)SDK Browser v2.0(kinect for windows)を起動
(2)Kinect Configuration Verifierを起動
P5.JPG
↑起動だけするとこの画面が出る
P6.JPG
↑KINECTをつなげるとこの画面になってカラー画像と深度データが出力される

(3)Color Basics-D2Dを起動
これでkinectで撮った映像が見える。
スナップショットもとれる。
(matlabで使うときは必要ないかも)

2.Image Acquisition Tool アプリの起動(matlab)←(1)リアルタイム画像を取得するだけならいらない。
アプリ一覧からImage Acquisition Tool を立ち上げる もしくは コマンドにimaqtool と入力する。)
(1)kinectからリアルタイム画像を取得
基本的には videoinput → preview の流れ

matlab
colorVid = videoinput('kinect',1); %カラー画像を取得
depthVid = videoinput('kinect',2); %深度画像を取得
 preview([colorVid depthVid]); 

関数

imaqtool

Image Acquisition Toolの起動


(1)Kinect V2の検知(基本情報の取得)
(参考記事:https://jp.mathworks.com/help/supportpkg/kinectforwindowsruntime/ug/detect-the-kinect-v2-devices.html)

imaqhwinfo

「Image Acquisition Hardware」の情報を取得
入力) info = imaqhwinfo('kinect')

info =

フィールドをもつ struct:

   AdaptorDllName: 'C:\ProgramData\MATLAB\SupportPackages\R2019a\toolbox\imaq\supportpackages\kinectruntime\adaptor\win64\mwkinectimaq.dll'
AdaptorDllVersion: '6.0 (R2019a)'
      AdaptorName: 'kinect'
        DeviceIDs: {[1]  [2]}
       DeviceInfo: [1×2 struct]

Deviceinfo

装置(Kinect)の情報について格納されている。主なデータは2種類
デバイスID
1.カラーセンサー
2.深度センサー

入力)
info.DeviceInfo(num)
(numは1または2)

1.カラーセンサ

         DefaultFormat: 'BGR_1920x1080'
   DeviceFileSupported: 0
            DeviceName: 'Kinect V2 Color Sensor'
              DeviceID: 1
 VideoInputConstructor: 'videoinput('kinect', 1)'
VideoDeviceConstructor: 'imaq.VideoDevice('kinect', 1)'
      SupportedFormats: {'BGR_1920x1080'}

2.深度センサ

         DefaultFormat: 'Depth_512x424'
   DeviceFileSupported: 0
            DeviceName: 'Kinect V2 Depth Sensor'
              DeviceID: 2
 VideoInputConstructor: 'videoinput('kinect', 2)'
VideoDeviceConstructor: 'imaq.VideoDevice('kinect', 2)'
      SupportedFormats: {'Depth_512x424'}

videoinput

preview

videoinputで取得したリアルタイム画像を画面上に出力する(Video Viewer)

closepreview

Video Viewerを閉じる

(参考記事:https://jp.mathworks.com/help/imaq/acquisition-using-kinect-for-windows-hardware.html)

8
5
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
8
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?